:root {
  --paper: #ffffff;
  --ink: #24221e;
  --muted: #6b6459;
  --line: #e4e1d8;
  --accent-soft: #aac0d6;
  --accent: #2f4d6b;
  --accent-strong: #1c3550;
  --error: #b3261e;
  --sumatra: #38764c;
  --java: #387176;
  --kalimantan: #384276;
  --sulawesi: #5c3876;
  --lombok: #763861;
  --content: min(1180px, calc(100vw - 48px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  background:
    radial-gradient(
      circle at 12% 8%,
      rgba(47, 77, 107, 0.045),
      transparent 22rem
    ),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  overflow: clip;
}

a {
  color: var(--accent);
  text-decoration-color: rgba(47, 77, 107, 0.35);
  text-underline-offset: 0.18em;
}

button,
select {
  font: inherit;
}

/* ==================================================
   HERO
   ================================================== */

.hero {
  position: relative;
  width: var(--content);
  margin: 0 auto;
}

.hero-top {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.65fr);
  align-items: center;
  gap: clamp(3rem, 9vw, 9rem);
  min-height: clamp(650px, 88svh, 840px);
  padding: clamp(4rem, 8vh, 7rem) 0;
}

.hero-copy {
  max-width: 840px;
}

.hero .eyebrow {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 clamp(2rem, 5vh, 4rem);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  line-height: 1;
  text-transform: uppercase;
}

.hero .eyebrow span {
  display: grid;
  place-items: center;
  width: 2rem;
  aspect-ratio: 1;
  flex: 0 0 auto;
  color: var(--accent-strong);
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.62rem;
  letter-spacing: 0;
}

.hero h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(3rem, 5.4vw, 5.6rem);
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: -0.06em;
  text-wrap: balance;
  color: var(--ink);
}

.hero h1 .lead {
  display: block;
  color: var(--muted);
  font-weight: 560;
}

.hero h1 em {
  display: block;
  margin-top: 0.06em;
  font-size: clamp(6.5rem, 13.5vw, 12.5rem);
  font-weight: 860;
  color: var(--accent-strong);
  font-style: normal;
  letter-spacing: -0.055em;
  line-height: 0.78;
}

