/* Basin — data center water calculator. No framework, no build step. */

:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --border: #dde1e6;
  --text: #0f1a24;
  --text-2: #4a5663;
  --text-3: #6b7683;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #e6effa;
  --series-1: #2a78d6;   /* on-site water */
  --series-2: #eb6834;   /* off-site water (power plants) */
  --grid: #e7eaee;
  --good: #0a7a0a;
  --warn-bg: #fff6e0;
  --warn-ink: #7a4b00;
  --crit-bg: #fdecec;
  --crit-ink: #9b2222;
  --ok-bg: #e9f6ec;
  --ok-ink: #1d6b2e;
  --info-bg: #eef4fb;
  --info-ink: #1c4f8f;
  --shadow: 0 1px 2px rgba(15, 26, 36, .06), 0 4px 16px rgba(15, 26, 36, .05);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0e1318;
    --surface: #161d24;
    --surface-2: #1d262f;
    --border: #2b3640;
    --text: #eef2f5;
    --text-2: #b7c1cb;
    --text-3: #8d99a5;
    --accent: #5598e7;
    --accent-ink: #0b1622;
    --accent-soft: #1a2d44;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #26313b;
    --good: #4cc35a;
    --warn-bg: #3a2c0c;
    --warn-ink: #ffd27a;
    --crit-bg: #3b1717;
    --crit-ink: #ffb0b0;
    --ok-bg: #12301b;
    --ok-ink: #9fe0ad;
    --info-bg: #15283d;
    --info-ink: #a9cdf5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1318;
  --surface: #161d24;
  --surface-2: #1d262f;
  --border: #2b3640;
  --text: #eef2f5;
  --text-2: #b7c1cb;
  --text-3: #8d99a5;
  --accent: #5598e7;
  --accent-ink: #0b1622;
  --accent-soft: #1a2d44;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #26313b;
  --good: #4cc35a;
  --warn-bg: #3a2c0c;
  --warn-ink: #ffd27a;
  --crit-bg: #3b1717;
  --crit-ink: #ffb0b0;
  --ok-bg: #12301b;
  --ok-ink: #9fe0ad;
  --info-bg: #15283d;
  --info-ink: #a9cdf5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  font-feature-settings: "tnum" 0;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- layout ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand small { font-weight: 500; color: var(--text-3); font-size: 13px; letter-spacing: 0; }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--text-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.theme-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.theme-btn svg { width: 16px; height: 16px; }

.hero { padding: 36px 0 22px; }
.hero h1 { font-size: clamp(28px, 4.2vw, 42px); letter-spacing: -.02em; max-width: 920px; }
.hero p { color: var(--text-2); margin-top: 10px; max-width: 720px; font-size: 17px; }
.hero .chips { margin-top: 16px; }

