/* Shared Wattlas styles.
 * Design tokens mirror the inline styles in index.html (the validated Spread
 * view). Used by the exploratory mockup pages (pulse/divergence/mismatch).
 * index.html keeps its own inline copy so the validated view is never affected
 * by edits here. */
@import url("tokens.css");
@import url("layout.css"); /* first-paint geometry, #370 */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; }
/* Fluid content width (issue #144): a fixed 920px cap left half of a wide screen empty
   while the text wrapped early. Grows with the viewport, still bounded for readability. */
.wrap { max-width: min(1220px, 100%); margin: 0 auto; padding: 24px 20px 64px; }
/* One type ramp with the chrome pages (redesign.css). A view is the front door most
   visitors use — they land on it from a search result, not from the home page — so it
   opens the way a hub does: the serif title at the hub's scale, the lede at the hub's
   lede size. Before this the view h1 was a 22px sans line and the lede, the one sentence
   written to orient a stranger, was the smallest text on the page (13px) while the
   generated prose beneath it ran 16–18px. --serif is declared by nav.js. */
h1 { font-family: var(--serif, Georgia, serif); font-weight: 500; font-size: clamp(28px, 3vw, 40px);
  line-height: 1.1; letter-spacing: -.015em; margin: 0 0 10px; text-wrap: balance; }
.sub { color: var(--muted); font-size: clamp(13px, 0.25vw + 10px, 15px); margin: 0 0 24px;
  max-width: var(--measure-text); }
/* The page lede only — .sub inside a card keeps the card's small size. */
h1 + .sub { font-size: clamp(16px, 1.4vw, 19px); line-height: 1.5; margin: 0 0 22px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px; }
.kpi .label { font-size: var(--fs-ui); color: var(--muted); margin-bottom: 6px; }
.kpi .val { font-size: clamp(24px, 0.5vw + 18px, 29px); font-weight: 500; }
.kpi .val.neg { color: var(--red); } .kpi .val.pos { color: var(--green); }
.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px; }
.card .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.card .title { font-size: var(--fs-card-title); font-weight: 500; text-wrap: balance; }
.card .meta { font-size: var(--fs-caption); color: var(--muted); max-width: var(--measure-text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.legend { font-size: var(--fs-caption); color: var(--muted); margin-top: 10px; display: flex; gap: 16px; flex-wrap: wrap; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
canvas { max-width: 100%; }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, 1fr); } .row2 { grid-template-columns: 1fr; } }
/* KPIs stay two-up all the way down. They used to collapse to one column below 380px,
   which caught every 375px-wide phone (SE, 12/13 mini, X/XS/11 Pro) and doubled the KPI
   block from 206px to 412px — pushing the first chart most of a screen further down. */
@media (max-width: 380px) { .kpi .val { font-size: 22px; } }

/* ---- Shared dashboard / self-explanatory components (v2 redesign) ---------
 * Used by dashboard.html (the home page) and available to the drill-down pages.
 * Layout specifics stay in each page; these are the reusable building blocks. */

