/* ============================================================================
   SolarEclipse — "Umbra" editorial system
   A dark long-read for the physics-literate. Serif display, sans reading voice,
   mono for every measured number. One reserved amber accent.
   ========================================================================== */

:root {
  --bg: #070A12;
  --surface: #0E1220;
  --surface-2: #141A2B;
  --ink: #E9E6DD;
  --muted: #89909F;
  --faint: #5A6172;
  --accent: #D9A441;      /* corona amber — reserved */
  --accent-2: #6E86B8;
  --line: #1B2233;
  --line-soft: #141A28;

  /* eclipse-type semantic colors (used everywhere consistently) */
  --total: #E8A33D;
  --annular: #6DB1FF;
  --partial: #9A8FD1;

  /* simulation body palette (read by simengine.js) */
  --sim-bg: #070A12;
  --inset-bg: #0A0E1A;
  --star: rgba(233,230,221,0.85);
  --sim-label: rgba(233,230,221,0.5);
  --sun: #FFD76E;
  --sun-core: #FFF3C4;
  --mercury: #B9A591;
  --venus: #E8C97A;
  --earth: #6DB1FF;
  --moon: #CFD4E2;
  --mars: #E0764F;
  --jupiter: #D9A96B;
  --saturn: #E3CF9B;
  --uranus: #9ADBE8;
  --neptune: #7A96F0;

  --display: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', 'Hoefler Text', serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Helvetica, Arial, sans-serif;
  --mono-stack: 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;

  --measure: 66ch;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: rgba(217,164,65,0.28); color: #fff; }

/* ---- shared type helpers ------------------------------------------------- */
.mono { font-family: var(--mono-stack); font-variant-numeric: tabular-nums; }
.kicker {
  font-family: var(--mono-stack);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}
.num { font-family: var(--mono-stack); color: var(--accent); font-variant-numeric: tabular-nums; }
a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); transition: border-color .3s var(--ease), color .3s var(--ease); }
a:hover { border-color: var(--accent); color: #fff; }

/* ============================ top nav ==================================== */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(18px, 4vw, 44px);
  background: linear-gradient(to bottom, rgba(7,10,18,0.9), rgba(7,10,18,0));
  backdrop-filter: blur(2px);
}
.topbar .wordmark { font-family: var(--display); font-size: 1.12rem; letter-spacing: 0.01em; border: 0; }
.topbar .wordmark b { color: var(--accent); font-weight: 600; }
.topbar nav { display: flex; gap: clamp(12px, 2.4vw, 30px); }
.topbar nav a {
  font-family: var(--mono-stack); font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted); border: 0; padding-bottom: 3px;
  border-bottom: 1px solid transparent;
}
.topbar nav a:hover, .topbar nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
/* back to the studio — set in the display face so it reads as a byline, not a section */
.topbar nav a.home {
  font-family: var(--display); font-size: 0.92rem; text-transform: none;
  letter-spacing: 0.01em; padding-left: clamp(12px, 2.4vw, 30px);
  border-left: 1px solid var(--line);
}
.topbar nav a.home em { font-style: normal; color: var(--accent); }
@media (max-width: 640px) { .topbar nav a[data-optional] { display: none; } }

/* ============================ the live figure (stage) ==================== */
/* Persistent orbit canvas: hero-sized, then docks to the right rail on scroll. */
#stage {
  position: fixed; z-index: 20;
  top: 50%; left: 50%;
  width: min(76vmin, 660px); height: min(76vmin, 660px);
  transform: translate(-50%, -50%);
  transition: top .8s var(--ease), left .8s var(--ease), width .8s var(--ease),
              height .8s var(--ease), transform .8s var(--ease), opacity .6s var(--ease);
  pointer-events: none;
}
@media (min-width: 1080px) {
  #stage:not(.is-docked) { left: 69%; }
}
/* tablets: the docked rail would sit over the article column — fade it out */
@media (max-width: 1079px) {
  #stage.is-docked { opacity: 0; }
}
#stage.is-docked {
  top: 96px; left: auto; right: clamp(20px, 3.5vw, 54px);
  width: clamp(200px, 22vw, 300px); height: clamp(200px, 22vw, 300px);
  transform: none;
}
#stage.is-hidden { opacity: 0; }
#stage canvas { width: 100%; height: 100%; display: block; }

