/* Stemma — one stylesheet for the whole site.
   Mobile-first. Light and dark via prefers-color-scheme. No framework. */

:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #1c1b18;
  --ink-soft: #55524c;
  --line: #e2ded4;
  --accent: #2f6d4a;
  --accent-ink: #ffffff;
  --warn-bg: #fdf3e0;
  --warn-line: #e6cf9d;
  --dispute: #a8481a;
  --kind-landrace: #9a6a1f;
  --kind-cultivar: #2f6d4a;
  --kind-cut: #3d6aa3;
  --kind-unknown: #6f6c64;
  --radius: 10px;
  --measure: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --panel: #1d1f18;
    --ink: #eceadf;
    --ink-soft: #a8a79b;
    --line: #333628;
    --accent: #8fd3a5;
    --accent-ink: #11150f;
    --warn-bg: #2a2416;
    --warn-line: #574a2a;
    --dispute: #e8a273;
    --kind-landrace: #d9ae63;
    --kind-cultivar: #8fd3a5;
    --kind-cut: #8ab4e8;
    --kind-unknown: #9b978c;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 1.75rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.35rem; }

p { margin: 0 0 0.75rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--panel);
  padding: 0.5rem 0.75rem;
  z-index: 20;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.masthead__brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
.masthead__nav { display: flex; gap: 1rem; font-size: 0.9rem; }

.main {
  padding: 1.25rem 1rem 2rem;
  max-width: var(--measure);
  margin: 0 auto;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 1rem;
  max-width: var(--measure);
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.footer p { margin: 0 0 0.35rem; }

.lede { color: var(--ink-soft); font-size: 1.05rem; }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button--quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 400;
}

/* -- search ---------------------------------------------------------- */

.search { margin-top: 1.5rem; }
.search__label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.3rem; }
.search__input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search__status { margin: 0.6rem 0 0; color: var(--ink-soft); font-size: 0.9rem; }

