/*
 * SaveNadi base: typography, controls and the shared components.
 * No cards: sections are separated by whitespace and one hairline. Boxes exist
 * only for overlays (panels, dialogs, popovers, map controls).
 */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
/* Links inside running text are underlined, so they never rely on colour alone. */
p a:not(.btn), .t-prose li > a, dd a:not(.btn), .help a, .empty a, .figure__meta a, .cell-2 a, .t-prose a, .notice a {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ------------------------------------------------------------ typography --- */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
.t-display { font: 500 32px/40px var(--font-serif); letter-spacing: -0.01em; text-wrap: balance; }
.t-assess { font: 500 18px/28px var(--font-serif); max-width: 64ch; }
.t-h1 { font-size: 24px; line-height: 32px; }
.t-h2 { font-size: 16px; line-height: 24px; }
.t-title { font-size: 20px; line-height: 28px; font-weight: 600; }
.t-body { font-size: 14px; line-height: 20px; }
.t-small { font-size: 13px; line-height: 20px; }
.t-caption { font-size: 12px; line-height: 16px; }
.t-mono { font: 400 12px/16px var(--font-mono); color: var(--text-2); white-space: nowrap; }
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); }
.t-strong { font-weight: 600; }
.t-num { font-variant-numeric: tabular-nums; }
.t-prose { max-width: 64ch; }
.t-prose p { margin: 0 0 12px; }
.section-label {
  font-size: 13px; line-height: 20px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: baseline; gap: 8px;
}
.eyebrow { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.skip-link:focus { top: 8px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- layout --- */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gutter); }
.stack > * + * { margin-top: var(--stack, 16px); }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.spacer { flex: 1; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.section { padding: 32px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }

/* -------------------------------------------------------- provenance / ops --- */
.ribbon {
  background: var(--ribbon-bg); color: var(--ribbon-ink);
  font-size: 13px; line-height: 20px; font-weight: 500;
  padding: 6px var(--gutter); text-align: left;
}
.ribbon a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.operator { font-size: 12px; line-height: 16px; color: var(--text-3); }

/* --------------------------------------------------------------- controls --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--accent); padding: 0 6px; }
.btn--quiet:hover { background: var(--surface-2); color: var(--accent-hover); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[aria-busy="true"]::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: grid; gap: 4px; }
.field > label, .field > .label { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--text-2); }
.input, .select, .textarea {
  height: var(--control-h); width: 100%; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; }
.select { appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-2); }
.help { font-size: 12px; line-height: 16px; color: var(--text-3); }
.error-text { font-size: 13px; line-height: 20px; color: var(--sev-violation); display: flex; gap: 6px; align-items: flex-start; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--text); color: var(--text); font-weight: 500; }

/* -------------------------------------------------------- register system --- */
/* Every claim is Measured, an AI lead, or a Recommendation — visibly. */
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
  border: 1px solid currentColor; border-radius: var(--radius);
  font-size: 10.5px; line-height: 1; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap; vertical-align: 2px; font-family: var(--font-sans);
}
.tag--measured { color: var(--text); }
.tag--ai { color: var(--ai); border-style: dashed; }
.tag--rec { color: var(--text); }
.tag--system { color: var(--system); }
.tag--stamp { color: var(--system); font-size: 11px; height: 20px; }

