/* ==========================================================================
   GB Power Markets Explorer — design system
   Clean "techy" aesthetic: IBM Plex Mono, white canvas, royal-blue accent.
   (Styled to match the benjames.io look & feel.)
   ========================================================================== */

:root {
  /* Canvas */
  --bg:            #ffffff;
  --bg-soft:       #f7f9fc;
  --panel:         #ffffff;
  --panel-2:       #f4f7fc;
  --card-blue:     #eaf3ff;   /* benjames light-blue card tint */
  --border:        #e4e8f0;
  --border-strong: #d4dae6;
  --dark:          #1e1e1e;   /* dark band */

  /* Ink */
  --text:          #222221;
  --text-soft:     #4a4f5a;
  --text-dim:      #6b7280;   /* AA-safe on white */

  /* Accent (royal blue) + topic hues */
  --accent:        #4169E1;
  --accent-hover:  #3158D0;
  --accent-soft:   #eaf0ff;

  --wind:          #4169E1;   /* royal blue   */
  --tnuos:         #d97a18;   /* amber        */
  --capacity:      #7c5cff;   /* violet       */
  --ldes:          #109e90;   /* teal         */

  --good:          #1f9d57;
  --warn:          #d97a18;
  --bad:           #d83a3a;

  --shadow:        0 4px 14px rgba(20,30,60,.07);
  --shadow-hover:  0 12px 28px rgba(20,30,60,.14);
  --radius:        10px;
  --radius-sm:     8px;
  --maxw:          1120px;

  --font: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01";
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* Accessibility: visible keyboard focus everywhere */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
  font-size: 13px; font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

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

/* ---------- Top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex; align-items: center; gap: 24px;
  height: 62px; max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 600; white-space: nowrap; color: var(--text); }
.brand:hover { color: var(--text); }
.brand .spark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
.brand small { color: var(--text-dim); font-weight: 400; font-size: 11px; letter-spacing: .3px; }
.brand > span:last-child { line-height: 1.2; }
.nav-links { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  padding: 7px 13px; border-radius: 6px; color: var(--text-soft);
  font-size: 13.5px; font-weight: 400; transition: all .18s ease;
  border: 1px solid transparent;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--text); }
.nav-links a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ---------- Hero ---------- */
.hero { padding: 76px 0 36px; }
.hero h1 {
  font-size: clamp(30px, 4.6vw, 50px); line-height: 1.12; margin: 0 0 20px;
  font-weight: 600; letter-spacing: -1px;
}
.hero h1 .grad { color: var(--accent); }
.hero p.lede { font-size: 17px; color: var(--text-soft); max-width: 700px; margin: 0; font-weight: 400; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 2px;
  color: var(--accent); margin-bottom: 20px;
}
.eyebrow::before { content: "//"; color: var(--accent); letter-spacing: 0; }

/* ---------- Topic cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; margin: 42px 0 72px; }
.card {
  position: relative; display: block; padding: 24px 22px 22px;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  box-shadow: var(--shadow); color: var(--text);
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--c, var(--accent)); border-radius: var(--radius) var(--radius) 0 0;
}
.card:hover { transform: translateY(-5px); border-color: var(--c, var(--accent)); box-shadow: var(--shadow-hover); }
.card .tag {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--c, var(--accent)); margin-bottom: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 19px; font-weight: 600; color: var(--text); }
.card p { margin: 0 0 16px; color: var(--text-soft); font-size: 13.5px; }
.card .go { font-size: 13px; font-weight: 600; color: var(--c, var(--accent)); }
.card.soon { opacity: .72; }
.card.soon .go { color: var(--text-dim); }
.card .badge-soon, .pill.soon-tag {
  position: absolute; top: 16px; right: 16px; font-size: 10px; font-weight: 600;
  letter-spacing: .5px; text-transform: uppercase; color: var(--text-dim);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 9px; background: var(--bg-soft);
}

/* ---------- Sections / panels ---------- */
section.block { padding: 16px 0; }
.section-head { margin: 50px 0 18px; }
.section-head .kicker {
  font-size: 11.5px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--accent);
}
.section-head .kicker::before { content: "// "; }
.section-head h2 { margin: 7px 0 6px; font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.section-head p { margin: 0; color: var(--text-soft); max-width: 740px; font-size: 14.5px; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin: 16px 0; box-shadow: var(--shadow);
}
.panel h3 { margin-top: 0; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- KPI stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px,1fr)); gap: 14px; }
.stat {
  background: var(--card-blue); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 18px;
}
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -.5px; color: var(--text); }
.stat .v.up { color: var(--good); } .stat .v.down { color: var(--bad); }
.stat .l { font-size: 12px; color: var(--text-dim); margin-top: 5px; line-height: 1.45; }