.stage-hud {
  position: absolute; left: 10px; bottom: 8px;
  font-family: var(--mono-stack); font-size: 0.66rem; line-height: 1.5;
  color: var(--muted); letter-spacing: 0.03em; opacity: 0.9;
}
.stage-hud b { color: var(--accent); font-weight: 400; }
#stage:not(.is-docked) .stage-hud { left: 50%; transform: translateX(-50%); bottom: 4%; text-align: center; }

/* ============================ hero ===================================== */
.hero {
  position: relative; z-index: 30;
  min-height: 100svh;
  display: flex; align-items: center;
  padding: 0 clamp(20px, 6vw, 80px);
  pointer-events: none;
}
.hero .inner { max-width: 720px; pointer-events: auto; }
@media (min-width: 1080px) { .hero .inner { max-width: 460px; } }
.hero .kicker { display: block; margin-bottom: 22px; }
.hero h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2rem, 4.2vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 40px rgba(7,10,18,0.9);
}
.hero .standfirst {
  margin-top: 22px; max-width: 46ch; color: rgba(233,230,221,0.88);
  font-size: clamp(0.94rem, 1.15vw, 1.04rem); line-height: 1.62;
  text-shadow: 0 1px 24px rgba(7,10,18,0.9);
}
.hero .rule { width: 120px; height: 1px; background: var(--accent); margin: 30px 0 26px; }
.hero .actions { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.hero .actions a { font-family: var(--mono-stack); font-size: 0.82rem; letter-spacing: 0.05em; border: 0; color: var(--muted); }
.hero .actions a:first-child { color: var(--ink); }
.hero .actions a::after { content: ' →'; color: var(--accent); }
.hero .actions a.down::after { content: ' ↓'; }
.scroll-cue { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono-stack); font-size: 0.64rem; letter-spacing: 0.2em; color: var(--faint);
  text-transform: uppercase; }

/* ============================ article ================================== */
.article { position: relative; z-index: 30; background: linear-gradient(to bottom, rgba(7,10,18,0) 0, var(--bg) 8vh); }
.chapter {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(56px, 11vh, 130px) clamp(20px, 5vw, 24px);
  border-top: 1px solid var(--line-soft);
}
.chapter:first-child { border-top: 0; }
/* leave room for the docked figure on wide screens */
@media (min-width: 1080px) {
  .article { padding-right: clamp(240px, 26vw, 360px); }
  .chapter { margin-left: max(24px, calc(50vw - var(--measure) - 8vw)); margin-right: 0; }
}
.chapter .chapnum {
  font-family: var(--mono-stack); font-size: 0.8rem; letter-spacing: 0.14em; color: var(--muted);
  display: inline-block; padding-bottom: 5px; margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.chapter .chapnum::after {
  content: ''; position: absolute; left: 0; bottom: -1px; height: 1px; width: 0;
  background: var(--accent); transition: width .7s var(--ease);
}
.chapter.in-view .chapnum::after { width: 100%; }
.chapter h2 {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.4rem, 2.7vw, 2rem); line-height: 1.18; letter-spacing: -0.01em;
  margin-bottom: 22px;
}
.chapter p { margin-bottom: 18px; color: rgba(233,230,221,0.9); font-size: 0.97rem; line-height: 1.68; }
.chapter p .num, .chapter p strong { color: var(--accent); font-weight: 500; }
.chapter p strong { font-family: var(--mono-stack); font-weight: 400; font-size: 0.95em; }

.pullquote {
  font-family: var(--display); font-size: clamp(1.15rem, 2.2vw, 1.55rem); line-height: 1.35;
  color: var(--ink); margin: 10px 0 8px; padding-left: 22px;
  border-left: 2px solid var(--accent);
}

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in-view { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { transform: none; transition: opacity .3s linear; }
  #stage { transition: none !important; }
}

