/* ═══════════════════════════════════════════
   THE SUNRISE PROBLEM — STYLE
   Aesthetic: Playful editorial journal
   Theme: Light / warm paper
   ═══════════════════════════════════════════ */

:root {
  /* Paper palette */
  --bg:         #FEF9F2;
  --bg-warm:    #FBF3E8;
  --text:       #2D2A26;
  --text-soft:  #6B6560;
  --text-faint: #A89F96;

  /* Accents */
  --amber:      #D4883A;
  --amber-soft: #E8B06A;
  --amber-glow: #FFF0D6;
  --rose:       #C4625A;
  --rose-soft:  #E8A29C;
  --sage:       #6A8F6E;
  --sage-soft:  #B5D4B8;
  --ink:        #3A3632;

  /* Surfaces */
  --card-bg:    #FFFFFF;
  --card-border:#E8E0D6;
  --card-shadow: 0 2px 16px rgba(45, 42, 38, 0.06);

  /* Type scale */
  --fs-xs:    0.75rem;
  --fs-sm:    0.875rem;
  --fs-base:  1.05rem;
  --fs-md:    1.25rem;
  --fs-lg:    1.6rem;
  --fs-xl:    2.2rem;
  --fs-xxl:   3rem;

  /* Rhythm */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  2.5rem;
  --space-xl:  4rem;
}

/* ── Reset ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  min-height: 100dvh;
  /* subtle paper texture */
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(212, 136, 58, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(196, 98, 90, 0.03) 0%, transparent 60%);
}

/* ── Progress Bar ── */
.progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-border);
  z-index: 100;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--amber), var(--rose));
  transition: width 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ── Stages ── */
.stage {
  display: none;
  min-height: 100dvh;
  padding: var(--space-lg) var(--space-md);
  padding-top: calc(var(--space-xl) + 3px);
  opacity: 0;
  transform: translateY(20px);
}

.stage.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: stageIn 0.7s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.stage.exiting {
  animation: stageOut 0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes stageIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes stageOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-16px); }
}

.stage-inner {
  max-width: 440px;
  width: 100%;
  text-align: center;
}

/* ── Stage Labels ── */
.stage-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-xs);
  letter-spacing: 0.2em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: var(--space-lg);
}

.stage-title {
  font-family: 'Caveat', cursive;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-lg);
  line-height: 1.3;
}

/* ── ASCII Art ── */
.ascii-art {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--amber);
  margin: 0 auto var(--space-lg);
  white-space: pre;
  user-select: none;
  opacity: 0.8;
}

.ascii-small {
  font-size: 0.65rem;
  margin: var(--space-md) auto;
  color: var(--text-faint);
}

.sun-art {
  font-size: 0.8rem;
  color: var(--amber);
  animation: sunPulse 4s ease-in-out infinite;
}

.sun-art-final {
  font-size: 0.7rem;
  color: var(--amber-soft);
  margin-bottom: var(--space-xl);
  animation: sunPulse 3s ease-in-out infinite;
}

