/* Plunge Watch — admiralty-chart aesthetic.
   Light = paper nautical chart; dark = night passage.
   Color roles follow the validated reference palette. */

:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;      /* blue — primary series */
  --series-2: #008300;      /* green — second class (weekend) */
  --seq-150: #b7d3f6;       /* meter track / shallow water */
  --seq-300: #6da7ec;
  --seq-450: #2a78d6;
  --seq-600: #184f95;       /* deep water */
  --seq-700: #0d366b;       /* the plunge zone floor */
  --accent-ink: #184f95;    /* engraved chart-ink accents */
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #008300;
    --seq-150: #104281;
    --seq-300: #1c5cab;
    --seq-450: #3987e5;
    --seq-600: #86b6ef;
    --seq-700: #b7d3f6;
    --accent-ink: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #008300;
  --seq-150: #104281;
  --seq-300: #1c5cab;
  --seq-450: #3987e5;
  --seq-600: #86b6ef;
  --seq-700: #b7d3f6;
  --accent-ink: #86b6ef;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 24px 64px;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace; }

/* ---------- masthead ---------- */

header.masthead {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 0 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
}

.masthead h1 {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 44px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.masthead h1 .tilde { color: var(--accent-ink); }

.issue-line {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  text-transform: uppercase;
  margin-top: 8px;
}

.masthead form { margin-left: auto; }

button.refresh {
  font: 600 13px/1 system-ui, sans-serif;
  color: var(--surface);
  background: var(--ink);
  border: none;
  border-radius: 4px;
  padding: 10px 16px;
  cursor: pointer;
}
button.refresh:hover { background: var(--accent-ink); }
button.refresh:focus-visible,
a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}

main { max-width: 1180px; margin: 0 auto; }

/* ---------- layout ---------- */

.grid {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}
/* Grid items must never inherit their content's minimum width — wide
   tables scroll inside their card instead of stretching the page. */
.grid > * { min-width: 0; }
.hero-grid { grid-template-columns: 320px 1fr; }
.trio { grid-template-columns: repeat(3, 1fr); }
.duo { grid-template-columns: 1fr 1fr; }

@media (max-width: 980px) {
  .hero-grid, .trio, .duo { grid-template-columns: 1fr; }
  .masthead h1 { font-size: 32px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px 14px;
  overflow-x: auto;   /* wide tables scroll here, never the page */
}

.card h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 2px;
}
.card .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }

section.band > h2 {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 40px 0 4px;
}
section.band > p.lede { color: var(--ink-2); max-width: 72ch; }

/* ---------- hero ---------- */

.hero-figure { padding-top: 26px; }
.hero-figure .label {
  font-size: 13px;
  color: var(--ink-2);
  max-width: 20ch;
}
.hero-figure .value {
  font-size: 76px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.hero-figure .value small { font-size: 32px; font-weight: 500; color: var(--ink-2); }

.meter {
  height: 10px;
  border-radius: 5px;
  background: var(--seq-150);
  margin: 18px 0 6px;
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  min-width: 4px;
  background: var(--seq-450);
  border-radius: 5px;
}
.meter-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.hero-stats { margin-top: 22px; border-top: 1px solid var(--grid); }
.hero-stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 13.5px;
}
.hero-stats dt { color: var(--ink-2); }
.hero-stats dd { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; }

/* ---------- recipe KPI row ---------- */

.recipe { counter-reset: step; }
.recipe .card { position: relative; }
.recipe .cond {
  font-size: 13px;
  color: var(--ink-2);
  min-height: 40px;
}
.recipe .rate { font-size: 40px; font-weight: 600; margin-top: 2px; }
.recipe .rate small { font-size: 18px; color: var(--ink-2); font-weight: 500; }
.recipe .n { font-size: 12px; color: var(--muted); }
.recipe .arrow {
  align-self: center;
  color: var(--muted);
  font-size: 20px;
  text-align: center;
}
.recipe-grid { grid-template-columns: 1fr 24px 1fr 24px 1fr 24px 1fr; align-items: stretch; }
@media (max-width: 980px) {
  .recipe-grid { grid-template-columns: 1fr; }
  .recipe .arrow { transform: rotate(90deg); }
}

