/* ── The AI Landscape — tabs, shared timeline, Layers, World energy ───
   Reuses the theme tokens from styles.css (--ink, --gold, --line, etc.).
   Layers maps the three statuses onto the site palette: terracotta for a
   bottleneck, gold for tight, plain paper for not binding. Each status
   also has a non-color cue (heavy border + icon, dashed border).
   World energy's chart colors are a validated categorical palette
   (fixed order, 2px gaps between stacked segments); the low-contrast
   slots are backed by the legend, tooltips and the data table. */

:root {
  --ail-bottleneck-bg: #f5dcd3;
  --ail-bottleneck-edge: var(--terracotta-dark);
  --ail-bottleneck-ink: #6c3325;
  --ail-tight-bg: #f6e7cc;
  --ail-tight-edge: var(--gold-dark);
  --ail-tight-ink: #6e4718;
  --ail-clear-bg: #fff;
  --ail-clear-edge: var(--line);
  --ail-hatch: rgba(255, 255, 255, 0.6);
  --ail-hatch-clear: rgba(22, 39, 81, 0.06);
  --ail-radius: 8px;
  --ail-thumb: 24px;
  --ail-ease: 0.45s ease;

  --we-coal: #6250d6;
  --we-gas: #eb6834;
  --we-hydro: #2a78d6;
  --we-nuclear: #e87ba4;
  --we-wind: #1baf7a;
  --we-solar: #eda100;
  --we-other: #008300;
  --we-dc-conventional: #2a78d6;
  --we-dc-ai: var(--gold);
}

/* ── Page hero ──────────────────────────────────────────── */

.page-hero {
  padding: 140px 0 32px;
  position: relative;
}

.page-hero-inner {
  max-width: 1200px;
}

.page-hero h1 {
  color: var(--ink);
  font-size: clamp(32px, 4.4vw, 50px);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 18px;
}

.page-hero-lead {
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
  max-width: 760px;
}

/* ── Section shell ──────────────────────────────────────── */

.ail-section {
  background: #fdfdfd;
  padding: 36px 0 64px;
}

.ail-inner {
  max-width: 1440px;
}

/* ── Tabs (same look as the Computation Companies sheet tabs) ── */

.ail-tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 22px;
}

.ail-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.6px;
  margin-bottom: -1px;
  padding: 12px 18px;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
}

.ail-tab:hover {
  color: var(--ink);
}

.ail-tab.is-active {
  border-bottom-color: var(--gold);
  color: var(--gold-dark);
}

.ail-tab:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.ail-panel[hidden] {
  display: none;
}

.ail-stage-head[hidden] {
  display: none;
}

/* ── Diagram ────────────────────────────────────────────── */

