@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin-ext.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/source-sans-3-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-600-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* Dual-theme tokens: Geological Monograph (Light) & Obsidian Glass Observatory (Dark) */
/* Base color-scheme stays light dark per modern-web-guidance dark-mode-toggle */
:root {
  color-scheme: light dark;
  --bg: #f4efe6;
  --bg-alt: #eae3d5;
  --bg-card: #fbf8f2;
  --stage-bg: #11161f;
  --fg: #14181f;
  --fg-muted: #3e4752;
  --rule: #c8bfae;
  --rule-strong: #1a212b;
  --acc: #0a4a78;
  --acc-soft: #e3eef6;
  --c-shallow: #9a4a00;
  --c-interm: #a82012;
  --c-trans: #7a1474;
  --c-deep: #00547a;
  --focus: #0a4a78;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --col: 1180px;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --bg: #080c12;
    --bg-alt: #101620;
    --bg-card: #0e141d;
    --stage-bg: #05080d;
    --fg: #f0f4f8;
    --fg-muted: #b4c0ce;
    --rule: #243040;
    --rule-strong: #dce4ee;
    --acc: #7cc9ff;
    --acc-soft: #13283d;
    --c-shallow: #ffbe4d;
    --c-interm: #ff6a47;
    --c-trans: #e879f9;
    --c-deep: #4ce8ff;
    --focus: #7cc9ff;
  }
}

:root[data-theme="dark"],
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  --bg: #080c12;
  --bg-alt: #101620;
  --bg-card: #0e141d;
  --stage-bg: #05080d;
  --fg: #f0f4f8;
  --fg-muted: #b4c0ce;
  --rule: #243040;
  --rule-strong: #dce4ee;
  --acc: #7cc9ff;
  --acc-soft: #13283d;
  --c-shallow: #ffbe4d;
  --c-interm: #ff6a47;
  --c-trans: #e879f9;
  --c-deep: #4ce8ff;
  --focus: #7cc9ff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
svg[hidden] { display: none; }

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.56;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  overflow-x: clip;
}

a {
  color: var(--acc);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex="0"]:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--fg);
  color: var(--bg);
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 0.85rem;
  z-index: 100;
}
.skip-link:focus { left: 10px; }

.wrap {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 20px;
}
.prose-wrap {
  max-width: 74ch;
  margin: 0 auto;
  padding: 0 20px;
}

/* Top bar */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--bg-alt);
}
.topbar-in {
  max-width: var(--col);
  margin: 0 auto;
  padding: 6px 20px;
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
}
.brand-link {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
  letter-spacing: 0.02em;
}
.brand-link:hover { text-decoration: underline; }
.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 0.88rem;
}
.top-nav a {
  text-decoration: none;
  color: var(--fg-muted);
  font-weight: 600;
}
.top-nav a:hover { color: var(--fg); text-decoration: underline; }
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 4px 11px;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.chip-btn:hover { border-color: var(--rule-strong); }

/* Hero header */
.hero {
  padding: 20px 0 14px;
  border-bottom: 1px solid var(--rule);
}
.kicker {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
h1 {
  margin: 0 0 9px;
  font-family: var(--serif);
  font-size: clamp(1.85rem, 3.5vw, 2.85rem);
  line-height: 1.07;
  font-weight: 700;
  letter-spacing: -0.018em;
  max-width: 28ch;
}
.deck {
  margin: 0 0 14px;
  font-size: 1.05rem;
  line-height: 1.48;
  color: var(--fg-muted);
  max-width: 72ch;
}

/* Telemetry strip */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
  list-style: none;
  margin: 0;
  padding: 0;
}
.stat-strip li {
  padding: 11px 14px 11px 0;
  border-right: 1px solid var(--rule);
}
.stat-strip li:not(:first-child) { padding-left: 14px; }
.stat-strip li:last-child { border-right: 0; padding-right: 0; }
.stat-val {
  display: block;
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--fg);
}
.stat-val.is-deep { color: var(--c-deep); }
.stat-val.is-shallow { color: var(--c-shallow); }
.stat-lbl {
  display: block;
  margin-top: 2px;
  font-size: 0.84rem;
  color: var(--fg-muted);
  line-height: 1.35;
}

