/*
  kachess2 site CSS — "Survey" visual direction (Phase2UI redesign, 2026-08-04).

  Replaces the kachess1 clone stylesheet. Bootstrap is GONE (see base.j2): its handful of used
  classes — the grid (row/col), tables, alert, button, a few utilities — are reimplemented here in
  the Survey style, so the templates render unchanged with no framework and no CDN.

  DESIGN — "Survey": a field-log / topographic feel. Sage paper, pine ink, a serif for reading and
  a mono for data, hairline rules instead of heavy bars. Everything is driven by the design tokens
  in :root, so re-skinning or tweaking later is a token edit, not a hunt through the file.

  DELIBERATELY UNTOUCHED: the Plotly chart data COLORS (kachess.js — Ross's tuned palette). This file
  styles the FRAME around charts, never their fill colors. (Chart FONTS *do* now match this page's
  serif — kachess.js + apps/compute/images.py.) The site accent is a single green for every lake; the
  per-lake red/green/blue survives only in the comparison chart (kachess.js `lakeAccents`), where
  telling the lakes apart matters.
*/

/* ============================================================================
   DESIGN TOKENS — the whole look lives here.
   ============================================================================ */
:root {
  /* Survey palette: cool sage paper, deep pine ink, mossy hairlines. */
  --bg: #eef1ea;
  --surface: #f7f8f3;
  --surface-2: #e7ebe1;
  --text: #232f28;
  --muted: #5c6b60;
  --border: #cfd6c9;
  --rule: #d7ddd0;
  --band: rgba(60, 80, 64, 0.1);

  /* One site accent for EVERY lake — a deeper green (Ross, 2026-08-05). The per-lake red/green/blue
     now lives only in the comparison chart (kachess.js `lakeAccents`), where telling lakes apart. */
  --accent: #238023;
  --accent-ink: #f7f8f3; /* text on the accent */
  --accent-weight: 6px; /* header accent-bar thickness */

  --radius: 3px;
  --shadow: 0 1px 2px rgba(35, 47, 40, 0.06);

  --font-head: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --content: 1500px; /* the wide chart column */
  --reading: 620px; /* constrained prose / stat boxes */
}

/* (per-lake accent overrides removed — every lake shares the green accent above) */

/* ============================================================================
   BASE
   ============================================================================ */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
a:hover { color: var(--text); }

/* ============================================================================
   BOOTSTRAP REPLACEMENT — the ~20 classes the templates use, hand-coded.
   ============================================================================ */
.container-fluid {
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 40px);
}

/* Grid: a plain flex row whose columns stack when narrow — which is all the site ever used
   Bootstrap's grid for (no 12-col sizing; CSS does the reflow for free). */
.row { display: flex; flex-wrap: wrap; gap: 0 24px; }
.col { flex: 1 1 0; min-width: 0; }
.justify-content-center { justify-content: center; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.d-block { display: block; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
@media (max-width: 575.9px) { .d-sm-none { display: none !important; } }

.img-fluid { max-width: 100%; height: auto; }

/* Tables — Survey: hairline rows, an accent header, a whisper-stripe, tabular figures. */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
.table td { font-variant-numeric: tabular-nums; }
.thead-dark th {
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: 0.03em;
  border-bottom: 0;
}
.table-striped tbody tr:nth-of-type(odd) { background: var(--surface-2); }
/* per-year (minmax) table: the two column groups (Maximum | Minimum) share the ONE green header —
   the old grey "Maximum" block was washed out and clashed with the green "Minimum" (Ross). A hairline
   on the group's right edge keeps the two halves distinct. */
.thead-dark .group2 { background: var(--accent); color: var(--accent-ink); }
/* vertical dividers down BOTH group boundaries: after Year (before Maximum) and after Maximum
   (before Minimum). Year is column 1; the Max group's last column (Volume) is column 4 of the 7. */
#minmax-table thead tr:first-child th:nth-child(1),
#minmax-table thead tr:nth-child(2) th:nth-child(1),
#minmax-table tbody td:nth-child(1),
#minmax-table thead tr:first-child th:nth-child(2),
#minmax-table thead tr:nth-child(2) th:nth-child(4),
#minmax-table tbody td:nth-child(4) { border-right: 2px solid rgba(35, 47, 40, 0.16); }
/* small units note under a table */
.k-table-note { margin: 8px 0 0; font-size: 0.85rem; font-style: italic; color: var(--muted); }

/* Alert (the "new here" feedback banner) */
.alert {
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.alert-warning {
  /* the "new here" notice — deliberately amber, NOT the green accent, so "new" actually reads as
     new instead of blending into the site color (Ross). */
  background: #f6ecc9;
  border-color: #d9bd6b;
  color: var(--text);
}
.alert-warning a { font-weight: 600; }

/* Buttons (the Feedback pill) */
.btn {
  display: inline-block;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 6px 16px;
}
.btn-sm { padding: 3px 12px; font-size: 0.85rem; }
.btn-success { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-success:hover { color: var(--accent-ink); filter: brightness(0.92); }

/* Select (the comparison-chart season picker) */
.custom-select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 30px 6px 12px;
}

/* Bootstrap responsive-embed (iframe fallback), and the site's own iframe wrapper */
.embed-responsive { position: relative; display: block; width: 100%; overflow: hidden; }
.embed-responsive::before { content: ""; display: block; }
.embed-responsive-16by9::before { padding-top: 56.25%; }
.embed-responsive-item, .embed-responsive iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}

/* ============================================================================
   HEADER · TITLE · NAV
   ============================================================================ */
.k-sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* the per-lake accent, as a survey rule across the very top */
  border-top: var(--accent-weight) solid var(--accent);
}
.k-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: 0.005em;
  text-wrap: balance;
  margin: 18px 0 12px;
}
.k-navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  padding: 8px 0 10px;
  margin-bottom: 26px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-head);
}
.k-navbar a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 5px 11px;
  border-radius: var(--radius);
}
.k-navbar a:hover { color: var(--text); background: var(--surface-2); }
/* current page — set by kachess.js. Scoped `.k-navbar a.…` so it beats `.k-navbar a` (class +
   element) on specificity — otherwise the muted link color wins and the accent never shows. */
