/* ──────────────────────────────────────────────────────────────────────────
   Africa Causes of Death — Explorable (treemap)
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --age-under5:   #F4D58D;
  --age-5-14:     #E5B25D;
  --age-15-49:    #C9483A;
  --age-50-69:    #4E3A6B;
  --age-70plus:   #1F1B3A;

  --ground:       #FAF6EE;
  --ground-deep:  #F1EADC;
  --ink:          #1F1B3A;
  --ink-muted:    #5C566F;
  --rule:         #D8CFBC;
  --grey:         #8A8378;

  --l1-cmnn:      #C9483A;
  --l1-ncd:       #4E3A6B;
  --l1-injury:    #E5B25D;

  --font-serif:   "Fraunces", Georgia, serif;
  --font-sans:    "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--l1-cmnn); text-decoration: underline; text-underline-offset: 0.15em; }
a:hover { color: var(--age-70plus); }
strong { font-weight: 600; }
ul { padding-left: 1.1rem; margin: 0.4em 0; }
li { margin-bottom: 0.35em; }

/* ── Page layout: sidebar + chart pane ─────────────────────────────────── */

.page {
  display: grid;
  grid-template-columns: minmax(310px, 380px) 1fr;
  min-height: 100vh;
}

@media (max-width: 800px) {
  .page { grid-template-columns: 1fr; }
}

.side {
  padding: 1.75rem 1.5rem 2rem;
  border-right: 1px solid var(--rule);
  background: var(--ground);
  max-height: 100vh;
  overflow-y: auto;
}

@media (max-width: 800px) {
  .side { max-height: none; border-right: none; border-bottom: 1px solid var(--rule); }
}

.chart-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  min-height: 600px;
  padding: 0;
}

#chart {
  flex: 1;
  position: relative;
  min-height: 540px;
}

/* ── Sidebar typography ────────────────────────────────────────────────── */

.kicker {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--l1-cmnn);
  margin-bottom: 0.5rem;
}

.side h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.015em;
  font-size: 1.65rem;
  line-height: 1.1;
  margin: 0 0 0.45rem;
}

.side .deck {
  font-size: 0.92rem;
  color: var(--ink-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

/* ── Detail panel (the primary content) ────────────────────────────────── */

.detail { margin: 0 0 1.25rem; }

.detail h3 {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--l1-cmnn);
  margin: 0 0 0.4rem;
}

.detail-card {
  background: var(--ground-deep);
  border-radius: 3px;
  padding: 0.9rem 1rem 1rem;
}

.detail-trail {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.detail-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.detail-meta {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}

.detail-total {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  margin-bottom: 0.85rem;
}
.detail-total strong { font-size: 1.1rem; color: var(--l1-cmnn); font-weight: 700; }

.detail-section-title {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.65rem;
  color: var(--ink-muted);
  margin: 0.85rem 0 0.4rem;
}

.detail-bars {
  display: grid;
  gap: 0.3rem;
}

.age-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 4rem;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  gap: 0.5rem;
}
.age-row-label { color: var(--ink-muted); text-align: right; }
.age-row-bar {
  display: block;
  height: 12px;
  background: var(--ground);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}
.age-row-bar span {
  display: block;
  height: 100%;
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}
.age-row-value {
  font-feature-settings: "tnum";
  color: var(--ink);
  text-align: right;
}

.detail-hint {
  margin: 0.75rem 0 0;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-style: italic;
}

/* ── Search ─────────────────────────────────────────────────────────────── */

.form-group { margin: 0 0 1.25rem; }

.label {
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 0.3rem;
}

#searchBox {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  background: var(--ground);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
#searchBox:focus {
  outline: 2px solid var(--l1-cmnn);
  outline-offset: -1px;
}

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

.legend { margin: 0 0 1.25rem; font-family: var(--font-sans); font-size: 0.8rem; color: var(--ink-muted); }
.legend-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.1rem 0; }
.legend-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
  color: var(--ink-muted);
  margin-right: 0.4rem;
}
.swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
}
.swatch.invisible { background: transparent !important; }

/* ── How-to (collapsible) ──────────────────────────────────────────────── */

.how {
  margin: 0 0 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.how summary {
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--l1-cmnn);
  padding: 0.25rem 0;
}
.how summary::marker { color: var(--rule); }
.how ul { margin-top: 0.4rem; }

/* ── Story cross-link ──────────────────────────────────────────────────── */

.story-link {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 0.88rem;
}
.story-link strong { display: block; margin-bottom: 0.3rem; }
.story-link p { margin: 0; color: var(--ink-muted); }

/* ── Colophon ─────────────────────────────────────────────────────────── */

.colophon {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.5;
}
.colophon p { margin: 0 0 0.5em; }
.scope-note { font-style: italic; }

/* ── Chart pane: breadcrumb + svg ──────────────────────────────────────── */

#loadText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  color: var(--ink-muted);
  font-size: 1rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
  flex-wrap: wrap;
}
.bc-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--l1-cmnn);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}
.bc-link:hover { color: var(--age-70plus); }
.bc-current { color: var(--ink); font-weight: 600; }
.bc-sep { color: var(--rule); }

/* ── Icicle-internal classes (consumed by main.js) ────────────────────── */

.cell-rect {
  stroke-width: 1.5;
  transition: opacity 180ms ease;
}
.cell:hover .cell-rect { filter: brightness(1.07); }

.cell-name {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}
.cell-val {
  font-family: var(--font-sans);
  font-size: 10.5px;
  pointer-events: none;
  font-feature-settings: "tnum";
}

/* Tooltip */
.nodeTooltip {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  background: var(--ink);
  color: var(--ground);
  padding: 5px 9px;
  border-radius: 3px;
  pointer-events: none;
  position: absolute;
  z-index: 10;
  white-space: nowrap;
  transition: opacity 120ms ease;
}
