/* ============================================================================
   ess-station-lab.css — the shared look of the Earth Systems Science station labs
   ----------------------------------------------------------------------------
   One stylesheet for every page under /courses/earth-systems-science/labs/<slug>/.
   The eighteen station labs share one engine (/assets/js/ess-station-lab.js) and
   one markup vocabulary, so their styles live here once instead of being pasted
   into eighteen page <style> blocks that would drift apart.

   Tokens only. Every colour is a studio token (--ink, --accent, --line, ...);
   the page sits inside `.light-band.course-ess`, which resolves those tokens to
   the ESS daylight palette. The ESS module pages are daylight-only, so there is
   no separate dark theme to cover here.

   CTAs use the global .btn-primary / .btn-secondary untouched: studio-tokens.css
   deliberately paints ESS primary buttons studio violet in daylight.
   ============================================================================ */

.esl-wrap { max-width: 980px; --accent-tint: var(--c-ess-tint); }

/* ---------- Header vocabulary (matches the ESS module pages) ---------- */
.esl-wrap .back-row { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin: 0 0 1.5rem; }
.esl-wrap .back-link { font-family: var(--font-mono); font-size: .78rem; color: var(--accent); border: 1px solid var(--line-strong); border-radius: 8px; padding: .55rem .9rem; text-decoration: none; background: var(--surface); display: inline-flex; align-items: center; min-height: 44px; }
.esl-wrap .back-link:hover { border-color: var(--accent); }
.esl-wrap .back-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--accent); }
.esl-wrap .page-hero h1 { overflow-wrap: anywhere; }
.lab-badge-row { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: .9rem; }
.lab-badge { font-family: var(--font-mono); font-size: .68rem; font-weight: 600; letter-spacing: .06em; color: var(--accent); background: var(--accent-tint); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .75rem; }
.ess-lede { max-width: 760px; margin: 0 auto 1.75rem; text-align: center; color: var(--ink-2); font-size: 1.03rem; line-height: 1.75; overflow-wrap: anywhere; }

/* The hidden attribute must win over component display rules such as the global
   .btn-primary { display: inline-flex }, or a hidden button stays on screen. */
.esl-app [hidden], .esl-dialog-backdrop[hidden] { display: none !important; }

/* ---------- Shared text + cards ---------- */
.esl-app { color: var(--ink-2); }
.esl-app p, .esl-app li, .esl-app label, .esl-app legend { overflow-wrap: anywhere; }
/* Table cells wrap only between words; the wrapper scrolls sideways if needed. */
.esl-table th, .esl-table td { overflow-wrap: normal; word-break: normal; hyphens: manual; }
.esl-mirror tbody th { min-width: 7.5rem; }
.esl-app h2 { font-family: var(--font-display); color: var(--ink); font-size: clamp(1.45rem, 1.1rem + 1.4vw, 1.95rem); line-height: 1.2; margin: .2rem 0 .8rem; }
.esl-app h2:focus { outline: none; }
.esl-app h2:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint); border-radius: 6px; }
.esl-app h3 { font-family: var(--font-heading); color: var(--ink); font-size: 1.08rem; margin: 0 0 .6rem; }
.esl-app p { line-height: 1.7; margin: 0 0 .85rem; }
.esl-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--arch-shadow-sm); padding: 1.15rem 1.25rem; margin: 0 0 1.1rem; }
.teach-card { background: var(--accent-tint); border: 1px solid var(--line-strong); border-left: 4px solid var(--accent); border-radius: 10px; padding: 1rem 1.1rem; margin: 0 0 1.1rem; color: var(--ink-2); }
.teach-card p:last-child, .esl-card p:last-child { margin-bottom: 0; }
.teach-card .teach-k { display: block; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: .35rem; }
.teach-card .teach-q { font-family: var(--font-heading); font-size: 1.12rem; color: var(--ink); font-weight: 700; line-height: 1.45; }
.esl-eyebrow { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 600; }
.esl-muted { color: var(--muted); font-size: .9rem; }
.lab-sr-only { 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; }

