/* =========================================================================
   MET-AL · Modernization prototype — dark "heavy-metal" theme
   Chrome / brushed-steel on near-black. CVD-safe accent palette.
   All offline; no web fonts, no external assets.
   ========================================================================= */

:root {
  /* base near-black with a cold steel cast */
  --bg-0: #0a0c0f;
  --bg-1: #101419;
  --bg-2: #161b22;
  --bg-3: #1d242d;
  --panel: linear-gradient(160deg, #181d24 0%, #11151b 60%, #0d1116 100%);
  --steel: linear-gradient(180deg, #3a4351 0%, #232a33 48%, #2c343f 52%, #161b22 100%);
  --chrome: linear-gradient(180deg, #e8eef5 0%, #aab6c4 18%, #6d7886 46%, #424b56 54%, #8b97a6 82%, #c7d1dc 100%);
  --line: #2a323c;
  --line-2: #39434f;

  --ink: #e7edf4;
  --ink-dim: #aab4c0;
  --ink-faint: #6f7a87;

  /* CVD-safe model palette (Okabe-Ito derived) */
  --c-gfs:   #56b4e9;  /* sky blue   */
  --c-hrrr:  #e69f00;  /* orange     */
  --c-ecmwf: #009e73;  /* bluish green */
  --c-extra: #cc79a7;  /* reddish purple */

  --good: #4fd49a;
  --warn: #e6c84f;
  --bad:  #ef7a6d;
  --accent: #7fc7ff;

  --shadow: 0 6px 22px rgba(0,0,0,.55);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #1a2230 0%, rgba(26,34,48,0) 60%),
    radial-gradient(900px 500px at -10% 110%, #15202b 0%, rgba(21,32,43,0) 55%),
    var(--bg-0);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); }

/* brushed-steel hairline used on bars and panels */
.metal-edge {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), var(--shadow);
}

/* ---------- app grid ---------- */
#app {
  display: grid;
  grid-template-columns: 232px 1fr 312px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header header"
    "rail   main   prov"
    "rail   narr   prov";
  min-height: 100vh;
  gap: 0;
}

/* ---------- header ---------- */
header.topbar {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--steel);
  border-bottom: 1px solid #000;
  box-shadow: 0 2px 0 rgba(255,255,255,.03), 0 8px 20px rgba(0,0,0,.5);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 42px; width: auto; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.brand .wordmark { display: flex; flex-direction: column; line-height: 1.05; }
.brand .wordmark b {
  font-size: 15px; letter-spacing: .14em;
  background: var(--chrome); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,.4);
}
.brand .wordmark span { font-size: 10px; letter-spacing: .22em; color: var(--ink-faint); text-transform: uppercase; }

.synthetic-banner {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px;
  background: repeating-linear-gradient(45deg, #2a2410 0 9px, #20210e 9px 18px);
  border: 1px solid #5a4d18; color: var(--warn);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  white-space: nowrap;
}
.synthetic-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); }

.share-cluster { display: flex; align-items: center; gap: 10px; margin-left: 14px; }

