/* ------------------------------------------------------------
   End Marginal Pricing — homepage styles
   Palette: ink on paper. Green = renewables. Orange = gas, only.
   ------------------------------------------------------------ */
:root {
  --paper: #f1ece2;
  --paper-2: #e7e0d2;
  --ink: #16140f;
  --ink-2: #4a463d;
  --ink-3: #8a8476;
  --rule: #cfc6b4;
  --green: #1f7a4a;
  --green-2: #3fa36b;
  --green-3: #9cc9a3;
  --gas: #e5560f;
  --gas-soft: #f6c2a2;
  --nuclear: #6d7f73;
  --muted: #b9b09f;

  --f-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --f-text: "Newsreader", Georgia, serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --gutter: clamp(16px, 5vw, 64px);
  --rail: clamp(28px, 6vw, 90px); /* space for the current line on the left */
  --ease: cubic-bezier(.2, .7, .1, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-text);
  font-size: clamp(17px, 1.15vw + 11px, 21px);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--green); }
::selection { background: var(--gas); color: var(--paper); }
.mono { font-family: var(--f-mono); font-size: .72em; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.small { font-size: .82em; color: var(--ink-2); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 900; line-height: .92; letter-spacing: -.005em; margin: 0; text-transform: uppercase; }
h2 { font-size: clamp(44px, 7vw, 108px); max-width: 14ch; }
h3 { font-size: clamp(24px, 2.4vw, 34px); font-weight: 700; line-height: 1; }
.label { text-transform: uppercase; color: var(--ink-3); margin: 0 0 1.2rem; letter-spacing: .08em; }
.gas-text { color: var(--gas); }

/* Grain overlay: printed, not rendered */
.grain {
  position: fixed; inset: -50%; z-index: 100; pointer-events: none; opacity: .22;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
  animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } 100% { transform: translate(0, 0); }
}

/* ---------- The current ---------- */
.current {
  position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; z-index: 1; overflow: visible;
}
.current path { fill: none; stroke-linecap: round; }
.current-track { stroke: var(--rule); stroke-width: 1.5; stroke-dasharray: 2 7; }
.current-live { stroke: var(--green); stroke-width: 3; }
.current-live.is-gas { stroke: var(--gas); }

main, .footer { position: relative; z-index: 2; }
section { padding: clamp(80px, 14vh, 160px) var(--gutter) clamp(80px, 14vh, 160px) calc(var(--gutter) + var(--rail)); }

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.wordmark { font-family: var(--f-display); font-weight: 900; font-size: 22px; text-transform: uppercase; text-decoration: none; letter-spacing: .01em; }
.wordmark span { color: var(--gas); }
.masthead nav { display: flex; gap: clamp(10px, 2vw, 28px); font-family: var(--f-mono); font-size: 13px; }
.masthead nav a { text-decoration: none; }
.nav-cta { background: var(--ink); color: var(--paper) !important; padding: 6px 12px; }
.nav-cta:hover { background: var(--green); }
@media (max-width: 720px) { .masthead nav a:not(.nav-cta) { display: none; } }

/* ---------- Hero ---------- */
.hero { min-height: calc(100svh - 60px); display: flex; flex-direction: column; justify-content: center; padding-top: 40px; }
.kicker { display: flex; align-items: center; gap: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); margin: 0 0 2rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,122,74,.5);} 70% { box-shadow: 0 0 0 10px rgba(31,122,74,0);} 100% { box-shadow: 0 0 0 0 rgba(31,122,74,0);} }
.hero-title { font-size: clamp(56px, 12.5vw, 210px); line-height: .84; margin-bottom: 2.4rem; }
.hero-title .line { display: block; overflow: hidden; padding-bottom: .04em; }
.hero-title .line > * , .hero-title .line { }
.js .hero-title .line { clip-path: inset(0 0 100% 0); transform: translateY(.4em); transition: clip-path 1s var(--ease), transform 1s var(--ease); }
.js .hero-title.in .line { clip-path: inset(0 0 -10% 0); transform: none; }
.js .hero-title.in .line:nth-child(2) { transition-delay: .12s; }
.js .hero-title.in .line:nth-child(3) { transition-delay: .24s; }
.gas-word { font-style: normal; color: var(--gas); position: relative; }
.gas-word::after { /* hand-drawn underline */
  content: ""; position: absolute; left: 0; right: 0; bottom: .02em; height: .09em; background: var(--gas);
  transform: scaleX(0); transform-origin: left; transition: transform .9s var(--ease) .9s;
}
.hero-title.in .gas-word::after { transform: scaleX(1); }
.wind-word { color: var(--green); }
.hero-lede { max-width: 34em; font-size: 1.08em; color: var(--ink-2); margin: 0 0 2.6rem; }
.js .hero-lede, .js .hero-foot, .js .kicker { opacity: 0; transform: translateY(14px); transition: opacity .9s var(--ease) .5s, transform .9s var(--ease) .5s; }
.js .loaded .hero-lede, .js .loaded .hero-foot, .js .loaded .kicker { opacity: 1; transform: none; }
.scroll-cue { text-decoration: none; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--ink); padding-bottom: 4px; }
.scroll-cue span { display: inline-block; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }

/* ---------- Reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Live mix ---------- */
.mix { border-top: 1px solid var(--rule); }
.section-head { margin-bottom: clamp(40px, 8vh, 80px); }
.mix-figure { max-width: 1200px; }
.mix-callout { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: clamp(16px, 3vw, 48px); margin-bottom: clamp(70px, 10vh, 110px); }
.mix-big { font-family: var(--f-display); font-weight: 900; font-size: clamp(110px, 20vw, 300px); line-height: .78; margin: 0; color: var(--gas); font-variant-numeric: tabular-nums; }
.mix-big .pct { font-size: .45em; vertical-align: top; margin-left: .04em; }
.mix-copy { margin: 0 0 .6em; max-width: 22em; font-size: 1.1em; }
@media (max-width: 720px) { .mix-callout { grid-template-columns: 1fr; } }

.mix-chart { position: relative; padding-top: 56px; }
.mix-bar {
  display: flex; height: clamp(90px, 14vw, 150px); width: 100%; background: var(--paper-2);
  outline: 1.5px solid var(--ink); outline-offset: 0; position: relative; overflow: hidden;
}
.seg {
  height: 100%; flex: 0 0 0%; position: relative; cursor: crosshair;
  transition: flex-basis 1.4s var(--ease), filter .2s;
  border-right: 1.5px solid var(--paper);
  overflow: hidden;
}
.seg:last-child { border-right: 0; }
.seg span { position: absolute; left: 8px; bottom: 8px; font-family: var(--f-mono); font-size: 12px; color: var(--paper); white-space: nowrap; opacity: 0; transition: opacity .4s .9s; }
.mix-bar.in .seg span { opacity: 1; }
.seg:hover { filter: brightness(1.12) saturate(1.1); }
.seg.gas { background: var(--gas); }
.seg.gas::after { /* gas pulses gently so the eye finds it */
  content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, transparent 0 9px, rgba(0,0,0,.08) 9px 11px);
  animation: slide 3s linear infinite;
}
@keyframes slide { to { background-position: 40px 0; } }
.bracket {
  position: absolute; left: 0; right: 0; top: 0; height: 40px;
  border: 1.5px solid var(--ink); border-bottom: 0;
  transform-origin: left; transform: scaleX(0); transition: transform 1.2s var(--ease) .6s;
}
.mix-chart.in .bracket { transform: scaleX(1); }
.bracket-label { position: absolute; left: 12px; top: -11px; background: var(--paper); padding: 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: 0; transition: opacity .6s 1.5s; }
.mix-chart.in .bracket-label { opacity: 1; }
.pointer { position: absolute; top: 206px; transform: translateX(-100%); display: flex; align-items: flex-start; gap: 0; margin-top: 6px; opacity: 0; transition: opacity .6s 2s, left 1.4s var(--ease); pointer-events: none; }
.mix-chart.in .pointer { opacity: 1; }
.pointer-arrow { width: 90px; height: 54px; flex: none; order: 2; transform: scaleX(-1); }
.pointer-arrow path { fill: none; stroke: var(--gas); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 160; stroke-dashoffset: 160; transition: stroke-dashoffset 1s var(--ease) 2.1s; }
.mix-chart.in .pointer-arrow path { stroke-dashoffset: 0; }
.pointer-label { order: 1; margin-top: 40px; color: var(--gas); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.pointer.flip { transform: none; }
.pointer.flip .pointer-arrow { order: 0; transform: none; }
.pointer.flip .pointer-label { order: 1; }

.mix-tooltip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--paper);
  padding: 8px 10px; font-size: 13px; line-height: 1.35; opacity: 0; transform: translate(-50%, calc(-100% - 14px)); transition: opacity .15s; white-space: nowrap;
}
.mix-tooltip.show { opacity: 1; }
.mix-tooltip b { font-weight: 600; }
.mix-legend { list-style: none; padding: 0; margin: 110px 0 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; }
.mix-legend li { display: flex; align-items: center; gap: 8px; }
.mix-legend i { width: 12px; height: 12px; display: inline-block; }
.mix-meta { color: var(--ink-3); margin-top: 28px; }