/* ---------- Phase 0 ---------- */
.esl-standards { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.esl-standards li { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: .65rem .8rem; line-height: 1.55; }
.esl-standards code { font-family: var(--font-mono); font-size: .78rem; color: var(--accent); font-weight: 700; margin-right: .35rem; }
.esl-map { list-style: none; counter-reset: esl-map; padding: 0; margin: 0; display: grid; gap: .55rem; }
@media (min-width: 720px) { .esl-map { grid-template-columns: 1fr 1fr; } }
.esl-map li { counter-increment: esl-map; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: .7rem .85rem .7rem 2.6rem; position: relative; line-height: 1.5; }
.esl-map li::before { content: counter(esl-map); position: absolute; left: .75rem; top: .7rem; width: 1.4rem; height: 1.4rem; border-radius: 999px; background: var(--accent-tint); color: var(--accent); font-family: var(--font-mono); font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
.esl-map strong { color: var(--ink); display: block; }

/* ---------- Figures + canvases ---------- */
.esl-figure { margin: 0 0 1rem; }
.esl-canvas-wrap { position: relative; width: 100%; max-width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: var(--surface); }
.esl-canvas-wrap canvas { display: block; width: 100%; height: auto; }
.esl-figure figcaption { font-size: .86rem; color: var(--muted); line-height: 1.55; margin-top: .5rem; }
.esl-locked { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; text-align: center; background: var(--paper); color: var(--ink-2); font-weight: 600; font-size: .95rem; line-height: 1.5; }
.esl-locked[hidden] { display: none; }

/* ---------- Stepper ---------- */
.esl-stepper { margin: 0 0 .5rem; }
.esl-stepper ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.esl-step { min-height: 44px; min-width: 44px; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-family: var(--font-mono); font-size: .74rem; font-weight: 600; letter-spacing: .03em; cursor: pointer; }
.esl-step:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.esl-step[aria-current="step"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.esl-step[data-done="true"]::after { content: " \2713"; }
.esl-step:disabled { cursor: not-allowed; color: var(--muted); background: var(--recessed); border-style: dashed; }
.esl-stepper-note { font-size: .82rem; color: var(--muted); margin: .25rem 0 0; }
.esl-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; border-bottom: 1px solid var(--line); padding-bottom: .8rem; margin: 0 0 1.4rem; }

/* ---------- Save indicator + banners ---------- */
.esl-save { font-family: var(--font-mono); font-size: .72rem; font-weight: 600; letter-spacing: .04em; border: 1px solid var(--line-strong); border-radius: 999px; padding: .35rem .75rem; color: var(--muted); background: var(--surface); }
.esl-save[data-state="saved"] { color: var(--accent); border-color: var(--accent); }
.esl-save[data-state="error"], .esl-save[data-state="offline"] { color: var(--ink); border-color: var(--ink); border-style: dashed; }
.esl-banner { border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--paper); padding: .8rem 1rem; margin: 0 0 1.1rem; display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.esl-banner p { margin: 0; }
.esl-banner[hidden] { display: none; }

/* ---------- Phases + beats ---------- */
.esl-phase[hidden] { display: none; }
.esl-beat { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 1.1rem 1.2rem; margin: 0 0 1rem; }
.esl-beat[hidden] { display: none; }
.esl-beat-k { display: inline-flex; align-items: center; gap: .45rem; font-family: var(--font-mono); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: .35rem; }
.esl-beat-k .esl-num { width: 1.4rem; height: 1.4rem; border-radius: 999px; background: var(--accent-tint); display: inline-grid; place-items: center; }
.esl-beat--locked { background: var(--paper); border-style: dashed; }

/* ---------- Inputs ---------- */
.esl-q { margin: 0 0 1rem; }
.esl-q-prompt { display: block; font-weight: 600; color: var(--ink); line-height: 1.55; margin: 0 0 .45rem; }
.esl-q-help { font-size: .84rem; color: var(--muted); margin: .35rem 0 0; }
.esl-text { width: 100%; max-width: 100%; min-height: 6.5rem; resize: vertical; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); padding: .7rem .8rem; font-family: var(--font-body); font-size: 1rem; line-height: 1.55; box-sizing: border-box; }
.esl-text[readonly] { background: var(--recessed); color: var(--ink-2); }
.esl-text:focus-visible, .lab-control:focus-visible, .esl-opt input:focus-visible + span, .esl-chip:focus-visible, .esl-disclosure:focus-visible, .esl-step:focus-visible, .esl-app .btn-primary:focus-visible, .esl-app .btn-secondary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 1px var(--accent); }
.esl-mc { border: 0; margin: 0 0 1rem; padding: 0; min-width: 0; }
.esl-mc legend { padding: 0; }
.esl-opts { display: grid; gap: .45rem; }
.esl-opt { display: flex; align-items: flex-start; gap: .6rem; min-height: 44px; padding: .6rem .75rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; line-height: 1.5; color: var(--ink-2); }
.esl-opt:hover { border-color: var(--accent); }
.esl-opt input { width: 1.15rem; height: 1.15rem; margin: .18rem 0 0; flex-shrink: 0; accent-color: var(--accent); }
.esl-opt input:checked + span { color: var(--ink); font-weight: 600; }
.esl-opt input:disabled { cursor: not-allowed; }
.esl-opt:has(input:disabled) { cursor: default; background: var(--recessed); }
.esl-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.esl-opt input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.esl-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .6rem 0 0; }
.esl-actions .btn-primary, .esl-actions .btn-secondary, .esl-app .btn-primary, .esl-app .btn-secondary { min-height: 44px; }
.esl-app .btn-primary:disabled, .esl-app .btn-secondary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.esl-why { font-size: .86rem; color: var(--muted); margin: .25rem 0 0; }

