/* Vinistory Encyclopedia — parchment / classic ampelographic plate aesthetic.
   The site deliberately commits to a single light look (color-scheme: light):
   engraved botanical plates live on paper. Chart chrome and the categorical
   palette are validated against the card surface #faf6ec (see CLAUDE.md). */

:root {
  --paper: #f6efe0;        /* page plane */
  --card: #faf6ec;         /* chart & card surface */
  --ink: #2b2318;          /* primary text */
  --ink-2: #6b5d4a;        /* secondary text */
  --muted: #8d8069;        /* axis / labels */
  --hair: #e0d7c0;         /* hairlines, gridlines */
  --hair-2: #cdc0a2;       /* stronger rules */
  --accent: #8e2c42;       /* garnet — links, marks */
  --track: #efe8d4;        /* unfilled meter track */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; line-height: 1.2; }
.skip {
  position: absolute; left: -999px; top: 0; background: var(--ink);
  color: var(--paper); padding: 0.5rem 1rem; z-index: 10;
}
.skip:focus { left: 0; }

/* ---------------------------------------------------------------- header */
.site-header {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  max-width: 1080px; margin: 0 auto; padding: 0.9rem 1.25rem;
  border-bottom: 3px double var(--hair-2);
}
.brand { display: flex; align-items: baseline; gap: 0.45rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
/* brand is split: "Vinistory" → parent site home, section name → encyclopedia home */
.brand-home { display: flex; align-items: baseline; gap: 0.45rem; color: var(--ink); }
.brand-enc { color: var(--ink-2); }
.brand-home:hover, .brand-enc:hover { text-decoration: none; }
.brand-home:hover .brand-name, .brand-enc:hover .brand-sub { text-decoration: underline; text-underline-offset: 3px; }
.brand-mark { width: 20px; height: 20px; align-self: center; }
.brand-mark circle:nth-child(1) { fill: #8e2c42; }
.brand-mark circle:nth-child(2) { fill: #6b3ab0; }
.brand-mark circle:nth-child(3) { fill: #d7a92e; }
.brand-name { font-size: 1.15rem; letter-spacing: 0.02em; font-weight: 600; }
.brand-sep { color: var(--muted); }
.brand-sub {
  font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--ink-2);
}
.lang-switch {
  margin-left: auto; font-family: var(--sans); font-size: 0.8rem;
  color: var(--ink-2); border: 1px solid var(--hair-2); border-radius: 999px;
  padding: 0.25rem 0.8rem;
}
.lang-switch:hover { background: var(--card); text-decoration: none; }

/* search */
.global-search { position: relative; flex: 1 1 240px; max-width: 460px; }
.global-search input {
  width: 100%; font-family: var(--serif); font-size: 0.95rem;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--hair-2); border-radius: 999px;
  padding: 0.5rem 1.1rem; outline-offset: 2px;
}
.global-search input::placeholder { color: var(--muted); font-style: italic; }
.search-suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: var(--card); border: 1px solid var(--hair-2); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(43, 35, 24, 0.14); overflow: hidden;
}
.search-suggest a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.9rem; color: var(--ink); font-size: 0.95rem;
}
.search-suggest a:hover, .search-suggest a.is-active {
  background: var(--paper); text-decoration: none;
}
.suggest-swatch {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px rgba(43, 35, 24, 0.15);
}
.suggest-type {
  margin-left: auto; font-family: var(--sans); font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.crumbs {
  font-family: var(--sans); font-size: 0.78rem; color: var(--muted);
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.6rem;
}
.crumbs a { color: var(--ink-2); }

/* ---------------------------------------------------------------- hero */
.hero { text-align: center; padding: 2.6rem 0 1.4rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.4rem; }
.tagline { color: var(--ink-2); font-style: italic; margin: 0 0 1.6rem; }
.hero-search { margin: 0 auto; max-width: 560px; }
.hero-search input { font-size: 1.05rem; padding: 0.75rem 1.4rem; }

/* tabs */
.tabs {
  display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center;
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
  padding: 0.55rem 0; margin: 1.4rem 0 1.8rem; position: sticky; top: 0;
  background: var(--paper); z-index: 5;
}
.tab {
  font-family: var(--sans); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--ink-2); background: none;
  border: 1px solid transparent; border-radius: 999px;
  padding: 0.42rem 1.05rem; cursor: pointer;
}
.tab:hover { border-color: var(--hair-2); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tab .count {
  font-size: 0.7rem; opacity: 0.75; margin-left: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* cards */
.card-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.1rem;
}
.card a {
  display: block; position: relative; height: 100%;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--hair); border-radius: 12px; overflow: hidden;
  padding-bottom: 0.9rem; text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card a:hover {
  text-decoration: none; transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(43, 35, 24, 0.12);
}
.card h3 { font-size: 1.02rem; margin: 0.65rem 0.8rem 0.15rem; }
.card p {
  margin: 0 0.8rem; font-family: var(--sans); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}
.card-plate { padding: 0.9rem 0 0; background: var(--card); }
.card-plate svg { height: 128px; width: auto; }
.card-swatch { height: 92px; border-bottom: 1px solid var(--hair); }
.card-bottle {
  padding: 0.9rem 0 0; background: var(--card);
  display: grid; place-items: center;
}
.card-bottle svg { height: 120px; width: auto; }
.empty { text-align: center; color: var(--muted); font-style: italic; padding: 2.5rem 0; }

/* ---------------------------------------------------------------- heritage badges
   A small status tag. The first three variants are factual (a real but vanishing
   wine or grape); `legendary` is the hedged tier — dashed, ghosted — for entities
   known only from ancient texts. */
.badge {
  display: inline-block; font-family: var(--sans);
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; padding: 0.12em 0.5em; border-radius: 3px;
  border: 1px solid currentColor; line-height: 1.55; white-space: nowrap;
}
.kicker .badge { vertical-align: 0.12em; margin-left: 0.35rem; }
.badge-near-extinct { color: #9a5a1e; background: #f6ecd6; }
.badge-rediscovered { color: #3f6a3a; background: #e9f0dd; }
.badge-historical   { color: #7a4a24; background: #f2e7d4; }
.badge-legendary    { color: #6f6250; background: transparent; border-style: dashed; }
.card-badge {
  position: absolute; top: 0.55rem; right: 0.55rem; z-index: 2;
  box-shadow: 0 1px 3px rgba(43, 35, 24, 0.12);
}

/* ---------------------------------------------------------------- producers */
.producer-list {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem;
  padding: 0; margin: 0.4rem 0 0;
}
.producer {
  font-size: 0.9rem; color: var(--ink-2); background: var(--card);
  border: 1px solid var(--hair-2); border-radius: 6px; padding: 0.3rem 0.75rem;
}
.producer-link { border-color: var(--accent); }
.producer-link a { color: var(--accent); font-weight: 600; }
.producer-link a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- entity head */
.entity-head {
  display: flex; gap: 2rem; align-items: flex-start; flex-wrap: wrap;
  padding-bottom: 1.4rem; border-bottom: 3px double var(--hair-2);
  margin-bottom: 1.6rem;
}
.head-text { flex: 1 1 380px; }
.kicker {
  font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.2em; color: var(--accent); margin: 0 0 0.3rem;
}
.entity-head h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); margin: 0 0 0.7rem; }
.head-line { color: var(--ink-2); font-size: 0.95rem; margin: 0.25rem 0; }
.head-line strong {
  font-family: var(--sans); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted); font-weight: 600;
}
.aroma-chips {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0; margin: 0.9rem 0 0;
}
.aroma-chips li {
  font-size: 0.82rem; font-style: italic; color: var(--ink-2);
  border: 1px solid var(--hair-2); border-radius: 999px; padding: 0.14rem 0.7rem;
}

/* the plate */
.head-plate { margin: 0; flex: 0 0 auto; }
.head-plate svg { height: 230px; width: auto; display: block; }
.head-plate, .card-plate, .head-bottle, .card-bottle {
  filter: drop-shadow(0 2px 3px rgba(43, 35, 24, 0.18));
}

/* wine bottle */
.head-bottle { margin: 0; flex: 0 0 auto; }
.head-bottle svg { height: 250px; width: auto; display: block; }
.head-tone { margin: 0; flex: 0 0 200px; }
.tone-band {
  display: block; height: 120px; border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(43,35,24,0.15), 0 6px 16px rgba(43,35,24,0.16);
}

/* facts */
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem 1.4rem; margin: 0 0 1.8rem; padding: 1.1rem 1.2rem;
  background: var(--card); border: 1px solid var(--hair); border-radius: 12px;
}
.facts dt {
  font-family: var(--sans); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--muted); margin-bottom: 0.15rem;
}
.facts dd { margin: 0; font-size: 0.94rem; }

/* prose */
.prose { max-width: 68ch; margin: 0 auto 2.4rem; }
.prose p { margin: 0 0 1.1rem; }
.prose p:first-child::first-letter {
  font-size: 3.1em; float: left; line-height: 0.82;
  padding: 0.08em 0.12em 0 0; color: var(--accent);
}

/* ---------------------------------------------------------------- viz */
.viz-section { margin: 0 0 2.2rem; }
.viz-section h2 {
  font-size: 1.25rem; margin: 0 0 0.2rem;
  padding-top: 1.1rem; border-top: 1px solid var(--hair);
}
.viz-sub {
  font-family: var(--sans); font-size: 0.78rem; color: var(--muted);
  margin: 0 0 1rem;
}
.viz-card, .viz-rows, .viz-era {
  background: var(--card); border: 1px solid var(--hair); border-radius: 12px;
}
.viz-card { padding: 1rem; }
.viz-rows { padding: 0.9rem 1rem; display: grid; gap: 0.55rem; }

/* stacked bar — marks 18px, 2px surface gaps, 4px rounded data-end */
.viz-stack { display: flex; gap: 2px; height: 18px; }
.viz-seg {
  min-width: 3px; position: relative; display: flex; align-items: center;
  justify-content: center; overflow: visible;
}
.viz-seg:last-child { border-radius: 0 4px 4px 0; }
.viz-seg:hover { filter: brightness(1.08); }
.viz-seg-label {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums; pointer-events: none;
}

/* meter / blend rows */
.viz-row {
  display: grid; grid-template-columns: 140px 1fr 52px;
  align-items: center; gap: 0.8rem;
}
.viz-row-label {
  font-family: var(--sans); font-size: 0.82rem; color: var(--ink);
  text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viz-row-label a { color: var(--ink); }
.viz-row-label a:hover { color: var(--accent); }
.viz-track { background: var(--track); border-radius: 4px; height: 18px; }
.viz-track-stack { background: none; }
.viz-fill { height: 100%; border-radius: 0 4px 4px 0; }
.viz-row:hover .viz-fill { filter: brightness(1.08); }
.viz-row-val {
  font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--ink-2);
}

/* legend */
.viz-legend {
  list-style: none; margin: 0.9rem 0 0; padding: 0.8rem 0 0;
  border-top: 1px solid var(--hair);
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.5rem;
}
.viz-legend li { display: flex; align-items: center; gap: 0.5rem; font-family: var(--sans); font-size: 0.82rem; }
.viz-swatch {
  width: 11px; height: 11px; border-radius: 3px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(43, 35, 24, 0.12);
}
.viz-legend-name a { color: var(--ink); }
.viz-legend-val { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* era line chart (SVG) */
.viz-era { width: 100%; height: auto; display: block; padding: 0.6rem; }
.viz-grid { stroke: var(--hair); stroke-width: 1; }
.viz-tick { font-family: var(--sans); font-size: 10px; fill: var(--muted); }
.viz-val { font-family: var(--sans); font-size: 11px; font-weight: 600; fill: var(--ink); }

/* ---------------------------------------------------------------- chips */
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.6rem 0; }
.chip-label {
  font-family: var(--sans); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted); margin-right: 0.3rem; flex: none;
}
.chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--card); border: 1px solid var(--hair); border-radius: 999px;
  padding: 0.3rem 0.85rem; color: var(--ink); font-size: 0.9rem;
}
.chip:hover { border-color: var(--hair-2); text-decoration: none; transform: translateY(-1px); }
.chip-swatch {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px rgba(43, 35, 24, 0.18);
}
.chip-sub {
  font-family: var(--sans); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted);
}
.related h2 { font-size: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--hair); }

