/* powercut: Europe at night. Outages are holes in the lights.
   Type: Public Sans throughout (as on growpanel.io); colour is kept for the data, not the words. */

:root {
  --night: #05070c;
  --night-2: #090c13;
  --paper: #efe8db;
  --paper-2: #cfc7b8;
  --dim: #9d968a;
  --faint: #6a655d;
  --rule: rgba(239, 232, 219, 0.13);
  --rule-strong: rgba(239, 232, 219, 0.28);
  --cut: #ff5a3c;
  --lights: #f3c26b;
  --planned: #93a8bd;
  --serif: 'Public Sans', system-ui, sans-serif;
  --sans: 'Public Sans', system-ui, sans-serif;
  --measure: 1180px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  color: var(--paper);
  background: var(--night);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration-color: rgba(239, 232, 219, 0.35); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--cut); }
::selection { background: var(--cut); color: var(--night); }

/* ------------------------------------------------------------------ masthead */
.masthead {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 18px var(--gutter) 30px;
  pointer-events: none;
  /* a soft night band so text scrolling underneath never collides with the nameplate */
  background: linear-gradient(#05070c 0 52%, rgba(5, 7, 12, 0));
}
.nameplate {
  pointer-events: auto;
  font: 750 25px/1 var(--sans);
  letter-spacing: -0.035em; text-decoration: none;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.9);
}
.nameplate span { font-weight: 350; }
.nameplate::before { content: ''; display: inline-block; width: 15px; height: 15px; margin-right: 9px; border-radius: 50%; background: #020203; border: 2.5px solid var(--cut); vertical-align: -1px; }
.dateline {
  margin: 0; display: flex; align-items: center; gap: 9px;
  font: 500 12px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--paper-2);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.9);
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cut); box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.6); animation: beat 2.2s ease-out infinite; }
.live-dot.stale { background: var(--faint); animation: none; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.55); } 70%, 100% { box-shadow: 0 0 0 9px rgba(255, 90, 60, 0); } }

/* ------------------------------------------------------------------ hero map */
.hero { position: relative; height: 100vh; height: 100svh; min-height: 560px; overflow: hidden; }
.map { position: absolute; inset: 0; background: var(--night); }
.hero-scrim {
  position: absolute; inset: auto 0 0 0; height: 62%; pointer-events: none;
  background: linear-gradient(to top, rgba(5, 7, 12, 0.96) 0%, rgba(5, 7, 12, 0.78) 34%, rgba(5, 7, 12, 0) 100%);
}
.hero::before { /* top shade behind the masthead */
  content: ''; position: absolute; inset: 0 0 auto 0; height: 120px; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 7, 12, 0.85), rgba(5, 7, 12, 0));
}
.hero-copy {
  position: absolute; left: var(--gutter); bottom: clamp(56px, 9vh, 96px); z-index: 2;
  max-width: min(760px, calc(100% - 2 * var(--gutter)));
  pointer-events: none;
}
.hero-copy > * { pointer-events: auto; }
h1 {
  margin: 0;
  font: 650 clamp(34px, 5vw, 68px)/1.03 var(--sans);
  letter-spacing: -0.035em; text-wrap: balance;
}
h1 .n { font-weight: 800; color: var(--paper); font-variant-numeric: tabular-nums; }
.dek { margin: 18px 0 0; max-width: 54ch; color: var(--paper-2); font-size: clamp(15px, 1.25vw, 18px); line-height: 1.5; text-wrap: pretty; }
.dek b { color: var(--paper); font-weight: 600; }