/* ---------- Chart containers ---------- */
.chart-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
}
.chart-card .chart-title { font-weight: 600; font-size: 15.5px; margin: 0 0 2px; }
.chart-card .chart-sub { font-size: 12.5px; color: var(--text-dim); margin: 0 0 14px; }
.chart-holder { position: relative; height: 340px; }
.chart-holder.tall { height: 420px; }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 16px; }
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--text-soft); cursor: pointer;
  padding: 7px 14px; border-radius: 6px; font-size: 12.5px; font-weight: 500; font-family: var(--font);
  transition: all .15s ease;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: #fff; }
.ctl-label { font-size: 12.5px; color: var(--text-dim); margin-right: 2px; }
input[type="range"] { accent-color: var(--accent); cursor: pointer; }

/* ---------- Steps / mechanism ---------- */
.steps { counter-reset: step; display: grid; gap: 12px; }
.step {
  position: relative; padding: 16px 18px 16px 60px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 16px; top: 16px; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 7px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
}
.step h4 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.step p { margin: 0; color: var(--text-soft); font-size: 13.5px; }

/* ---------- Callouts ---------- */
.callout {
  border-left: 3px solid var(--accent); background: var(--bg-soft);
  padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 16px 0;
  font-size: 14px; color: var(--text-soft);
}
.callout.warn { border-color: var(--warn); background: #fdf6ec; }
.callout.bad  { border-color: var(--bad); background: #fdeeee; }
.callout strong { color: var(--text); }

/* ---------- Tables ---------- */
.tbl-scroll { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; background: var(--panel); }
table.data th, table.data td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { background: var(--panel-2); color: var(--text-soft); font-weight: 600; position: sticky; top: 0; }
table.data tbody tr:hover { background: var(--bg-soft); }
table.data .muted { color: var(--text-dim); }

/* ---------- Footnotes / sources ---------- */
.sources { font-size: 13px; color: var(--text-dim); }
.sources h4 { color: var(--text-soft); margin-bottom: 8px; font-weight: 600; }
.sources ol { margin: 0; padding-left: 20px; }
.sources a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.sources li { margin-bottom: 6px; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border-strong); color: var(--text-soft);
}
.pill.ok  { color: var(--good); border-color: rgba(31,157,87,.4); background: #eefaf2; }
.pill.no  { color: var(--bad);  border-color: rgba(216,58,58,.4); background: #fdeeee; }

/* ---------- Topic page header ---------- */
.topic-hero { padding: 56px 0 20px; }
.topic-hero .tag {
  font-size: 11.5px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--c, var(--accent));
}
.topic-hero .tag::before { content: "// "; }
.topic-hero h1 { font-size: clamp(28px,4.2vw,42px); margin: 12px 0 14px; font-weight: 600; letter-spacing: -.7px; }
.topic-hero p { font-size: 16.5px; color: var(--text-soft); max-width: 760px; margin: 0; }

/* In-page tab nav for a topic */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0 8px; position: sticky; top: 62px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); padding: 11px 0; z-index: 30;
  border-bottom: 1px solid var(--border); }
.subnav a { padding: 6px 13px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-soft); border: 1px solid transparent; }
.subnav a:hover { background: var(--bg-soft); color: var(--text); }
.subnav a.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 76px; padding: 28px 0 56px; color: var(--text-dim); font-size: 12.5px; background: var(--bg-soft); }
.footer a { color: var(--accent); }