.register { position: relative; }
.register--ai { border: 1px dashed var(--ai); border-radius: var(--radius-lg); padding: 16px; }
.register--rec { border-left: 2px solid var(--text); padding-left: 14px; }
.ai-inline { color: var(--ai); text-decoration: underline dashed; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.ai-footer { font-size: 12px; line-height: 16px; color: var(--ai); margin-top: 12px; }

/* -------------------------------------------------------- severity & state --- */
.sev { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; }
.sev svg { width: 12px; height: 12px; flex: none; }
.sev--ok { color: var(--sev-ok); font-weight: 400; }
.sev > span:not(.visually-hidden) { color: var(--text); }
.sev--ok > span:not(.visually-hidden) { color: var(--text-2); }
.sev--warning { color: var(--sev-warning); }
.sev--violation { color: var(--sev-violation); }
.sev--severe { color: var(--sev-severe); }
.sev-value--warning { color: var(--sev-warning); }
.sev-value--violation { color: var(--sev-violation); }
.sev-value--severe { color: var(--sev-severe); }

.fresh { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); white-space: nowrap; }
.fresh svg { width: 10px; height: 10px; }
.system-state { color: var(--system); display: inline-flex; align-items: center; gap: 6px; }
.stage { color: var(--text-2); white-space: nowrap; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 9px;
  font-size: 11px; font-weight: 600; color: var(--text-2); line-height: 1;
}

/* ------------------------------------------------------------------ tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline-offset: -2px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.table th {
  text-align: left; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-2);
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg);
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: var(--surface-2); }
.table tbody tr.is-severe { box-shadow: inset 3px 0 0 var(--sev-severe); }
.table tbody tr.is-severe:hover { background: var(--sev-severe-tint); }
.table tbody tr[aria-selected="true"] { background: var(--surface-2); }
.table .muted { color: var(--text-3); }
.cell-2 { display: block; font-size: 12px; line-height: 16px; color: var(--text-3); }
.nowrap { white-space: nowrap; }

/* Hairline-separated rows without boxes (Needs decision, lists). */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows > li { border-bottom: 1px solid var(--line); }
.rows > li > a, .rows > li > .row-inner {
  display: grid; align-items: center; gap: 4px 16px; padding: 14px 4px; color: inherit; text-decoration: none;
}
.rows > li > a:hover { background: var(--surface-2); }

/* ---------------------------------------------------------- overlays --- */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 40;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-overlay);
  display: flex; flex-direction: column; transform: translateX(0);
  transition: transform var(--dur-panel) var(--ease-out);
}
.panel[hidden] { display: flex !important; transform: translateX(100%); visibility: hidden; }
.panel__head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel__body { flex: 1; overflow-y: auto; padding: 20px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-overlay);
}
dialog::backdrop { background: rgba(12, 13, 15, 0.4); }
.dialog__head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.dialog__body { padding: 20px; display: grid; gap: 16px; }
.dialog__foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.icon-btn {
  width: var(--control-h); height: var(--control-h); display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: var(--radius); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.disclosure > summary { cursor: pointer; list-style: none; color: var(--accent); font-size: 13px; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "›"; display: inline-block; width: 12px; transition: transform var(--dur-fast) var(--ease-out); }
.disclosure[open] > summary::before { transform: rotate(90deg); }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 280px;
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 8px 10px;
  font-size: 12px; line-height: 16px; box-shadow: var(--shadow-overlay);
}
.tooltip strong { font-size: 13px; }

/* Explainers: the "?" beside a term of art and its bubble (ui.js hint(), main.js). */
.hint {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 16px; height: 16px; margin: 0 0 0 5px; padding: 0; vertical-align: -3px;
  border: 1px solid var(--line-strong); border-radius: 50%; background: transparent;
  color: var(--text-2); font: 600 11px/1 var(--font-sans); letter-spacing: 0; text-transform: none; cursor: help;
}
.hint::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; } /* 26 px target */
.hint:hover, .hint[aria-expanded="true"] { color: var(--text); border-color: var(--text-2); background: var(--surface-2); }
.hint:focus-visible { outline-offset: 1px; border-radius: 50%; }
.hint-pop {
  position: fixed; z-index: 60; display: block; width: max-content; max-width: min(320px, calc(100vw - 24px));
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow-overlay);
  font: 400 13px/19px var(--font-sans); letter-spacing: 0; text-align: left; text-transform: none; white-space: normal;
}
.hint-pop[hidden] { display: none; }
.hint-pop strong { display: block; font-weight: 600; margin-bottom: 2px; }
.hint-pop--wide { max-width: min(380px, calc(100vw - 24px)); }
.hint-pop__row { display: block; margin-top: 6px; }
.hint-pop__row b { font-weight: 600; }
.hint-pop a { color: inherit; text-decoration: underline; white-space: nowrap; }
.hint-pop a:focus-visible { outline-color: var(--bg); }
.terms-phone { display: none; margin: 8px 0 0; }
.terms-dl { margin: 8px 0 0; font-size: 13px; line-height: 19px; }
.terms-dl dt { font-weight: 600; margin-top: 8px; }
.terms-dl dd { margin: 0; color: var(--text-2); }
@media (max-width: 639px) { .terms-phone { display: block; } }
@media (forced-colors: active) {
  .hint { border-color: ButtonText; color: ButtonText; }
  .hint-pop { border: 1px solid CanvasText; }
}

