/* =========================================================================
   Quiz scene — full-screen zone with sidebar (diagram + Koro) and main area
   ========================================================================= */

.quiz-scene {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--color-bg-deep);
  overflow-y: auto;
  transition: opacity 0.5s ease, background 1.2s ease;
}

.quiz-layout {
  display: flex;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
  gap: 32px;
}

/* --- Sidebar: diagram + Koro + dialog line --- */

.quiz-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 200px;
  flex-shrink: 0;
  padding-top: 32px;
}

.quiz-koro {
  position: relative;
  /* Match the in-dojo engine sprite size (engine.css:8 → 128x128) so
     Koro stays consistent across quiz, reveal, and gameplay. */
  width: 128px;
  height: 128px;
}

.quiz-koro .koro-sprite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 0 6px var(--color-gold));
}

.quiz-koro .koro-sprite.koro-active {
  opacity: 1;
  animation: quizKoroBreath 2.5s ease-in-out infinite;
}

@keyframes quizKoroBreath {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* State-specific animations override the default breath */
.quiz-koro[data-state="thinking"] .koro-active {
  animation: quizKoroThink 3s ease-in-out infinite;
}

@keyframes quizKoroThink {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-2px) rotate(-2deg); }
  75% { transform: translateY(-1px) rotate(1deg); }
}

.quiz-koro[data-state="excited"] .koro-active {
  animation: quizKoroExcited 0.4s ease-out;
}

@keyframes quizKoroExcited {
  0% { transform: scale(1); }
  40% { transform: scale(1.12) translateY(-4px); }
  100% { transform: scale(1) translateY(0); }
}

.quiz-koro[data-state="walking"] .koro-active {
  animation: quizKoroWalk 0.8s ease-in-out infinite;
}

@keyframes quizKoroWalk {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(3px) translateY(-2px); }
  75% { transform: translateX(-3px) translateY(-2px); }
}

.quiz-koro-line {
  font-family: var(--font-display);
  font-size: 9px;
  line-height: 1.6;
  color: var(--color-pixel-cream);
  text-align: center;
  max-width: 180px;
  min-height: 3em;
}

/* --- Main area: header + question --- */

.quiz-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-top: 32px;
}

.quiz-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.quiz-zone-label {
  font-family: var(--font-display);
  font-size: clamp(11px, 1.4vw, 15px);
  letter-spacing: 1px;
  white-space: nowrap;
}

/* --- Progress bar --- */

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-progress-bar {
  width: 120px;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
  image-rendering: pixelated;
}

.quiz-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-gold);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.4);
}

.quiz-progress-text {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--color-pixel-cream);
  opacity: 0.7;
}

/* --- Question area --- */

.question-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: opacity 0.4s ease;
}

.question-text {
  font-family: var(--font-body);
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 700;
  color: var(--color-pixel-cream);
  line-height: 1.4;
  margin: 0;
}

/* --- Option cards --- */

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-card {
  display: block;
  width: 100%;
  padding: 16px 20px;
  font-family: var(--font-body);
  font-size: clamp(14px, 1.6vw, 17px);
  line-height: 1.4;
  color: var(--color-pixel-cream);
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.12s ease,
    opacity 0.3s ease;
}

.option-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-teal);
  transform: translateX(4px);
}

.option-card:focus-visible {
  outline: 2px solid var(--color-teal);
  outline-offset: 2px;
}

.option-card.option-selected {
  background: rgba(46, 196, 182, 0.15);
  border-color: var(--color-teal);
  color: var(--color-teal);
}

.option-card.option-dimmed {
  opacity: 0.3;
}

/* --- Zone environment backgrounds --- */

.quiz-scene[data-zone="1"] { background: linear-gradient(170deg, #1a0a20 0%, #0f0e17 40%, #1a1210 100%); }
.quiz-scene[data-zone="2"] { background: linear-gradient(170deg, #1a1408 0%, #0f0e17 40%, #141018 100%); }
.quiz-scene[data-zone="3"] { background: linear-gradient(170deg, #0a1a1a 0%, #0f0e17 40%, #0f1414 100%); }
.quiz-scene[data-zone="4"] { background: linear-gradient(170deg, #1a1a08 0%, #0f0e17 40%, #18140a 100%); }

/* Phone landscape: compress sidebar, hide atmospheric content, shrink
   typography and padding so the question + options fit a 393-tall
   viewport without scroll. The progress bar carries the same info as
   the IkigaiDiagram and koro-line, so hiding those is informational
   neutral. Keeps sidebar+main row layout (horizontal space is plenty).
   Desktop is unaffected (gate doesn't match). */
@media (orientation: landscape) and (max-height: 500px) {
  .quiz-layout {
    min-height: 100svh;
    padding: 6px 12px;
    gap: 12px;
  }
  .quiz-sidebar {
    width: 72px;
    padding-top: 2px;
    gap: 4px;
  }
  .quiz-sidebar .ikigai-diagram,
  .quiz-koro-line {
    display: none;
  }
  .quiz-koro {
    width: 56px;
    height: 56px;
  }
  .quiz-main {
    padding-top: 2px;
    gap: 8px;
  }
  .quiz-zone-header {
    gap: 6px;
  }
  .quiz-zone-label {
    font-size: 10px;
  }
  .question-text {
    font-size: 14px;
    line-height: 1.25;
  }
  .question-container {
    gap: 10px;
  }
  .options-grid {
    gap: 4px;
  }
  .option-card {
    padding: 6px 10px;
    font-size: 11px;
    line-height: 1.25;
  }
}

/* --- Mobile --- */

@media (max-width: 600px) {
  .quiz-layout {
    flex-direction: column;
    padding: 16px 12px;
    gap: 20px;
  }

  .quiz-sidebar {
    flex-direction: row;
    width: 100%;
    padding-top: 8px;
    gap: 12px;
  }

  .quiz-koro {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
  }

  .quiz-koro-line {
    font-size: 8px;
    text-align: left;
    max-width: none;
  }

  .quiz-main {
    padding-top: 0;
  }

  .quiz-zone-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .option-card {
    padding: 14px 16px;
  }
}