.k-navbar a.k-nav-active { color: var(--accent); font-weight: 700; background: transparent; }
/* Feedback pill — solid accent, white text, fully rounded, pushed to the right of the row. Same
   `.k-navbar a.…` scoping so it actually overrides the plain nav-link color/padding/radius. */
.k-navbar a.k-nav-feedback {
  margin-left: auto;
  margin-right: 14px; /* clear gap from the container edge */
  padding: 4px 14px; /* smaller */
  font-size: 0.8rem; /* smaller text → smaller pill */
  border-radius: 999px; /* full pill */
  background: var(--accent);
  color: #fff;
  border: 0;
  font-family: var(--font-body);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(35, 47, 40, 0.18);
}
.k-navbar a.k-nav-feedback:hover { background: var(--accent); color: #fff; filter: brightness(1.07); }

/* ============================================================================
   SECTIONS
   ============================================================================ */
.k-section { margin: 30px 0; padding-top: 28px; border-top: 1px solid var(--rule); }
.k-section:first-of-type { margin-top: 18px; padding-top: 0; border-top: 0; }
.k-section h1, .k-section h2, .k-section h3, .k-section h4 {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: 0.005em;
  text-wrap: balance;
  text-align: center;
}
.k-section h1 { font-size: clamp(22px, 3vw, 28px); margin: 6px 0 26px; }
.k-section h2 { font-size: clamp(20px, 2.6vw, 25px); }
.k-section h3 { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.k-section h1 + h2, .k-section h1 + h3, .k-section h1 + h4 { margin-top: -18px; margin-bottom: 26px; }
.k-section p { padding: 0 15px; }
.k-section ul, .k-section ol { line-height: 1.65; }
/* images (SNOTEL PNGs, the USBR example) framed with a survey hairline, not a hard black rule */
.k-section img {
  display: block;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============================================================================
   QUICK-STATS + "about/data" boxes
   ============================================================================ */
.k-sec-about, .k-sec-summary {
  max-width: var(--reading);
  margin: 18px auto;
  padding: 8px 0;
}
.k-sec-summary { margin-top: 12px; margin-bottom: 8px; }

/* About page — a readable prose column (constrained, left-aligned essay). */
.k-about { max-width: var(--reading); margin: 0 auto; text-align: left; }
.k-about p { padding: 0; margin: 0 0 1.05em; }
.k-sec-about h1, .k-sec-summary h1 { margin-top: 0; padding-top: 0; }
.k-sec-about h3, .k-sec-summary h3 { padding: 0 0 10px; }
.summary-table { font-size: 1.05rem; }
.summary-table td[data-stat], .summary-table .text-right { font-family: var(--font-mono); }

/* "Learn about the data →" link under Quick Stats */
.k-data-link { margin-top: 12px; font-size: 0.95rem; }
.k-data-link a { font-weight: 600; text-decoration: none; }
.k-data-link a:hover { text-decoration: underline; }

/* Data page: excludes/repairs list, the record note, the modeled-elevation note */
.k-audit-list { max-width: var(--reading); margin: 8px auto; font-family: var(--font-mono); font-size: 0.95rem; }
.k-record-note, .k-modeled-note {
  max-width: var(--reading);
  margin: 12px auto 0;
  padding: 12px 16px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.98rem;
  color: var(--text);
}

/* the feetdown-method equation box + any legacy regression table */
.k-regr-results {
  max-width: 760px;
  margin: 28px auto;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.k-equation, .k-regr-table { font-family: var(--font-mono); }
.k-equation { font-size: 1.15rem; padding-top: 14px; }

/* ============================================================================
   CHARTS — frame only. The chart CONTENTS (colors/fonts) belong to kachess.js.
   ============================================================================ */
.k-section .chart {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 2; /* placeholder height; kachess.js sets the scaled height */
  margin: 0 auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden; /* clip the 1500px inner box to the framed container */
}
.k-section .chart .chart-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left; /* width/height set by kachess.js */
}
.k-section .chart-copy {
  display: block;
  margin: 8px auto 0;
  padding: 4px 14px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.k-section .chart-copy:hover { color: var(--text); border-color: var(--muted); }
.k-section .chart--error {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a241d;
  background: var(--surface); /* fallback for engines without color-mix (Safari < 16.2) */
  background: color-mix(in srgb, #b4472e 12%, var(--surface));
  font-size: 0.95rem;
}

/* Horizontal-scroll container for wide tables on narrow (phone) viewports — the Data page's 7-column
   min/max table and 5-column field table overflow ~375px otherwise, scrolling the whole page body. */
.table-scroll {
  overflow-x: auto;
}

/* Notice shown when a comparison lake's data failed to load (comparison.js) — so the chart drawing
   fewer lakes never reads as "complete". */
.chart-notice {
  text-align: center;
  color: #7a241d;
  font-size: 0.9rem;
  margin: 0 0 10px;
}

/* the selected comparison series subtitle (comparison.js) */
.chart-series {
  text-align: center;
  color: var(--muted);
  font-size: 1.1rem;
  margin: -4px 0 8px;
}

/* ============================================================================
   EXPLAINER — "How to read this chart" (native <details>, no JS)
   ============================================================================ */
.k-explainer {
  max-width: var(--reading);
  margin: 22px auto 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.k-explainer > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 18px;
  text-align: center;
}
.k-explainer > summary::-webkit-details-marker { display: none; }
.k-explainer:hover { border-color: var(--muted); }
.k-explainer__title {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}
.k-explainer > summary:hover .k-explainer__title { text-decoration: underline; }
/* Teaser: a single clipped line of the real text so casual users see there's content. */
.k-explainer__teaser {
  margin-top: 6px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.k-explainer__teaser * {
  display: inline;
  white-space: nowrap;
  margin: 0;
  padding: 0;
  list-style: none;
}
.k-explainer__teaser br { display: none; }
.k-explainer[open] .k-explainer__teaser { display: none; }
.k-explainer__more { display: block; margin-top: 8px; color: var(--accent); font-size: 0.9rem; }
.k-explainer__more-text::after { content: "Read more"; }
.k-explainer[open] .k-explainer__more-text::after { content: "Show less"; }
.k-explainer__more::after {
  content: "\2304";
  display: inline-block;
  margin-left: 6px;
  transition: transform 0.15s ease;
}
.k-explainer[open] .k-explainer__more::after { transform: rotate(180deg); }
.k-explainer__body { padding: 4px 18px 16px; color: var(--text); }

/* ============================================================================
   SNOTEL — captured PNG + caption
   ============================================================================ */
.k-snotel { display: block; }
.k-snotel-asof {
  margin: 6px auto 0;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
  text-align: center;
}
/* legacy iframe fallback wrapper (when no capture exists) */
.responsive-iframe-container {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding-top: 80%;
}
.responsive-iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ============================================================================
   Reservoir list (an unused landing helper kept from kachess1; harmless)
   ============================================================================ */
ul.reservoir-list { max-width: var(--reading); margin: 0 auto; padding: 0; list-style: none; }
ul.reservoir-list li {
  margin: 0 0 12px;
  padding: 15px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
a.reservoir-link { font-size: 1.2rem; font-weight: 600; }
ul.reservoir-list .freshness { display: block; margin-top: 6px; color: var(--muted); font-size: 0.85rem; }

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