.grid { display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 20px; align-items: start; padding-bottom: 48px; }
@media (max-width: 920px) { .grid { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 17px; letter-spacing: -.01em; }
.card .sub { color: var(--text-3); font-size: 14px; margin-top: 4px; }
.inputs { position: sticky; top: 16px; }
@media (max-width: 920px) { .inputs { position: static; } }

/* ---------- form ---------- */
.field { margin-top: 18px; }
.field:first-of-type { margin-top: 14px; }
.label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.label .hint { font-weight: 400; color: var(--text-3); font-size: 13px; }
.help { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.input, .select {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: 0 12px; font-size: 16px;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 8px 6px; font-size: 14px; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.options { display: grid; gap: 8px; }
.option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; background: var(--surface); }
.option:hover { border-color: var(--text-3); }
.option input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.option b { display: block; font-size: 14px; }
.option span { display: block; color: var(--text-3); font-size: 13px; line-height: 1.35; margin-top: 1px; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

details.adv { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
details.adv summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 6px; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: "▸"; font-size: 12px; transition: transform .15s; }
details.adv[open] summary::before { transform: rotate(90deg); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row output { font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; font-size: 14px; color: var(--text-2); }

/* autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 300px; overflow: auto; padding: 4px; margin: 0; list-style: none; }
.ac-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.ac-list li small { color: var(--text-3); white-space: nowrap; }
.ac-list li[aria-selected="true"], .ac-list li:hover { background: var(--accent-soft); }
.place-chip { margin-top: 8px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.chip:hover { border-color: var(--accent); color: var(--text); }

/* ---------- results ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty svg { width: 56px; height: 56px; opacity: .6; }
.headline .eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.hero-num { font-size: clamp(40px, 6vw, 56px); font-weight: 700; letter-spacing: -.025em; line-height: 1.05; margin-top: 6px; }
.hero-num .unit { font-size: .42em; font-weight: 600; letter-spacing: 0; color: var(--text-2); margin-left: 6px; }
.hero-num .unit.block { display: block; font-size: 17px; margin: 6px 0 0; }
.hero-range { color: var(--text-2); margin-top: 6px; font-size: 15px; }
.kv { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.kv div { font-size: 14px; color: var(--text-2); }
.kv b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 16px; }
.tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .tiles.two { grid-template-columns: minmax(0, 1fr); } }
.tile { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; min-width: 0; }
.tile .t-label { font-size: 13px; color: var(--text-3); }
.tile .t-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .t-note { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.35; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 3px 10px; }
.badge svg { width: 14px; height: 14px; }
.b-ok { background: var(--ok-bg); color: var(--ok-ink); }
.b-warn { background: var(--warn-bg); color: var(--warn-ink); }
.b-crit { background: var(--crit-bg); color: var(--crit-ink); }
.b-info { background: var(--info-bg); color: var(--info-ink); }
.b-neutral { background: var(--surface-2); color: var(--text-2); }

.callout { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-top: 14px; display: flex; gap: 10px; align-items: flex-start; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.info { background: var(--info-bg); color: var(--info-ink); }
.callout.warn { background: var(--warn-bg); color: var(--warn-ink); }
.callout.ok { background: var(--ok-bg); color: var(--ok-ink); }
.callout.crit { background: var(--crit-bg); color: var(--crit-ink); }

/* chart */
.chart { margin-top: 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart .lbl { fill: var(--text-2); font-size: 12px; }
.chart .cat { fill: var(--text); font-size: 13px; font-weight: 600; }
.chart .val { fill: var(--text); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .sel { fill: var(--text-3); font-size: 12px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; padding: 7px 9px; border-radius: 7px; max-width: 260px; line-height: 1.4; box-shadow: var(--shadow); }
.table-toggle { margin-top: 10px; font-size: 13px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-3); font-weight: 600; }

/* claim checker */
.claim .row { margin-top: 12px; flex-wrap: wrap; }
.claim .row .input { flex: 1 1 140px; }
.claim .row .select { width: auto; flex: 0 1 190px; }
.verdict { margin-top: 14px; }
.verdict h3 { font-size: 15px; margin-bottom: 4px; }
.meter { margin-top: 14px; }
.meter-track { position: relative; height: 12px; }
.meter-zone { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, currentColor 16%, transparent); background-clip: padding-box; border-right: 2px solid transparent; }
.meter-zone:first-child { border-radius: 6px 0 0 6px; }
.meter-zone.z-over { border-right: 0; border-radius: 0 6px 6px 0; }
.meter-zone.on { background-color: color-mix(in srgb, currentColor 42%, transparent); }
.meter-mark { position: absolute; top: -5px; width: 4px; height: 22px; background: currentColor; border-radius: 2px; transform: translateX(-2px); box-shadow: 0 0 0 2px var(--surface); }
.meter-labels { position: relative; height: 18px; margin-top: 6px; font-size: 11.5px; }
.meter-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; opacity: .75; }
.meter-labels span:last-child { transform: translateX(-80%); }
.meter-labels span.on { opacity: 1; font-weight: 700; }

/* lists */
ul.qs, ul.levers { margin: 10px 0 0; padding: 0; list-style: none; }
ul.qs li, ul.levers li { padding: 10px 0; border-top: 1px solid var(--border); font-size: 14.5px; display: flex; gap: 10px; }
ul.qs li:first-child, ul.levers li:first-child { border-top: 0; }
ul.qs li::before { content: "?"; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; display: grid; place-items: center; margin-top: 1px; }
ul.levers li .lv-num { margin-left: auto; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
ul.levers li .lv-txt small { display: block; color: var(--text-3); font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); text-decoration: none; }
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn svg { width: 16px; height: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); }

.src { font-size: 12.5px; color: var(--text-3); margin-top: 10px; }
.src a { color: var(--text-3); }

/* ---------- prose (methodology) ---------- */
.prose { max-width: 820px; padding: 32px 0 64px; }
.prose h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.02em; }
.prose h2 { font-size: 22px; margin-top: 36px; letter-spacing: -.01em; }
.prose h3 { font-size: 17px; margin-top: 24px; }
.prose p, .prose li { color: var(--text-2); font-size: 16px; }
.prose p { margin-top: 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-top: 6px; }
.prose code, .prose .formula { font-family: var(--mono); font-size: 14px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.prose .formula { display: block; padding: 12px 14px; margin-top: 12px; white-space: pre-wrap; overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { color: var(--text-3); font-weight: 600; white-space: nowrap; }
.prose td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prose .lead { font-size: 18px; color: var(--text-2); margin-top: 12px; }

.site-footer { border-top: 1px solid var(--border); padding: 28px 0 40px; color: var(--text-3); font-size: 13.5px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }
.site-footer a { color: var(--text-2); }

@media (max-width: 600px) {
  .card { padding: 16px; }
  .hero { padding: 24px 0 16px; }
  .hero p { font-size: 16px; }
  .nav a.hide-sm, .brand small { display: none; }
  .nav a { white-space: nowrap; padding: 6px 8px; }
  .seg button { font-size: 13px; padding: 8px 4px; }
  .hero .chips { flex-wrap: nowrap; overflow-x: auto; margin: 16px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
  .hero .chips::-webkit-scrollbar { display: none; }
  .hero .chips > * { flex: none; }
}
@media print {
  .site-header, .inputs, .actions, .site-footer, .chips { display: none !important; }
  .grid { grid-template-columns: 1fr; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- embed mode (?embed=1): results only, for iframes ---------- */
.embed body { background: transparent; }
.embed .site-header, .embed .hero, .embed .inputs, .embed .site-footer, .embed .share-card { display: none !important; }
.embed main.wrap { padding: 0; max-width: none; }
.embed .grid { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
.embed .card { box-shadow: none; }
.embed-attrib { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); padding: 12px 4px 4px; }
.embed-attrib a { color: var(--accent); font-weight: 600; text-decoration: none; }