/* ---------- Model controls ---------- */
.esl-controls { display: grid; gap: .9rem; margin: 0 0 1rem; }
@media (min-width: 720px) { .esl-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.esl-control { min-width: 0; }
.esl-control-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem .6rem; align-items: baseline; margin-bottom: .2rem; }
.esl-control-head label, .esl-control legend { font-weight: 600; color: var(--ink); font-size: .95rem; }
.esl-control output { font-family: var(--font-mono); font-size: .82rem; color: var(--accent); font-weight: 700; }
.esl-control input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); margin: 0; }
.esl-control .esl-q-help { margin-top: 0; }
fieldset.esl-control { border: 0; padding: 0; margin: 0; }
.esl-choice { display: flex; flex-wrap: wrap; gap: .4rem; }
.esl-choice .esl-opt { padding: .45rem .7rem; }

/* ---------- Mirror + data tables ---------- */
.esl-table-wrap { max-width: 100%; overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 10px; }
.esl-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.esl-table caption { text-align: left; font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: .55rem .75rem; }
.esl-table th, .esl-table td { text-align: left; padding: .45rem .75rem; border-top: 1px solid var(--line); vertical-align: top; }
.esl-table thead th { color: var(--ink); font-weight: 700; background: var(--recessed); }
.esl-table tbody th { color: var(--ink-2); font-weight: 600; }
.esl-table td { font-family: var(--font-mono); font-size: .82rem; color: var(--ink); }
.esl-empty { color: var(--muted); font-style: italic; font-family: var(--font-body); }