/* ---------------------------------------------------------------- era page */
.timeline { display: flex; gap: 3px; margin: 0 0 1.8rem; }
.timeline-seg {
  flex: 1; min-width: 0; padding: 0.5rem 0.6rem 0.45rem;
  border-top: 5px solid var(--tint); background: var(--card);
  border-radius: 0 0 8px 8px; color: var(--ink);
}
.timeline-seg:hover { text-decoration: none; background: var(--paper); }
.timeline-seg.is-current { background: var(--ink); color: var(--paper); }
.timeline-year {
  display: block; font-family: var(--sans); font-size: 0.7rem;
  font-variant-numeric: tabular-nums; color: var(--muted);
}
.timeline-seg.is-current .timeline-year { color: var(--hair); }
.timeline-name {
  display: block; font-size: 0.8rem; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.events { list-style: none; margin: 0; padding: 0; max-width: 60ch; }
.events li {
  display: flex; gap: 1.1rem; padding: 0.55rem 0;
  border-bottom: 1px solid var(--hair);
}
.event-year {
  flex: 0 0 4.2rem; font-family: var(--sans); font-weight: 600;
  font-size: 0.85rem; color: var(--accent); font-variant-numeric: tabular-nums;
}
.event-text { font-size: 0.97rem; }
.era-pager { display: flex; justify-content: space-between; margin-top: 2.2rem; gap: 1rem; }
.pager-next { margin-left: auto; }

/* ---------------------------------------------------------------- footer */
.site-footer {
  border-top: 3px double var(--hair-2); margin-top: 2rem;
  padding: 1.4rem 1.25rem 2.2rem; text-align: center;
}
.footer-axes { display: flex; justify-content: center; gap: 1.4rem; flex-wrap: wrap; }
.footer-axes a {
  font-family: var(--sans); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--ink-2);
}
.footer-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.9rem; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 640px) {
  .viz-row { grid-template-columns: 96px 1fr 44px; gap: 0.5rem; }
  .viz-row-label { font-size: 0.74rem; }
  .entity-head { gap: 1.2rem; }
  .head-plate svg { height: 170px; }
  .head-bottle svg { height: 200px; }
  .timeline { flex-wrap: wrap; }
  .timeline-seg { flex: 1 1 30%; }
  .site-header { gap: 0.7rem; }
  .brand-sub { display: none; }
}