.legend-note { font-size: 12px; color: var(--text-dim); margin-top: 10px; line-height: 1.5; }

/* ---------- Interactive market timeline (proximity to delivery) ---------- */
.tl-track { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; align-items: stretch; }
.tl-bucket { flex: 1 1 0; min-width: 138px; display: flex; flex-direction: column; }
.tl-when {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim);
  text-align: center; padding-bottom: 8px; margin-bottom: 10px; font-weight: 700;
  border-bottom: 2px solid var(--border-strong);
}
.tl-items { display: flex; flex-direction: column; gap: 8px; }
.tl-item {
  font-family: var(--font); text-align: left; cursor: pointer; width: 100%;
  border: 1px solid var(--border); border-left: 3px solid var(--c, var(--accent));
  background: var(--panel); border-radius: 8px; padding: 9px 11px; font-size: 12.5px; font-weight: 600;
  color: var(--text); transition: transform .15s ease, box-shadow .15s ease, background .15s ease; box-shadow: var(--shadow);
}
.tl-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.tl-item small { display: block; font-weight: 400; font-size: 10.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.tl-item.active { background: var(--c, var(--accent)); color: #fff; border-color: var(--c, var(--accent)); }
.tl-item.active small { color: rgba(255,255,255,.88); }
.tl-axis { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: 11px; color: var(--text-dim); font-weight: 600; }
.tl-axis .line { flex: 1; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--border-strong), var(--accent)); }
.tl-axis .end { color: var(--accent); }

/* Selection detail panel */
.tl-detail { margin-top: 16px; background: var(--card-blue); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.tl-detail .d-tag { display: inline-block; color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; padding: 3px 10px; border-radius: 999px; }
.tl-detail h4 { margin: 9px 0 4px; font-size: 17px; font-weight: 700; }
.tl-detail .d-purpose { font-size: 14px; font-weight: 500; color: var(--text); margin: 0 0 4px; line-height: 1.5; }
.tl-detail .d-purpose-label {
  display: inline-block; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 5px; margin-right: 6px; vertical-align: middle;
}
.tl-detail .d-meta { display: flex; gap: 22px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); margin: 9px 0; }
.tl-detail .d-meta b { color: var(--text); font-weight: 600; }
.tl-detail p { font-size: 13.5px; color: var(--text-soft); margin: 6px 0 0; }
.tl-detail .d-prompt { color: var(--text-dim); margin: 0; font-size: 13.5px; }