/* ---------- charts ---------- */

figure.viz { position: relative; }
figure.viz svg { display: block; width: 100%; height: auto; }

.viz-tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  padding: 7px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  display: none;
  max-width: 240px;
}
.viz-tip .tt-t { color: var(--ink-2); font-size: 11.5px; }
.viz-tip .tt-v { font-family: "IBM Plex Mono", ui-monospace, monospace; }

.legend {
  display: flex;
  gap: 16px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 6px;
  flex-wrap: wrap;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

details.tbl { margin-top: 8px; }
details.tbl summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
details.tbl summary::before { content: "▸ "; }
details.tbl[open] summary::before { content: "▾ "; }
details.tbl table {
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 12.5px;
  width: 100%;
}
details.tbl th {
  text-align: left;
  color: var(--ink-2);
  font-weight: 600;
  border-bottom: 1px solid var(--baseline);
  padding: 4px 8px 4px 0;
}
details.tbl td {
  border-bottom: 1px solid var(--grid);
  padding: 4px 8px 4px 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- track record ---------- */

table.track {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.track th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  border-bottom: 1px solid var(--baseline);
  padding: 8px 12px 8px 0;
}
table.track td {
  border-bottom: 1px solid var(--grid);
  padding: 8px 12px 8px 0;
  font-variant-numeric: tabular-nums;
}
.hit { color: var(--series-2); font-weight: 600; }
.pill {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
}

/* ---------- static site: cartouche masthead ---------- */

a.gh {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 14px;
  background: var(--surface);
}
a.gh:hover { color: var(--ink); border-color: var(--ink-2); }

.cartouche {
  max-width: 760px;
  margin: 44px auto 8px;
  padding: 26px 20px 22px;
  text-align: center;
  border-top: 4px double var(--ink);
  border-bottom: 4px double var(--ink);
}
.cartouche h1 {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 52px;
  line-height: 1.05;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 10px 0 8px;
}
.cartouche h1 .tilde { color: var(--accent-ink); }
.cart-sub {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 16px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.cartouche .issue-line { margin-top: 12px; }

.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* region dial — an engraved annotation, not a form control */
.eyebrow label[for="region-select"] { cursor: pointer; }
#region-select {
  font: 500 11px/1.4 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--baseline);
  border-radius: 0;
  padding: 1px 2px;
  cursor: pointer;
  appearance: auto;
}
#region-select:hover { color: var(--ink); border-bottom-color: var(--ink-2); }
#region-select:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}
.region-note { font-style: italic; margin-top: 8px; }
section.band > .eyebrow { margin: 40px 0 -34px; }
section.band > .eyebrow + h2 { margin-top: 40px; }
.hero-band > .sub { text-align: center; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

::selection { background: var(--seq-150); }

/* ---------- the sounding chart (hero) ---------- */

:root {
  --water-shallow: #eef4fc;
  --water-deep: #c3d9f4;
  --water-line: rgba(42, 120, 214, 0.22);
  --delta-up: #006300;
  --delta-down: #898781;
  --confirmed: #8a6d1f;   /* brass — a fact, not a forecast */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --water-shallow: #101b2c;
    --water-deep: #0a1424;
    --water-line: rgba(57, 135, 229, 0.28);
    --delta-up: #0ca30c;
    --delta-down: #898781;
    --confirmed: #d9b44a;
  }
}
:root[data-theme="dark"] {
  --water-shallow: #101b2c;
  --water-deep: #0a1424;
  --water-line: rgba(57, 135, 229, 0.28);
  --delta-up: #0ca30c;
  --delta-down: #898781;
  --confirmed: #d9b44a;
}

.hero-band .lede { margin: 14px auto 6px; text-align: center; }
.hero-band > h2 + figure.sounding { margin-top: 18px; }
figure.sounding {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

/* Mobile-first: the cartouche and chart own the first screen */
@media (max-width: 700px) {
  body { padding: 0 10px 48px; }
  a.gh { display: none; }               /* footer carries the source link */
  .cartouche {
    margin: 14px auto 0;
    padding: 12px 6px 10px;
    border-top-width: 3px;
    border-bottom-width: 3px;
  }
  .cartouche h1 { font-size: 29px; letter-spacing: 0.12em; margin: 6px 0 4px; }
  .cartouche .eyebrow { font-size: 9.5px; letter-spacing: 0.12em; }
  .cart-sub { font-size: 11px; letter-spacing: 0.15em; }
  .cartouche .issue-line { margin-top: 6px; font-size: 10.5px; }
  .hero-band > h2 + figure.sounding { margin-top: 12px; }
  .hero-band .lede { font-size: 13.5px; }
  section.band > h2 { font-size: 18px; }
  table.track { min-width: 540px; }  /* scroll within the card, uncrushed */
}

/* "The working" — tap a day for the full derivation */
.working { margin-top: 14px; text-align: left; position: relative; }
.working h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}
.working .w-final { font-size: 26px; font-weight: 600; margin: 2px 0 10px; }
.working .w-final small { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.working h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 14px 0 4px;
}
/* Step 1 — the reading log: grouped inputs, value gauges, a gloss per row */
.working .w-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 2px;
}
.working .w-table td {
  border-bottom: 1px solid var(--grid);
  padding: 5px 14px 5px 0;
  vertical-align: top;
}
.working .w-table td:first-child { color: var(--ink-2); white-space: nowrap; }
.working .w-table .w-val {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.working .w-table .w-gloss { color: var(--muted); font-size: 12.5px; }
.working .w-table .w-gloss b { color: var(--ink); }
.working .w-group th {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 14px 0 3px;
  border-bottom: 1px solid var(--baseline);
}
.working .w-bar {
  display: inline-block;
  width: 56px;
  height: 7px;
  background: var(--seq-150);
  border-radius: 4px;
  overflow: hidden;
  margin-left: 8px;
  vertical-align: 1px;
}
.working .w-bar i {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--seq-450);
  border-radius: 4px;
}
@media (max-width: 700px) {
  /* stack each reading: name + value on one line, dial and gloss beneath */
  .working .w-table tr { display: grid; grid-template-columns: 1fr auto; }
  .working .w-table td:first-child { order: 1; border-bottom: 0; padding-bottom: 0; }
  .working .w-table .w-val { order: 2; border-bottom: 0; padding: 5px 0 0; text-align: right; }
  .working .w-table .w-ctl {
    order: 3;
    grid-column: 1 / -1;
    width: auto;
    min-width: 0;
    border-bottom: 0;
    padding: 4px 0 0;
  }
  .working .w-table .w-gloss { order: 4; grid-column: 1 / -1; padding-top: 1px; font-size: 12px; }
  .working .w-group { grid-template-columns: 1fr; }
}