/* Sticky control bar (zone + window) */
.bar { position: sticky; top: 0; z-index: 20; background: var(--bg);
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.bar label { font-size: var(--fs-caption); color: var(--muted); margin-right: 6px; }
.bar select { font: inherit; font-size: var(--fs-ui); padding: 6px 10px; border-radius: var(--radius-sm);
  border: 0.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }

/* Native form controls, themed once. A <select> or a date input ships with the browser's
   own border, radius and arrow on a page where every other surface is authored; these
   take the segmented control's dress. Pages used to restate this per page. */
select, input[type="date"] {
  font: inherit; font-size: var(--fs-ui); padding: 6px 10px; border-radius: var(--radius-sm);
  border: 0.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }

/* Segmented control.
   `flex: none` on the buttons is load-bearing: as flex items they used to shrink below
   their own labels, and the `overflow: hidden` that rounds the corners then silently ate
   the overflow. On a 375px phone that made the last option of the Nordic country picker
   (207px of control in 167px of space) unreadable and untappable. */
.seg { display: inline-flex; max-width: 100%; border: 0.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { flex: none; font: inherit; font-size: var(--fs-ui); padding: 6px 11px; border: none; background: var(--surface);
  color: var(--text); cursor: pointer; }
.seg button.active { background: var(--text); color: var(--bg); }

/* Section jump-nav (scroll-spy chips) */
.jumpnav { position: sticky; top: 49px; z-index: 19; background: var(--bg);
  display: flex; gap: 6px; padding: 8px 0 10px; margin-bottom: 8px; overflow-x: auto;
  border-bottom: 0.5px solid var(--border); }
.jumpnav a { font-size: var(--fs-caption); color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 5px 11px; border-radius: 999px; border: 0.5px solid transparent; }
.jumpnav a:hover { color: var(--text); }
.jumpnav a.active { color: var(--text); background: var(--surface-2); border-color: var(--border); }

/* Wrap policy.
   Every block runs to the edge of its container, so `balance` is off on body text —
   it would pull lines back in from the edge they are meant to reach. Headings keep
   it: a headline that fills one line and drops two words onto the next is the break
   that reads as broken. Chrome implements `text-wrap: pretty` as a no-op on these
   blocks, so `balance` is the only declaration that actually does anything. */

/* Themed section */
.sec { padding-top: 36px; scroll-margin-top: 96px; }
.sec > h2 { font-size: 18px; font-weight: 500; margin: 0 0 4px; padding-bottom: 8px; border-bottom: 0.5px solid var(--border); text-wrap: balance; }
.sec-intro { color: var(--muted); font-size: var(--fs-ui); margin: 8px 0 18px; max-width: var(--measure-text); }
.sec .full-view { float: right; font-size: var(--fs-caption); font-weight: 400; color: var(--muted); text-decoration: none; }
.sec .full-view:hover { color: var(--text); }
.card .cap { font-size: var(--fs-caption); color: var(--muted); margin: 8px 0 0; max-width: var(--measure-text); }
/* A caption directly under a KPI row (#462: /capture-price's official market value). */
.kpis + .cap { font-size: var(--fs-caption); color: var(--muted); margin: -12px 0 24px; max-width: var(--measure-text); }

/* Card hover lift (perceived quality) */
.card { transition: box-shadow 0.15s ease; }
.card.hoverable:hover { box-shadow: 0 2px 12px rgba(43,42,39,.06); }

/* The lead chart — the page's answer — stands on the paper. nav.js marks the first .card
   on a view page (the same card the hub frames for it). It used to be boxed exactly like
   the third-ranked panel beneath it; the hub had already dropped that box in its frame
   because a box in a box was its most visible seam. Secondary panels keep the card, so the
   page reads answer first, then evidence. Prototyped on /negative-prices, approved, then
   made the rule. */
.card.lead { border: 0; background: transparent; padding: 0; margin-bottom: 30px; box-shadow: none; }
.card.lead .title { font-size: 16px; }
.card.lead.hoverable:hover { box-shadow: none; }
@media (max-width: 760px) { .card.lead { padding-left: 0; padding-right: 0; } }

/* Info "i" affordance + tooltip popover */
.info { font: 600 var(--fs-label)/15px -apple-system, sans-serif; display: inline-flex; align-items: center;
  justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 0.5px solid var(--border);
  background: var(--surface-2); color: var(--muted); cursor: pointer; padding: 0; margin-left: 5px; vertical-align: middle; }
.info:hover { color: var(--text); border-color: var(--hint); }
.info:focus-visible { color: var(--text); outline: 2px solid var(--text); outline-offset: 2px; }
.tip-pop { position: absolute; max-width: 280px; background: var(--text); color: var(--bg);
  font-size: var(--fs-caption); line-height: 1.5; font-weight: 400; padding: 9px 11px; border-radius: var(--radius-sm);
  z-index: 60; box-shadow: 0 4px 16px rgba(43,42,39,.20); }

/* Skeleton loader + no-data state for chart boxes */
.chartbox { position: relative; }
.skeleton { background: linear-gradient(100deg, var(--surface-2) 30%, #e8e6df 50%, var(--surface-2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.nodata { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 120px;
  color: var(--hint); font-size: var(--fs-caption); text-align: center; padding: 20px; }

/* The loading / empty / awaiting state (#status.loading) is styled by nav.js, which has to
   carry it anyway for the four pages that load no stylesheet (spread, panels, the two
   redirectors). It used to be pasted here as well; one copy, in the file that reaches
   every page. */

/* ---- Topic block (Layout A: full-width stacked, KPI rail + chart) --------- */
.block { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 22px; scroll-margin-top: 104px; transition: box-shadow 0.15s ease; }
.block:hover { box-shadow: 0 2px 14px rgba(43,42,39,.05); }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.block-head h2 { font-size: 19px; font-weight: 500; margin: 0; text-wrap: balance; }
.block-head h2 .lede { color: var(--hint); font-weight: 400; font-size: var(--fs-emph); }
.block-head .full-view { font-size: var(--fs-caption); color: var(--muted); text-decoration: none; white-space: nowrap; }
.block-head .full-view:hover { color: var(--text); }
.block-pitch { color: var(--muted); font-size: var(--fs-ui); margin: 6px 0 16px; max-width: var(--measure-text); }
.block-body { display: flex; gap: 20px; align-items: stretch; }
.rail { flex: 0 0 226px; display: flex; flex-direction: column; gap: 10px; }
.rail .kpi { padding: 12px 14px; }
.rail .kpi.headline { background: var(--surface); border: 0.5px solid var(--border); }
.rail .kpi.headline .val { font-size: 30px; }
.rail .kpi .val { font-size: 19px; }
.chartcol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chartcol .seg { align-self: flex-start; margin-bottom: 10px; }
.chartwrap { position: relative; flex: 1; min-height: 240px; height: 240px; }
.chartwrap canvas { max-width: 100%; }
.block .cap { font-size: var(--fs-caption); color: var(--muted); margin: 10px 0 0; max-width: var(--measure-text); }
.block .fuel-legend { font-size: var(--fs-label); color: var(--muted); margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.block .fuel-legend .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
@media (max-width: 760px) {
  .block-body { flex-direction: column; }
  .rail { flex: auto; flex-direction: row; flex-wrap: wrap; }
  .rail .kpi { flex: 1 1 calc(50% - 5px); }
  .rail .kpi.headline { flex-basis: 100%; }
  .chartwrap { height: 220px; }
}

/* ---- Component spacing -------------------------------------------------------
   About seventy elements across seventeen view pages typed their spacing inline, and the
   values had drifted: a source note was 8px from its chart on one card and 12px on the
   next, and every period note pulled itself up with -16px. These are the components
   those inline styles were standing in for. */
/* The source / method note under a chart. */
.meta.src { margin-top: 10px; }
/* "Data shown for the 12 months to …" — a caption to the summary above it, so the summary
   tightens toward it rather than the note reaching back with a negative margin. */
.period-note { margin: 0 0 22px; }
.wx-generated:has(+ .period-note) { margin-bottom: 6px; }
/* A legend set above its chart, not below. */
.legend.above { margin: 0 0 6px; }
/* A small label heading a list or a column. */
.meta.lbl { margin-bottom: 6px; }
/* The pitch paragraph inside a card (the page lede is `h1 + .sub`). */
.card .sub { margin: 0 0 12px; }

/* ---- Shared view components --------------------------------------------------
   Rules that two or more views used to repeat verbatim in their own <style> blocks —
   the control row, the map host and its colour-ramp legend, the choropleth path, the
   top-N bar rows. A page that needs a variant overrides here; the copies are gone.
   (.ramp-legend takes the align-items:center two pages had and two lacked; the two
   without it wrapped a swatch a pixel low.) */
.controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.controls label { font-size: var(--fs-caption); color: var(--muted); margin-right: 6px; }
.map-host { width: 100%; max-width: 360px; margin: 0 auto; }
.ramp-legend { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: var(--fs-label); color: var(--muted); margin-top: 10px; align-items: center; }
.ramp-legend .sw { width: 13px; height: 11px; border-radius: 2px; display: inline-block; }
.ramp-legend .b { display: inline-flex; align-items: center; gap: 4px; }
.lk { fill: #e3e1d8; stroke: var(--bg); stroke-width: 0.35; }
.lk:hover { stroke: var(--text); stroke-width: 0.8; }
.toprow { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: var(--fs-caption); }
.toprow .bar { flex: 1; height: 9px; background: var(--surface-2); border-radius: 2px; position: relative; }
.toprow .bar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; }

/* Site navigation (sidebar + mobile scroll-nav) lives in nav.js — it injects its
 * own styles so it works even on pages that don't load this stylesheet. */

/* ---- Generated prose + FAQ (pipeline/build_seo_prose.py, issue #114 Steps 7-8) --------
   The data-driven summary and Q&A injected after each view's intro lede. Kept understated:
   it reads as the "in brief" that precedes the charts, not a second hero. */
.wx-generated { margin: 0 0 22px; }
/* Reading measure comes from the shared scale at the top of this file, so this
   prose ends on the same edge as the ledes and captions around it. */
/* Body size: it sits UNDER the lede in the hierarchy, and used to be a step larger. */
.wx-generated > p { max-width: var(--measure-text); margin: 0 0 10px; color: var(--text);
  font-size: var(--fs-emph); line-height: 1.6; }
/* The FAQ is generated too, but it lives after the charts (build_seo_prose.py puts it in
   its own FAQ:auto block): a reader meets the evidence before the questions about it. */
.wx-faq-block { margin: 32px 0 8px; }
.wx-faq { margin: 20px 0 4px; padding-top: 16px; border-top: 1px solid var(--border); }
.wx-faq > h2 { font-size: var(--fs-emph); font-weight: 600; letter-spacing: .01em; margin: 0 0 12px; color: var(--muted); }
.faq-item { margin: 0 0 14px; }
.faq-q { font-size: clamp(15.5px, 0.2vw + 13.1px, 17px); font-weight: 600; margin: 0 0 4px; color: var(--text); text-wrap: balance; }
.faq-a { font-size: clamp(14.5px, 0.2vw + 12.1px, 16px); margin: 0; max-width: var(--measure-text); color: var(--muted); }

/* The hand-written explanation (#349). A person owns this region and the pipeline owns
   the generated one at the top of the page; landmine 20 keeps them apart. It sits after
   the charts for the same reason the FAQ does: a reader who came for the figure meets
   the figure first, and stays for the explanation. */
.longform { margin: 32px 0 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.longform > h2 { font-size: var(--fs-emph); font-weight: 600; letter-spacing: .01em; margin: 0 0 12px; color: var(--muted); }
.longform p { font-size: clamp(14.5px, 0.2vw + 12.1px, 16px); line-height: 1.65; margin: 0 0 12px;
  max-width: var(--measure-text); color: var(--text); }
.longform p:last-child { margin-bottom: 0; }


/* ---- Phone layout -----------------------------------------------------------
   Three levels of horizontal padding used to stack on a phone — .main (16px),
   .wrap (20px) and .card (20px) — spending 117px of a 375px screen, 31% of it, on
   gutter alone. The chart canvas got what was left: 258px. Desktop pays the same
   117px out of 1220px and never notices.

   One gutter is enough on a phone: .main keeps it, .wrap gives it up entirely, and
   .card trims to the smallest padding that still reads as a card. That returns the
   canvas to ~324px. Paired with charts.js, which stops the chart's HEIGHT from
   shrinking along with its width. */
@media (max-width: 760px) {
  .wrap { padding-left: 0; padding-right: 0; }
  .card { padding-left: 13px; padding-right: 13px; }
  .block { padding-left: 13px; padding-right: 13px; }

  /* A joined segmented control cannot wrap without breaking its own corner radii, and
     on a phone the options routinely need more width than there is. Below this width it
     becomes separate pills, which wrap cleanly — and grow to a 38px tap target. */
  .seg { flex-wrap: wrap; gap: 6px; border: none; border-radius: 0; overflow: visible; }
  .seg button { border: 0.5px solid var(--border); border-radius: 999px; padding: 9px 14px; }
}

/* ---- AI & Data Centres (section 07) ---- */
.wx-assume { display:flex; flex-wrap:wrap; gap:12px 20px; align-items:center; margin:0 0 16px; font-size:var(--fs-ui); color:var(--muted); }
.wx-assume label { display:inline-flex; align-items:center; gap:8px; }
.wx-assume input[type=range] { width:140px; accent-color: var(--s-indigo, #4b5aa6); }
.wx-assume output { font-variant-numeric: tabular-nums; color:var(--text); min-width:3.2em; }
.wx-sources { margin-top:16px; font-size:var(--fs-ui); }
.wx-sources summary { cursor:pointer; color:var(--muted); }
.wx-sources table { width:100%; border-collapse:collapse; margin-top:8px; font-size:var(--fs-caption); }
.wx-sources td, .wx-sources th { text-align:left; padding:4px 8px 4px 0; border-bottom:0.5px solid var(--border); vertical-align:top; }
.wx-sources .dt { font-size:var(--fs-label); padding:1px 6px; border-radius:999px; background:var(--surface-2); white-space:nowrap; }
.legend .swatch.dashed { background:transparent; border:1.5px dashed currentColor; }
.legend .swatch.dotted { background:transparent; border:1.5px dotted currentColor; }
.wx-estimate-note { font-size:var(--fs-caption); color:var(--muted); background:color-mix(in oklch, var(--s-indigo, #4b5aa6) 8%, var(--surface-2));
  border-radius:var(--radius-sm); padding:8px 12px; margin:12px 0; max-width:var(--measure-text); }
@media (max-width: 480px) { .wx-assume input[type=range] { width:100px; } }