/* Main 3D Glass Earth Observatory */
.observatory {
  padding: 20px 0 28px;
  border-bottom: 1px solid var(--rule);
}
.obs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.stage-shell {
  position: relative;
  border: 1px solid var(--rule-strong);
  background: var(--stage-bg);
  overflow: hidden;
}
.stage-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 360px;
  max-height: 640px;
  touch-action: none;
  cursor: grab;
}
.stage-canvas-wrap:active { cursor: grabbing; }
.stage-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-hud-top {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.hud-readout {
  background: rgba(8, 12, 18, 0.82);
  color: #f0f4f8;
  border: 1px solid rgba(180, 198, 220, 0.28);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.35;
  pointer-events: auto;
}
.hud-readout strong { color: #4ce8ff; }

.stage-zoom {
  display: flex;
  gap: 4px;
  pointer-events: auto;
}
.zoom-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid rgba(180, 198, 220, 0.35);
  background: rgba(8, 12, 18, 0.84);
  color: #f0f4f8;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.zoom-btn:hover { background: #1d2a3d; }

.stage-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 9px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--fg-muted);
}
.depth-ramp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.ramp-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.swatch.s1 { background: #ffbe4d; border: 1px solid rgba(0, 0, 0, 0.35); }
.swatch.s2 { background: #ff5733; }
.swatch.s3 { background: #d946ef; }
.swatch.s4 { background: #38e8ff; border: 1px solid rgba(0, 0, 0, 0.35); }

/* Right-hand Control & Slab Panel */
.obs-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.panel-box {
  border: 1px solid var(--rule);
  background: var(--bg-card);
  padding: 14px;
}
.panel-box h2, .panel-box h3 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.preset-btn {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.preset-btn:hover { border-color: var(--rule-strong); }
.preset-btn[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.preset-btn.full { grid-column: 1 / -1; }

.ctl-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}
.ctl-row:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.ctl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 0.88rem;
}
.ctl-head label { font-weight: 600; color: var(--fg); }
.ctl-val {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--acc);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--acc);
  min-height: 28px;
  cursor: pointer;
}
.seg-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.seg-btn {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.play-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.play-btn {
  min-height: 36px;
  padding: 5px 12px;
  border: 1px solid var(--rule-strong);
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.play-btn:hover { opacity: 0.9; }

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 8px;
  font-size: 0.86rem;
}
.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Synchronized 2D Slab Cross-Section Viewer */
.slab-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
}
.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 18px;
  margin-bottom: 12px;
}
.sec-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 700;
}
.sec-sub {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg-muted);
  max-width: 72ch;
}
.slab-frame {
  border: 1px solid var(--rule-strong);
  background: var(--bg-card);
  padding: 12px;
}
.slab-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.slab-meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.slab-canvas-wrap {
  position: relative;
  width: 100%;
  height: 310px;
}
.slab-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.slab-hover {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--fg);
  min-height: 1.4em;
}
.slab-note {
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: var(--fg-muted);
  max-width: 78ch;
}

/* Depth Histogram Figure (The 5.12x Finding) */
.hist-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--rule);
}
.hist-frame {
  border: 1px solid var(--rule);
  background: var(--bg-card);
  padding: 16px;
  overflow-x: auto;
}
.hist-svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}

/* Personal City & Birth-Year Lookup + Share */
.lookup-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--rule);
}
.lookup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: start;
}
.lookup-form {
  border: 1px solid var(--rule);
  background: var(--bg-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-group label {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.field-group input, .field-group select {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
}
.quick-cities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.qcity-btn {
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.qcity-btn:hover { border-color: var(--rule-strong); }

.lookup-result {
  border: 2px solid var(--rule-strong);
  background: var(--bg-card);
  padding: 18px;
}
.res-kicker {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--acc);
}
.res-headline {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.38rem;
  line-height: 1.24;
  font-weight: 700;
}
.res-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
  margin: 0 0 14px;
}
.res-stats dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.res-stats dd {
  margin: 2px 0 0;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--fg);
}
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.action-btn.primary {
  background: var(--fg);
  color: var(--bg);
}
.action-btn:hover { opacity: 0.88; }
.share-status {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--acc);
  min-height: 1.2em;
}

/* Editorial Chapters & Data Tables */
.story-section {
  padding: 32px 0;
  border-bottom: 1px solid var(--rule);
}
.story-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 30px;
  max-width: 72ch;
}
.chapter h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
}
.chapter p {
  margin: 0 0 12px;
  font-size: 1.03rem;
  line-height: 1.62;
  color: var(--fg);
}
.chapter p.muted { color: var(--fg-muted); font-size: 0.95rem; }

.ref-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 14px 0;
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  background: var(--bg-card);
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}
.ref-table th, .ref-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--rule);
}
.ref-table thead th {
  font-family: var(--mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-alt);
  color: var(--fg);
  white-space: nowrap;
}
.ref-table td.num {
  font-family: var(--mono);
  white-space: nowrap;
}
.ref-table tbody th,
.ref-table tfoot th {
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
}
.ref-table tfoot th,
.ref-table tfoot td {
  border-top: 2px solid var(--rule-strong);
  border-bottom: 0;
  background: var(--bg-alt);
}
.depth-table-details {
  margin-top: 16px;
  border: 1px solid var(--rule);
  background: var(--bg-card);
}
.depth-table-details > summary {
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg);
  list-style-position: inside;
}
.depth-table-details > summary:hover {
  background: var(--bg-alt);
}
.depth-table-details .ref-table-wrap {
  margin: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 0;
}

/* Method & Sources */
.method-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--rule);
}
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 32px;
}
.method-grid h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.25rem;
}
.method-grid p, .method-grid li {
  margin: 0 0 9px;
  font-size: 0.94rem;
  color: var(--fg-muted);
}
.method-grid ul { margin: 0; padding-left: 18px; }

/* Footer */
.site-footer {
  padding: 24px 0 42px;
  font-size: 0.88rem;
  color: var(--fg-muted);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 20px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

@media (max-width: 960px) {
  .obs-grid { grid-template-columns: 1fr; }
  .lookup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip li:nth-child(2) { border-right: 0; }
  .stat-strip li:nth-child(3) { padding-left: 0; border-top: 1px solid var(--rule); }
  .stat-strip li:nth-child(4) { border-top: 1px solid var(--rule); }
  .method-grid { grid-template-columns: 1fr; }
  .stage-canvas-wrap { aspect-ratio: 1 / 1; min-height: 310px; }
  .res-stats { grid-template-columns: 1fr; }
  .top-nav { display: none; }
}
