/* CO₂ Model Lab — klymot design system (Codex-compatible) */

:root {
  color-scheme: dark;
  --bg:           #0a1628;
  --bg-secondary: #0f2047;
  --ink:          #e8e4d8;
  --muted:        #b9ad98;
  --soft:         #8f9aae;
  --line:         rgba(212,168,85,0.24);
  --line-strong:  rgba(212,168,85,0.44);
  --panel:        #132847;
  --panel-2:      #0f2047;
  --paper:        #f7f2e8;
  --paper-ink:    #221b13;
  --accent:       #d4a855;
  --accent-hover: #e0bc72;
  --accent-2:     #f08030;
  --accent-3:     #60a8e0;
  --bad:          #f87171;
  --shadow:       0 18px 60px rgba(0,0,0,0.28);

  font-family: 'Source Sans 3', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(212,168,85,0.10), transparent 32%),
    radial-gradient(circle at 88% 8%, rgba(80,144,248,0.14), transparent 24%),
    var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; }
a { color: var(--accent-hover); }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: #000;
  padding: .7rem 1rem;
  border-radius: .4rem;
  z-index: 20;
}
.skip-link:focus { top: 1rem; }

/* ── Shell ── */
.shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 36px;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(15,32,71,0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.brand:hover .brand-name { color: var(--accent-hover); }

.brand-logo { width: 32px; height: 32px; flex: 0 0 auto; }

.brand-copy { display: grid; gap: 1px; min-width: 0; }

.brand-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.22rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.brand-section {
  color: var(--soft);
  font-size: .72rem;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.header-actions { display: flex; align-items: center; }

/* ── Stepper dots ── */
.stepper {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 2px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(232,228,216,0.28);
  flex: 0 0 auto;
  transition: width .2s, background .2s;
}
.dot.active  { width: 30px; background: var(--accent); }
.dot.done    { background: rgba(212,168,85,0.5); }

/* ── Screen card ── */
.screen {
  background: rgba(19,40,71,0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

/* ── Two-column grid inside screen ── */
.screen-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 18px;
  padding: 20px;
}

/* ── Typography ── */
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1, h2 { font-family: 'Playfair Display', Georgia, serif; line-height: 1.05; letter-spacing: 0; }
h3      { font-family: 'Source Sans 3', sans-serif; line-height: 1.1; }
h1 { margin: 0 0 18px; font-size: clamp(2.4rem, 7vw, 5.4rem); max-width: 11ch; }
h2 { margin: 0 0 14px; font-size: clamp(1.8rem, 4vw, 3.15rem); max-width: 14ch; }
h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 700; }

p { line-height: 1.58; color: var(--muted); margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }
.lead { font-size: clamp(1.04rem, 2vw, 1.25rem); max-width: 64ch; color: var(--muted); }

/* ── Context panel (right column) ── */
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(10,22,40,0.38);
  overflow: hidden;
}
.panel h3 { color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 10px; }
.panel p  { font-size: .92rem; }

/* ── Choice cards ── */
.choices { display: grid; gap: 12px; margin: 18px 0; }

.choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(10,22,40,0.28);
  cursor: pointer;
  display: grid;
  gap: 6px;
  text-align: left;
  width: 100%;
  color: inherit;
  transition: border-color .15s, background .15s;
}
.choice:hover   { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,168,85,0.14); }
.choice input   { position: absolute; opacity: 0; pointer-events: none; }
.choice.selected { border-color: var(--accent); background: rgba(212,168,85,0.12); }
.choice-title   { font-weight: 800; color: var(--ink); font-size: 1rem; }
.choice-eq      { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--soft); }
.choice-text    { color: var(--muted); font-size: .92rem; line-height: 1.5; }

/* ── Controls ── */
.controls { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 18px; }

label.control {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

input[type="range"]  { width: 100%; accent-color: var(--accent); }
select, input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem .8rem;
  background: var(--bg);
  color: var(--ink);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--soft);
  margin-top: 4px;
}

.split-preview {
  display: flex;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-top: 8px;
}
.split-train { background: rgba(13,87,153,0.55); min-width: 4px; transition: width .15s; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.split-test  { flex: 1; background: rgba(176,77,10,0.45); display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }

/* ── Actions bar ── */
.actions {
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(10,22,40,0.38);
  border-top: 1px solid var(--line);
}

/* ── Buttons ── */
.button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .85rem 1.4rem;
  min-height: 44px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  background: var(--accent);
  color: #0a1628;
  width: 100%;
  text-align: center;
  transition: background .15s;
}
.button:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.button.secondary:hover:not(:disabled) { border-color: var(--accent); background: rgba(212,168,85,0.08); }
.button:disabled { cursor: not-allowed; opacity: .38; }

.button:focus-visible,
.choice:focus-visible {
  outline: 3px solid rgba(212,168,85,.45);
  outline-offset: 2px;
}