@keyframes sunPulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ── Title Screen ── */
.title-main {
  font-family: 'Crimson Text', serif;
  font-size: var(--fs-xxl);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.title-accent {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  color: var(--amber);
  font-size: 1.2em;
}

.title-sub {
  font-size: var(--fs-base);
  color: var(--text-soft);
  font-style: italic;
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: var(--space-md);
  letter-spacing: 0.05em;
}

/* ── Buttons ── */
.btn {
  font-family: 'Crimson Text', serif;
  font-size: var(--fs-base);
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  display: inline-block;
  background: var(--text);
  color: var(--bg);
  padding: 0.85em 2.8em;
  border-radius: 100px;
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn-primary:hover {
  background: var(--amber);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 136, 58, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Option buttons */
.options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.options-binary {
  flex-direction: row;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.btn-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 1em 1.2em;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  text-align: left;
  color: var(--text);
  box-shadow: var(--card-shadow);
}

.btn-option:hover {
  border-color: var(--amber-soft);
  background: var(--amber-glow);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(212, 136, 58, 0.12);
}

.btn-option:active {
  transform: translateY(0);
}

.btn-option.selected {
  border-color: var(--amber);
  background: var(--amber-glow);
  box-shadow: 0 0 0 3px rgba(212, 136, 58, 0.15);
}

.btn-binary {
  width: auto;
  min-width: 100px;
  justify-content: center;
  font-size: var(--fs-md);
  font-weight: 600;
  padding: 0.8em 2em;
}

.option-icon {
  font-size: 1.3em;
  flex-shrink: 0;
  width: 2.2em;
  text-align: center;
}

.option-text {
  font-size: var(--fs-base);
  line-height: 1.4;
}

/* Next / Reveal buttons */
.btn-next,
.btn-reveal {
  display: inline-block;
  background: none;
  color: var(--amber);
  font-size: var(--fs-base);
  font-weight: 600;
  padding: 0.7em 1.8em;
  border: 2px solid var(--amber);
  border-radius: 100px;
  margin-top: var(--space-md);
}

.btn-next:hover,
.btn-reveal:hover {
  background: var(--amber);
  color: var(--bg);
}

.btn-restart {
  display: inline-block;
  background: none;
  color: var(--text-faint);
  font-size: var(--fs-sm);
  padding: 0.6em 1.5em;
  border: 1.5px solid var(--card-border);
  border-radius: 100px;
  margin-top: var(--space-lg);
}

.btn-restart:hover {
  color: var(--text);
  border-color: var(--text-soft);
}

/* ── Questions ── */
.question-text {
  font-size: var(--fs-md);
  color: var(--text-soft);
  line-height: 1.6;
  margin-bottom: var(--space-xs);
}

.question-main {
  font-family: 'Caveat', cursive;
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.question-smaller {
  font-size: var(--fs-lg);
}

/* ── Response (after user taps) ── */
.response {
  margin-top: var(--space-lg);
}

.response-text {
  font-size: var(--fs-lg);
  font-style: italic;
  color: var(--text);
  margin-bottom: var(--space-xs);
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.hidden {
  display: none !important;
}

/* Staggered delays */
.delay-1 { animation-delay: 0.5s !important; opacity: 0; }
.delay-2 { animation-delay: 1.0s !important; opacity: 0; }
.delay-3 { animation-delay: 1.5s !important; opacity: 0; }
.delay-4 { animation-delay: 2.0s !important; opacity: 0; }
.delay-5 { animation-delay: 2.5s !important; opacity: 0; }

/* When inside an active/visible container, animate */
.stage.active .delay-1,
.stage.active .delay-2,
.stage.active .delay-3,
.stage.active .delay-4,
.stage.active .delay-5,
.response:not(.hidden) .delay-1,
.response:not(.hidden) .delay-2,
.answer-block:not(.hidden) .delay-1 {
  animation: fadeUp 0.6s ease forwards;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Fact Block (Stage 2) ── */
.fact-block {
  text-align: center;
  margin-bottom: var(--space-md);
}

.fact-text {
  font-size: var(--fs-base);
  color: var(--text-soft);
  margin-bottom: var(--space-xs);
  line-height: 1.6;
}

.fact-text strong {
  color: var(--text);
}

.fact-punch {
  font-size: var(--fs-md);
  color: var(--text);
  margin-top: var(--space-sm);
  font-weight: 600;
}

.highlight {
  background: var(--amber-glow);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--amber);
  font-weight: 700;
}

.divider {
  color: var(--text-faint);
  font-size: var(--fs-md);
  letter-spacing: 0.5em;
  margin: var(--space-md) 0;
}

/* ── Theory Cards (Stage 3) ── */
.theory-card {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  text-align: left;
  box-shadow: var(--card-shadow);
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.theory-card:nth-child(2) { animation-delay: 0.15s; }
.theory-card:nth-child(3) { animation-delay: 0.3s; }
.theory-card:nth-child(4) { animation-delay: 0.45s; }

.theory-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--card-border);
}

.theory-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-xs);
  color: var(--text-faint);
  letter-spacing: 0.1em;
}

.theory-name {
  font-family: 'Caveat', cursive;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
}

.theory-list {
  list-style: none;
}

.theory-list li {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  padding: 0.4em 0;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
}

.check {
  color: var(--sage);
  font-weight: 700;
  flex-shrink: 0;
}

.cross {
  color: var(--rose);
  font-weight: 700;
  flex-shrink: 0;
}

.dash {
  color: var(--amber);
  font-weight: 700;
  flex-shrink: 0;
}

.theory-list .pass { color: var(--text-soft); }
.theory-list .fail { color: var(--rose); }
.theory-list .feel { color: var(--text-soft); font-style: italic; }
.theory-list .warn { color: var(--amber); font-style: italic; }

/* ── Stage 4: Uncomfortable ── */
.uncomfortable-block {
  margin-bottom: var(--space-md);
}

.punch-text {
  font-size: var(--fs-md);
  color: var(--text);
  margin-bottom: var(--space-sm);
  line-height: 1.5;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}

.punch-text strong {
  color: var(--rose);
}

/* ── Stage 5: Separator ── */
.separator-list {
  margin: var(--space-md) 0;
}

.strike {
  font-size: var(--fs-md);
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--rose-soft);
  text-decoration-thickness: 2px;
  margin-bottom: var(--space-xs);
  line-height: 1.8;
}

.separator-answer {
  margin: var(--space-lg) 0 var(--space-md);
}

.separator-text {
  font-size: var(--fs-base);
  color: var(--text-soft);
  margin-bottom: var(--space-xs);
}

.separator-key {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
  padding: var(--space-sm) var(--space-md);
  background: var(--amber-glow);
  border-left: 4px solid var(--amber);
  border-radius: 0 8px 8px 0;
  text-align: left;
}

.separator-key em {
  color: var(--amber);
}

.example-block {
  text-align: left;
  padding: 0 var(--space-xs);
}

.example-text {
  font-size: var(--fs-base);
  color: var(--text-soft);
  margin-bottom: var(--space-xs);
  line-height: 1.6;
}

.example-text em {
  color: var(--text);
}

.example-punch {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--sage);
}