/* ---------------------------------------------------------------- maps
   Region dots on Natural Earth coastlines (data/geo.json). Position carries
   the data, so the dots are one nominal sepia hue; the accent is reserved for
   the region a page is about. Labels ride hidden until hover/focus, except on
   the sparse world map (.viz-map-labelled), which pins them on. */
.map-deck { display: grid; gap: 1rem; margin: 0 0 1.6rem; }
.map-card { margin: 0; padding: 0.9rem 1rem 0.7rem; }
.map-title {
  font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted); margin: 0 0 0.5rem;
}
.map-note {
  font-family: var(--sans); font-size: 0.68rem; color: var(--muted);
  margin: 0.4rem 0 0;
}
.viz-map { width: 100%; height: auto; display: block; }
.viz-map-land path {
  fill: #e7ddc6; stroke: #c4b593; stroke-width: 0.6; stroke-linejoin: round;
}
.viz-map-inset {
  fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 4;
  opacity: 0.5;
}
/* the area blob — each region filled with its own tone (translucent so
   overlaps read as dense wine country); size ≈ vineyard hectares, and the
   core dot marks the exact spot. */
.viz-map-area {
  fill-opacity: 0.5; stroke: #5c4a30; stroke-width: 1.3;
  transition: fill-opacity 0.12s ease, stroke 0.12s ease;
}
.viz-map-area-focus {
  fill: var(--accent); fill-opacity: 0.4; stroke: var(--accent);
  stroke-width: 2.4;
}
.viz-map-core {
  fill: #4a3a28; stroke: var(--card); stroke-width: 1;
  transition: fill 0.12s ease;
}
.viz-map-core-focus { fill: var(--accent); }
.viz-map-label {
  font-family: var(--sans); font-size: 11px; fill: var(--ink);
  paint-order: stroke; stroke: var(--card); stroke-width: 3.5;
  stroke-linejoin: round; opacity: 0; pointer-events: none;
  transition: opacity 0.12s ease;
}
/* labels live in a top layer above every blob (never occluded); always shown
   on the pinned world map, and on hover elsewhere (JS adds .is-hover to the
   label whose pin is hovered, matched by data-id) */