.hero h1 em .rest {
  color: var(--ink);
  font-size: 0.42em;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.subtitle {
  max-width: 610px;
  margin: clamp(2rem, 5vh, 3.25rem) 0 0;
  padding-left: clamp(1rem, 2vw, 1.75rem);
  color: var(--muted);
  border-left: 2px solid var(--accent-soft);
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  font-weight: 500;
  line-height: 1.55;
}

.hero-summary {
  align-self: center;
}

.hero-intro {
  max-width: 430px;
  margin: 0 0 clamp(3.5rem, 8vh, 6rem);
  color: var(--ink);
  font-size: clamp(1.35rem, 2.1vw, 1.9rem);
  font-weight: 520;
  line-height: 1.35;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.hero-stats {
  display: block;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.hero-stat {
  display: grid;
  grid-template-columns: minmax(4.5rem, 0.35fr) minmax(0, 1fr);
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.hero-stat:last-child {
  border-bottom: 1px solid var(--line);
}

.hero-stat dd,
.hero-stat dt {
  margin: 0;
}

.stat-number {
  color: var(--ink);
  font-size: clamp(2.1rem, 3vw, 3.25rem);
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.hero-stat dt {
  font-size: 0.76rem;
  line-height: 1.35;
  text-transform: lowercase;
}

.hero-index {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.hero-index span {
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-index span:nth-child(2) {
  text-align: center;
}

.hero-index span:last-child {
  text-align: right;
}

/* ==================================================
   INTRODUCTION
   ================================================== */

.story-note.intro-note {
  display: grid;
  grid-template-columns: minmax(150px, 0.3fr) minmax(0, 1.7fr);
  gap: clamp(2.5rem, 8vw, 8rem);
  width: var(--content);
  margin: 0 auto 88px;
  padding: clamp(4rem, 8vw, 7rem) 0;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.story-note-label {
  display: flex;
  justify-content: space-between;
  align-self: start;
  gap: 1rem;
  padding-top: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.story-note-label span:last-child {
  color: var(--accent-strong);
}

.story-note-copy {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  align-items: start;
  gap: clamp(2.5rem, 6vw, 6rem);
}

.story-note h2 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  font-weight: 720;
  line-height: 1.02;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.story-note-copy p {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  line-height: 1.75;
}

/* ==================================================
   CHAPTERS
   ================================================== */

.chapter-number,
.detail-kicker {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chapter {
  width: var(--content);
  margin: 0 auto;
  padding: 88px 0;
  border-top: 1px solid var(--line);
}

.chapter-heading {
  display: grid;
  grid-template-columns: minmax(230px, 0.65fr) minmax(380px, 1.1fr);
  column-gap: 9vw;
  align-items: start;
  margin-bottom: 54px;
}

.chapter-heading .chapter-number {
  grid-row: 1 / span 2;
}

.chapter-heading h2,
.methods-section h2,
.sources-section h2 {
  margin: 0;
  font-size: clamp(2.35rem, 5vw, 4.8rem);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.chapter-heading > p:last-child {
  max-width: 660px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

/* ==================================================
   TRANSITIONS
   ================================================== */

.transition {
  display: grid;
  place-items: center;
  min-height: 38vh;
  padding: 80px 24px;
  background: var(--ink);
  color: var(--paper);
}

.transition p {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

/* ==================================================
   CONTROLS
   ================================================== */

.text-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 22px;
}

.text-tabs button {
  padding: 8px 0 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.text-tabs button:hover,
.text-tabs button:focus-visible,
.text-tabs button.is-active {
  border-bottom-color: var(--accent-strong);
  color: var(--ink);
  outline: 0;
}

/* ==================================================
   MAP AND NETWORK LAYOUTS
   ================================================== */

.map-layout,
.network-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 42px;
  align-items: start;
  margin-top: 26px;
}

.viz-shell {
  min-height: 580px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.viz-shell svg {
  display: block;
  width: 100%;
  height: auto;
}

.detail-panel {
  position: sticky;
  top: 30px;
  min-height: 290px;
  padding: 24px 0 24px 22px;
  border-left: 1px solid var(--line);
}

.detail-panel h3 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.detail-panel p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.detail-panel .detail-place {
  color: var(--ink);
  font-weight: 650;
}

/* ==================================================
   VARIANT LIST
   ================================================== */

.variant-list {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.variant-list li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

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

.variant-list span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.variant-image-link {
  display: inline-block;
  margin-top: 9px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration-thickness: 1px;
}

.variant-image-link:hover,
.variant-image-link:focus-visible {
  color: var(--accent-strong);
  outline-offset: 3px;
}

.variant-list .variant-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin-top: 9px;
}

.variant-links .variant-image-link,
.variant-links .variant-source-link {
  margin-top: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.variant-links .variant-image-link:hover,
.variant-links .variant-image-link:focus-visible,
.variant-links .variant-source-link:hover,
.variant-links .variant-source-link:focus-visible {
  color: var(--accent-strong);
  outline-offset: 3px;
}

/* ==================================================
   LEGENDS
   ================================================== */

.legend-row,
.network-key {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 26px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* ==================================================
   MAP
   ================================================== */

.map-point {
  cursor: pointer;
  stroke: var(--paper);
  stroke-width: 2;
  transition:
    opacity 160ms ease,
    r 160ms ease;
}

.map-point:hover,
.map-point:focus {
  stroke: var(--ink);
  stroke-width: 2.5;
  outline: 0;
}

.map-label {
  fill: rgba(36, 34, 30, 0.54);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ==================================================
   TOOLBARS
   ================================================== */

.matrix-toolbar,
.network-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ==================================================
   MATRIX
   ================================================== */

.matrix-scroll,
.constellation-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--line) transparent;
}

.matrix-scroll svg {
  display: block;
  min-width: 1000px;
}

.matrix-label {
  fill: var(--ink);
  font-size: 11px;
}

.matrix-ingredient {
  fill: var(--muted);
  font-size: 10px;
}

.matrix-gridline {
  stroke: rgba(107, 100, 89, 0.14);
}

.matrix-mark {
  cursor: default;
  stroke: var(--paper);
  stroke-width: 1.3;
}

.matrix-row-hit,
.matrix-col-hit {
  fill: transparent;
}

.matrix-row.is-muted,
.matrix-column.is-muted {
  opacity: 0.18;
}

.matrix-row.is-active .matrix-label {
  font-weight: 750;
}

.mobile-hint {
  display: none;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ==================================================
   NETWORK
   ================================================== */

.network-toolbar {
  justify-content: flex-end;
}

.network-toolbar label {
  color: var(--ink);
  font-weight: 650;
}

.network-toolbar select {
  min-width: 220px;
  padding: 9px 34px 9px 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.constellation-stage {
  min-width: 760px;
}

.network-link {
  stroke: var(--accent);
  transition: opacity 140ms ease;
}

.network-node {
  cursor: pointer;
  stroke: var(--paper);
  stroke-width: 2.2;
  transition:
    opacity 140ms ease,
    stroke 140ms ease;
}

.network-node:focus {
  stroke: var(--ink);
  stroke-width: 3;
  outline: 0;
}

.node-label {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 650;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.network-key {
  justify-content: flex-start;
}

.network-key span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.line-sample {
  display: inline-block;
  width: 42px;
  border-top: solid var(--accent);
}

.line-faint {
  border-top-width: 1px;
  opacity: 0.45;
}

.line-strong {
  border-top-width: 4px;
}

/* ==================================================
   INGREDIENTS AND RELATIVES
   ================================================== */

.ingredient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.ingredient-list li {
  border-bottom: 2px solid var(--accent-soft);
  font-size: 0.82rem;
}

.relative-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.relative-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.relative-list strong {
  color: var(--ink);
}

/* ==================================================
   SPOTLIGHTS
   ================================================== */

#spotlight-list {
  margin-top: 20px;
}

.spotlight {
  display: grid;
  grid-template-columns:
    minmax(210px, 0.65fr)
    minmax(300px, 1fr)
    minmax(230px, 0.7fr);
  gap: 5vw;
  padding: 48px 0;
  border-top: 1px solid var(--line);
}

.spotlight-index {
  display: block;
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
}

.spotlight h3 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.spotlight-place {
  margin-top: 12px;
  color: var(--muted);
}

.spotlight-description {
  margin: 0 0 26px;
  font-size: 1.05rem;
}

.spotlight h4 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.spotlight-ingredients {
  color: var(--muted);
  font-size: 0.9rem;
}

.spotlight-ingredients strong {
  color: var(--ink);
}

/* ==================================================
   METHODS AND SOURCES
   ================================================== */

.methods-section,
.sources-section {
  display: grid;
  grid-template-columns: minmax(250px, 0.7fr) minmax(420px, 1.3fr);
  align-items: center;
  gap: 8vw;
  width: var(--content);
  margin: 0 auto;
  padding: 80px 0;
  border-top: 1px solid var(--line);
}

.methods-copy {
  columns: 2;
  column-gap: 48px;
  color: var(--muted);
}

.methods-copy p {
  break-inside: avoid;
  margin: 0 0 22px;
}

.sources-section {
  display: block;
}

.sources-section h2 {
  margin-bottom: 48px;
}

.source-entry {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 28px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.source-type {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-entry p {
  margin: 0;
}

.source-entry .source-notes {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

/* ==================================================
   FOOTER
   ================================================== */

.story-footer {
  display: flex;
  justify-content: space-between;
  width: var(--content);
  margin: 0 auto;
  padding: 36px 0 52px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.story-footer p {
  margin: 0;
}

/* ==================================================
   TOOLTIPS AND ERRORS
   ================================================== */

.viz-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 260px;
  padding: 9px 11px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(12px, 12px);
  transition: opacity 90ms ease;
}

.viz-tooltip.is-visible {
  opacity: 1;
}

.viz-tooltip strong {
  display: block;
  color: #fff;
}

.viz-tooltip .tooltip-muted {
  display: inline-block;
  margin-top: 0.35rem;
  color: #d9ccb6;
}

.error-note {
  padding: 24px;
  color: var(--error);
}

/* ==================================================
   TABLET
   ================================================== */

@media (max-width: 900px) {
  :root {
    --content: min(100% - 32px, 720px);
  }

  .hero-top {
    grid-template-columns: 1fr;
    gap: 4rem;
    min-height: 0;
    padding: 5rem 0;
  }

  .hero-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr);
    align-items: end;
    gap: 3rem;
  }

  .hero-intro {
    margin: 0;
  }

  .story-note.intro-note {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .chapter-heading,
  .methods-section {
    grid-template-columns: 1fr;
  }

  .chapter-heading .chapter-number {
    grid-row: auto;
  }

  .map-layout,
  .network-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    min-height: 0;
  }

  .spotlight {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .methods-copy {
    columns: 1;
  }
}

/* ==================================================
   MOBILE
   ================================================== */

@media (max-width: 620px) {
  .hero-top {
    gap: 3rem;
    padding: 4.5rem 0 3.5rem;
  }

  .hero h1 {
    font-size: clamp(2.1rem, 9vw, 2.7rem);
  }

  .hero h1 em {
    font-size: clamp(3.6rem, 22vw, 5.6rem);
  }

  .hero .eyebrow {
    margin-bottom: 2.5rem;
  }

  .hero-summary {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .hero-intro {
    max-width: 34rem;
  }

  .hero-index span {
    font-size: 0.57rem;
    letter-spacing: 0.06em;
  }

  .story-note.intro-note {
    gap: 2.5rem;
    margin-bottom: 60px;
    padding: 3.5rem 0;
  }

  .story-note-copy {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .chapter {
    padding: 60px 0;
  }

  .chapter-heading {
    margin-bottom: 38px;
  }

  .chapter-heading h2,
  .methods-section h2,
  .sources-section h2 {
    font-size: 2.65rem;
  }

  .transition {
    min-height: 30vh;
  }

  .map-shell {
    min-height: 0;
  }

  .matrix-toolbar,
  .network-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .mobile-hint {
    display: block;
  }

  .methods-section,
  .sources-section {
    padding: 56px 0;
  }

  .source-entry {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .story-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

/* ==================================================
   REDUCED MOTION
   ================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
.closing-transition {
  min-height: auto;
  padding: clamp(70px, 9vw, 110px) 24px;
}

.closing-inner {
  width: var(--content);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(420px, 1.2fr) minmax(300px, 0.8fr);
  gap: clamp(48px, 7vw, 100px);
  align-items: center;
}

.closing-inner h2 {
  margin: 0;
  color: var(--paper);
  font-size: clamp(3rem, 6vw, 6.5rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.closing-inner p {
  margin: 0;
  color: rgba(255, 252, 242, 0.8);
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  line-height: 1.6;
}

@media (max-width: 760px) {
  .closing-inner {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .closing-inner h2 {
    font-size: clamp(3rem, 14vw, 5rem);
  }
}