.ail-stage-head {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.ail-year {
  color: var(--ink);
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

.ail-badge {
  border: 1.5px dashed var(--gold-dark);
  border-radius: 999px;
  color: var(--gold-dark);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.4px;
  padding: 4px 12px;
  text-transform: uppercase;
}

.ail-badge[hidden] {
  display: none;
}

.ail-explorer {
  align-items: start;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.ail-diagram {
  display: grid;
  gap: 8px;
}

.ail-layer {
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue-2);
  border-radius: var(--ail-radius);
  display: grid;
  gap: 16px;
  grid-template-columns: 170px minmax(0, 1fr);
  padding: 12px 14px;
  transition: border-color var(--ail-ease);
}

.ail-layer.is-binding {
  border-left-color: var(--terracotta);
}

.ail-layer-head {
  align-self: center;
}

.ail-layer-name {
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.ail-layer-count {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  margin: 0;
}

.ail-layer-title {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-decoration: none;
}

.ail-layer-title:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.ail-comps {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ail-comp {
  align-items: center;
  background-color: var(--ail-clear-bg);
  border: 1px solid var(--ail-clear-edge);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  gap: 6px;
  justify-content: space-between;
  line-height: 1.3;
  min-height: 48px;
  padding: 8px 10px;
  text-align: left;
  transition:
    background-color var(--ail-ease),
    border-color var(--ail-ease),
    color var(--ail-ease);
}

.ail-comp:hover {
  box-shadow: 0 6px 16px rgba(35, 64, 104, 0.1);
}

.ail-comp:focus-visible,
.ail-play:focus-visible,
.ail-event:focus-visible,
.ail-detail-close:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ail-comp[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--ink);
}

/* Bottleneck: heavy solid border + warning icon. */
.ail-comp.is-bottleneck,
.ail-swatch.is-bottleneck {
  background-color: var(--ail-bottleneck-bg);
  border: 2.5px solid var(--ail-bottleneck-edge);
  color: var(--ail-bottleneck-ink);
}

.ail-comp.is-bottleneck {
  font-weight: 600;
}

/* Tight: dashed border. */
.ail-comp.is-tight,
.ail-swatch.is-tight {
  background-color: var(--ail-tight-bg);
  border: 2px dashed var(--ail-tight-edge);
  color: var(--ail-tight-ink);
}

.ail-swatch.is-clear {
  background-color: var(--ail-clear-bg);
  border: 1px solid var(--muted);
}

.ail-comp-icon {
  flex: none;
  height: 16px;
  opacity: 0;
  width: 16px;
}

.ail-comp.is-bottleneck .ail-comp-icon {
  opacity: 1;
}

/* Projected years: hatch the fills so they read as speculative. */
.ail-diagram.is-projected .ail-comp,
.ail-swatch.is-hatched {
  background-image: repeating-linear-gradient(
    135deg,
    var(--ail-hatch) 0 4px,
    transparent 4px 9px
  );
}

.ail-diagram.is-projected .ail-comp.is-clear {
  background-image: repeating-linear-gradient(
    135deg,
    var(--ail-hatch-clear) 0 4px,
    transparent 4px 9px
  );
}

/* ── Detail panel ───────────────────────────────────────── */

.ail-detail {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ail-clear-edge);
  border-radius: var(--ail-radius);
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 16px 48px 16px 18px;
  position: sticky;
  top: 110px;
}

.ail-detail[hidden] {
  display: none;
}

.ail-detail.is-bottleneck {
  border-left-color: var(--ail-bottleneck-edge);
}

.ail-detail.is-tight {
  border-left-color: var(--ail-tight-edge);
}

.ail-detail h3 {
  color: var(--ink);
  font-size: 17px;
  margin: 0 0 6px;
}

.ail-detail-layer {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
}

.ail-detail-status {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}

.ail-detail-status strong {
  color: var(--ink);
}

.ail-detail-note {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  margin: 0;
}

.ail-detail-note + .ail-detail-note {
  margin-top: 12px;
}

.ail-detail.is-overview {
  border-left-color: var(--blue-2);
}

.ail-detail.is-overview .ail-detail-source {
  display: block;
}

.ail-detail-source {
  color: var(--gold-dark);
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

.ail-detail-source:hover {
  text-decoration: underline;
}

.ail-detail-close {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  position: absolute;
  right: 8px;
  top: 8px;
}

.ail-detail-close:hover {
  color: var(--ink);
}

/* ── Legend ─────────────────────────────────────────────── */

.ail-legend {
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 10px 22px;
  justify-content: center;
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.ail-legend li {
  align-items: center;
  display: flex;
  gap: 8px;
}

.ail-swatch {
  border-radius: 4px;
  display: inline-block;
  height: 18px;
  width: 26px;
}

/* ── Controls: scenario + summary ───────────────────────── */

.ail-controls {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 24px;
}

.ail-scenarios {
  border: none;
  margin: 0;
  padding: 0;
  text-align: center;
}

.ail-scenarios legend {
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  margin: 0 auto 10px;
  text-transform: uppercase;
}

.ail-scenarios legend span {
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.ail-scenario-options {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  overflow: hidden;
}

.ail-scenario-options input {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.ail-scenario-options label {
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  transition: background-color 0.15s, color 0.15s;
}

.ail-scenario-options label:hover {
  color: var(--ink);
}

.ail-scenario-options input:checked + label {
  background: var(--blue-1);
  color: var(--gold-dark);
}

.ail-scenario-options input:focus-visible + label {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.ail-scenario-desc {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 10px auto 0;
  max-width: 640px;
  text-align: center;
}

.ail-summary {
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  margin: 14px auto 0;
  max-width: 760px;
  text-align: center;
}

/* ── Timeline (shared by every tab) ─────────────────────── */

.ail-timeline-wrap {
  border-top: 1px solid var(--line);
  margin-top: 28px;
}

.ail-timeline {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  margin-top: 24px;
}

.ail-play {
  align-items: center;
  background: var(--ink);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex: none;
  height: 44px;
  justify-content: center;
  margin-bottom: 22px;
  width: 44px;
}

.ail-play svg {
  fill: currentColor;
  height: 20px;
  width: 20px;
}

.ail-play .ail-icon-pause,
.ail-play.is-playing .ail-icon-play {
  display: none;
}

.ail-play.is-playing .ail-icon-pause {
  display: block;
}

.ail-track-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}

/* Ticks, eras and events share the slider's usable width: the thumb's
   center runs from thumb/2 to 100% - thumb/2, so pad by half a thumb. */
.ail-events,
.ail-eras,
.ail-ticks {
  margin: 0 calc(var(--ail-thumb) / 2);
  position: relative;
}

.ail-events {
  height: calc(var(--ail-event-rows, 1) * 22px);
  margin-bottom: 6px;
}

.ail-event {
  background: var(--blue-1);
  border: 1px solid var(--blue-2);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  height: 18px;
  line-height: 16px;
  min-width: 18px;
  overflow: hidden;
  padding: 0 7px;
  position: absolute;
  text-overflow: ellipsis;
  transform: translateX(-9px);
  white-space: nowrap;
}

.ail-event:hover,
.ail-event.is-active {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #fff;
}

.ail-eras {
  display: flex;
  height: 22px;
}

.ail-era {
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 22px;
  overflow: hidden;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.ail-era.is-historical {
  background: var(--blue-2);
}

.ail-era.is-current {
  background: var(--gold);
  color: #fff;
  margin: 0 2px;
}

.ail-era.is-projected {
  background-color: var(--cream);
  background-image: repeating-linear-gradient(
    135deg,
    var(--stone) 0 3px,
    transparent 3px 8px
  );
  color: var(--muted);
}

.ail-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  display: block;
  height: 32px;
  margin: 0;
  width: 100%;
}

.ail-slider:focus {
  outline: none;
}

.ail-slider::-webkit-slider-runnable-track {
  background: var(--line);
  border-radius: 2px;
  height: 4px;
}

.ail-slider::-moz-range-track {
  background: var(--line);
  border-radius: 2px;
  height: 4px;
}

.ail-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: #fff;
  border: 3px solid var(--gold-dark);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(35, 64, 104, 0.25);
  height: var(--ail-thumb);
  margin-top: calc((4px - var(--ail-thumb)) / 2);
  width: var(--ail-thumb);
}

.ail-slider::-moz-range-thumb {
  background: #fff;
  border: 3px solid var(--gold-dark);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(35, 64, 104, 0.25);
  box-sizing: border-box;
  height: var(--ail-thumb);
  width: var(--ail-thumb);
}

.ail-slider:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ail-slider:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ail-ticks {
  height: 22px;
}

.ail-tick {
  color: var(--muted);
  font-size: 12px;
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
}

.ail-tick.is-selected {
  color: var(--ink);
  font-weight: 700;
}

.ail-captions {
  display: grid;
  gap: 6px;
  margin: 14px auto 0;
  max-width: 760px;
  min-height: 24px;
}

.ail-caption {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  text-align: center;
}

.ail-caption strong {
  color: var(--gold-dark);
}

.ail-footnote {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 28px 0 0;
  text-align: center;
}

/* ── World energy ───────────────────────────────────────── */

.we-panel {
  position: relative;
}

.we-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.we-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--ail-radius);
  padding: 14px 16px;
}

.we-stat.is-ai {
  border-top: 3px solid var(--gold);
}

.we-stat p {
  margin: 0;
}

.we-stat-label {
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.we-stat-value {
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px !important;
}

.we-stat-sub {
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.45;
  margin-top: 4px !important;
}

.we-charts {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  margin-top: 16px;
}

.we-figure {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--ail-radius);
  margin: 0;
  min-width: 0;
  padding: 16px 16px 8px;
}

.we-figure h3 {
  color: var(--ink);
  font-size: 16px;
  margin: 0 0 2px;
}

.we-figure figcaption p {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
}

.we-legend {
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  font-size: 12.5px;
  gap: 4px 14px;
  list-style: none;
  margin: 10px 0 4px;
  padding: 0;
}

.we-legend li {
  align-items: center;
  display: flex;
  gap: 6px;
}

.we-key {
  border-radius: 3px;
  display: inline-block;
  flex: none;
  height: 10px;
  width: 10px;
}

/* Fixed height so a redraw never resizes the box it measures. */
.we-chart {
  height: 270px;
}

.we-chart svg {
  display: block;
}

.we-grid {
  stroke: var(--line);
  stroke-dasharray: 2 3;
}

.we-baseline {
  stroke: var(--muted);
}

.we-axis {
  fill: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
}

.we-axis.is-selected {
  fill: var(--ink);
  font-weight: 700;
}

.we-total {
  fill: var(--ink);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  paint-order: stroke;
  pointer-events: none;
  stroke: #fff;
  stroke-linejoin: round;
  stroke-width: 4px;
}

.we-col-selected {
  fill: var(--blue-1);
}

.we-hit {
  cursor: pointer;
  fill: transparent;
}

.we-tip {
  background: var(--ink);
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(22, 39, 81, 0.25);
  color: #fff;
  font-size: 12.5px;
  max-width: 260px;
  padding: 10px 12px;
  pointer-events: none;
  position: absolute;
  z-index: 3;
}

.we-tip[hidden] {
  display: none;
}

.we-tip p {
  margin: 0;
}

.we-tip-head {
  font-weight: 700;
  margin-bottom: 6px !important;
}

.we-tip table {
  border-collapse: collapse;
  width: 100%;
}

.we-tip td {
  padding: 1px 0;
}

.we-tip td:first-child {
  align-items: center;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  gap: 6px;
  padding-right: 14px;
}

.we-tip td:last-child {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.we-tip-total td {
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff !important;
  font-weight: 600;
  padding-top: 4px;
}

.we-tip-note {
  color: rgba(255, 255, 255, 0.75);
  margin-top: 6px !important;
}

.we-table-wrap {
  margin-top: 16px;
}

.we-table-wrap summary {
  color: var(--gold-dark);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}

.we-table-scroll {
  margin-top: 10px;
  overflow-x: auto;
}

.we-table {
  background: #fff;
  border: 1px solid var(--line);
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

.we-table th,
.we-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
}

.we-table thead th {
  background: var(--blue-1);
  color: var(--ink);
  font-weight: 600;
}

.we-table tbody th {
  color: var(--ink);
  text-align: left;
}

.we-table tr.is-selected {
  background: #fdf4e6;
}

.we-table-note,
.we-sources {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 8px 0 0;
}

.we-sources a {
  color: var(--gold-dark);
  font-weight: 600;
}

.we-sources a:hover {
  text-decoration: underline;
}

/* ── Motion ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ail-layer,
  .ail-comp {
    transition: none;
  }
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 1100px) {
  .ail-explorer {
    gap: 12px;
    grid-template-columns: minmax(0, 1fr);
  }

  .ail-detail {
    position: relative;
    top: auto;
  }
}

@media (max-width: 860px) {
  .ail-layer {
    gap: 10px;
    grid-template-columns: 1fr;
  }

  .we-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .we-charts {
    grid-template-columns: minmax(0, 1fr);
  }

  .ail-layer-head {
    align-items: baseline;
    display: flex;
    gap: 10px;
  }
}

@media (max-width: 680px) {
  .page-hero {
    padding-top: 36px;
  }

  .ail-comps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ail-comp {
    font-size: 13px;
  }

  .ail-timeline {
    gap: 10px;
  }

  .ail-era {
    font-size: 9px;
    letter-spacing: 0.4px;
  }

  /* Only label even years so the ticks don't collide. */
  .ail-tick.is-odd:not(.is-selected) {
    visibility: hidden;
  }

  .ail-event {
    font-size: 0;
    padding: 0;
  }

  .ail-scenario-options {
    display: flex;
    flex-direction: column;
  }

  .we-stats {
    gap: 8px;
  }

  .we-stat {
    padding: 12px;
  }

  .we-stat-value {
    font-size: 20px;
  }

  .we-figure {
    padding: 14px 10px 6px;
  }

  .we-chart {
    height: 220px;
  }
}
