/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --bg:          #F7F5F0;
  --surface:     #FFFFFF;
  --border:      #E2DDD6;
  --border-dark: #C8C0B4;
  --text-primary:#1A1714;
  --text-muted:  #7A7268;
  --text-faint:  #B0A89E;
  --accent:      #2A4A3E;
  --accent-light:#EBF2EF;
  --accent-mid:  #4A7A6A;
  --ai-bg:       #F0F4F2;
  --ai-border:   #A8C4B8;
  --danger:      #C0392B;
  --success:     #2A7A4A;
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.06);
  --font-display:"DM Serif Display", Georgia, serif;
  --font-body:   "DM Sans", system-ui, sans-serif;
  --font-mono:   "DM Mono", "Courier New", monospace;
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Noise texture overlay */
.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247,245,240,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 760px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
}

.header-label {
  font-size: .75rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted);
  white-space: nowrap;
}

.progress-track {
  flex: 1; height: 3px; background: var(--border);
  border-radius: 99px; overflow: hidden;
}

.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 99px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
  width: 0%;
}

.step-counter {
  font-size: .72rem; font-weight: 500; color: var(--text-muted);
  white-space: nowrap; min-width: 68px; text-align: right;
}

/* ============================================================
   MAIN + CARD
   ============================================================ */
.main-content {
  max-width: 760px; margin: 0 auto;
  padding: 48px 24px 80px;
  position: relative; z-index: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px);
}

.card.card-in {
  animation: cardReveal .35s cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes cardReveal {
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.eyebrow {
  font-size: .72rem; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 10px;
}

.display-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15; color: var(--text-primary);
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  line-height: 1.2; color: var(--text-primary);
  margin-bottom: 28px;
}

.body-lg {
  font-size: 1.05rem; line-height: 1.7; color: var(--text-primary);
  margin-bottom: 16px;
}

.note-text {
  font-size: .85rem; color: var(--text-muted);
  margin-bottom: 36px; line-height: 1.5;
}

.hint-text {
  font-size: .8rem; color: var(--text-muted); margin-bottom: 12px;
}

/* ============================================================
   SCENARIO BODY
   ============================================================ */
.scenario-body { font-size: .95rem; line-height: 1.7; color: var(--text-primary); }

.scenario-body p { margin-bottom: 12px; }

.scenario-body ul {
  margin: 8px 0 12px 20px;
}
.scenario-body ul li { margin-bottom: 6px; }

.scenario-body strong { font-weight: 600; }

.scenario-body blockquote {
  border-left: 3px solid var(--accent-mid);
  padding: 10px 16px;
  margin: 16px 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic; color: var(--text-primary);
}

/* Tables */
.scenario-body table {
  width: 100%; border-collapse: collapse;
  font-size: .88rem; margin: 16px 0;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
}

.scenario-body thead tr {
  background: var(--accent);
  color: #fff;
}

.scenario-body thead th {
  padding: 10px 14px; text-align: left;
  font-weight: 600; font-size: .8rem;
  letter-spacing: .04em; text-transform: uppercase;
}

.scenario-body tbody tr { border-bottom: 1px solid var(--border); }
.scenario-body tbody tr:nth-child(even) { background: #FAFAF8; }
.scenario-body tbody td { padding: 9px 14px; }

.scenario-body .avg-row { background: #F0EDE8 !important; font-weight: 600; }

code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: #EEE9E2;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

/* ============================================================
   DIVIDER
   ============================================================ */
.divider {
  height: 1px; background: var(--border);
  margin: 28px 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px;
  font-family: var(--font-body); font-size: .9rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all .18s ease;
  letter-spacing: .02em; text-decoration: none;
}

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(42,74,62,.25);
}
.btn-primary:hover:not(:disabled) {
  background: #1E3A30;
  box-shadow: 0 4px 14px rgba(42,74,62,.35);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-primary:disabled, .btn-locked {
  background: var(--border-dark) !important;
  color: var(--text-faint) !important;
  cursor: not-allowed;
  box-shadow: none; transform: none;
}

.btn-ai {
  background: var(--ai-bg);
  color: var(--accent);
  border: 1.5px solid var(--ai-border);
  font-weight: 600;
}
.btn-ai:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent-mid);
  transform: translateY(-1px);
}
.btn-ai:disabled {
  background: #F5F5F4; color: var(--text-faint);
  border-color: var(--border); cursor: not-allowed;
}

.ai-icon { font-size: 1em; }

/* ============================================================
   RADIO GROUPS
   ============================================================ */
.radio-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }

.radio-option {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}

.radio-option:hover:not(.radio-disabled) {
  border-color: var(--accent-mid);
  background: var(--accent-light);
}

.radio-option input[type="radio"] { display: none; }

.radio-custom {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid var(--border-dark);
  border-radius: 50%;
  transition: all .15s;
  position: relative;
}

.radio-option input:checked ~ .radio-custom {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px #fff;
}

.radio-option input:checked ~ .radio-text { font-weight: 600; }

.radio-text { font-size: .92rem; color: var(--text-primary); }

.radio-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* Selected state highlight */
.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ============================================================
   NUMBER INPUT
   ============================================================ */
.number-input {
  width: 100%; padding: 12px 16px;
  font-family: var(--font-mono); font-size: 1.05rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FAFAF8;
  color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  margin-bottom: 8px;
}

.number-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42,74,62,.12);
  background: #fff;
}

.number-input:disabled {
  opacity: .45; cursor: not-allowed; background: #F0EDE8;
}

/* ============================================================
   QUESTION GROUP
   ============================================================ */
.question-group { margin-bottom: 28px; }

.question-label {
  font-size: .95rem; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px; line-height: 1.4;
}

/* ============================================================
   VALIDATION
   ============================================================ */
.validation-msg {
  font-size: .85rem; color: var(--danger);
  margin-bottom: 12px; font-weight: 500;
}
.hidden { display: none !important; }

/* ============================================================
   AI PANEL
   ============================================================ */
.ai-section { margin-bottom: 4px; }

.ai-panel {
  border: 1.5px solid var(--ai-border);
  border-radius: var(--radius-md);
  background: var(--ai-bg);
  overflow: hidden;
}

.ai-panel-inner { padding: 22px 24px; }

.ai-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ai-badge {
  font-size: .78rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-light);
  border: 1px solid var(--ai-border);
  padding: 4px 10px; border-radius: 99px;
}

/* Thinking dots */
.ai-thinking {
  display: flex; gap: 5px; align-items: center;
}
.ai-thinking.hidden { display: none; }

.thinking-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-mid); opacity: .4;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: .2s; }
.thinking-dot:nth-child(3) { animation-delay: .4s; }

@keyframes dotPulse {
  0%, 100% { opacity: .25; transform: scale(.85); }
  50%       { opacity: 1;   transform: scale(1); }
}

/* Thinking steps */
.thinking-steps { margin-bottom: 8px; }

.thinking-step {
  font-size: .82rem; color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 5px;
  opacity: 0;
  transition: opacity .35s ease;
}

/* AI advice body typewriter */
.ai-advice-body {
  font-size: .9rem; line-height: 1.7; color: var(--text-primary);
}

.ai-advice-body p { margin-bottom: 10px; }
.ai-advice-body p:last-child { margin-bottom: 0; }

.ai-advice-body code {
  background: rgba(42,74,62,.1);
  color: var(--accent);
}

.ai-disabled { opacity: 1; }
.ai-disabled-note {
  font-size: .82rem; color: var(--text-muted);
  margin-top: 8px;
}

/* ============================================================
   ANSWER SECTION
   ============================================================ */
.answer-section { }
.answer-locked { opacity: .55; pointer-events: none; }
.answer-locked .btn-primary { cursor: not-allowed; }

/* ============================================================
   DEBRIEF
   ============================================================ */
.debrief-quote {
  font-family: var(--font-display);
  font-size: 1.05rem; font-style: italic;
  line-height: 1.65; color: var(--text-primary);
  border-left: 3px solid var(--accent);
  padding: 14px 20px;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 36px;
}

.metrics-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-bottom: 28px;
}

.metric-card {
  background: #FAFAF8; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}

.metric-label {
  font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 10px;
}

.metric-row {
  display: flex; justify-content: space-between;
  font-size: .82rem; color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-row span:last-child {
  font-family: var(--font-mono); font-weight: 500;
  color: var(--text-primary);
}

.status-banner {
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600;
}
.status-ok  { background: #EBF5F0; color: var(--success); border: 1px solid #A8D4B8; }
.status-err { background: #FDF0EE; color: var(--danger);  border: 1px solid #F0B8B0; }

/* ============================================================
   INTRO STEP
   ============================================================ */
.step-intro { max-width: 560px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
.fade-in { animation: fadeIn .3s ease forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .card { padding: 28px 20px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .header-inner { gap: 10px; }
  .header-label { display: none; }
}