.results, .card-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.results li, .card-list li { border-bottom: 1px solid var(--line); }
.results a, .card-list a {
  display: block;
  padding: 0.7rem 0.25rem;
  text-decoration: none;
  color: var(--ink);
}
.results a:hover, .card-list a:hover { background: var(--panel); }
.result__name, .card-list strong { display: block; font-weight: 600; }
.result__meta {
  display: block;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.browse { margin-top: 2rem; }
.empty { color: var(--ink-soft); }

/* -- strain page ----------------------------------------------------- */

.strain__header { margin-bottom: 1rem; }
.aliases { color: var(--ink-soft); font-size: 0.95rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0.6rem 0 0; padding: 0; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}
.chip__hint { font-size: 0.75rem; }

.badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--panel);
  color: var(--ink-soft);
}
.badge--genetically-tested { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.badge--documented { font-weight: 600; }

.facts { margin: 1.25rem 0 0; }
.facts div { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.facts dt { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.facts dd { margin: 0.15rem 0 0; }

.evidence { list-style: none; margin: 0.35rem 0 0; padding: 0; font-size: 0.85rem; color: var(--ink-soft); }
.evidence li { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; margin-top: 0.2rem; }

.relations { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.relations li { margin-bottom: 0.7rem; }
.relations .badge { margin-left: 0.25rem; }

/* -- lineage graph ---------------------------------------------------- */
/* Rendered at build time as plain SVG. The "show disputed" control is a
   checkbox this stylesheet reads, so no script patches styles at runtime. */

.lineage-graph { margin-top: 1.25rem; }

.lineage-graph__bar { margin: 0 0 0.5rem; }
.lineage-graph__switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.9rem 0 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.lineage-graph__switch::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 1px solid var(--ink-soft);
  border-radius: 3px;
  background: transparent;
}
.lineage-graph__toggle:checked ~ .lineage-graph__bar .lineage-graph__switch {
  border-color: var(--dispute);
}
.lineage-graph__toggle:checked ~ .lineage-graph__bar .lineage-graph__switch::before {
  background: var(--dispute);
  border-color: var(--dispute);
}
.lineage-graph__toggle:focus-visible ~ .lineage-graph__bar .lineage-graph__switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The diagram scrolls inside this box; the page itself never scrolls sideways. */
.lineage-graph__scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lineage-graph__scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lineage-svg { display: block; max-width: none; }

.lineage-graph__note { margin: 0.5rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.lineage-edge {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.6;
}
.lineage-edge--genetically-tested,
.lineage-edge--documented { stroke-dasharray: none; }
.lineage-edge--breeder-claimed { stroke-dasharray: 7 4; }
.lineage-edge--folklore { stroke-dasharray: 1.5 4; stroke-linecap: round; }
.lineage-edge--disputed { stroke: var(--dispute); }

/* Disputed edges, and anything only reachable through one, stay off until the
   toggle is on. They are laid out either way, so nothing else moves. */
.lineage-layer--disputed { display: none; }
.lineage-graph__toggle:checked ~ .lineage-graph__scroll .lineage-layer--disputed {
  display: inline;
}

.lineage-node__box { fill: var(--bg); stroke: var(--line); stroke-width: 1; }
.lineage-node__name { font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; fill: var(--ink); }
.lineage-node__meta { font: 11px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; fill: var(--ink-soft); }

a.lineage-node { cursor: pointer; text-decoration: none; }
a.lineage-node:hover .lineage-node__box,
a.lineage-node:focus .lineage-node__box { stroke: var(--accent); stroke-width: 2.5; }

.lineage-node--current .lineage-node__box { fill: var(--accent); stroke: var(--accent); }
.lineage-node--current .lineage-node__name { fill: var(--accent-ink); }
.lineage-node--current .lineage-node__meta { fill: var(--accent-ink); opacity: 0.85; }

.lineage-node--stub .lineage-node__box { fill: transparent; stroke-dasharray: 4 3; }
.lineage-node--stub .lineage-node__name,
.lineage-node--stub .lineage-node__meta { fill: var(--ink-soft); }

.lineage-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.lineage-key__item { display: inline-flex; align-items: center; gap: 0.4rem; }
.lineage-key__line {
  width: 26px;
  border-top: 2px solid var(--ink-soft);
}
.lineage-key__line--dashed { border-top-style: dashed; }
.lineage-key__line--dotted { border-top-style: dotted; }
.lineage-key__line--disputed { border-top-color: var(--dispute); }

.lineage__elsewhere { margin: 0.9rem 0 0; font-size: 0.9rem; }

/* -- timeline --------------------------------------------------------- */
/* Bars are laid out at build time, as plain SVG. The family filter only ever
   adds .is-filtered to a row, so the axis never moves and no script writes
   styles at runtime. */

.timeline__filter { margin: 1.5rem 0 0; }
.timeline__active { margin: 0.6rem 0 0; font-size: 0.9rem; }
.timeline__active[hidden] { display: none; }
.timeline__chart { margin-top: 1rem; }
.timeline__note { margin: 0.7rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

/* The axis scrolls inside this box; the page itself never scrolls sideways. */
.timeline__scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.timeline__scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.timeline-svg { display: block; max-width: none; }

.timeline-band { fill: var(--ink); opacity: 0.045; }
.timeline-grid { stroke: var(--line); stroke-width: 1; }
.timeline-rule { stroke: var(--line); stroke-width: 1; }
.timeline-axis__label,
.timeline-caption {
  font: 600 11px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  fill: var(--ink-soft);
  letter-spacing: 0.06em;
}
.timeline-row__name { font: 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; fill: var(--ink); }
.timeline-row__name--inside { font-weight: 600; }

.timeline-bar { stroke-width: 1; }
.timeline-bar--landrace { fill: var(--kind-landrace); stroke: var(--kind-landrace); }
.timeline-bar--cultivar { fill: var(--kind-cultivar); stroke: var(--kind-cultivar); }
.timeline-bar--cut { fill: var(--kind-cut); stroke: var(--kind-cut); }
.timeline-bar--unknown { fill: var(--kind-unknown); stroke: var(--kind-unknown); }

/* In the strip the name sits inside its box, so the fill stays a tint. */
.timeline-row--root .timeline-bar { fill-opacity: 0.22; }

a.timeline-row { cursor: pointer; text-decoration: none; }
a.timeline-row:hover .timeline-bar,
a.timeline-row:focus .timeline-bar { stroke-width: 2.5; }
a.timeline-row:hover .timeline-row__name,
a.timeline-row:focus .timeline-row__name { text-decoration: underline; }

/* The family filter: out of the family, out of the diagram. */
.timeline-row.is-filtered { display: none; }

.timeline-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.timeline-key__item { display: inline-flex; align-items: center; gap: 0.4rem; }
.timeline-key__swatch {
  width: 22px;
  height: 12px;
  border-radius: 3px;
  background: var(--kind-unknown);
}
.timeline-key__swatch--landrace { background: var(--kind-landrace); }
.timeline-key__swatch--cultivar { background: var(--kind-cultivar); }
.timeline-key__swatch--cut { background: var(--kind-cut); }

/* -- origin map -------------------------------------------------------- */
/* Leaflet draws into .map; everything it draws is classed, so the colours
   live here and no script patches a style. The lists under the map are the
   same markers in text, and filter with them. */

.map__filter { margin: 1.5rem 0 0; }
.map__active { margin: 0.6rem 0 0; font-size: 0.9rem; }
.map__active[hidden] { display: none; }
.map__note { margin: 0.7rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }

.map {
  height: 22rem;
  margin-top: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 0; /* keep the tiles under the 21+ notice */
}
.map--unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  height: auto;
  min-height: 8rem;
  color: var(--ink-soft);
  text-align: center;
}

/* A marker is one centroid, sized by how many strains share it. */
.map-marker {
  fill: var(--accent);
  fill-opacity: 0.85;
  stroke: var(--panel);
}
.map-marker:hover, .map-marker:focus { fill-opacity: 1; stroke: var(--ink); }

.map-arc { fill: none; stroke: var(--ink); stroke-opacity: 0.75; }
.map-arc--genetically-tested, .map-arc--documented { stroke-opacity: 0.85; }

.map-popup__place { margin: 0 0 0.25rem; font-weight: 600; }
.map-popup__list { list-style: none; margin: 0; padding: 0; }
.map-popup__list li { border-bottom: 0; }
.map-popup__list a { display: block; padding: 0.25rem 0; text-decoration: none; }

.map-places { list-style: none; margin: 1rem 0 0; padding: 0; }
.map-place { border-top: 1px solid var(--line); padding: 0.5rem 0; }
.map-place__name { margin: 0; font-size: 0.95rem; }
.map-place__strains { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.map-place__strain { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.map-place__strain .result__meta { display: inline; }

.map-unknown {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 1.5rem 0 0;
}
.map-unknown h2 { margin-top: 0; }

/* The family filter: out of the family, out of the list. */
.map-place.is-filtered,
.map-place__strain.is-filtered,
.map-unknown.is-filtered,
.map-unknown .card-list li.is-filtered { display: none; }

.note, .stub-notice, .disputes {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}
.stub-notice, .disputes { background: var(--warn-bg); border-color: var(--warn-line); }
.disputes h2 { margin-top: 0; }
.dispute + .dispute { border-top: 1px solid var(--warn-line); margin-top: 0.85rem; padding-top: 0.85rem; }

.sources { padding-left: 1.1rem; font-size: 0.9rem; }
.sources li { margin-bottom: 0.45rem; }
.sources .publisher { color: var(--ink-soft); }

.strain__footer { margin-top: 1.75rem; border-top: 1px solid var(--line); padding-top: 0.85rem; font-size: 0.9rem; color: var(--ink-soft); }

.prose { max-width: var(--measure); }
.tiers dt { margin-top: 0.9rem; }
.tiers dd { margin: 0.25rem 0 0; }

/* -- 21+ notice ------------------------------------------------------ */

.age-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 12, 8, 0.86);
}
.age-gate[hidden] { display: none; }
.age-gate__panel {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 24rem;
  width: 100%;
}
.age-gate__title { margin: 0 0 0.5rem; font-size: 1.25rem; }
.age-gate__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0; }
.age-gate__declined { margin: 0.85rem 0 0; color: var(--ink-soft); }
body.age-gate-open { overflow: hidden; }

@media (min-width: 40rem) {
  h1 { font-size: 2.1rem; }
  .main { padding: 2rem 1.5rem 3rem; }
}
