/* Grid Lens — standalone dashboard. House palette (matches project.css),
   plus a fuel-colour system: fossils warm/dark, renewables cool/bright. */

:root {
  --bg: #faf8f4;
  --card: #ffffff;
  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .14);
  --text: #1a1714;
  --text-muted: #7a6e63;
  --text-dim: #b8ab9c;
  --accent: oklch(52% 0.10 200);      /* teal — the piece hue */

  /* carbon-intensity ramp (low → high gCO2/kWh) */
  --ci-clean: oklch(58% 0.15 150);
  --ci-mid:   oklch(64% 0.15 70);
  --ci-dirty: oklch(54% 0.17 28);

  /* fuel colours */
  --f-coal: #3f3a34;
  --f-gas: #c77d3a;
  --f-distillate: #8c4a2f;
  --f-bioenergy: #9c8a3e;
  --f-hydro: #2f7fae;
  --f-wind: #3a9d8c;
  --f-solar: #e6b53c;
  --f-battery_discharging: #8266a8;

  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Space Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ── header ───────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff, var(--bg));
}
.head-inner { padding: 34px 0 28px; }
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.back { color: var(--text-muted); text-decoration: none; }
.back:hover { color: var(--text); }
h1 {
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 6px 0 4px;
}
.tagline { color: var(--text-muted); font-size: 17px; max-width: 60ch; }
.statusline {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-muted);
}
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--text); }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ci-clean);
  box-shadow: 0 0 0 0 var(--ci-clean);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ci-clean) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.statusline a { color: var(--accent); text-decoration: none; }
.statusline a:hover { text-decoration: underline; }

/* ── sections ─────────────────────────────────────────── */
section { padding: 40px 0; border-bottom: 1px solid var(--border); }
.sec-label {
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 4px;
}
h2 { font-size: 23px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 6px; }
.sec-note { color: var(--text-muted); font-size: 15px; max-width: 64ch; margin-bottom: 24px; }

/* ── hero stats ───────────────────────────────────────── */
.hero { padding-top: 34px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 18px 16px; position: relative; overflow: hidden;
}
.stat .lbl {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
}
.stat .num { font-size: 40px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.stat .unit { font-size: 15px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.stat .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; font-family: var(--mono); }
.stat.ci { color: #fff; }
.stat.ci .lbl, .stat.ci .sub { color: rgba(255,255,255,.78); }
.stat .bar-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }

/* ── current mix bar ──────────────────────────────────── */
.mixbar { display: flex; height: 46px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.mixbar > span { display: block; height: 100%; transition: opacity .15s; }
.mixbar > span:hover { opacity: .82; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 13px; font-family: var(--mono); }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend .pct { color: var(--text-muted); }

/* ── charts ───────────────────────────────────────────── */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.axis text { font-family: var(--mono); font-size: 10.5px; fill: var(--text-muted); }
.axis path, .axis line { stroke: var(--border); }
.gridline line { stroke: var(--border); stroke-dasharray: 2 3; }
.gridline path { display: none; }

.tip {
  position: fixed; pointer-events: none; opacity: 0;
  background: var(--text); color: #fff; padding: 8px 11px; border-radius: 8px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; z-index: 50;
  transition: opacity .12s; box-shadow: 0 6px 22px rgba(0,0,0,.18); max-width: 240px;
}
.tip b { font-weight: 600; }

/* ── regions ──────────────────────────────────────────── */
.regions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.region {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 15px; display: flex; flex-direction: column; gap: 10px;
}
.region .rname { font-family: var(--mono); font-size: 13px; letter-spacing: .06em; color: var(--text-muted); }
.region .rci { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.region .rci .u { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.region .rren { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.region .rmix { display: flex; height: 8px; border-radius: 4px; overflow: hidden; }
.region .rmix > span { display: block; height: 100%; }

/* ── history controls ─────────────────────────────────── */
.toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.toggle button {
  font-family: var(--mono); font-size: 12px; padding: 7px 14px; border: 0;
  background: var(--card); color: var(--text-muted); cursor: pointer; letter-spacing: .04em;
}
.toggle button + button { border-left: 1px solid var(--border); }
.toggle button.on { background: var(--text); color: #fff; }

/* ── method / footer ──────────────────────────────────── */
.method { font-size: 14.5px; color: var(--text-muted); }
.method h3 { font-size: 14px; color: var(--text); font-family: var(--mono); letter-spacing: .04em; text-transform: uppercase; margin: 0 0 8px; }
.method .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.method p { margin-bottom: 10px; max-width: 60ch; }
.method code { font-family: var(--mono); font-size: 13px; background: rgba(0,0,0,.04); padding: 1px 5px; border-radius: 4px; }
footer { padding: 28px 0 60px; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
footer a { color: var(--text-muted); }

/* ── long-form prose (woven between charts) ───────────── */
.lead { font-size: 20px; line-height: 1.6; color: var(--text); max-width: 60ch; margin: 14px 0 0; }
.prose { max-width: 68ch; }
.prose p { font-size: 16.5px; line-height: 1.72; margin-bottom: 14px; color: var(--text); }
.prose ul { margin: 0 0 14px 20px; }
.prose li { font-size: 16px; line-height: 1.62; margin-bottom: 7px; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose code, .codeblock code, .method code {
  font-family: var(--mono); font-size: .88em; background: rgba(0,0,0,.05);
  padding: 1px 5px; border-radius: 4px;
}
blockquote {
  margin: 26px 0 6px; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent);
  font-size: 18px; line-height: 1.55; color: var(--text); max-width: 62ch;
}
blockquote a { color: var(--accent); }

/* figures */
figure.fig { margin: 20px 0 6px; max-width: 760px; }
figure.fig img { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; display: block; }
figure.fig figcaption { font-size: 12.5px; color: var(--text-muted); margin-top: 9px; font-family: var(--mono); line-height: 1.5; }

/* code block */
.codeblock {
  background: #221d18; color: #e9e1d4; border-radius: 10px; padding: 16px 18px;
  overflow-x: auto; margin: 16px 0; max-width: 760px;
}
.codeblock code { font-family: var(--mono); font-size: 13px; line-height: 1.6; background: none; padding: 0; color: inherit; }
.codeblock .c { color: #9a8f7e; }       /* comment */
.codeblock .k { color: #d8a96a; }       /* keyword/fn */

@media (max-width: 880px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .regions { grid-template-columns: repeat(2, 1fr); }
  .method .cols { grid-template-columns: 1fr; gap: 16px; }
  .lead { font-size: 18px; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .regions { grid-template-columns: 1fr; }
}