/* --------------------------------------------------------------- states --- */
.skeleton { background: var(--surface-2); border-radius: var(--radius); }
.skeleton-line { height: 12px; margin: 8px 0; }
.is-refreshing { opacity: 0.55; transition: opacity var(--dur-fast); }
.empty { color: var(--text-2); padding: 24px 0; max-width: 64ch; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; font-size: 13px; line-height: 20px;
  border-left: 3px solid var(--system); background: var(--surface); color: var(--text);
}
.notice--info { border-left-color: var(--line-strong); }

/* ---------------------------------------------------------------- charts --- */
.figure { margin: 0; }
.figure__title { font-size: 14px; line-height: 20px; font-weight: 600; margin: 0 0 2px; }
.figure__meta { font-size: 12px; line-height: 16px; color: var(--text-3); margin-bottom: 12px; }
.figure__foot { font-size: 12px; line-height: 16px; color: var(--text-3); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.figure svg text { font-family: var(--font-sans); }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-label { fill: var(--text-3); font-size: 11px; }
.chart-label--strong { fill: var(--text); font-size: 12px; font-weight: 500; }
.chart-standard { stroke: var(--text); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); }
.legend__key { display: inline-flex; align-items: center; gap: 6px; }

/* Print: ink on paper, no chrome. */
@media print {
  .no-print, header.app-header, nav, .panel, .ribbon a, .hint, .hint-pop, .terms-phone { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ------------------------------------------------------------- exhibit map --- */
.exhibit { width: 100%; height: auto; max-width: 420px; margin: 0 auto; }
.ex-land { fill: none; stroke: var(--line-strong); stroke-width: 0.9; stroke-linejoin: round; opacity: 0.7; }
.ex-river { fill: none; stroke: var(--water); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.ex-river-label { fill: var(--text-3); font-size: 10px; letter-spacing: 0.02em; }
.ex-site-label { fill: var(--text); font-size: 11px; font-weight: 500; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.ex-ok { fill: var(--sev-ok); stroke: var(--bg); stroke-width: 1; }
.ex-warning { fill: var(--sev-warning); stroke: var(--surface); stroke-width: 1; }
.ex-violation { fill: var(--sev-violation); stroke: var(--surface); stroke-width: 1; }
.ex-severe { fill: var(--sev-severe); stroke: var(--surface); stroke-width: 1; }
.ex-silent { fill: var(--surface); stroke: var(--nodata); stroke-width: 1.5; stroke-dasharray: 2 1.6; }
.ex-ring { fill: none; stroke: var(--text); }
.exhibit-legend { margin-top: 12px; }
.exhibit-legend .sev svg, .exhibit-legend .fresh svg { width: 10px; height: 10px; }
.table-twin { margin-top: 12px; }

/* ---------------------------------------------------------------- wordmark --- */
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; color: var(--text); }
.wordmark svg { color: var(--text); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 16px 0; }
.kv dt { color: var(--text-2); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* Row headers read as the row's name, not as a column header. */
.table tbody th[scope="row"] { font-size: inherit; line-height: 20px; font-weight: 500; color: var(--text); background: none; position: static; white-space: normal; }