.separator-coda {
  font-size: var(--fs-md);
  color: var(--text);
  line-height: 1.5;
  margin-top: var(--space-md);
}

/* ── Stage 6: Return ── */
.return-block {
  margin: var(--space-md) 0;
}

.return-label {
  font-size: var(--fs-sm);
  color: var(--text-faint);
  margin-bottom: var(--space-sm);
}

.return-choice {
  display: inline-block;
  background: var(--amber-glow);
  border: 2px solid var(--amber);
  border-radius: 12px;
  padding: 0.8em 1.4em;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--amber);
}

.return-text {
  font-size: var(--fs-base);
  color: var(--text-soft);
  margin-bottom: var(--space-xs);
  line-height: 1.6;
}

.return-punch {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin: var(--space-sm) 0;
}

.return-coda {
  font-family: 'Caveat', cursive;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--amber);
  margin-top: var(--space-md);
  line-height: 1.3;
}

/* ── Stage 7: Final ── */
.stage-final {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.final-text {
  font-size: var(--fs-md);
  color: var(--text);
  line-height: 1.6;
  margin-bottom: var(--space-md);
  max-width: 360px;
  opacity: 0;
  animation: fadeUp 0.8s ease forwards;
}

.final-text:nth-of-type(2) { animation-delay: 0.6s; }

.final-last {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink);
  margin-top: var(--space-sm);
  animation-delay: 1.2s !important;
  line-height: 1.4;
}

/* ── Answer Block (Stage 4) ── */
.answer-block {
  margin-top: var(--space-md);
}

.answer-text {
  font-size: var(--fs-md);
  color: var(--text-soft);
  margin-bottom: var(--space-xs);
}

.answer-punch {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  font-family: 'Caveat', cursive;
}

/* ── Responsive ── */
@media (min-width: 600px) {
  :root {
    --fs-base: 1.1rem;
    --fs-md:   1.35rem;
    --fs-lg:   1.8rem;
    --fs-xl:   2.6rem;
    --fs-xxl:  3.5rem;
  }

  .stage {
    padding: var(--space-xl) var(--space-lg);
  }

  .stage-inner {
    max-width: 520px;
  }
}

@media (min-width: 900px) {
  .stage-inner {
    max-width: 580px;
  }
}

/* ── Accessibility ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Selection ── */
::selection {
  background: var(--amber-glow);
  color: var(--text);
}