.key { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 22px; font-size: 13px; color: var(--dim); }
.key-item { display: inline-flex; align-items: center; gap: 8px; }
.key-item svg { width: 18px; height: 18px; }
.k-cut { fill: #000; stroke: var(--cut); stroke-width: 1.6; }
.k-planned { fill: none; stroke: var(--planned); stroke-width: 1.3; }
.k-wind { width: 18px; height: 12px; border-radius: 50%; background: radial-gradient(closest-side, rgba(215, 228, 255, 0.6), rgba(160, 190, 240, 0.18) 60%, transparent); }
.dek .warn { color: #c8d6f0; }
.largest .gust { color: #c8d6f0; }
.key-toggle {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px;
}
.key-toggle[aria-pressed='false'] { color: var(--faint); text-decoration-line: line-through; }
.key-toggle:focus-visible { outline: 1px solid var(--cut); outline-offset: 4px; }

.scroll-cue {
  position: absolute; right: var(--gutter); bottom: 26px; z-index: 2;
  font: 500 12px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); text-decoration: none;
  display: inline-flex; align-items: center; gap: 10px;
}
.scroll-cue::after { content: ''; width: 1px; height: 28px; background: linear-gradient(var(--dim), transparent); }
.scroll-cue:hover { color: var(--paper); }

/* map chrome */
.maplibregl-ctrl-bottom-right { right: calc(var(--gutter) - 10px); bottom: 70px; }
.maplibregl-ctrl-group { background: rgba(9, 12, 19, 0.82); border: 1px solid var(--rule); box-shadow: none; border-radius: 4px; }
.maplibregl-ctrl-group button { width: 30px; height: 30px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--rule); }
.maplibregl-ctrl-icon { filter: invert(0.9) sepia(0.15); opacity: 0.8; }
.maplibregl-ctrl-attrib { background: transparent !important; font-size: 10px; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib a { color: var(--faint) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(0.8); opacity: 0.5; }

/* the popup is a paper tag on the night map */
.maplibregl-popup-content {
  background: var(--paper); color: #16130f; border-radius: 2px; padding: 14px 16px 13px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55); font: 13px/1.4 var(--sans); min-width: 230px;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--paper); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--paper); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--paper); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--paper); }
.maplibregl-popup-close-button { color: #6b645a; font-size: 18px; padding: 2px 7px; }
.tag .kind { font: 600 10.5px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: #b8361d; }
.tag .kind.planned { color: #4a5d72; }
.tag h3 { margin: 7px 0 1px; font: 700 18px/1.2 var(--sans); letter-spacing: -0.015em; }
.tag .op { color: #6b645a; font-size: 12px; }
.tag dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 11px 0 0; padding-top: 10px; border-top: 1px solid rgba(22, 19, 15, 0.14); font-size: 12.5px; }
.tag dt { color: #6b645a; }
.tag dd { margin: 0; font-weight: 500; }
.tag .cause { margin: 10px 0 0; color: #4c463e; font: 13px/1.45 var(--sans); }

/* ------------------------------------------------------------------ editorial body */
.paper {
  position: relative; z-index: 3;
  background: var(--night);
  padding: 0 var(--gutter);
}
.block { max-width: var(--measure); margin: 0 auto; padding: 88px 0 24px; display: grid; grid-template-columns: minmax(220px, 1fr) 2.2fr; gap: 24px 64px; }
.block + .block { border-top: 1px solid var(--rule); margin-top: 40px; }
.block-head { align-self: start; position: sticky; top: 96px; }
.block-head h2 { margin: 0; font: 650 30px/1.1 var(--sans); letter-spacing: -0.025em; text-wrap: balance; }
.block-head p { margin: 14px 0 0; color: var(--dim); font-size: 14.5px; max-width: 34ch; text-wrap: pretty; }
.block > :not(.block-head) { grid-column: 2; }

/* the ledger */
.ledger { width: 100%; border-collapse: collapse; }
.ledger th {
  text-align: left; font: 500 11px/1 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint);
  padding: 0 0 12px; border-bottom: 1px solid var(--rule-strong);
}
.ledger .r { text-align: right; }
.ledger td { padding: 16px 0 15px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger tbody tr { cursor: pointer; }
.ledger tbody tr:hover .cname, .ledger tbody tr:focus-visible .cname { text-decoration: underline; text-decoration-color: var(--cut); text-underline-offset: 5px; }
.ledger tbody tr:focus-visible { outline: none; }
.cname { display: block; font: 600 20px/1.2 var(--sans); letter-spacing: -0.015em; transition: color 0.15s; }
.cnote { display: block; margin-top: 5px; color: var(--faint); font-size: 12.5px; max-width: 46ch; }
.fig { font-variant-numeric: tabular-nums; text-align: right; font: 500 20px/1.2 var(--sans); font-variant-numeric: lining-nums tabular-nums; padding-left: 18px !important; white-space: nowrap; }
.fig.cust { color: var(--paper); font-weight: 700; }
.fig .nc { color: var(--faint); font-size: 16px; font-style: italic; }
.spark-col { width: 180px; padding-left: 28px !important; }
.ledger td.spark-col svg { display: block; width: 100%; height: 34px; margin-top: 2px; }
.spark-empty { font-size: 13px; color: var(--faint); }
.aside { margin: 22px 0 0; color: var(--faint); font-size: 13.5px; max-width: 64ch; }
.aside + .aside { margin-top: 10px; }

/* largest outages */
.largest { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.largest li {
  counter-increment: rank;
  display: grid; grid-template-columns: 56px 1fr auto; gap: 2px 18px; align-items: baseline;
  padding: 16px 0 15px; border-bottom: 1px solid var(--rule); cursor: pointer; position: relative;
}
/* the bottom rule doubles as a bar: how long this outage has lasted, relative to the longest */
.largest li::after { content: ''; position: absolute; left: 0; bottom: -1px; height: 3px; width: var(--dur, 0); background: var(--cut); }
.largest-key { margin: 12px 0 0; display: flex; justify-content: space-between; color: var(--faint); font-size: 11.5px; }
.largest-key span:first-child::before { content: ''; display: inline-block; width: 22px; height: 3px; margin-right: 8px; vertical-align: 3px; background: var(--cut); }
.largest li:first-child { border-top: 1px solid var(--rule-strong); }
.largest li::before { content: counter(rank, decimal-leading-zero); font: 300 22px/1 var(--sans); color: var(--faint); grid-row: span 2; font-variant-numeric: tabular-nums; }
.largest .place { font: 600 19px/1.2 var(--sans); letter-spacing: -0.015em; }
.largest .place small { font: 500 11px/1 var(--sans); letter-spacing: 0.08em; color: var(--faint); margin-left: 8px; vertical-align: 3px; }
.largest .place em { font: 400 14px var(--sans); font-style: normal; color: var(--faint); margin-left: 6px; }
.largest .count { font: 700 21px/1 var(--sans); color: var(--paper); text-align: right; font-variant-numeric: tabular-nums; }
.largest .count small { display: block; font: 500 10.5px/1.6 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.largest .meta { grid-column: 2 / -1; color: var(--dim); font-size: 13px; }
.largest li:hover .place, .largest li:focus-visible .place { text-decoration: underline; text-decoration-color: var(--cut); text-underline-offset: 5px; }
.largest li:focus-visible { outline: none; }

/* reliability strip plot */
.strip { margin: 0; }
.strip svg { width: 100%; height: auto; display: block; overflow: visible; }
.strip .axis text, .strip .lbl { font: 12px var(--sans); fill: var(--dim); }
.strip .axis line { stroke: var(--rule); }
.strip .axis .tick-major line { stroke: var(--rule-strong); }
.strip .row line.stem { stroke: rgba(239, 232, 219, 0.18); }
.strip .row circle { fill: var(--paper-2); }
.strip .row.live circle { fill: var(--cut); }
.strip .row.live .lbl { fill: var(--paper); font-weight: 600; }
.strip .row .val { font: 12px var(--sans); fill: var(--faint); font-variant-numeric: tabular-nums; }
.strip .row.live .val { fill: var(--paper-2); }
.strip .note { font: 15px var(--sans); fill: var(--paper); }
.source { color: var(--faint); font-size: 12.5px; margin: 18px 0 0; max-width: 72ch; }

/* Iberia feature */
.iberia {
  display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 24px 56px; align-items: end;
  max-width: var(--measure); margin: 120px auto 0; padding: 56px 0; text-decoration: none;
  border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong);
}
.iberia .kicker { margin: 0; font: 600 12px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.iberia h2 { margin: 14px 0 0; font: 650 38px/1.06 var(--sans); letter-spacing: -0.03em; text-wrap: balance; }
.iberia p:not(.kicker) { color: var(--dim); font-size: 15px; margin: 16px 0 0; text-wrap: pretty; }
.iberia .cta { display: inline-block; margin-top: 20px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--paper-2); padding-bottom: 2px; }
.iberia:hover .cta { border-bottom-color: var(--paper); }
.iberia-chart { width: 100%; height: auto; display: block; overflow: visible; }
.iberia-chart .area { fill: url(#gold); }
.iberia-chart .line { fill: none; stroke: var(--lights); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.iberia-chart .mark { stroke: var(--cut); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 3; }

/* colophon */
.colophon {
  max-width: var(--measure); margin: 0 auto; padding: 72px 0 80px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; color: var(--dim); font-size: 13px;
}
.colophon h3 { margin: 0 0 12px; font: 500 11px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--paper-2); }
.colophon p { margin: 0; }
.sources { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
.sources li { break-inside: avoid; padding: 0 0 9px; }
.sources b { display: block; color: var(--paper-2); font-weight: 500; }
.sources span { display: block; color: var(--faint); font-size: 12px; line-height: 1.4; }
.sources .off { text-decoration: line-through; text-decoration-color: rgba(239, 232, 219, 0.3); }
.sources .err { color: var(--cut); }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .block { grid-template-columns: 1fr; padding-top: 64px; }
  .block > :not(.block-head) { grid-column: 1; }
  .block-head { position: static; }
  .block-head p { max-width: none; }
  .iberia { grid-template-columns: 1fr; margin-top: 72px; }
  .iberia h2 { font-size: 30px; }
  .colophon { grid-template-columns: 1fr; gap: 28px; }
  .spark-col { width: 96px; padding-left: 14px !important; }
}
@media (max-width: 640px) {
  .hero { height: auto; min-height: 0; display: flex; flex-direction: column; }
  .map { position: relative; height: 64svh; inset: auto; }
  .hero-scrim { display: none; }
  .hero-copy { position: relative; left: auto; bottom: auto; max-width: none; padding: 26px var(--gutter) 8px; }
  .scroll-cue { display: none; }
  .maplibregl-ctrl-bottom-right { bottom: 10px; }
  .masthead { padding-bottom: 12px; background: #05070c; border-bottom: 1px solid var(--rule); }
  .nameplate { font-size: 22px; }
  .sources { columns: 1; }
  .dateline { font-size: 10.5px; }
  .ledger th.spark-col, .ledger td.spark-col { display: none; }
  .ledger th.r { padding-left: 14px; }
  .cname, .fig { font-size: 18px; }
  .largest li { grid-template-columns: 40px 1fr auto; }
  .largest li::before { font-size: 18px; }
  .largest .place { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* "Use ⌘ + scroll to zoom" overlay, in the site's own voice */
.maplibregl-cooperative-gesture-screen { background: rgba(5, 7, 12, 0.55); color: var(--paper); font: 600 18px/1.4 var(--sans); padding: 24px; }
.key-toggle[hidden] { display: none; }
.alert-link { color: var(--paper-2); text-decoration-color: rgba(243, 194, 107, 0.6); text-underline-offset: 4px; }
.alert-link::before { content: ''; width: 8px; height: 8px; margin: 0 3px 0 4px; border-radius: 50%; background: var(--lights); box-shadow: 0 0 9px rgba(243, 194, 107, 0.7); }
.tag .wsrc { margin: 8px 0 0; font-size: 11px; color: #6b645a; }
.tag .wsrc a { color: inherit; }
.dek .warn a { color: inherit; }
