/* ── reservoir-explorer.css ──────────────────────────────────────────────────
   Styling for the reusable reservoir 3D block (see reservoir-explorer.mjs).

   THEME MODEL — read this before changing a colour.
   Every colour is a `--rx-*` token whose value is `var(--<site token>, <fallback>)`.
   That two-level chain does the theming with no JS and no duplication:

     • On a host page that defines the site's token set (the five special-report
       pages define --panel/--ink/--line/--accent/... and pin `color-scheme: dark`),
       the site token WINS and the block inherits the page exactly — including under
       a light OS, which is correct: those pages are intentionally dark-only.
     • On a page that defines nothing (the local preview harness, or a future light
       page), the fallback applies, and the `prefers-color-scheme: light` block below
       swaps only the FALLBACKS, so the block is legible in both schemes.

   `data-rx-theme="light"|"dark"` on the container forces one palette (the harness
   uses it to screenshot both without touching the OS setting).

   The block never sets a font-family: it inherits the host page's. Sizes are rem.
   ─────────────────────────────────────────────────────────────────────────── */

.reservoir-explorer {
    /* geometry */
    --rx-radius: 14px;
    --rx-aspect: 4 / 3;
    --rx-max-width: 860px;
    --rx-gauge-width: 124px;

    /* palette — dark defaults (site tokens win wherever the page defines them) */
    --rx-panel: var(--panel, #171c24);
    --rx-panel-2: var(--panel-2, #1e2530);
    --rx-ink: var(--ink, #e9edf3);
    --rx-ink-dim: var(--ink-dim, #9aa7b8);
    --rx-ink-faint: var(--ink-faint, #66738a);
    --rx-line: var(--line, #2a3342);
    --rx-accent: var(--accent, #4c9be8);
    --rx-brand: var(--brand, #e8b64c);
    --rx-danger: var(--danger, #d96b6b);
    --rx-stage-bg: var(--panel, #171c24);
    --rx-track: var(--panel-2, #1e2530);
    --rx-water: #3d86c9;
    --rx-water-top: #6fb2ea;

    display: block;
    max-width: var(--rx-max-width);
    color: var(--rx-ink);
}

@media (prefers-color-scheme: light) {
    .reservoir-explorer:not([data-rx-theme="dark"]) {
        --rx-panel: var(--panel, #f5f7fa);
        --rx-panel-2: var(--panel-2, #e9edf3);
        --rx-ink: var(--ink, #14181f);
        --rx-ink-dim: var(--ink-dim, #414d60);
        --rx-ink-faint: var(--ink-faint, #5c6a7e);
        --rx-line: var(--line, #d3dae5);
        --rx-accent: var(--accent, #1a63a8);
        --rx-brand: var(--brand, #8a6208);
        --rx-danger: var(--danger, #a83232);
        --rx-stage-bg: var(--panel, #dfe5ee);
        --rx-track: var(--panel-2, #e9edf3);
        --rx-water: #2f74b4;
        --rx-water-top: #5aa0dc;
    }
}

.reservoir-explorer[data-rx-theme="light"] {
    --rx-panel: #f5f7fa;
    --rx-panel-2: #e9edf3;
    --rx-ink: #14181f;
    --rx-ink-dim: #414d60;
    --rx-ink-faint: #5c6a7e;
    --rx-line: #d3dae5;
    --rx-accent: #1a63a8;
    --rx-brand: #8a6208;
    --rx-danger: #a83232;
    --rx-stage-bg: #dfe5ee;
    --rx-track: #e9edf3;
    --rx-water: #2f74b4;
    --rx-water-top: #5aa0dc;
    color-scheme: light;
}

.reservoir-explorer *,
.reservoir-explorer *::before,
.reservoir-explorer *::after { box-sizing: border-box; }

/* ── stage + gauge row ─────────────────────────────────────────────────────── */

.rx-body { display: flex; gap: 14px; align-items: stretch; }

/* The stage mirrors `.model-shell` on great-salt-lake-files.html. The aspect
   ratio is LOAD-BEARING: the poster is rendered from exactly the camera-orbit /
   field-of-view the element is given, so poster → live model is seamless. Any
   other aspect changes the horizontal extent (FOV is vertical) and the model
   visibly jumps when it swaps in. Override per-mount with `cfg.aspect`. */
.rx-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    aspect-ratio: var(--rx-aspect);
    border: 1px solid var(--rx-line);
    border-radius: var(--rx-radius);
    overflow: hidden;
    background: var(--rx-stage-bg);
}
.rx-stage model-viewer {
    display: block; width: 100%; height: 100%;
    --poster-color: transparent;
}
.rx-poster {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.reservoir-explorer.rx-live .rx-poster { display: none; }

/* Year badge floated over the model while scrubbing. The readout below carries
   the same value and is what assistive tech reads, so this is aria-hidden. */
.rx-badge {
    position: absolute; left: 12px; top: 12px;
    padding: 5px 13px; border-radius: 999px;
    background: rgba(10, 13, 18, .74);
    border: 1px solid rgba(255, 255, 255, .18);
    color: #f2f5fa;
    font-size: .82rem; font-weight: 700; letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(6px);
    pointer-events: none;
}
.reservoir-explorer.rx-static .rx-badge,
.reservoir-explorer.rx-no-levels .rx-badge { display: none; }

/* ── elevation gauge ───────────────────────────────────────────────────────── */

.rx-gauge {
    flex: 0 0 var(--rx-gauge-width);
    border: 1px solid var(--rx-line);
    border-radius: var(--rx-radius);
    background: var(--rx-panel);
    padding: 12px 10px;
    display: flex; flex-direction: column; gap: 8px;
}
.rx-gauge-title {
    font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
    color: var(--rx-ink-faint); text-align: center;
}
.rx-gauge-track {
    position: relative; flex: 1 1 auto; min-height: 150px;
    border-radius: 8px;
    background: var(--rx-track);
    border: 1px solid var(--rx-line);
    overflow: hidden;
}
.rx-gauge-fill {
    position: absolute; left: 0; right: 0; bottom: 0;
    height: 0%;
    background: linear-gradient(180deg, var(--rx-water-top), var(--rx-water));
    transition: height .18s linear;
}
.rx-ref {
    position: absolute; left: 0; right: 0;
    border-top: 1px dashed var(--rx-ink-faint);
    pointer-events: none;
}
/* Number only. The gauge is ~124px wide, so a full label ("Minimum power pool
   3,490") overruns the track and clips; the names are carried in full by the
   legend below instead. The panel-coloured chip keeps the value legible where a
   line falls inside the water fill. */
.rx-ref > span {
    position: absolute; right: 3px; bottom: 1px;
    padding: 0 4px; border-radius: 3px;
    background: var(--rx-panel);
    font-size: .6rem; letter-spacing: .03em; line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: var(--rx-ink-dim);
    white-space: nowrap;
}
/* A line near the top of the track would push its label out through the
   track's `overflow: hidden` edge (visible at phone width, where the track is
   only ~180px tall). Hang those labels below the line instead. */
.rx-ref.rx-ref-high > span { bottom: auto; top: 1px; }
.rx-ref-full { border-top-color: var(--rx-accent); }
.rx-ref-full > span { color: var(--rx-accent); }
.rx-ref-record { border-top: 1px solid var(--rx-danger); }
.rx-ref-record > span { color: var(--rx-danger); }
.rx-gauge-marker {
    position: absolute; left: -1px; right: -1px;
    border-top: 2px solid var(--rx-ink);
    transition: bottom .18s linear;
}

/* ── controls ──────────────────────────────────────────────────────────────── */

.rx-controls {
    margin-top: 14px;
    border: 1px solid var(--rx-line);
    border-radius: var(--rx-radius);
    background: var(--rx-panel);
    padding: 14px 16px 12px;
}

.rx-readout {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px;
    margin-bottom: 12px;
}
.rx-readout-year {
    font-size: 1.65rem; font-weight: 800; line-height: 1;
    color: var(--rx-ink); font-variant-numeric: tabular-nums;
}
.rx-readout-metric { display: flex; align-items: baseline; gap: 6px; }
.rx-readout-value {
    font-size: 1.05rem; font-weight: 700; color: var(--rx-ink);
    font-variant-numeric: tabular-nums;
}
.rx-readout-label {
    font-size: .68rem; letter-spacing: .13em; text-transform: uppercase;
    color: var(--rx-ink-faint);
}
.rx-readout-note {
    flex-basis: 100%;
    font-size: .74rem; color: var(--rx-ink-faint);
}

.rx-scrub-row { display: flex; align-items: center; gap: 12px; }

.rx-play {
    flex: 0 0 auto;
    min-width: 84px; min-height: 34px;
    padding: 7px 14px;
    border: 1px solid var(--rx-line);
    border-radius: 999px;
    background: var(--rx-panel-2);
    color: var(--rx-ink);
    font: inherit; font-size: .8rem; font-weight: 600;
    cursor: pointer;
}
.rx-play:hover { border-color: var(--rx-accent); }
.rx-play:focus-visible { outline: 2px solid var(--rx-accent); outline-offset: 2px; }

.rx-scrub {
    flex: 1 1 auto; min-width: 0;
    accent-color: var(--rx-accent);
    height: 34px;
    cursor: pointer;
}
.rx-scrub:focus-visible { outline: 2px solid var(--rx-accent); outline-offset: 4px; border-radius: 6px; }

/* The tick rail lines up with the slider thumb, not the Play button. */
.rx-ticks {
    display: flex; justify-content: space-between;
    margin-top: 2px;
    padding-left: calc(84px + 12px);
    font-size: .68rem; color: var(--rx-ink-faint);
    font-variant-numeric: tabular-nums;
}

.rx-legend {
    margin-top: 12px;
    display: flex; flex-wrap: wrap; gap: 6px 10px;
    font-size: .72rem; color: var(--rx-ink-dim);
}
.rx-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.rx-legend-swatch {
    width: 16px; height: 0;
    border-top: 2px dashed var(--rx-ink-faint);
    display: inline-block;
}
.rx-legend-item[data-kind="full"] .rx-legend-swatch { border-top-color: var(--rx-accent); }
.rx-legend-item[data-kind="record"] .rx-legend-swatch { border-top-style: solid; border-top-color: var(--rx-danger); }
.rx-legend-item[data-kind="now"] .rx-legend-swatch { border-top-style: solid; border-top-color: var(--rx-ink); }

/* Standing footnotes under the legend swatches: which capacity the percentages
   are divided by (Powell publishes two, ~3% apart), and the initial-fill
   minimum that would otherwise read as a contradiction of the record-low line.
   Full width so they never wrap into the swatch row. */
.rx-legend-note {
    flex-basis: 100%;
    margin: 2px 0 0;
    font-size: .7rem;
    line-height: 1.5;
    color: var(--rx-ink-faint);
}

/* ── the "today" stop ──────────────────────────────────────────────────────── */
/* The last slider position is not a year: it is the latest daily reading, one
   key past the year grid. The rendered doc clip turns its elevation orange the
   moment it passes that grid; the block marks the same crossing so a reader
   cannot mistake a daily reading for a calendar-year mean. */
.reservoir-explorer[data-rx-position="today"] .rx-readout-year { color: var(--rx-danger); }
.reservoir-explorer[data-rx-position="today"] .rx-badge {
    background: rgba(96, 20, 20, .80);
    border-color: rgba(255, 190, 190, .34);
}

.rx-ar-hint, .rx-caption, .rx-disclosure, .rx-status {
    font-size: .8rem; color: var(--rx-ink-faint);
    margin-top: 10px; max-width: var(--rx-max-width);
}
.rx-ar-hint { display: none; color: var(--rx-ink-dim); }
.rx-ar-hint.rx-show { display: block; }
.rx-disclosure { font-size: .74rem; }
.rx-status[hidden] { display: none; }

/* Visible only to assistive tech — carries the scrub announcements. */
.rx-sr {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ── narrow layout ─────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
    .rx-body { flex-direction: column; }
    /* Tall enough that reference lines a few tens of feet apart do not collide.
       The legend below carries every value in full regardless. */
    .rx-gauge { flex: 0 0 auto; height: 196px; flex-direction: row; align-items: stretch; gap: 10px; }
    .rx-gauge-title { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; }
    .rx-gauge-track { min-height: 0; }
    .rx-scrub-row { flex-wrap: wrap; }
    .rx-play { order: 2; }
    .rx-scrub { order: 1; flex-basis: 100%; }
    .rx-ticks { padding-left: 0; }
    .rx-readout-year { font-size: 1.4rem; }
}

/* ── reduced motion ────────────────────────────────────────────────────────── */
/* The block never animates on its own — there is no autoplay, ever. Under a
   reduced-motion preference we additionally drop the easing on the gauge (so a
   scrub is an instant redraw) and slow the user-initiated year sweep; the sweep
   cadence itself lives in the module. */
@media (prefers-reduced-motion: reduce) {
    .rx-gauge-fill, .rx-gauge-marker { transition: none; }
}
.reservoir-explorer[data-rx-reduced-motion="1"] .rx-gauge-fill,
.reservoir-explorer[data-rx-reduced-motion="1"] .rx-gauge-marker { transition: none; }