/* Matrix column cross-highlight when a stream is selected on the timeline */
.matrix [data-stream].col-active { background: var(--accent-soft); }
.matrix thead .strm th[data-stream].col-active { background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- Technology × revenue-stream matrix ---------- */
.matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 760px; }
.matrix th, .matrix td { padding: 9px 7px; text-align: center; border-bottom: 1px solid var(--border); }
.matrix thead .grp th { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 0 7px 6px; border-bottom: 0; color: var(--text-dim); }
.matrix thead .grp th.g-market { color: var(--wind); }
.matrix thead .grp th.g-support { color: var(--ldes); }
.matrix thead .grp th.g-system { color: var(--capacity); }
.matrix thead .strm th { font-weight: 600; vertical-align: bottom; font-size: 11.5px; color: var(--text-soft); border-bottom: 2px solid var(--border-strong); }
.matrix thead .strm th a { color: var(--accent); text-decoration: none; }
.matrix thead .strm th a:hover { text-decoration: underline; }
.matrix .tech-h { text-align: left; }
.matrix td.tech {
  text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 2;
  font-weight: 600; white-space: nowrap; border-right: 1px solid var(--border);
}
.matrix tbody tr:hover td { background: var(--bg-soft); }
.matrix tbody tr:hover td.tech { background: var(--card-blue); }
.matrix .cell { cursor: help; }
.dot { width: 15px; height: 15px; border-radius: 50%; display: inline-block; vertical-align: middle; box-sizing: border-box; }
.dot.full { background: var(--good); }
.dot.partial { background: linear-gradient(90deg, var(--warn) 50%, #fff 50%); border: 1.5px solid var(--warn); }
.dot.none { background: transparent; border: 1.5px solid var(--border-strong); }
.matrix-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12px; color: var(--text-soft); align-items: center; }
.matrix-legend span { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- Info tooltip (explains a calculation) ---------- */
.info {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 7px; border-radius: 50%;
  border: 1px solid var(--accent); color: var(--accent);
  font-size: 10px; font-weight: 700; font-style: normal; cursor: help; vertical-align: middle;
  transition: all .15s ease; flex: none;
}
.info:hover, .info:focus-visible { background: var(--accent); color: #fff; outline: none; }
.info .info-pop {
  position: absolute; bottom: 150%; left: 50%; transform: translateX(-50%);
  width: 270px; max-width: 72vw;
  background: var(--dark); color: #eaf0ff; text-align: left;
  font-size: 12px; font-weight: 400; line-height: 1.55; letter-spacing: 0;
  padding: 11px 13px; border-radius: 9px; box-shadow: var(--shadow-hover);
  opacity: 0; visibility: hidden; transition: opacity .15s ease; z-index: 70; pointer-events: none;
}
.info .info-pop::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--dark);
}
.info:hover .info-pop, .info:focus .info-pop, .info:focus-within .info-pop { opacity: 1; visibility: visible; }
.info-pop b { color: #fff; }
.info-pop .f {
  display: block; background: rgba(255,255,255,.10); color: #fff;
  padding: 6px 9px; border-radius: 6px; margin: 6px 0; font-size: 11.5px;
}
@media (max-width: 600px) { .info .info-pop { left: auto; right: -8px; transform: none; } .info .info-pop::after { left: auto; right: 14px; } }

/* ---------- Formula block (mono, for "the maths") ---------- */
.formula {
  background: var(--bg-soft); border: 1px solid var(--border); border-left: 3px solid var(--c, var(--accent));
  border-radius: 6px; padding: 12px 14px; margin: 12px 0; font-size: 13px; color: var(--text);
  line-height: 1.6;
}
.formula .fx-lhs { color: var(--text-dim); }
.formula .fx-term { padding-left: 16px; display: block; }
.formula b { color: var(--c, var(--accent)); font-weight: 600; }

/* Definition list for formula components */
.defs { display: grid; gap: 9px; margin: 4px 0 0; }
.defs .def { font-size: 13px; line-height: 1.5; }
.defs .def-term {
  color: var(--c, var(--accent)); font-weight: 600;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 7px; margin-right: 4px; white-space: nowrap;
}
.defs .def-body { color: var(--text-soft); }
.whopays { list-style: none; padding: 0; margin: 6px 0; }
.whopays li { font-size: 13.5px; color: var(--text-soft); padding: 4px 0 4px 22px; position: relative; }
.whopays li::before { position: absolute; left: 0; top: 4px; font-weight: 700; }
.whopays li.pay::before { content: "✓"; color: var(--good); }
.whopays li.no::before { content: "✕"; color: var(--bad); }

/* ---------- Timeline (reform milestones) ---------- */
.timeline { position: relative; margin: 8px 0; padding-left: 6px; }
.timeline::before {
  content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border-strong);
}
.tl-item { position: relative; padding: 0 0 22px 36px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: 3px; top: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--c, var(--accent)); box-sizing: border-box;
}
.tl-item .tl-date {
  font-size: 11.5px; font-weight: 600; letter-spacing: .4px; color: var(--c, var(--accent));
  text-transform: uppercase;
}
.tl-item .tl-title { font-size: 15px; font-weight: 600; margin: 2px 0 3px; }
.tl-item .tl-body { font-size: 13.5px; color: var(--text-soft); margin: 0; }

/* Selects inherit the mono font + focus ring */
select:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
#reform-for li, #reform-against li { margin-bottom: 8px; }

/* ---------- Responsive: keep nav on one line, never overlap content ---------- */
@media (max-width: 820px) {
  .nav-inner { gap: 14px; }
  .brand small { display: none; }
  .nav-links { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { white-space: nowrap; }
  .subnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav a { white-space: nowrap; }
  .hero { padding: 48px 0 28px; }
}
