:root {
  --ink: #17201d;
  --muted: #62706c;
  --paper: #f7f4ee;
  --panel: #fffdf8;
  --line: #d8d0c2;
  --teal: #117c78;
  --coral: #d65d47;
  --gold: #d99a2b;
  --night: #1c2430;
  --blue: #3f6f9f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
}

.hero {
  min-height: 92vh;
  position: relative;
  overflow: hidden;
  background: var(--night);
  color: #fffdf6;
  display: grid;
  align-items: end;
  padding: 24px;
}

.hero__map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.68;
}

.hero__content {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  padding: 12vh 0 8vh;
}

.hero h1 {
  margin: 0;
  font-size: clamp(4rem, 14vw, 11rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.subtitle {
  max-width: 720px;
  margin: 28px 0 0;
  color: #f2e6d3;
  font-size: clamp(1.25rem, 2.8vw, 2rem);
  line-height: 1.25;
}

.topbar {
  position: absolute;
  inset: 24px 24px auto auto;
  z-index: 3;
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar a {
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fffdf6;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(28, 36, 48, 0.55);
  backdrop-filter: blur(8px);
  font-size: 0.92rem;
}

.eyebrow,
.kicker {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--coral);
  font-size: 0.78rem;
}

.chapter {
  width: min(860px, calc(100% - 36px));
  margin: 0 auto;
  padding: 76px 0;
}

.intro-grid,
.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

.split--side {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 44px;
  align-items: start;
}

/* Side-by-side sections: headline spans full width, body text flows normally */
.split--side {
  grid-template-areas:
    "head head"
    "copy panel"
    "full full";
}

.split--side .split-head {
  grid-area: head;
}

.split--side .copy {
  grid-area: copy;
}

.split--side > .panel {
  grid-area: panel;
  align-self: start;
  margin-top: 8px;
}

.split--side > .full-row {
  grid-area: full;
}

.copy {
  max-width: none;
}

.copy--wide {
  max-width: 780px;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  line-height: 1.03;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 18px;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 800;
}

p {
  font-size: 1.06rem;
}

.copy p {
  margin: 0 0 14px;
}

.copy p:last-child {
  margin-bottom: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  min-height: 128px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
}

.metric strong {
  display: block;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(32, 25, 16, 0.06);
}

.panel--stack {
  display: grid;
  gap: 12px;
}

.panel-subtitle {
  margin: 8px 0 -4px;
}

.warning {
  margin-top: 24px;
  border-left: 4px solid var(--coral);
  background: #fff1e9;
  padding: 16px 18px;
  border-radius: 0 8px 8px 0;
  color: #613126;
  font-weight: 700;
}

.chart {
  width: 100%;
  min-height: 340px;
  display: block;
}

.plotly-chart {
  overflow: hidden;
}

.plotly-chart .main-svg {
  font-family: inherit !important;
}

.plotly-chart .modebar {
  right: 4px !important;
}

.heatmap {
  min-height: 420px;
}

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

.bar-value text {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chart-note {
  margin: -6px 0 18px;
  color: var(--muted);
  font-size: 0.98rem;
}

.axis path,
.axis line {
  stroke: var(--line);
}

.chart--short {
  min-height: 300px;
}

.shape-stack {
  margin-top: 12px;
}

#shape-group-stack {
  min-height: 120px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf0;
}

.shape-stack__bar {
  display: flex;
  width: 100%;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.shape-stack__segment {
  min-width: 2px;
}

.shape-stack__legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-top: 14px;
}

.shape-stack__item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-size: 0.88rem;
}

.shape-stack__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.shape-stack__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shape-stack__item strong {
  font-size: 0.9rem;
}

.shape-stack__item small {
  grid-column: 2 / -1;
  color: var(--muted);
}

.figure-note {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.figure-note--map {
  margin: 0;
  padding: 14px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.map-chapter {
  width: min(1280px, calc(100% - 28px));
}

/* Hotspot chapter: centered heading block */
.map-chapter .copy--wide {
  margin: 0 auto;
}

.map-chapter .copy--wide .kicker,
.map-chapter .copy--wide h2 {
  text-align: center;
}

.map-chapter .copy--wide p {
  text-align: left;
  margin-left: auto;
  margin-right: auto;
}

.map-shell {
  position: relative;
  margin-top: 28px;
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.map-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.map-controls label {
  color: var(--muted);
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--teal);
  min-width: min(420px, 100%);
}

#hotspot-map {
  width: 100%;
  height: min(72vh, 720px);
  min-height: 460px;
  display: block;
  background: #e9f1ef;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.mode-button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  min-height: 300px;
}

.word-cloud span {
  color: var(--teal);
  font-weight: 900;
  line-height: 1;
}

.callout-grid,
.era-grid {
  display: grid;
  gap: 12px;
}

.callout-grid {
  margin-top: 22px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-metric,
.era-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
}

.mini-metric strong,
.era-card strong {
  display: block;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1;
}

.mini-metric span,
.era-card span,
.era-card small {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

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

.era-card dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  margin: 18px 0 0;
}

.era-card dt,
.era-card dd {
  margin: 0;
  font-size: 0.94rem;
}

.era-card dt {
  color: var(--muted);
}

.era-card dd {
  font-weight: 800;
  text-align: right;
}

.country-panel {
  margin: 28px auto;
  text-align: left;
  max-width: 760px;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(23, 32, 29, 0.94);
  color: #fffdf6;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  max-width: 260px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.conclusion {
  max-width: 900px;
  text-align: center;
  padding-bottom: 120px;
}

.reference-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.reference-list a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.split > .full-row {
  grid-column: 1 / -1;
  padding-top: 6px;
  max-width: none;
  margin: 0;
}

.split > .full-row p {
  margin-top: 0;
  break-inside: avoid;
}

.split > .full-row p + p {
  margin-top: 1em;
}

@media (max-width: 820px) {
  .hero {
    min-height: 86vh;
  }

  .topbar {
    inset: 14px 14px auto auto;
  }

  .topbar a {
    padding: 7px 9px;
    font-size: 0.82rem;
  }

  .intro-grid,
  .split {
    gap: 18px;
  }

  .split--side {
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
  }
  .split--side {
    grid-template-areas:
      "head"
      "copy"
      "panel"
      "full";
  }

  .chapter {
    width: min(100% - 24px, 1180px);
    padding: 62px 0;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .callout-grid,
  .era-grid {
    grid-template-columns: 1fr;
  }

  .split > .full-row {
    max-width: 100%;
  }

  .panel {
    padding: 16px;
  }

  .chart {
    min-height: 320px;
  }

  .map-controls {
    align-items: stretch;
  }

  input[type="range"] {
    width: 100%;
  }
}