.viz-map-labelled .viz-map-label { opacity: 1; }
.viz-map-label.is-hover { opacity: 1; }
.viz-map-label.is-dim { opacity: 0; }
.viz-map-pin { cursor: pointer; }
.viz-map-pin:hover .viz-map-area,
.viz-map-pin:focus-visible .viz-map-area {
  fill-opacity: 0.72; stroke: var(--accent); stroke-width: 2;
}
.viz-map-pin:hover .viz-map-core,
.viz-map-pin:focus-visible .viz-map-core { fill: var(--accent); }
/* search on the hub dims the pins in step with the cards */
.viz-map-pin.is-dim { opacity: 0.22; }

@media (min-width: 900px) {
  .map-deck { grid-template-columns: 1fr; }
}
/* no un-colliding slot was free — this one waits for hover (JS .is-hover) */
.viz-map-labelled .viz-map-label-crowded { opacity: 0; }
.viz-map-label-crowded.is-hover { opacity: 1; }

/* ---------------------------------------------------------------- pedigree
   Radial family tree (data/pedigree.yaml). Ring = generations of separation,
   so distance from the centre is the encoding; the marks stay one nominal
   sepia, the accent means "this page", grey means "forebear without an
   article". Dashed link = mutation, not a cross. */
.fam-card { margin: 0; padding: 0.6rem 0.9rem 0.7rem; }
.viz-fam { width: 100%; height: auto; display: block; }
.viz-fam-ring { fill: none; stroke: var(--hair); stroke-width: 1; }
.viz-fam-link { stroke: #bcab8d; stroke-width: 1.6; }
.viz-fam-link-extra { stroke-width: 1; opacity: 0.3; }
.viz-fam-node { fill: #7a5c3e; stroke: var(--card); stroke-width: 1.5; }
.viz-fam-node-focus { fill: var(--accent); stroke-width: 2.5; }
.viz-fam-node-ancestor { fill: #8a8578; }
.viz-fam-name {
  font-family: var(--sans); font-size: 11.5px; fill: var(--ink);
  paint-order: stroke; stroke: var(--card); stroke-width: 3.5;
  stroke-linejoin: round;
}
.viz-fam-name-focus { font-size: 13px; font-weight: 600; fill: var(--accent); }
.viz-fam-name-ancestor { fill: var(--ink-2); font-style: italic; }
.viz-fam-pin { cursor: pointer; }
.viz-fam-pin:hover .viz-fam-node,
.viz-fam-pin:focus-visible .viz-fam-node { fill: var(--accent); }
.viz-fam-pin:hover .viz-fam-name,
.viz-fam-pin:focus-visible .viz-fam-name { fill: var(--accent); }

/* ---------------------------------------------------------------- global tree
   The home-page family tree of every documented cépage cross/mutation
   (data/pedigree.yaml, sourced in data/relations.yaml). A layered top→bottom
   DAG; pills are tinted by berry-colour CLASS (decorative identity, not the
   reserved chart slots). Solid tie = a documented cross, dashed = a mutation.
   Families are packed into a roughly square canvas that fits the card; JS layers
   viewBox zoom/pan on top (no scroller). */
.tree-section { margin: 2.6rem 0 0.5rem; }
.tree-section h2 {
  font-size: 1.35rem; margin: 0 0 0.3rem;
  padding-top: 1.4rem; border-top: 3px double var(--hair-2);
}
.tree-intro { color: var(--ink-2); max-width: 70ch; margin: 0 0 1rem; }
.tree-legend {
  list-style: none; margin: 0 0 0.6rem; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem;
  font-family: var(--sans); font-size: 0.78rem; color: var(--ink-2);
}
.tree-legend li { display: flex; align-items: center; gap: 0.45rem; }
.tree-key-swatch {
  width: 14px; height: 14px; border-radius: 5px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(43, 35, 24, 0.16);
}
.tree-key-ext {
  background: #f1ead9;
  box-shadow: inset 0 0 0 1.3px #b3a688;
}
.tree-key-line { width: 26px; height: 8px; flex: none; }
.tree-key-line line { stroke: #a6906b; stroke-width: 2; }
.tree-scroll {
  font-family: var(--sans); font-size: 0.72rem; color: var(--muted);
  margin: 0 0 0.6rem;
}
.tree-card { margin: 0; padding: 0.6rem 0.4rem; }
/* The whole tree fits the card (no scroller); zoom/pan is JS progressive
   enhancement that rewrites the SVG viewBox. */
.tree-viewport { position: relative; }
.viz-tree { display: block; width: 100%; height: auto; }
.tree-viewport.tree-ready .viz-tree { touch-action: pan-y; cursor: grab; }
.tree-viewport.tree-ready.is-panning .viz-tree { cursor: grabbing; }
/* zoom controls: hidden until JS wires them up */
.tree-zoom { display: none; }
.tree-viewport.tree-ready .tree-zoom {
  display: flex; flex-direction: column; gap: 4px;
  position: absolute; top: 8px; right: 8px; z-index: 2;
}
.tree-zoom-btn {
  width: 30px; height: 30px; padding: 0; cursor: pointer;
  font: 500 17px/1 var(--sans); color: var(--ink-1);
  background: rgba(250, 246, 236, 0.92);
  border: 1px solid var(--hair-2); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(43, 35, 24, 0.14);
}
.tree-zoom-btn:hover { border-color: var(--accent); color: var(--accent); }
.tree-zoom-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.viz-tree-family {
  fill: rgba(120, 94, 60, 0.05); stroke: rgba(120, 94, 60, 0.15); stroke-width: 1;
}
.viz-tree-tie { stroke: #bcab8d; stroke-width: 1.4; }
.viz-tree-tie-mut { stroke-dasharray: 4 3; }
.viz-tree-join { fill: #7a5c3e; }
.viz-tree-pill { stroke: rgba(43, 35, 24, 0.16); stroke-width: 1; }
.viz-tree-pill-ext {
  fill: #f1ead9; stroke: #b3a688; stroke-width: 1.2; stroke-dasharray: 3 2.5;
}
.viz-tree-name {
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
}
.viz-tree-name-ext { fill: var(--ink-2); font-style: italic; font-weight: 400; }
.viz-tree-node { cursor: pointer; }
a.viz-tree-node:hover { text-decoration: none; }
a.viz-tree-node:hover .viz-tree-pill,
a.viz-tree-node:focus-visible .viz-tree-pill { stroke: var(--accent); stroke-width: 2; }
.tree-credit {
  font-family: var(--sans); font-size: 0.72rem; color: var(--muted);
  margin: 0.7rem 0.4rem 0.2rem; line-height: 1.5;
}
.tree-open { margin-left: 0.9rem; white-space: nowrap; }