/* ── Chart wrapper ── */
.chart-wrap {
  background: rgba(10,22,40,0.55);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 18px;
}
.chart-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}
.chart-canvas-wrap {
  position: relative;
  height: 240px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 8px;
  font-size: .8rem;
  color: var(--muted);
}
.legend-item  { display: flex; align-items: center; gap: 5px; }
.legend-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-swatch { width: 18px; height: 3px; flex-shrink: 0; border-radius: 2px; }

/* ── Metrics grid ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin: 16px 0;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(10,22,40,0.28);
}
.metric span { color: var(--muted); font-size: .78rem; display: block; margin-bottom: 2px; }
.metric b    { font-size: clamp(1.05rem,5vw,1.35rem); line-height: 1.1; font-family: 'JetBrains Mono', monospace; }

/* ── Callout / info box ── */
.callout {
  border-left: 4px solid var(--accent-2);
  background: rgba(240,128,48,0.10);
  padding: 12px 14px;
  border-radius: 6px;
  color: #f0d5bc;
  font-size: .92rem;
  line-height: 1.55;
  margin-top: 14px;
}
.callout.info {
  border-left-color: var(--accent-3);
  background: rgba(96,168,224,0.10);
  color: #c0d8f0;
}

/* ── Math box ── */
.math-box {
  background: rgba(10,22,40,0.55);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
  margin-top: 14px;
  overflow-x: auto;
  white-space: pre;
}
.math-box .comment { color: var(--soft); }
.math-box strong   { color: var(--accent); }

/* ── Details / method box ── */
details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(10,22,40,0.28);
  margin-top: 14px;
}
summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--muted);
  font-size: .9rem;
  list-style: none;
}
summary::before { content: '▸ '; }
details[open] summary::before { content: '▾ '; }
details p { font-size: .9rem; margin-top: 10px; }
details code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: rgba(212,168,85,0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Score ring ── */
.score-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 16px;
}
.score-ring-wrap svg { width: 100%; height: 100%; }
.score-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-r2       { font-size: 1.8rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.score-r2-label { font-size: .75rem; color: var(--soft); text-transform: uppercase; letter-spacing: .08em; }

/* ── Interpretation box ── */
.interp-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(10,22,40,0.28);
  margin-top: 16px;
}
.interp-box h4 { margin: 0 0 10px; font-size: .85rem; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; font-family: 'Source Sans 3', sans-serif; }

/* ── Share URL box ── */
.share-url-box {
  overflow-wrap: anywhere;
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  color: var(--accent-3);
  cursor: text;
  margin-top: 8px;
}

.copy-success {
  color: #30c880;
  font-size: .9rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity .3s;
}
.copy-success.show { opacity: 1; }

/* ── AIC table ── */
.aic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}
.aic-table th {
  text-align: left;
  color: var(--soft);
  padding: 4px 10px 4px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.aic-table td { padding: 5px 10px 5px 0; }
.aic-table .winner { font-weight: 800; color: var(--accent); }
.aic-table .aic-val { font-family: 'JetBrains Mono', monospace; color: var(--muted); text-align: right; }

/* ── Strength slider wrap ── */
#strengthSliderWrap { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: rgba(10,22,40,0.28); }

/* ── Responsive ── */
@media (min-width: 680px) {
  .shell { width: min(1180px, calc(100% - 32px)); padding: 24px 0 48px; }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .actions {
    flex-direction: row;
    padding: 18px clamp(22px,4vw,44px);
  }
  .button { width: auto; min-width: 140px; }

  .metrics { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .chart-canvas-wrap { height: 280px; }
}

@media (min-width: 900px) {
  .screen-grid {
    grid-template-columns: minmax(0,1fr) minmax(320px,440px);
    gap: 26px;
    padding: clamp(28px,4vw,44px);
  }

  .metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .chart-canvas-wrap { height: 320px; }
}

/* ── Named step items ── */
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.dot-label {
  display: none;
  font-size: 8px;
  color: var(--soft);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
@media (min-width: 680px) {
  .dot-label { display: block; }
}

/* ── Slider context markers ── */
.slider-markers {
  position: relative;
  height: 28px;
  margin-top: 4px;
}
.slider-marker {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.marker-label { font-size: 9px; color: var(--soft); line-height: 1; }
.marker-year  { font-size: 9px; color: var(--soft); font-family: 'JetBrains Mono', monospace; }

/* ── Floating scroll hint ── */
.scroll-hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(19,40,71,0.95);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 20px;
  color: var(--accent);
  font-size: .85rem;
  font-weight: 700;
  pointer-events: none;
  transition: opacity .4s;
  z-index: 100;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.scroll-hint.hidden { opacity: 0; }

/* ── Score section divider ── */
.score-section-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0;
}
