/* =========================================================
   Spirit Lens - Game-Specific Sumi-e Styles
   ========================================================= */

/* --- Game Container --- */
#game-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  position: relative;
}

/* --- Header --- */
#header {
  text-align: center;
  margin-bottom: 20px;
}

#header .sumi-subtitle {
  margin-top: 4px;
  font-size: 1rem;
}

#progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  color: var(--ink-wash);
}

#progress .sumi-seal {
  width: 48px;
  height: 48px;
  font-size: 1.1rem;
}

/* --- Workspace --- */
#workspace {
  min-height: 200px;
  background: var(--paper);
  border: 2px solid var(--ink-wash);
  border-image: repeating-linear-gradient(
    90deg,
    var(--ink-wash) 0px,
    var(--ink-wash) 8px,
    transparent 8px,
    transparent 14px
  ) 2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  border-radius: 4px;
  overflow: hidden;
}

#workspace-hint {
  color: var(--ink-wash);
  opacity: 0.5;
  font-size: 0.9rem;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

#workspace-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 2;
  min-height: 80px;
}

.workspace-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 18px;
  background: var(--paper);
  border: 2px solid var(--ink);
  cursor: pointer;
  user-select: none;
  min-width: 80px;
  animation: ink-spread 0.3s ease-out;
}

.workspace-card .icon {
  font-size: 2rem;
  margin-bottom: 4px;
}

.workspace-card .name {
  font-size: 0.8rem;
  color: var(--ink);
  font-family: 'Noto Serif JP', serif;
}

.workspace-plus {
  font-size: 1.5rem;
  color: var(--ink-wash);
  opacity: 0.5;
  font-family: 'Noto Serif JP', serif;
}

/* --- Effect Canvas --- */
#effect-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* --- Element Tray --- */
#element-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 16px;
  border-top: 1px solid var(--ink-wash);
}

/* --- Element Card --- */
.element-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--ink-wash);
  cursor: grab;
  user-select: none;
  min-width: 70px;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.element-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(26, 26, 46, 0.15);
}

.element-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.element-card .icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
  line-height: 1;
}

.element-card .name {
  font-size: 0.75rem;
  color: var(--ink-wash);
  font-family: 'Noto Serif JP', serif;
  text-align: center;
  white-space: nowrap;
}

.element-card.new {
  animation: ink-spread 0.5s ease-out;
}

/* --- Album --- */
#album {
  margin-top: 24px;
  border-top: 1px solid var(--ink-wash);
  padding-top: 16px;
}

#album-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.album-tab {
  padding: 6px 14px;
  font-family: 'Noto Serif JP', serif;
  font-size: 0.8rem;
  border: 1px solid var(--ink-wash);
  background: transparent;
  cursor: pointer;
  color: var(--ink-wash);
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.album-tab:hover {
  background: var(--water);
}

.album-tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

#album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.album-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--water);
  font-size: 0.7rem;
  padding: 4px;
  text-align: center;
  transition: border-color 0.3s, opacity 0.3s;
}

.album-cell .icon {
  font-size: 1.5rem;
  margin-bottom: 2px;
}

.album-cell .name {
  font-family: 'Noto Serif JP', serif;
  color: var(--ink-wash);
}

.album-cell.discovered {
  border-style: solid;
  border-color: var(--ink-wash);
}

.album-cell.undiscovered {
  opacity: 0.3;
}

.album-cell.undiscovered .icon {
  font-size: 1.2rem;
  color: var(--ink-wash);
}

/* --- Journal --- */
#journal {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--paper);
  border-left: 2px solid var(--ink-wash);
  padding: 24px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: -4px 0 16px rgba(26, 26, 46, 0.15);
  transition: transform 0.3s ease;
}

.journal-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--water);
  animation: brush-write 1s ease-out;
}

.journal-entry .trigger-name {
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--vermillion);
  margin-bottom: 4px;
}

.journal-entry .trigger-text {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink);
}

#close-journal {
  margin-top: 16px;
  width: 100%;
}

/* --- Journal Toggle --- */
#open-journal {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  padding: 10px 20px;
  font-size: 0.85rem;
}

/* --- Discovery Popup --- */
#discovery-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 32px;
  z-index: 300;
  text-align: center;
  animation: seal-stamp 0.4s ease-out;
  min-width: 250px;
  box-shadow: 0 8px 32px rgba(26, 26, 46, 0.3);
}

#discovery-popup .popup-icon {
  font-size: 3rem;
  margin-bottom: 8px;
  display: block;
}

#discovery-popup .popup-name {
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: 4px;
}

#discovery-popup .popup-category {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.8rem;
  color: var(--ink-wash);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#discovery-popup .popup-story {
  margin-top: 12px;
  font-family: 'Noto Serif JP', serif;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
  border-top: 1px solid var(--water);
  padding-top: 12px;
  font-style: italic;
}

/* --- Victory --- */
#victory {
  text-align: center;
  position: fixed;
  border-radius: 0;
}

#victory .sumi-title {
  margin-bottom: 8px;
}

#victory-text {
  max-width: 500px;
  line-height: 1.8;
  font-size: 1rem;
}

/* --- Drag Clone --- */
.drag-clone {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.85;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(26, 26, 46, 0.25);
}

/* --- No-result feedback --- */
.workspace-shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 600px) {
  #game-container {
    padding: 12px;
  }

  #journal {
    width: 100%;
    border-left: none;
    border-top: 2px solid var(--ink-wash);
  }

  .element-card {
    min-width: 60px;
    padding: 10px 8px;
  }

  .element-card .icon {
    font-size: 1.5rem;
  }

  .element-card .name {
    font-size: 0.65rem;
  }

  #album-grid {
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 6px;
  }

  .album-cell .icon {
    font-size: 1.2rem;
  }

  .album-cell .name {
    font-size: 0.6rem;
  }

  #workspace {
    min-height: 160px;
  }

  #discovery-popup {
    min-width: 200px;
    padding: 24px;
  }

  #progress .sumi-seal {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
  }
}