/* Step 1 live dials: sliders and switches inside the reading log */
.working .w-table .w-ctl { width: 30%; min-width: 140px; }
.working .w-table .w-ctl input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--series-1);
  vertical-align: middle;
}
.working .w-table .w-ctl input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--series-1);
  vertical-align: middle;
}
.working .w-live .w-val { text-align: right; }

/* Step 2 — the live plate: formula, dials, curve, substitution */
.working .w-math {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12.5px;
  background: var(--plane);
  border: 1px solid var(--grid);
  border-radius: 5px;
  padding: 10px 14px 12px;
  margin-top: 4px;
  overflow-x: auto;
}
.working .w-formula {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  margin-bottom: 4px;
}
.working .w-controls {
  display: grid;
  gap: 2px 0;
  margin: 10px 0 2px;
  max-width: 720px;
}
.working .w-controls label {
  display: grid;
  grid-template-columns: 44px 1fr 76px;
  align-items: center;
  gap: 2px 12px;
  font-size: 12px;
  padding: 4px 0;
}
.working .w-ctl-name { color: var(--accent-ink); font-weight: 600; }
.working .w-controls input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--series-1);
}
.working .w-controls output {
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.working .w-ctl-gloss {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.working .w-leads {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 2px;
  font-size: 11.5px;
  color: var(--muted);
}
.working .w-leads button,
.working .w-tools button,
.working .w-tools a {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 9px;
  cursor: pointer;
  text-decoration: none;
}
.working .w-leads button:hover,
.working .w-tools button:hover,
.working .w-tools a:hover { color: var(--ink); border-color: var(--ink-2); }
.working .w-leads button.on {
  color: var(--accent-ink);
  border-color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent-ink) 10%, transparent);
}
.working .w-curve { margin: 10px 0 2px; }
.working .w-curve svg {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
}
.working .w-tune p.w-note { font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; }
.working .w-fine { margin-top: 8px; }
.working .w-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.working input[type="range"]:focus-visible,
.working input[type="checkbox"]:focus-visible,
.working .w-leads button:focus-visible,
.working .w-tools button:focus-visible,
.working .w-tools a:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}
.working .w-sub {
  border-top: 1px dashed var(--baseline);
  padding-top: 7px;
  white-space: nowrap;
  line-height: 1.8;
}
@media (max-width: 700px) {
  /* let the arithmetic wrap — the final % must not hide behind a scroll */
  .working .w-sub { white-space: normal; }
  .working .w-controls label { grid-template-columns: 36px 1fr 68px; }
}
.working p.w-note { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.working .w-confirmed {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--confirmed);
  background: color-mix(in srgb, var(--confirmed) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--confirmed) 35%, transparent);
  border-radius: 5px;
  padding: 7px 10px;
  margin-bottom: 10px;
}
.viz .confirmed-note {
  font-weight: 600;
  color: var(--confirmed);
}
.working .w-close {
  position: absolute;
  top: 12px; right: 14px;
  font: 600 13px/1 system-ui, sans-serif;
  color: var(--ink-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}
.working .w-close:hover { color: var(--ink); }

.plumb line, .plumb circle { transform-box: fill-box; }
@media (prefers-reduced-motion: no-preference) {
  .plumb {
    opacity: 0;
    animation: plumb-in 0.4s ease-out forwards;
    animation-delay: calc(var(--i) * 110ms + 200ms);
  }
  .plumb line {
    transform-origin: center top;
    transform: scaleY(0);
    animation: plumb-drop 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
    animation-delay: calc(var(--i) * 110ms + 200ms);
  }
  @keyframes plumb-in { to { opacity: 1; } }
  @keyframes plumb-drop { to { transform: scaleY(1); } }
}

/* ---------- backtest ---------- */

.cal-row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
}
.cal-band { color: var(--ink-2); font-size: 12px; }
.cal-bar { height: 10px; background: var(--seq-150); border-radius: 5px; overflow: hidden; }
.cal-bar i { display: block; height: 100%; min-width: 2px; background: var(--seq-450); border-radius: 5px; }
.cal-val { font-variant-numeric: tabular-nums; }
.cal-val em { color: var(--muted); font-style: normal; font-size: 12px; }

.bt-cell { width: 30%; }
.bt-bar {
  display: block; height: 8px;
  background: var(--seq-150);
  border-radius: 4px; overflow: hidden;
}
.bt-bar i { display: block; height: 100%; min-width: 2px; background: var(--seq-450); border-radius: 4px; }

footer {
  max-width: 1180px;
  margin: 48px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--baseline);
  font-size: 12.5px;
  color: var(--muted);
}
footer a { color: var(--ink-2); }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

@media (prefers-reduced-motion: no-preference) {
  .meter > i { transition: width 600ms ease-out; }
}