/* ---- figures ------------------------------------------------------------ */
.figure {
  margin: 34px 0; padding: 22px 24px; background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.figure .figcap { font-family: var(--mono-stack); font-size: 0.7rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin-top: 16px; }
.figure .figcap b { color: var(--accent); font-weight: 400; }
.equation {
  font-family: var(--mono-stack); text-align: center; color: var(--ink);
  font-size: clamp(1rem, 2.4vw, 1.5rem); letter-spacing: 0.02em; padding: 10px 0;
}
.equation .sub { color: var(--accent); }
.figure svg { display: block; width: 100%; height: auto; }

/* timeline device */
.timeline { display: flex; align-items: center; gap: 0; margin: 6px 0; }
.timeline .seg { flex: 1; height: 1px; background: var(--line); position: relative; }
.timeline .tick { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.timeline .tick.hollow { background: transparent; border: 1px solid var(--muted); }
.tl-labels { display: flex; justify-content: space-between; font-family: var(--mono-stack);
  font-size: 0.68rem; color: var(--muted); margin-top: 10px; letter-spacing: 0.04em; }

/* legend */
.legend { display: flex; gap: 22px; flex-wrap: wrap; margin: 22px 0 4px; font-family: var(--mono-stack);
  font-size: 0.76rem; letter-spacing: 0.04em; }
.legend span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend .l-total i { background: var(--total); }
.legend .l-annular i { background: var(--annular); }
.legend .l-partial i { background: var(--partial); }

/* ============================ interactive instrument ==================== */
.instrument {
  max-width: 1100px; margin: 40px auto 0; padding: 0 clamp(16px, 4vw, 24px);
}
@media (min-width: 1080px) { .article .instrument-wrap { padding-right: 0; } }
.instrument-frame {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 20px 60px rgba(0,0,0,0.4);
}
.instrument-stage { position: relative; aspect-ratio: 16 / 10; background: var(--sim-bg); }
@media (max-width: 720px) { .instrument-stage { aspect-ratio: 4 / 5; } }
.instrument-stage canvas#instOrbit { width: 100%; height: 100%; display: block; }
.inst-inset {
  position: absolute; right: 14px; bottom: 14px; width: clamp(150px, 26%, 230px); aspect-ratio: 3 / 2;
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--inset-bg);
}
.inst-inset canvas { width: 100%; height: 100%; display: block; }
.inst-inset .lbl { position: absolute; top: 6px; left: 8px; font-family: var(--mono-stack);
  font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.inst-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  font-family: var(--mono-stack); font-size: 0.7rem; letter-spacing: 0.02em;
  color: var(--ink); background: rgba(10,14,26,0.92); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 9px; white-space: nowrap;
  opacity: 0; transform: translateY(2px); transition: opacity .15s var(--ease);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.inst-tooltip.show { opacity: 1; transform: none; }
.inst-tooltip b { color: var(--accent); font-weight: 400; }

.inst-clock { position: absolute; top: 14px; left: 16px; font-family: var(--mono-stack); }
.inst-clock .d { font-size: 1.3rem; color: var(--ink); letter-spacing: 0.02em; }
.inst-clock .sub { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

.inst-banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: rgba(20,14,3,0.92); border: 1px solid var(--accent); color: var(--accent);
  border-radius: 8px; padding: 9px 20px; font-family: var(--mono-stack); font-size: 0.8rem;
  letter-spacing: 0.04em; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity .4s var(--ease), transform .4s var(--ease); max-width: 90%;
}
.inst-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.inst-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.inst-controls button, .inst-controls .seg-btn {
  font-family: var(--mono-stack); font-size: 0.76rem; letter-spacing: 0.03em;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 13px; cursor: pointer;
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.inst-controls button:hover, .seg-btn:hover { border-color: var(--accent); }
.inst-controls button.primary { color: var(--accent); border-color: rgba(217,164,65,0.5); background: rgba(217,164,65,0.06); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg .seg-btn { border: 0; border-radius: 0; }
.seg .seg-btn.active { color: var(--accent); background: rgba(217,164,65,0.08); }
.inst-controls .speed { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-family: var(--mono-stack); font-size: 0.72rem; }
.inst-controls input[type=range] { accent-color: var(--accent); width: 120px; }
.inst-controls .jump { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono-stack); font-size: 0.72rem; color: var(--muted); }
.inst-controls select {
  font-family: var(--mono-stack); font-size: 0.74rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; cursor: pointer; max-width: 220px;
  transition: border-color .25s var(--ease);
}
.inst-controls select:hover { border-color: var(--accent); }
.inst-controls .spacer { flex: 1; }
.inst-controls .rate { font-family: var(--mono-stack); font-size: 0.72rem; color: var(--muted); min-width: 70px; text-align: right; }

.inst-log { padding: 6px 16px 16px; }
.inst-log:empty { display: none; }
.inst-log .ev {
  display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono-stack); font-size: 0.78rem;
}
.chip {
  font-family: var(--mono-stack); font-size: 0.62rem; letter-spacing: 0.1em; font-weight: 600;
  padding: 2px 8px; border-radius: 3px; text-transform: uppercase; flex: 0 0 auto;
}
.chip.total { background: rgba(232,163,61,0.16); color: var(--total); }
.chip.annular { background: rgba(109,177,255,0.14); color: var(--annular); }
.chip.partial { background: rgba(154,143,209,0.16); color: var(--partial); }
.inst-log .ev .when { color: var(--ink); }
.inst-log .ev .meta { color: var(--muted); }
.inst-log .ev .ok { color: #5DD39E; }

/* ============================ verification table ======================= */
.vtable-wrap {
  overflow-x: auto; margin: 26px 0 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
table.vtable th:first-child, table.vtable td:first-child { padding-left: 22px; }
table.vtable th:last-child, table.vtable td:last-child { padding-right: 22px; }
table.vtable tr:last-child td { border-bottom: 0; }
table.vtable { width: 100%; border-collapse: collapse; font-family: var(--mono-stack); font-size: 0.82rem; }
table.vtable th, table.vtable td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.vtable th { color: var(--muted); font-weight: 400; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.66rem; border-bottom-color: var(--line); }
table.vtable td { color: var(--ink); font-variant-numeric: tabular-nums; }
table.vtable td.err { color: var(--muted); }
table.vtable .ok { color: #5DD39E; }
.scorecard { display: flex; gap: 26px; flex-wrap: wrap; margin: 8px 0 4px; }
.scorecard .stat { }
.scorecard .stat .v { font-family: var(--mono-stack); font-size: 1.7rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.scorecard .stat .k { font-family: var(--mono-stack); font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2px; }

/* ============================ limitations box ========================== */
.limits {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 26px clamp(22px, 4vw, 34px); margin: 8px 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.limits ul { list-style: none; }
.limits li { padding: 14px 0; border-bottom: 1px solid var(--line-soft); color: rgba(233,230,221,0.88); }
.limits li:last-child { border-bottom: 0; padding-bottom: 0; }
.limits li b { font-family: var(--mono-stack); font-weight: 400; color: var(--accent); font-size: 0.9em; }

/* ============================ colophon ================================= */
.colophon { text-align: left; }
.colophon .credit { font-family: var(--mono-stack); font-size: 0.78rem; color: var(--muted); line-height: 2; letter-spacing: 0.03em; }
.colophon .credit b { color: var(--ink); font-weight: 400; }
.colophon .links { margin-top: 20px; display: flex; gap: 22px; flex-wrap: wrap; font-family: var(--mono-stack); font-size: 0.78rem; }
.footer-rule { width: 100%; height: 1px; background: var(--line); margin: 40px 0 0; }
.pagefoot { max-width: var(--measure); margin: 0 auto; padding: 28px clamp(20px,5vw,24px) 80px;
  font-family: var(--mono-stack); font-size: 0.72rem; color: var(--faint); letter-spacing: 0.03em; }
@media (min-width: 1080px) { .pagefoot { margin-left: max(24px, calc(50vw - var(--measure) - 8vw)); } }

/* ============================ page-load sequence ======================= */
/* fill-mode backwards: hidden only before/during the run, then CSS resumes
   control — so the docking opacity transitions on #stage are never overridden */
@keyframes se-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes se-fade { from { opacity: 0; } }
html.intro .hero .inner > * { animation: se-rise 0.8s var(--ease) backwards; }
html.intro .hero .inner > .kicker     { animation-delay: 0.15s; }
html.intro .hero .inner > h1          { animation-delay: 0.28s; }
html.intro .hero .inner > .rule       { animation-delay: 0.52s; }
html.intro .hero .inner > .standfirst { animation-delay: 0.64s; }
html.intro .hero .inner > .actions    { animation-delay: 0.80s; }
html.intro #stage      { animation: se-fade 1.7s ease backwards; }
html.intro .scroll-cue { animation: se-fade 1s ease 0.95s backwards; }
@media (prefers-reduced-motion: reduce) {
  html.intro .hero .inner > *, html.intro #stage, html.intro .scroll-cue { animation: none; }
}

/* ===================== mobile / small screens ========================== */
@media (max-width: 1000px) {
  /* the live orbit becomes a faint full-bleed backdrop; no corner figure
     floating over the article on a small screen */
  #stage {
    position: fixed; top: 0; left: 0; right: auto;
    width: 100vw; height: 100svh; transform: none; opacity: 0.42;
  }
  #stage.is-docked, #stage.is-hidden { display: none; }
  #stage .stage-hud { display: none; }

  /* a soft scrim keeps the hero type crisp over the moving orbit */
  .hero { align-items: center; }
  .hero::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: radial-gradient(120% 90% at 25% 45%, rgba(7,10,18,0.72) 0%, rgba(7,10,18,0.5) 45%, rgba(7,10,18,0.2) 100%);
  }
  .hero .inner { padding: 10vh 0; }
  .hero .actions { flex-direction: column; align-items: flex-start; gap: 12px; }
  .hero .actions a { font-size: 0.9rem; }
  .inst-controls .jump > span { white-space: nowrap; }

  /* instrument controls: compact, thumb-friendly two-up layout */
  .inst-controls { gap: 10px; padding: 12px; }
  .inst-controls .spacer { display: none; }
  .inst-controls #btnPlay   { order: 1; flex: 1 1 44%; justify-content: center; }
  .inst-controls #btnPredict{ order: 2; flex: 1 1 44%; }
  .inst-controls .speed     { order: 3; flex: 1 1 100%; }
  .inst-controls .speed input[type=range] { flex: 1; width: auto; }
  .inst-controls .seg       { order: 4; flex: 1 1 100%; }
  .inst-controls .seg .seg-btn { flex: 1; text-align: center; }
  .inst-controls .jump      { order: 5; flex: 1 1 100%; }
  .inst-controls .jump select { flex: 1; max-width: none; }
  .inst-controls #btnReseed { order: 6; flex: 1 1 100%; }
  .inst-controls button { text-align: center; padding: 10px 13px; }
}
@media (max-width: 720px) {
  .instrument-stage { aspect-ratio: 1 / 1; }
  .inst-inset { width: 40%; min-width: 0; right: 10px; bottom: 10px; }
  .inst-inset .lbl { font-size: 0.54rem; }
  .inst-clock .d { font-size: 1.1rem; }
  .inst-clock .sub { font-size: 0.6rem; }
  .inst-banner { font-size: 0.68rem; padding: 7px 12px; }
  .hero h1 { font-size: clamp(2.5rem, 12vw, 3.4rem); }
  .chapter h2 { font-size: clamp(1.55rem, 6vw, 2rem); }
}
