/* =============================================================================
 * layout.css — page shell, water column, era sections, gauge rail (D1)
 * ============================================================================= */

/* ------------------------------------------------------------- background */
.water { position: fixed; inset: 0; z-index: var(--z-bg); pointer-events: none; }

.zone-stack { position: absolute; inset: 0; }
.zone-layer {
  position: absolute; inset: 0;
  opacity: 0;
  will-change: opacity;
}

.snow { position: absolute; inset: 0; z-index: var(--z-snow); pointer-events: none; }

.caustics {
  position: absolute; top: 0; left: 0; right: 0; height: 60vh;
  z-index: var(--z-snow);
  background:
    radial-gradient(60% 40% at 30% 0%, rgba(180, 255, 245, 0.14), transparent 70%),
    radial-gradient(50% 30% at 72% 0%, rgba(180, 255, 245, 0.10), transparent 70%);
  mix-blend-mode: screen;
}

.silhouettes { position: absolute; inset: 0; z-index: var(--z-silhouette); }

.haze {
  position: absolute; inset: 0; z-index: var(--z-haze);
  background: radial-gradient(120% 80% at 50% 45%, transparent 40%, rgba(1, 5, 10, 0.55) 100%);
}

/* -------------------------------------------------------------------- HUD */
.hud {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--hud-w);
  z-index: var(--z-hud);
  padding: 1.1rem 1rem 1rem;
  display: flex; flex-direction: column; gap: 0.9rem;
  background: var(--surface-panel);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.hud-brand { display: flex; flex-direction: column; }
.hud-eyebrow {
  font-size: var(--step--1); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--whale-faint);
}
.hud-title { font-family: var(--font-serif); font-size: var(--step-1); line-height: 1.15; }

.hud-readout {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  gap: 0.2rem 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--inset-bg);
}
.readout-year {
  grid-column: 1; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--step-2); color: var(--current); line-height: 1;
}
.readout-depth {
  grid-column: 2; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--step--1); color: var(--whale-faint);
}
.readout-era { grid-column: 1 / -1; font-size: var(--step--1); color: var(--whale-dim); }

.hud-controls { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.hud-search input {
  width: 100%; padding: 0.5rem 0.6rem;
  background: var(--inset-bg);
  border: 1px solid var(--hairline); border-radius: 6px;
  color: var(--whale-white);
}
.hud-legend { flex: 0 0 auto; }
/* 11 era labels need room; without a real minimum they pile onto each other. */
.hud-minimap { position: relative; flex: 1 0 auto; min-height: 330px; margin-top: 0.4rem; }

/* ------------------------------------------------------------- gauge rail */
.gauge {
  position: fixed;
  top: 0; bottom: 0;
  left: var(--hud-w);
  width: var(--gauge-w);
  z-index: calc(var(--z-hud) - 1);
  border-right: 1px solid var(--hairline-soft);
  /* Opaque enough that the year labels keep contrast over the bright surface
   * bands as well as the hadal ones. */
  background: var(--surface-panel);
}
.gauge-band { position: absolute; left: 0; width: 6px; opacity: 0.85; }
.gauge-break {
  position: absolute; left: 0; width: var(--gauge-w); height: 0;
  border-top: 1px dashed var(--hairline);
}
.gauge-line { position: absolute; left: 8px; right: 2px; transform: translateY(-50%); }
.gauge-line::before {
  content: ''; position: absolute; left: -8px; top: 50%; width: 6px; height: 1px;
  background: var(--current); opacity: 0.7;
}
/* Crowded anchors keep their tick — the scale stays honest — but drop the text. */
.gauge-line.is-tick-only::before { width: 4px; opacity: 0.4; }
.gauge-year {
  display: block; font-family: var(--font-mono); font-size: 9px;
  font-variant-numeric: tabular-nums; color: var(--whale-dim); line-height: 1.1;
}
.gauge-label { display: block; font-size: 8px; color: var(--whale-dim); line-height: 1.1; }
.gauge-marker {
  position: absolute; left: 0; width: var(--gauge-w); height: 2px;
  background: var(--current);
  box-shadow: 0 0 10px var(--current);
  transform: translateY(-1px);
}

/* ------------------------------------------------------------------- main */
#main { margin-left: calc(var(--hud-w) + var(--gauge-w)); position: relative; z-index: var(--z-nodes); }

.overture {
  min-height: 100vh;
  display: grid; place-content: center; justify-items: center;
  text-align: center; padding: 2rem;
  gap: 1.2rem;
}
.overture-title {
  font-family: var(--font-serif);
  font-size: var(--step-5);
  letter-spacing: -0.02em; line-height: 0.95;
}
.overture-thesis { font-family: var(--font-serif); font-size: var(--step-2); color: var(--whale-dim); }
.overture-thesis .turn { color: var(--current); }
/* --whale-faint is only 2.8:1 on the surface band; this line is body-size text. */
.overture-sub { color: var(--whale-dim); max-width: 46ch; }
.overture-cue { width: 1px; height: 64px; background: linear-gradient(var(--current), transparent); }

/* --------------------------------------------------------- water column */
.timeline { position: relative; }

.era {
  position: absolute;
  left: 0; right: 0;
  top: var(--era-top);
  height: var(--era-height);
  contain-intrinsic-size: auto var(--era-height);
}

/* The heading floats over the water column, whose brightness swings from
 * surface-teal to hadal-black. A soft scrim keyed to the page ink guarantees
 * the eyebrow and blurb clear contrast at EVERY depth, in either theme. */
.era-head {
  position: sticky; top: 1.2rem;
  width: min(34ch, var(--field-left, 40%));
  margin-left: 2rem;
  padding: 1rem 1.4rem 1.2rem;
  pointer-events: none;
  background: radial-gradient(120% 100% at 0% 50%, var(--era-head-scrim) 45%, transparent 100%);
  border-radius: 10px;
}
:root { --era-head-scrim: rgba(2, 10, 18, 0.74); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --era-head-scrim: rgba(244, 250, 252, 0.82); }
}
:root[data-theme="light"] { --era-head-scrim: rgba(244, 250, 252, 0.82); }