/* ---------- Merit order ---------- */
.merit { border-top: 1px solid var(--rule); padding-top: 0; padding-bottom: 0; height: 520vh; position: relative; }
.merit-sticky {
  position: sticky; top: 60px; height: calc(100svh - 60px);
  display: grid; grid-template-columns: minmax(260px, 5fr) 7fr; gap: clamp(24px, 4vw, 70px); align-items: center;
}
.steps { list-style: none; padding: 0; margin: 0; position: relative; min-height: 15em; }
.steps li { position: absolute; inset: 0 0 auto 0; opacity: 0; transform: translateY(18px); transition: opacity .5s var(--ease), transform .5s var(--ease); pointer-events: none; }
.steps li.active { opacity: 1; transform: none; pointer-events: auto; }
.steps h3 { font-size: clamp(30px, 3.6vw, 56px); margin-bottom: .6em; max-width: 12ch; }
.steps p { color: var(--ink-2); margin: 0; max-width: 24em; }
.steps li[data-step="5"] h3, .steps li[data-step="6"] h3 { color: var(--gas); }
.merit-svg { width: 100%; height: auto; overflow: visible; }
.axes line { stroke: var(--ink); stroke-width: 1.5; }
.axis-label, .demand-label, .price-label, .bar-label { font-family: var(--f-mono); font-size: 11px; fill: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.bar rect { transition: y .9s var(--ease), height .9s var(--ease); }
.bar.wind rect, .bar.solar rect { fill: var(--green); }
.bar.solar rect { fill: var(--green-2); }
.bar.nuclear rect { fill: var(--nuclear); }
.bar.other rect { fill: var(--muted); }
.bar.gas rect { fill: var(--gas); }
.bar-label { opacity: 0; transition: opacity .4s .5s; }
.bar.up .bar-label { opacity: 1; }
.demand line { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 5; }
.demand-label { font-weight: 600; fill: var(--ink); }
.demand { opacity: 0; transition: opacity .6s, transform 1.1s var(--ease); }
.demand.on { opacity: 1; }
.price line { stroke: var(--gas); stroke-width: 3; stroke-dasharray: 600; stroke-dashoffset: 600; transition: stroke-dashoffset 1.2s var(--ease); }
.price.on line { stroke-dashoffset: 0; }
.price-label { fill: var(--gas); font-weight: 600; opacity: 0; transition: opacity .5s .8s; }
.price.on .price-label { opacity: 1; }
.hatch-line { stroke: var(--gas); stroke-width: 2; }
.overpay rect { fill: url(#hatch); opacity: 0; transform-origin: bottom; transition: opacity .6s var(--ease); }
.overpay.on rect { opacity: .85; }
.merit-note { color: var(--ink-3); margin-top: 8px; }
@media (max-width: 860px) {
  .merit-sticky { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: center; gap: 12px; }
  .steps { min-height: 10.5em; }
  .steps h3 { font-size: 30px; margin-bottom: .4em; }
  .steps p { font-size: .92em; }
}

/* ---------- Numbers ---------- */
.numbers { border-top: 1px solid var(--rule); }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li {
  display: grid; grid-template-columns: minmax(200px, 5fr) 7fr; gap: 6px clamp(20px, 4vw, 60px); align-items: end;
  padding: clamp(28px, 5vh, 56px) 0; border-bottom: 1px solid var(--rule);
}
.stat-list li:first-child { border-top: 1.5px solid var(--ink); }
.stat { font-family: var(--f-display); font-weight: 900; font-size: clamp(96px, 15vw, 230px); line-height: .78; margin: 0; grid-row: span 2; font-variant-numeric: tabular-nums; }
.stat .unit { font-size: .5em; vertical-align: top; color: var(--ink-2); }
.stat .unit.pre { margin-right: .05em; }
.stat-list li:first-child .stat { color: var(--gas); }
.stat-text { margin: 0; font-size: 1.15em; max-width: 24em; }
.stat-src { color: var(--ink-3); margin: 0; }
@media (max-width: 720px) { .stat-list li { grid-template-columns: 1fr; } .stat { grid-row: auto; margin-bottom: 12px; } }

/* ---------- Fix ---------- */
.fix { background: var(--ink); color: var(--paper); position: relative; z-index: 2; }
.fix .label { color: var(--muted); }
.fix-title { max-width: 13ch; font-size: clamp(52px, 8.5vw, 140px); }
.fix .wind-word { color: var(--green-3); }
.cord { margin: clamp(30px, 6vh, 60px) 0; height: 80px; }
.cord svg { width: 100%; height: 100%; overflow: visible; }
.cord path { fill: none; stroke-width: 4; stroke-linecap: round; transition: transform 1.2s var(--ease); }
.cord-left { stroke: var(--gas); }
.cord-right { stroke: var(--green-3); }
.cord.cut .cord-left { transform: translateX(-30px) rotate(-2deg); }
.cord.cut .cord-right { transform: translateX(30px) rotate(2deg); }
.fix-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: clamp(20px, 3vw, 48px); max-width: 1200px; }
.fix-cols p { margin: 0; color: #d9d2c3; }
.fix-cols p:first-child::first-letter { font-family: var(--f-display); font-weight: 900; font-size: 4.2em; float: left; line-height: .8; margin: .05em .08em 0 0; color: var(--paper); }

/* ---------- Act ---------- */
.act { border-top: 0; }
.act h2 { margin-bottom: clamp(40px, 7vh, 70px); }
.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1.5px solid var(--ink); max-width: 1200px; }
.act-block { padding: clamp(22px, 3.5vw, 44px); }
.act-block + .act-block { border-left: 1.5px solid var(--ink); }
.act-block p { color: var(--ink-2); }
.step-num { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border: 1.5px solid currentColor; border-radius: 50%; font-size: .5em; vertical-align: middle; margin-right: .3em; }
@media (max-width: 860px) { .act-grid { grid-template-columns: 1fr; } .act-block + .act-block { border-left: 0; border-top: 1.5px solid var(--ink); } }

form label { display: block; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 18px 0 6px; }
input, textarea {
  width: 100%; font: inherit; font-size: 18px; color: var(--ink); background: var(--paper);
  border: 0; border-bottom: 1.5px solid var(--ink); padding: 10px 2px; border-radius: 0;
}
textarea { border: 1.5px solid var(--ink); padding: 12px; font-size: 16px; line-height: 1.5; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 2px 0 var(--green); }
.field-row { display: flex; gap: 10px; align-items: end; }
button, .btn {
  font-family: var(--f-mono); font-size: 14px; text-transform: uppercase; letter-spacing: .06em; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink); padding: 13px 20px; text-decoration: none; display: inline-block;
  transition: background .2s, color .2s, transform .15s;
}
button:hover, .btn:hover { background: var(--green); border-color: var(--green); color: var(--paper); }
button:active, .btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.join-form button { margin-top: 22px; width: 100%; }
.field-row button { flex: none; }
.check { display: flex !important; gap: 10px; align-items: flex-start; text-transform: none !important; letter-spacing: 0 !important; font-family: var(--f-text); font-size: 15px; }
.check input { width: auto; margin-top: 4px; accent-color: var(--green); }
.form-msg { min-height: 1.4em; margin: 10px 0 0; }
.form-msg.err { color: var(--gas); }
.form-msg.ok { color: var(--green); }
.letter { margin-top: 24px; }
.mp-found { font-size: 1.05em; color: var(--ink) !important; }
.letter-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.share { display: flex; align-items: center; gap: 18px; margin-top: 50px; }
.share p { margin: 0; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }

/* ---------- Footer ---------- */
.footer { border-top: 1.5px solid var(--ink); padding: 60px var(--gutter) 40px calc(var(--gutter) + var(--rail)); }
.footer .wordmark { font-size: clamp(40px, 7vw, 96px); margin: 0 0 30px; line-height: .9; }
.sources p { text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 8px; }
.sources ul { margin: 0 0 30px; padding-left: 1.1em; font-size: .85em; color: var(--ink-2); max-width: 60em; }
.sources li { margin-bottom: 6px; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