/* ---------- Feedback + quotes ---------- */
.esl-feedback { border-radius: 10px; padding: .75rem .9rem; margin: .6rem 0 0; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-2); line-height: 1.55; }
.esl-feedback[hidden] { display: none; }
.esl-feedback strong { color: var(--ink); }
.esl-feedback[data-correct="true"] { border-left: 4px solid var(--accent); }
.esl-feedback[data-correct="false"] { border-left: 4px dashed var(--ink); }
.esl-quote { margin: 0 0 .9rem; padding: .7rem .9rem; border-left: 4px solid var(--line-strong); background: var(--recessed); border-radius: 0 10px 10px 0; color: var(--ink); line-height: 1.55; white-space: pre-wrap; }
.esl-quote-k { display: block; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: .25rem; white-space: normal; }

/* ---------- Disclosures ---------- */
.esl-disclosure { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: .45rem .85rem; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .9rem; cursor: pointer; text-align: left; }
.esl-disclosure::before { content: "+"; font-family: var(--font-mono); color: var(--accent); font-weight: 700; }
.esl-disclosure[aria-expanded="true"]::before { content: "\2212"; }
.esl-disclosure-body { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: .8rem 1rem; margin: .5rem 0 1rem; }
.esl-disclosure-body[hidden] { display: none; }
.esl-disclosure-body ul { margin: 0; padding-left: 1.1rem; }
.esl-disclosure-body li { margin: 0 0 .4rem; line-height: 1.55; }

/* ---------- CER chips ---------- */
.esl-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .5rem; padding: 0; list-style: none; }
.esl-chip { min-height: 44px; padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: .84rem; font-weight: 600; cursor: pointer; }
.esl-chip:hover { border-color: var(--accent); color: var(--accent); }
.esl-rubric { margin: 0; padding-left: 1.1rem; }
.esl-rubric li { margin: 0 0 .35rem; line-height: 1.55; }

/* ---------- Summary + submission ---------- */
.esl-summary { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; }
.esl-summary li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; border-bottom: 1px dashed var(--line); padding: .35rem 0; }
.esl-summary li span:last-child { font-family: var(--font-mono); font-size: .82rem; color: var(--ink); }
.esl-confidence .esl-opts { grid-template-columns: 1fr; }
@media (min-width: 720px) { .esl-confidence .esl-opts { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.esl-submitted { border: 1px solid var(--accent); background: var(--accent-tint); border-radius: 12px; padding: .9rem 1rem; color: var(--ink); margin: 0 0 1rem; }
.esl-submitted[hidden] { display: none; }

/* ---------- Dialog (save failure) ---------- */
.esl-dialog-backdrop { position: fixed; inset: 0; z-index: 5000; background: color-mix(in srgb, var(--ink) 55%, transparent); display: grid; place-items: center; padding: 16px; }
.esl-dialog-backdrop[hidden] { display: none; }
.esl-dialog { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--arch-shadow-lg); padding: 1.3rem 1.4rem; }
.esl-dialog h2 { font-family: var(--font-heading); font-size: 1.25rem; color: var(--ink); margin: 0 0 .6rem; }

.esl-sources { font-size: .84rem; color: var(--muted); line-height: 1.6; }
.esl-sources a { color: var(--accent); }
.esl-app a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .esl-app *, .esl-app *::before, .esl-app *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Print: every phase, no controls ----------
   .light-band defeats `body > *:not(...)` negations (the recorded blank-printout
   trap), so this targets the lab's own classes explicitly. */
@media print {
  #nav-root, #footer-root, .skip-link, .esl-stepper, .esl-stepper-note, .esl-save, .esl-controls,
  .esl-actions, .esl-chips, .esl-canvas-wrap, .esl-disclosure, .esl-banner, .esl-dialog-backdrop,
  .back-row, .esl-start { display: none !important; }
  .esl-phase, .esl-beat, .esl-disclosure-body { display: block !important; }
  .esl-phase[hidden], .esl-beat[hidden], .esl-disclosure-body[hidden] { display: block !important; }
  .esl-card, .esl-beat, .teach-card, .esl-text, .esl-opt { background: var(--surface) !important; box-shadow: none !important; }
  .esl-phase { break-before: page; }
  .esl-phase:first-of-type { break-before: auto; }
}