.era-zone {
  font-size: var(--step--1); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--whale-dim);
}
.era-title { font-family: var(--font-serif); font-size: var(--step-3); line-height: 1.05; margin: 0.2rem 0 0.5rem; }
.era-blurb { color: var(--whale-dim); font-size: var(--step-0); max-width: 34ch; }

/* The node field starts to the right of the sticky era heading (see layout()). */
.era-field { position: absolute; inset: 0 0 0 var(--field-left, 0px); }

.empty-note { padding: 20vh 2rem; color: var(--whale-dim); text-align: center; }

/* ------------------------------------------------------------- chart mode */
/* Chart mode sits to the right of the persistent chrome, so the star-field
 * never paints under the HUD or the gauge. */
.chart {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  left: calc(var(--hud-w) + var(--gauge-w));
  z-index: var(--z-card);
  background: var(--surface-panel);
  overflow-y: auto;
}
/* Decorative only — it must never compete with the table of contents. */
#chart-canvas { position: absolute; inset: 0; pointer-events: none; opacity: 0.3; }

@media (max-width: 900px) { .chart { left: 0; } }
.chart-toc {
  position: relative; z-index: 1;
  max-width: 78ch; margin: 0 auto; padding: 4rem 1.5rem 6rem;
}
html.chart-mode #main > .timeline { visibility: hidden; }

/* --------------------------------------------------------------- colophon */
.colophon { padding: 6rem 2rem 8rem; max-width: var(--measure); margin-inline: auto; color: var(--whale-dim); }

/* -------------------------------------------------------------- noscript */
.noscript-note { max-width: 60ch; margin: 4rem auto; padding: 2rem; }
.noscript-note h1 { font-family: var(--font-serif); margin-bottom: 1rem; }
.noscript-note p { margin-bottom: 1rem; }

/* --------------------------------------------------------------- responsive
 * At narrow widths the HUD becomes a top bar and the gauge hides. At 320px /
 * 400% zoom we fall back to the linearized column (see components.css).
 * ------------------------------------------------------------------- */
@media (max-width: 900px) {
  .hud {
    position: sticky; top: 0; bottom: auto;
    width: 100%; height: auto; max-height: 42vh;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    border-right: 0; border-bottom: 1px solid var(--hairline);
  }
  .hud-minimap, .hud-legend { display: none; }
  .gauge { display: none; }
  #main { margin-left: 0; }
  .era-head { width: auto; max-width: 90%; margin-left: 1rem; }
}