/* ---------- step rail ---------- */
nav.rail {
  grid-area: rail;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.rail h2 { font-size: 10px; letter-spacing: .2em; color: var(--ink-faint); text-transform: uppercase; margin: 2px 6px 10px; }
.rail .nav-hint { margin-top: auto; font-size: 11px; color: var(--ink-faint); padding: 10px 6px 2px; border-top: 1px solid var(--line); }
.step-btn {
  display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 10px;
  text-align: left; width: 100%;
  padding: 10px 10px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  transition: background .12s, border-color .12s, color .12s;
}
.step-btn:hover { background: var(--bg-2); color: var(--ink); }
.step-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.step-btn .num {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--ink-dim);
}
.step-btn .label { display: flex; flex-direction: column; }
.step-btn .label b { font-size: 13px; font-weight: 600; }
.step-btn .label small { font-size: 10.5px; color: var(--ink-faint); }
.step-btn[aria-current="step"] {
  background: linear-gradient(180deg, #1f2937, #151c25);
  border-color: var(--line-2); color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}
.step-btn[aria-current="step"] .num { background: linear-gradient(180deg,#2b6fb0,#1b4a78); color: #eaf4ff; border-color: #3a83c4; }
.step-btn.done .num { background: linear-gradient(180deg,#1c3a2e,#143025); color: var(--good); border-color: #265a45; }

/* ---------- main ---------- */
main.stage {
  grid-area: main;
  padding: 18px 22px 8px;
  min-width: 0;
  overflow: auto;
}
.stage-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.stage-head h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: .01em; }
.stage-head .q { color: var(--accent); font-size: 13px; font-style: italic; }
.stage-sub { color: var(--ink-dim); font-size: 12.5px; margin: 2px 0 14px; max-width: 70ch; }

/* selection bar */
.selbar {
  display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end;
  padding: 12px 14px; margin-bottom: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #141a21, #0f141a);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }
.field.disabled { opacity: .4; pointer-events: none; }
select, .seg, .chiprow { background: var(--bg-2); }
select {
  appearance: none; -webkit-appearance: none;
  padding: 7px 28px 7px 10px; border-radius: 7px; border: 1px solid var(--line-2);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  min-width: 92px; cursor: pointer;
}
select:focus-visible, .chip:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chiprow { display: flex; gap: 6px; padding: 3px; border-radius: 8px; border: 1px solid var(--line); }
.chip {
  padding: 6px 11px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
  border: 1px solid transparent; background: transparent; color: var(--ink-dim);
}
.chip[aria-pressed="true"] { color: #061018; font-weight: 650; }
.chip.m-GFS[aria-pressed="true"]   { background: var(--c-gfs); }
.chip.m-HRRR[aria-pressed="true"]  { background: var(--c-hrrr); }
.chip.m-ECMWF[aria-pressed="true"] { background: var(--c-ecmwf); }
.chip[aria-pressed="false"]:hover { background: var(--bg-3); color: var(--ink); }

.seg { display: inline-flex; border-radius: 8px; border: 1px solid var(--line); padding: 3px; }
.seg button {
  padding: 6px 11px; border-radius: 6px; border: none; background: transparent;
  color: var(--ink-dim); cursor: pointer; font-size: 12.5px;
}
.seg button[aria-pressed="true"] { background: var(--bg-3); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }

/* generic button */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  background: var(--steel); border: 1px solid var(--line-2); color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  transition: transform .06s, filter .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg,#2b6fb0,#1b4a78); border-color: #3a83c4; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; }

.nav-row { display: flex; justify-content: space-between; gap: 12px; margin: 18px 0 6px; }

/* cards / panels in main */
.card {
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.card > h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .03em; color: var(--ink); display:flex; align-items:center; gap:8px; }
.card .tag { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); border:1px solid var(--line-2); border-radius: 4px; padding: 1px 6px; }

/* scorecard grid */
.scorecards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.scorecard {
  border-radius: var(--radius); padding: 12px 14px;
  background: linear-gradient(180deg, #151b23, #0e1318);
  border: 1px solid var(--line); border-top: 2px solid var(--mcol, var(--line-2));
}
.scorecard .mname { font-weight: 700; letter-spacing: .04em; font-size: 14px; }
.scorecard .stat-row { display: flex; justify-content: space-between; margin-top: 7px; font-variant-numeric: tabular-nums; }
.scorecard .stat-row .k { color: var(--ink-faint); font-size: 11px; letter-spacing: .06em; }
.scorecard .stat-row .v { font-family: var(--mono); font-size: 13px; }
.scorecard .best { color: var(--good); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }

table.met { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.met th, table.met td { padding: 6px 9px; text-align: right; border-bottom: 1px solid var(--line); }
table.met th { color: var(--ink-faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
table.met td:first-child, table.met th:first-child { text-align: left; }
table.met td.mono { font-family: var(--mono); }

/* 2x2 contingency table */
.ctc2x2 { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px; max-width: 360px; }
.ctc2x2 .cell {
  padding: 12px 8px; text-align: center; border-radius: 6px; font-variant-numeric: tabular-nums;
  background: var(--bg-2); border: 1px solid var(--line);
}
.ctc2x2 .hdr { background: transparent; border: none; color: var(--ink-faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; align-self: center; }
.ctc2x2 .cell b { display: block; font-family: var(--mono); font-size: 17px; }
.ctc2x2 .cell small { color: var(--ink-faint); font-size: 9.5px; letter-spacing: .06em; }
.ctc2x2 .hit  b { color: var(--good); }
.ctc2x2 .miss b, .ctc2x2 .fa b { color: var(--warn); }
.ctc2x2 .cn  b { color: var(--ink-dim); }

/* chart container */
.chartwrap { width: 100%; overflow: visible; }
.chartwrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 2px 0; font-size: 12px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-dim); }
.legend .swatch { width: 14px; height: 4px; border-radius: 2px; display:inline-block; }
.legend .swatch.dash { background: repeating-linear-gradient(90deg,currentColor 0 4px, transparent 4px 7px); height: 2px;}

/* ---------- provenance ---------- */
aside.prov {
  grid-area: prov;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 16px 14px;
  overflow: auto;
}
aside.prov h2 { font-size: 10px; letter-spacing: .2em; color: var(--ink-faint); text-transform: uppercase; margin: 0 0 12px; display:flex; align-items:center; gap:8px;}
.prov-group { margin-bottom: 14px; }
.prov-group > .gh { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 5px; }
.prov-kv { display: grid; grid-template-columns: 88px 1fr; gap: 3px 8px; font-size: 11.5px; }
.prov-kv .k { color: var(--ink-faint); }
.prov-kv .v { font-family: var(--mono); color: var(--ink); word-break: break-word; }
.prov-pill { display:inline-block; padding: 1px 6px; border-radius: 4px; background: var(--bg-3); border:1px solid var(--line-2); font-family: var(--mono); font-size: 10.5px; }
.prov-foot { font-size: 10px; color: var(--ink-faint); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }

/* ---------- narration ---------- */
section.narr {
  grid-area: narr;
  background: linear-gradient(180deg, #12171d, #0c1015);
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 14px 22px 18px;
}
section.narr h2 {
  font-size: 10px; letter-spacing: .2em; color: var(--ink-faint); text-transform: uppercase;
  margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
section.narr h2 .badge {
  font-size: 9px; letter-spacing: .08em; color: var(--accent);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 6px; text-transform: none;
}
.narr-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 12px; }
.narr-item { display: flex; gap: 10px; align-items: flex-start; }
.narr-item .ic {
  flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; border: 1px solid var(--line-2);
}
.narr-item.verdict .ic { background: rgba(79,212,154,.12); color: var(--good); }
.narr-item.evidence .ic { background: rgba(127,199,255,.12); color: var(--accent); }
.narr-item.caveat .ic { background: rgba(230,200,79,.12); color: var(--warn); }
.narr-item .tx b { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 2px; }
.narr-item .tx p { margin: 0; font-size: 13px; color: var(--ink); }
.narr-item .tx p em { color: var(--accent); font-style: normal; font-weight: 600; }
.narr-item .tx p .num { font-family: var(--mono); color: #cfe6ff; }

/* toast */
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
  font-size: 13px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* live url indicator */
.url-live {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-dim);
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px;
  max-width: 360px;
}
.url-live .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 7px var(--good); flex:none;}
.url-live code { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.url-live.synced .pulse { background: var(--good); }
.url-live.dirty .pulse { background: var(--warn); box-shadow: 0 0 7px var(--warn); }

/* misc */
.muted { color: var(--ink-faint); }
.mono { font-family: var(--mono); }
.hl-good { color: var(--good); } .hl-warn { color: var(--warn); } .hl-bad { color: var(--bad); }
.kbd { font-family: var(--mono); font-size: 11px; background: var(--bg-3); border:1px solid var(--line-2); border-bottom-width:2px; border-radius:4px; padding:1px 5px;}
.note { font-size: 11.5px; color: var(--ink-faint); margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* responsive: collapse side panels under main on narrow screens */
@media (max-width: 1080px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "rail" "main" "narr" "prov";
  }
  nav.rail { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  .rail h2, .rail .nav-hint { width: 100%; }
  aside.prov, section.narr { border-left: none; border-right: none; }
}
