/* Science pages (/aquifer.html, /coastal.html): KPI tiles, inline SVG charts and the aquifer schematic.
   Loaded after site.css; colours come from its tokens plus a few chart roles defined here. */

.sci {
  --lv1: #9cc9e6;   /* ordered levels, light -> dark */
  --lv2: #3f8fca;
  --lv3: #0d4a87;
  --rain: #6aa7d8;
  --wt: #8a6a32;    /* water table */
  --pond: #007a69;
  --spill: #c4501d;
  --soil-u: #efe3c4;
  --soil-l: #bcd9ec;
  --soil-b: #8e7f68;
  --flux: #102626;
  --plus: #b0471a;  /* AquaSWMM additions */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sci {
    --lv1: #2b5c85; --lv2: #4f9bd4; --lv3: #a9d5f4;
    --rain: #4f8fc4; --wt: #d6b77a; --pond: #5fe8c9; --spill: #f2925d;
    --soil-u: #3a3424; --soil-l: #173a52; --soil-b: #a89a82; --flux: #e2f1ee; --plus: #f2a36b;
  }
}
:root[data-theme="dark"] .sci {
  --lv1: #2b5c85; --lv2: #4f9bd4; --lv3: #a9d5f4;
  --rain: #4f8fc4; --wt: #d6b77a; --pond: #5fe8c9; --spill: #f2925d;
  --soil-u: #3a3424; --soil-l: #173a52; --soil-b: #a89a82; --flux: #e2f1ee; --plus: #f2a36b;
}

.sci .eyebrow { font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--deep); margin: 0 0 0.6rem; }
.sci h2 { margin-top: 3rem; }
.sci .prose { max-width: var(--measure); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 1.8rem 0 2.4rem; }
.kpi { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 2rem; line-height: 1.1; letter-spacing: -0.02em; color: var(--ink); }
.kpi span { display: block; margin-top: 6px; font-size: 0.92rem; color: var(--ink-2); }

.sci figure.shot { margin: 1.6rem 0; }
.fig-wide { max-width: 1100px; }

.chart { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 16px 10px; margin: 1.4rem 0; position: relative; }
.chart h3 { font-size: 1.05rem; margin: 0 0 4px; }
.chart .sub { margin: 0 0 10px; color: var(--ink-2); font-size: 0.9rem; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .ax { stroke: var(--rule); stroke-width: 1; }
.chart .ax0 { stroke: var(--ink-2); stroke-width: 1; }
.chart text { fill: var(--ink-2); font-family: var(--sans); font-size: 12px; }
.chart text.val { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.chart text.lab { fill: var(--ink); font-size: 12.5px; }
.chart .b1 { fill: var(--lv1); } .chart .b2 { fill: var(--lv2); } .chart .b3 { fill: var(--lv3); }
.chart rect.bar { stroke: var(--panel); stroke-width: 1; }
.chart rect.bar:hover, .chart rect.bar:focus { opacity: 0.8; outline: none; }
.chart .rainbar { fill: var(--rain); }
.chart .l-wt { stroke: var(--wt); stroke-width: 2; fill: none; }
.chart .l-pond { stroke: var(--pond); stroke-width: 2; fill: none; }
.chart .l-spill { stroke: var(--spill); stroke-width: 2; fill: none; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--panel); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 0.9rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 7px; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.sw.ln { height: 3px; border-radius: 2px; width: 18px; }
.sw.b1 { background: var(--lv1); } .sw.b2 { background: var(--lv2); } .sw.b3 { background: var(--lv3); }
.sw.rain { background: var(--rain); } .sw.wt { background: var(--wt); } .sw.pond { background: var(--pond); } .sw.spill { background: var(--spill); }

.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 0.85rem; padding: 6px 9px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity 0.08s; z-index: 3; }
.tip.on { opacity: 1; }

.chart details { margin-top: 8px; font-size: 0.9rem; }
.chart details summary { cursor: pointer; color: var(--deep); }
.chart details .vtable { margin-top: 8px; }

/* level ladder */
.ladder .tick { stroke: var(--rule); }
.ladder .lvl { stroke-width: 2; }
.ladder .lvl.water { stroke: var(--lv2); }
.ladder .lvl.road { stroke: var(--ink-2); stroke-dasharray: 4 3; }
.ladder .lvl.storm { stroke: var(--spill); }
.ladder .band { fill: var(--lv1); opacity: 0.35; }
.ladder text.name { fill: var(--ink); font-size: 12.5px; }
.ladder text.m { fill: var(--ink-2); font-family: var(--mono); font-size: 11.5px; }

/* aquifer schematic */
.schem { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 12px; margin: 1.4rem 0; }
.schem svg { display: block; width: 100%; height: auto; }
.schem .z-u { fill: var(--soil-u); }
.schem .z-l { fill: var(--soil-l); }
.schem .bed { fill: var(--soil-b); }
.schem .ground { stroke: var(--ink); stroke-width: 2; fill: none; }
.schem .cells { stroke: var(--ink-2); stroke-width: 0.8; fill: none; opacity: 0.6; }
.schem .surfw { fill: var(--rain); opacity: 0.75; }
.schem .wtline { stroke: var(--wt); stroke-width: 2; stroke-dasharray: 7 4; fill: none; }
.schem .arr { stroke: var(--flux); stroke-width: 2; fill: none; marker-end: url(#ah); }
.schem .arr.plus { stroke: var(--plus); stroke-dasharray: 5 3; marker-end: url(#ahp); }
.schem .ahead { fill: var(--flux); } .schem .ahead.plus { fill: var(--plus); }
.schem .pipe { fill: var(--panel); stroke: var(--ink); stroke-width: 2; }
.schem text { fill: var(--ink); font-family: var(--sans); font-size: 13px; }
.schem text.sym { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.schem text.plus { fill: var(--plus); }
.schem text.zone { font-weight: 700; font-size: 13.5px; }
.schem text.note { fill: var(--ink-2); font-size: 12px; }

.eq { background: var(--panel); border: 1px solid var(--rule); border-left: 4px solid var(--deep); border-radius: 6px; padding: 14px 18px; margin: 1.2rem 0; font-family: var(--mono); font-size: 0.95rem; overflow-x: auto; line-height: 2; }
.eq i { font-family: var(--sans); }
.plus-tag { display: inline-block; font-size: 0.75rem; font-weight: 700; color: var(--plus); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: 1px; }
.sci .vtable td i, .sci .vtable th i { font-family: var(--sans); }
.sci pre { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 12px 14px; overflow-x: auto; font-size: 0.86rem; }
.limits { background: var(--warn-soft); border: 1px solid var(--rule); border-radius: 8px; padding: 6px 20px 10px; margin: 2rem 0; }
.limits h2 { margin-top: 0.9rem; }
.two-col { display: grid; gap: 22px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
.sci pre code { background: none; padding: 0; border: 0; font-size: inherit; }
.chart text { font-size: 13px; }
/* On phones, charts keep a readable size and scroll sideways inside their box. */
.chart { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart svg { min-width: 480px; }
.chart svg.ladder { min-width: 700px; }
.chart svg[data-series] { min-width: 600px; }
.schem { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.schem svg { min-width: 620px; }
