/* Layout concept: one full-bleed herbarium sheet; the tree grows left (deep past) to right (today);
   chrome sits in the margins like a manuscript's rubrics and marginalia. */
:root {
  --paper: #efe6cf;
  --paper-deep: #dccdaa;
  --ink: #2a2014;
  --ink-soft: #776345;
  --rubric: #b0331d;
  --gold: #9c7419;
  --rose: #b14d68;
  --tea: #4b7a35;
  --indigo: #3c4c86;
  --revived: #6c9c35;
  --fox: #b58650;
  --is-dark: 0;

  --wash-sahul: #6aa1bd;
  --wash-americas: #c97b8c;
  --wash-neurasia: #7d8ec0;
  --wash-easia: #66a886;
  --wash-sasia: #e0ab45;
  --wash-weurasia: #9db35c;
  --wash-africa: #d6955a;

  --zone-1: #d0703a;
  --zone-2: #4a7fbb;
  --zone-3: #c9a01f;
  --zone-4: #3f9a6a;
  --zone-5: #8a5ca8;
  --zone-6: #c2486a;
  --zone-7: #8a6538;
  --zone-8: #2f98a0;

  --surface: rgba(240, 231, 208, 0.94);
  --line: rgba(42, 32, 20, 0.22);
  --shadow: 0 10px 30px rgba(54, 38, 14, 0.18), 0 2px 6px rgba(54, 38, 14, 0.12);
  --halo: 0 0 2px var(--paper), 0 0 4px var(--paper), 0 0 7px var(--paper);

  --f-display: 'IM Fell English SC', 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --f-fell: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --f-body: 'Alegreya', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --f-caps: 'Alegreya SC', 'Alegreya', Georgia, serif;

  --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #25211b;
    --paper-deep: #181510;
    --ink: #e8dbbf;
    --ink-soft: #a69270;
    --rubric: #e5694c;
    --gold: #e2b85a;
    --rose: #e27b96;
    --tea: #93c06e;
    --indigo: #94a3e6;
    --revived: #a3d266;
    --fox: #3b2e1f;
    --is-dark: 1;
    --wash-sahul: #4f9cc2;
    --wash-americas: #c26580;
    --wash-neurasia: #6a7cc4;
    --wash-easia: #4ea67d;
    --wash-sasia: #d6a334;
    --wash-weurasia: #8daa47;
    --wash-africa: #cf8040;
    --zone-1: #e08a52;
    --zone-2: #6c9be0;
    --zone-3: #ddb93a;
    --zone-4: #5cbc88;
    --zone-5: #ad84cc;
    --zone-6: #e0708c;
    --zone-7: #b58c5c;
    --zone-8: #4cc0c8;
    --surface: rgba(32, 28, 22, 0.95);
    --line: rgba(232, 219, 191, 0.2);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #25211b;
  --paper-deep: #181510;
  --ink: #e8dbbf;
  --ink-soft: #a69270;
  --rubric: #e5694c;
  --gold: #e2b85a;
  --rose: #e27b96;
  --tea: #93c06e;
  --indigo: #94a3e6;
  --revived: #a3d266;
  --fox: #3b2e1f;
  --is-dark: 1;
  --wash-sahul: #4f9cc2;
  --wash-americas: #c26580;
  --wash-neurasia: #6a7cc4;
  --wash-easia: #4ea67d;
  --wash-sasia: #d6a334;
  --wash-weurasia: #8daa47;
  --wash-africa: #cf8040;
  --zone-1: #e08a52;
  --zone-2: #6c9be0;
  --zone-3: #ddb93a;
  --zone-4: #5cbc88;
  --zone-5: #ad84cc;
  --zone-6: #e0708c;
  --zone-7: #b58c5c;
  --zone-8: #4cc0c8;
  --surface: rgba(32, 28, 22, 0.95);
  --line: rgba(232, 219, 191, 0.2);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; border-radius: 3px; }
/* translatable text waits for its locale: index.html sets i18n-wait, js/i18n.js lifts it */
html.i18n-wait [data-i18n] { visibility: hidden; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sr-only:focus-within { position: fixed !important; width: auto; height: auto; clip: auto; inset: 80px auto auto 16px; max-height: 70vh; overflow: auto; background: var(--surface); padding: 16px 20px; z-index: 50; box-shadow: var(--shadow); border-radius: 6px; white-space: normal; }
#outline ul { list-style: none; padding-left: 1em; margin: 0; }
#outline button { background: none; border: 0; padding: 2px 0; text-align: left; }

/* ---------------------------------------------------------------- stage */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
#stage.dragging { cursor: grabbing; }
#stage canvas { display: block; position: absolute; inset: 0; z-index: 1; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }

.lbl {
  position: absolute;
  left: 0; top: 0;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: 0 0;
  will-change: transform;
  text-shadow: var(--halo);
  line-height: 1.15;
}
.lbl-fam {
  font-family: var(--f-display);
  font-size: 15.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.lbl-fam .orn {
  font-family: var(--f-fell);
  color: var(--rubric);
  font-size: 0.82em;
  margin-left: 0.28em;
  opacity: 0.55;
  transition: opacity 0.2s;
  vertical-align: 0.12em;
}
.lbl-fam:hover .orn { opacity: 1; }
.lbl-fam:hover .nm { text-decoration: underline; text-decoration-color: var(--rubric); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.lbl-fam.is-iso { font-family: var(--f-fell); font-style: italic; font-size: 14px; color: var(--ink); letter-spacing: 0; }
.lbl-fam.is-creole { font-family: var(--f-fell); font-style: italic; font-size: 14px; color: var(--rose); letter-spacing: 0; }
.lbl-node {
  font-family: var(--f-fell);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.lbl-node:hover, .lbl-leaf:hover { color: var(--rubric); }
.lbl-leaf {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink);
}
.lbl-leaf.is-ext, .lbl-leaf.is-lit { color: var(--ink-soft); }
.lbl-region {
  font-family: var(--f-fell);
  font-style: italic;
  font-size: 27px;
  color: var(--ink);
  opacity: 0.8;
  letter-spacing: 0.01em;
  text-shadow: 0 0 6px var(--paper), 0 0 14px var(--paper);
}
.lbl-region span { border-bottom: 1px solid transparent; }
.lbl-region:hover span { border-bottom-color: var(--rubric); }
.lbl-mile {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-fell);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
  transform-origin: 0 50%;
  margin-top: -10px;
  margin-left: -10px;
}
.lbl-mile b {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: 1px solid var(--rubric);
  border-radius: 10px;
  font-family: var(--f-display);
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--rubric);
  background: var(--paper);
  text-shadow: none;
}
.lbl-mile:hover span { color: var(--rubric); }
.lbl-mile.compact span { display: none; }
.lbl.dim { opacity: 0.32; }
.lbl-zone { font-family: var(--f-fell); font-style: italic; font-size: 14px; color: var(--zc, var(--ink)); }
.lbl-prop { font-family: var(--f-fell); font-style: italic; font-size: 13px; color: var(--indigo); }

/* -------------------------------------------------------------- chrome */
.cartouche {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 26px;
  max-width: 380px;
  pointer-events: none;
  text-shadow: var(--halo);
  z-index: 5;
}
/* zoomed in, the title steps back; the search under it stays */
.cartouche .eyebrow, .cartouche h1 { transition: opacity 0.5s ease, text-shadow 0.8s ease; }
body.zoomed .cartouche .eyebrow, body.zoomed .cartouche h1 { opacity: 0; }
.cartouche .search { margin-top: 10px; width: max-content; pointer-events: auto; }
.cartouche .eyebrow {
  margin: 0;
  font-family: var(--f-fell);
  font-style: italic;
  font-size: 14px;
  color: var(--rubric);
  letter-spacing: 0.02em;
}
.cartouche h1 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.cartouche .tagline {
  margin: 6px 0 0;
  font-style: italic;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-soft);
  max-width: 34ch;
}

.tools {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 6;
}
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 2px; width: 17px; height: 17px; fill: none; stroke: var(--ink-soft); stroke-width: 1.5; pointer-events: none; }
#search {
  width: 210px;
  padding: 6px 6px 5px 26px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-style: italic;
  font-size: 15.5px;
  color: var(--ink);
  border-radius: 0;
  transition: border-color 0.2s, width 0.25s;
}
#search::placeholder { color: var(--ink-soft); opacity: 0.85; }
#search:focus { outline: none; border-bottom-color: var(--rubric); width: 250px; }
#search::-webkit-search-cancel-button { display: none; }
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 290px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  text-shadow: none;
}
#search-results li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 14px;
  cursor: pointer;
}
#search-results li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#search-results li small { flex: none; font-family: var(--f-caps); font-size: 12px; color: var(--ink-soft); letter-spacing: 0.04em; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#search-results li.on, #search-results li:hover { background: color-mix(in srgb, var(--rubric) 12%, transparent); }

.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  font-family: var(--f-caps);
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--ink);
  border-radius: 4px;
  text-shadow: var(--halo);
}
.tbtn:hover, .tbtn[aria-expanded="true"] { color: var(--rubric); }
a.tbtn { text-decoration: none; }
.tbtn.icon { padding: 6px; }
.tbtn[hidden] { display: none; }
.tbtn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.dock .mobile-only { display: none; }
.dock {
  position: fixed;
  left: 18px;
  bottom: calc(34px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 2px;
  z-index: 6;
}
.zoom {
  position: fixed;
  right: 22px;
  bottom: calc(36px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 6;
  transition: right 0.3s ease;
}
.zoom button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-family: var(--f-fell);
  font-size: 21px;
  line-height: 1;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.zoom button:hover { color: var(--rubric); border-color: var(--rubric); }
.zoom svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }

#axis {
  position: fixed;
  left: 0; right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  height: 26px;
  pointer-events: none;
  z-index: 4;
  border-top: 1px solid var(--line);
  background: linear-gradient(to top, color-mix(in srgb, var(--paper) 88%, transparent), transparent);
}
#axis .tick {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  font-family: var(--f-caps);
  font-size: 12px;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ink-soft);
}
#axis .tick::before { content: ''; position: absolute; left: 0; top: -1px; width: 1px; height: 6px; background: var(--ink-soft); }
#axis .tick span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; }
#axis .axis-cap { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); font-family: var(--f-fell); font-style: italic; font-size: 12.5px; color: var(--ink-soft); display: none; }

#hint {
  position: fixed;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  margin: 0;
  padding: 0 12px;
  font-style: italic;
  font-size: 14.5px;
  color: var(--ink-soft);
  text-shadow: var(--halo);
  pointer-events: none;
  z-index: 4;
  white-space: nowrap;
  transition: opacity 1.2s ease;
  animation: hint-in 1.2s ease 4.2s both;
}
#hint.gone { opacity: 0; }
@keyframes hint-in { from { opacity: 0; } to { opacity: 1; } }

#tooltip {
  position: fixed;
  left: 0; top: 0;
  max-width: 280px;
  padding: 8px 12px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
#tooltip[hidden] { display: none; }
#tooltip strong { font-family: var(--f-display); font-weight: 400; font-size: 16.5px; line-height: 1.2; }
#tooltip span { font-size: 13.5px; color: var(--ink-soft); line-height: 1.35; }
#tooltip em { font-family: var(--f-fell); font-size: 12.5px; color: var(--rubric); margin-top: 2px; }

/* ------------------------------------------------------------ popovers */
.pop {
  position: fixed;
  z-index: 15;
  width: min(380px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  overflow: auto;
  padding: 16px 20px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.pop h2 { margin: 0 0 10px; font-family: var(--f-display); font-weight: 400; font-size: 21px; }
#pop-key, #pop-layers { left: 16px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
#pop-essays, #pop-lang { right: 16px; top: calc(64px + env(safe-area-inset-top, 0px)); }
#pop-lang { width: min(260px, calc(100vw - 32px)); }
.key { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.key li { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; font-size: 14.5px; line-height: 1.35; }
.key svg { width: 46px; height: 18px; overflow: visible; }
.k-ink { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.k-dot { stroke-dasharray: 2.2 3; stroke-width: 1.6; }
.k-seal { fill: var(--wash-weurasia); stroke: var(--ink); stroke-width: 1.4; }
.k-seed { fill: var(--paper); stroke: var(--ink); stroke-width: 1.2; }
.k-leaf { fill: var(--wash-easia); stroke: var(--ink); stroke-width: 0.9; }
.k-pale { fill: color-mix(in srgb, var(--wash-easia) 40%, var(--paper)); }
.k-new { fill: var(--revived); }
.k-dead { fill: color-mix(in srgb, var(--ink-soft) 65%, var(--paper)); stroke: var(--ink-soft); stroke-width: 0.9; }
.k-ghost { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 2; }
.k-thread { fill: none; stroke: var(--rubric); stroke-width: 2.4; stroke-linecap: round; }
.k-creole { fill: none; stroke: var(--rose); stroke-width: 2; stroke-linecap: round; }
.k-flower { fill: var(--rose); stroke: var(--ink); stroke-width: 0.8; }
.k-wash { fill: color-mix(in srgb, var(--wash-sahul) 55%, transparent); }
.key-note { margin: 12px 0 0; font-size: 13.5px; font-style: italic; color: var(--ink-soft); }
.layer { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 7px 0; align-items: start; cursor: pointer; font-size: 14.5px; line-height: 1.35; }
.layer input { margin: 3px 0 0; accent-color: var(--rubric); width: 16px; height: 16px; }
.layer b { display: block; font-family: var(--f-caps); font-weight: 500; letter-spacing: 0.03em; font-size: 15px; }
.layer span { color: var(--ink-soft); }
.layer b { color: var(--ink); }
#essay-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
#essay-list button { width: 100%; display: grid; grid-template-columns: 34px 1fr; gap: 6px; text-align: left; border: 0; background: none; padding: 6px 4px; border-radius: 4px; font-size: 15.5px; line-height: 1.3; }
#essay-list button b { font-family: var(--f-display); font-weight: 400; color: var(--rubric); font-size: 14px; padding-top: 1px; }
#essay-list button:hover { background: color-mix(in srgb, var(--rubric) 9%, transparent); }
.langs { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.langs button { width: 100%; text-align: start; border: 0; background: none; padding: 6px 8px; border-radius: 4px; font-size: 15.5px; line-height: 1.3; }
.langs button:hover { background: color-mix(in srgb, var(--rubric) 9%, transparent); }
.langs button[aria-current] { color: var(--rubric); }
.langs button[aria-current]::after { content: ' ❧'; font-family: var(--f-fell); }

/* --------------------------------------------------------------- folio */
#folio {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(450px, 100vw);
  z-index: 12;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(40, 28, 10, 0.16);
  transform: translateX(104%);
  transition: transform 0.32s cubic-bezier(.2, .7, .2, 1);
  display: flex;
  flex-direction: column;
}
#folio::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--fam, var(--rubric)) 16%, transparent), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, color-mix(in srgb, var(--paper-deep) 50%, transparent), transparent 70%);
}
#folio.open { transform: none; }
body.has-folio .zoom { right: calc(min(450px, 100vw) + 18px); }
body.has-folio .tools { right: calc(min(450px, 100vw) + 18px); }
#folio-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 14px;
  z-index: 2;
  width: 34px; height: 34px;
  border: 0;
  background: transparent;
  font-family: var(--f-fell);
  font-size: 28px;
  line-height: 1;
  color: var(--ink-soft);
  border-radius: 50%;
}
#folio-close:hover { color: var(--rubric); background: color-mix(in srgb, var(--rubric) 8%, transparent); }
#folio-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: calc(26px + env(safe-area-inset-top, 0px)) 32px calc(40px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior: contain;
}
#folio-body:focus { outline: none; }
.kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 40px 6px 0;
  font-family: var(--f-caps);
  font-size: 13.5px;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}
.kicker .grp { letter-spacing: 0.04em; }
.sw {
  display: inline-block;
  width: 13px; height: 13px;
  border-radius: 50% 46% 52% 44%;
  background: var(--fam, var(--rubric));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 35%, transparent);
  flex: none;
}
.sw.thread { border-radius: 3px; height: 4px; width: 16px; background: var(--rubric); box-shadow: none; }
.sw.thread.creole { background: var(--rose); }
.sw.thread.wander { background: var(--tea); }
#folio h2 {
  margin: 0 40px 10px 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0.005em;
  text-wrap: balance;
}
.lede { margin: 0 0 16px; font-size: 17.5px; line-height: 1.5; display: flow-root; }
.lede::first-letter {
  float: left;
  font-family: var(--f-fell);
  font-size: 3.2em;
  line-height: 0.82;
  padding: 0.06em 0.08em 0 0;
  color: var(--rubric);
}
.sub { font-style: italic; color: var(--ink-soft); }
.crumbs { margin: -4px 0 14px; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.crumbs i { font-style: normal; margin: 0 0.4em; color: var(--ink-soft); opacity: 0.7; }
.crumbs span { color: var(--ink); }
#folio a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--rubric) 55%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
#folio a:hover { color: var(--rubric); text-decoration-color: var(--rubric); }
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 0 0 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.facts div { min-width: 0; }
.facts dt { font-family: var(--f-caps); font-size: 12.5px; letter-spacing: 0.06em; color: var(--ink-soft); }
.facts dd { margin: 0; font-size: 15.5px; line-height: 1.35; font-variant-numeric: lining-nums; overflow-wrap: anywhere; }
.prose { font-size: 16px; line-height: 1.58; }
.prose p { margin: 0 0 0.85em; }
.prose h3 { margin: 1.3em 0 0.4em; font-family: var(--f-display); font-weight: 400; font-size: 20px; }
.prose em, .prose i { font-style: italic; }
.prose blockquote { margin: 0.6em 0 1em; padding-left: 14px; border-left: 2px solid var(--rubric); font-style: italic; color: var(--ink-soft); }
.prose ul, .prose ol { margin: 0 0 0.9em; padding-left: 1.2em; }
.prose li { margin: 0.2em 0; }
.prose .tbl { overflow-x: auto; margin: 0.6em 0 1em; }
.prose table { border-collapse: collapse; font-size: 14.5px; min-width: 100%; }
.prose th, .prose td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { font-family: var(--f-caps); font-weight: 500; letter-spacing: 0.04em; font-size: 13px; color: var(--ink-soft); }
.prose td:first-child { font-family: var(--f-caps); color: var(--ink-soft); white-space: nowrap; }
details.note { margin: 6px 0; border-top: 1px dotted var(--line); }
details.note:last-of-type { border-bottom: 1px dotted var(--line); }
details.note summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 0;
  font-family: var(--f-display);
  font-size: 18px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
details.note summary::-webkit-details-marker { display: none; }
details.note summary .orn { color: var(--rubric); font-family: var(--f-fell); transition: transform 0.25s; display: inline-block; }
details.note[open] summary .orn { transform: rotate(90deg); }
details.note summary:hover { color: var(--rubric); }
details.note .prose { padding: 0 0 8px; }
.sources { margin: 18px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.sources span { font-family: var(--f-caps); letter-spacing: 0.06em; margin-right: 4px; color: var(--ink); }
.rel { margin-top: 22px; }
.rel h3 { margin: 16px 0 6px; font-family: var(--f-caps); font-weight: 500; font-size: 14px; letter-spacing: 0.08em; color: var(--ink-soft); }
.chips { margin: 0; line-height: 1.75; font-size: 15.5px; }
.chips a + a::before { content: '·'; display: inline-block; margin: 0 0.5em; color: var(--ink-soft); text-decoration: none; }
.chips a.leaf { font-style: italic; }
.links { list-style: none; margin: 0; padding: 0; font-size: 15.5px; }
.links li { padding: 3px 0 3px 18px; position: relative; }
.links li::before { content: '❧'; position: absolute; left: 0; top: 3px; color: var(--rubric); font-family: var(--f-fell); font-size: 13px; }
.links small { color: var(--ink-soft); font-size: 13px; margin-left: 4px; }
.links.pairs i { font-style: normal; color: var(--rubric); margin: 0 3px; }
.verdict { font-style: italic; color: var(--ink-soft); }
.tea-link { margin-top: 14px; font-style: italic; }
.plate summary small { font-family: var(--f-body); font-size: 13px; color: var(--ink-soft); margin-left: auto; }
.plate-wrap { margin: 4px 0 10px; }
.plate svg { display: block; overflow: visible; }
.plate .e { fill: none; stroke: var(--ink); stroke-width: 1.15; stroke-linecap: round; }
.plate .e.q { stroke-dasharray: 2 3; }
.plate .e.x { stroke: var(--ink-soft); opacity: 0.75; }
.plate .e.g { stroke: var(--ink-soft); stroke-width: 0.7; stroke-dasharray: 1 3; opacity: 0.6; }
.plate .e.f { stroke: var(--gold); stroke-width: 2.4; }
.plate .nd { fill: var(--paper); stroke: var(--ink); stroke-width: 1.1; }
.plate .nd.rt { fill: var(--fam, var(--rubric)); }
.plate .lf { fill: var(--fam, var(--rubric)); stroke: var(--ink); stroke-width: 0.8; }
.plate .lf.en { fill: color-mix(in srgb, var(--fam, var(--rubric)) 40%, var(--paper)); }
.plate .lf.rv { fill: var(--revived); }
.plate .lf.x { fill: color-mix(in srgb, var(--ink-soft) 55%, var(--paper)); stroke: var(--ink-soft); }
.plate .lf.lt { fill: none; stroke-dasharray: 1.5 1.5; }
.plate text { font-family: var(--f-body); fill: var(--ink); }
.plate .ln { font-style: italic; font-size: 13.5px; }
.plate .ln.x { fill: var(--ink-soft); }
.plate .ln.on { fill: var(--rubric); font-weight: 700; }
.plate .bn { font-family: var(--f-fell); font-style: italic; font-size: 11px; fill: var(--ink-soft); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
#folio .plate a { text-decoration: none; }
.plate a:hover text { fill: var(--rubric); }
.plate .ax { font-family: var(--f-caps); font-size: 11px; fill: var(--ink-soft); letter-spacing: 0.04em; }
.essay-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14.5px; }
.essay-nav a:last-child { text-align: right; }

/* -------------------------------------------------------- lineage tour */
/* A codex page in the lower left is written letter by letter while the
   camera follows a gold line of descent; pages turn as the story moves on. */
.tour-cta { margin: -4px 0 16px; }
.tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border: 1px solid color-mix(in srgb, var(--rubric) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--rubric) 6%, transparent);
  font-family: var(--f-caps);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--rubric);
}
.tour-btn svg { width: 16px; height: 16px; fill: currentColor; }
.tour-btn small { font-family: var(--f-body); font-style: italic; font-size: 13.5px; letter-spacing: 0; color: var(--ink-soft); }
.tour-btn:hover { background: color-mix(in srgb, var(--rubric) 13%, transparent); }

#tour-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
  background: radial-gradient(ellipse 72% 74% at var(--vx, 62%) var(--vy, 48%), transparent 50%, color-mix(in srgb, var(--paper-deep) 80%, transparent) 100%);
}
body.touring #tour-veil { opacity: 1; }
body.touring .search, body.touring .tools, body.touring .dock, body.touring .zoom, body.touring #hint {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
.lbl.tour-focus { color: var(--rubric); opacity: 1; }
.lbl.tour-line { color: color-mix(in srgb, var(--rubric) 55%, var(--ink)); }
.tour-tag {
  font-family: var(--f-fell);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.7s ease;
}
.tour-tag.show { opacity: 1; }
.tour-tag.on { color: var(--rubric); }
.tour-tag.on::before { content: '❧ '; font-style: normal; color: var(--gold); }

/* the codex: a stack of pages, the top one being written */
#codex {
  position: fixed;
  left: 18px;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  width: min(372px, calc(100vw - 36px));
  height: min(392px, calc(100vh - 150px));
  z-index: 9;
}
#codex[hidden] { display: none; }
.codex-book { position: absolute; inset: 0; perspective: 2000px; perspective-origin: 0% 50%; }
.codex-book::before, .codex-book::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px 6px 6px 3px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-deep) 55%, var(--paper));
}
.codex-book::before { transform: translate(5px, 5px); box-shadow: var(--shadow); }
.codex-book::after { transform: translate(2.5px, 2.5px); background: var(--paper); }
.cx-page {
  --cx-fs: 16.5px;
  --cx-ink: var(--ink);
  position: absolute;
  inset: 0;
  z-index: 1;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}
.cx-front, .cx-back {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.cx-front {
  display: flex;
  flex-direction: column;
  padding: 24px 28px 12px 34px;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--paper-deep) 90%, transparent), transparent 24px),
    radial-gradient(130% 95% at 55% 42%, transparent 58%, color-mix(in srgb, var(--paper-deep) 65%, transparent)),
    radial-gradient(16px 11px at 84% 12%, color-mix(in srgb, var(--fox) 24%, transparent), transparent),
    radial-gradient(26px 18px at 14% 88%, color-mix(in srgb, var(--fox) 18%, transparent), transparent),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .34 0 0 0 0 .18 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* ruled frame, as on a manuscript leaf */
.cx-front::before {
  content: '';
  position: absolute;
  inset: 10px 12px 10px 17px;
  border: 1px solid color-mix(in srgb, var(--rubric) 34%, transparent);
  outline: 1px solid color-mix(in srgb, var(--rubric) 15%, transparent);
  outline-offset: 3px;
  pointer-events: none;
}
.cx-back {
  transform: rotateY(180deg);
  background: linear-gradient(to left, color-mix(in srgb, var(--paper-deep) 95%, transparent), var(--paper) 45%);
}
.cx-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to right, transparent, rgba(40, 26, 8, 0.3));
}
.cx-kicker {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 3px;
  font-family: var(--f-caps);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--rubric);
}
.cx-num { font-family: var(--f-display); font-size: 15px; letter-spacing: 0.05em; }
.cx-num::after { content: '·'; margin-left: 8px; color: var(--ink-soft); }
.cx-title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: 0.005em;
  text-wrap: balance;
}
.cx-when { --cx-ink: var(--ink-soft); margin: 3px 0 0; font-family: var(--f-fell); font-style: italic; font-size: 15px; line-height: 1.3; color: var(--ink-soft); }
.cx-body { margin-top: 12px; font-size: var(--cx-fs); line-height: 1.5; }
.cx-body b { --cx-ink: var(--rubric); font-weight: 500; color: var(--rubric); }
.cx-cap {
  float: left;
  margin: 0.1em 0.16em 0 0;
  padding: 0.12em 0.13em 0.02em;
  font-family: var(--f-fell);
  font-size: 3.1em;
  line-height: 0.8;
  color: var(--rubric);
  background: color-mix(in srgb, var(--gold) 13%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--gold) 70%, transparent),
    inset 0 0 0 3px color-mix(in srgb, var(--paper) 70%, transparent),
    inset 0 0 0 4px color-mix(in srgb, var(--rubric) 28%, transparent);
  opacity: 0;
}
.cx-cap.on { opacity: 1; animation: cx-illum 1.3s ease-out backwards; }
/* Each letter is drawn, not faded in: the ink is painted through the glyph
   from left to right behind a bright wet edge, and dries from gold to ink.
   The padding (cancelled by the margin) leaves room for italic overhangs. */
@property --cx-wet { syntax: '<color>'; inherits: false; initial-value: transparent; }
.cx-page .ch { opacity: 0; padding: 0.24em 0.1em; margin: 0 -0.1em; }
.cx-page .ch.on {
  --cx-wet: var(--cx-ink);
  opacity: 1;
  color: transparent;
  background: linear-gradient(90deg, var(--cx-wet) 0 44%, var(--gold) 48%, transparent 52%) 0 0 / 230% 100% no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  animation: cx-stroke var(--cx-stroke, 0.17s) cubic-bezier(0.3, 0.1, 0.55, 1) backwards, cx-dry 1.8s ease-out backwards;
}
@keyframes cx-stroke { from { background-position: 100% 0; } }
@keyframes cx-dry { from { --cx-wet: color-mix(in srgb, var(--rubric) 45%, var(--gold)); } }
#codex.still .ch.on, #codex.still .cx-cap.on { animation: none; }
@keyframes cx-illum {
  0% { opacity: 0; color: var(--gold); transform: scale(0.82); filter: blur(2px); }
  40% { opacity: 1; color: var(--gold); transform: scale(1.04); filter: blur(0); text-shadow: 0 0 10px color-mix(in srgb, var(--gold) 70%, transparent); }
  100% { opacity: 1; color: var(--rubric); transform: none; }
}
.cx-end { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; visibility: hidden; opacity: 0; transition: opacity 0.6s ease; }
.cx-end.show { visibility: visible; opacity: 1; }
.cx-end button {
  padding: 5px 13px;
  border: 1px solid color-mix(in srgb, var(--rubric) 55%, transparent);
  border-radius: 999px;
  background: transparent;
  font-family: var(--f-caps);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--rubric);
}
.cx-end button:first-child { background: var(--rubric); color: var(--paper); }
.cx-end button:hover { background: color-mix(in srgb, var(--rubric) 14%, transparent); color: var(--rubric); }
.cx-folio {
  margin: auto 0 0;
  padding-top: 6px;
  text-align: center;
  font-family: var(--f-caps);
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.cx-folio::before, .cx-folio::after { content: '—'; margin: 0 0.6em; opacity: 0.55; }
.cx-page.turn-away { z-index: 2; pointer-events: none; animation: cx-turn-away 0.95s cubic-bezier(0.45, 0.05, 0.35, 1) forwards; }
.cx-page.turn-back { z-index: 2; animation: cx-turn-back 0.95s cubic-bezier(0.45, 0.05, 0.35, 1) both; }
.cx-page.turn-away .cx-shade, .cx-page.turn-back .cx-shade { animation: cx-shade 0.95s ease both; animation-duration: inherit; }
.cx-page.turn-back .cx-shade { animation-direction: reverse; }
@keyframes cx-turn-away {
  0% { transform: rotateY(0deg); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: rotateY(-168deg); opacity: 0; }
}
@keyframes cx-turn-back {
  0% { transform: rotateY(-168deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: rotateY(0deg); opacity: 1; }
}
@keyframes cx-shade { 0% { opacity: 0; } 55% { opacity: 1; } 100% { opacity: 0.7; } }

/* transport */
#tour-bar {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 18px;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
#tour-bar[hidden] { display: none; }
#tour-bar button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
}
#tour-bar button:hover:not(:disabled) { color: var(--rubric); background: color-mix(in srgb, var(--rubric) 9%, transparent); }
#tour-bar button:disabled { opacity: 0.35; cursor: default; }
#tour-bar svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#tour-bar .tb-play { width: 40px; height: 40px; border: 1.5px solid color-mix(in srgb, var(--rubric) 60%, transparent); color: var(--rubric); }
.tb-play svg { display: none; }
.tb-play[data-state="pause"] .i-pause, .tb-play[data-state="play"] .i-play, .tb-play[data-state="replay"] .i-replay { display: block; }
.tb-play .i-play path { fill: currentColor; }
#tour-bar .tb-speed {
  width: auto;
  min-width: 42px;
  padding: 0 8px;
  border-radius: 18px;
  font-family: var(--f-caps);
  font-size: 15.5px;
  font-variant-numeric: lining-nums;
}
#tour-motion .mo-off { display: none; }
#tour-motion[aria-pressed="false"] .mo-off { display: inline; }
#tour-sound .snd-on, #tour-sound[aria-pressed="true"] .snd-off { display: none; }
#tour-sound[aria-pressed="true"] .snd-on { display: inline; }
#tour-sound[aria-pressed="true"] { color: var(--rubric); }
.tb-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--line); }
#tour-toast {
  position: absolute;
  top: calc(100% + 8px);
  right: 4px;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
#tour-toast.show { opacity: 1; transform: none; }

/* page rail: one seal per page, joined by a thread that fills with the page's time */
#tour-rail {
  position: fixed;
  right: 22px;
  bottom: calc(42px + env(safe-area-inset-bottom, 0px));
  z-index: 9;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 6px 10px;
  list-style: none;
  border-radius: 20px;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
}
#tour-rail[hidden] { display: none; }
#tour-rail li { display: flex; align-items: center; }
#tour-rail li + li::before {
  content: '';
  width: 26px;
  height: 2px;
  margin: 0 3px;
  border-radius: 1px;
  background: linear-gradient(to right, var(--gold) var(--fill, 0%), color-mix(in srgb, var(--ink-soft) 35%, transparent) var(--fill, 0%));
}
#tour-rail button {
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border: 1.5px solid color-mix(in srgb, var(--ink-soft) 70%, transparent);
  border-radius: 12px;
  background: var(--paper);
  font-family: var(--f-display);
  font-size: 10.5px;
  line-height: 1;
  color: var(--ink-soft);
  transition: transform 0.25s ease, background 0.25s ease;
}
#tour-rail .done button { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 22%, var(--paper)); color: var(--ink); }
#tour-rail button[aria-current="step"] { border-color: var(--rubric); background: var(--rubric); color: var(--paper); transform: scale(1.15); }
#tour-rail button:hover:not([aria-current]) { border-color: var(--rubric); color: var(--rubric); }

@media (max-width: 720px) {
  body.touring .cartouche { opacity: 0; }
  #codex { left: 10px; right: 10px; width: auto; height: min(44vh, 330px); bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
  .cx-front { padding: 18px 20px 8px 26px; }
  .cx-title { font-size: 23px; }
  .cx-when { font-size: 14px; }
  .cx-body { margin-top: 8px; }
  #tour-bar { top: calc(10px + env(safe-area-inset-top, 0px)); right: 50%; transform: translateX(50%); }
  #tour-bar button { width: 34px; height: 34px; }
  #tour-bar .tb-play { width: 38px; height: 38px; }
  #tour-toast { right: 50%; transform: translate(50%, -4px); }
  #tour-toast.show { transform: translateX(50%); }
  #tour-rail { right: 50%; bottom: auto; top: calc(62px + env(safe-area-inset-top, 0px)); transform: translateX(50%); padding: 4px 8px; }
  #tour-rail li + li::before { width: 12px; margin: 0 2px; }
}

/* ------------------------------------------------------------- welcome */
/* A frontispiece on a plain visit: a small tree grows left to right and the title is
   inked in gold; then the words fly to the cartouche while the real tree grows in.
   index.html sets html.wl before first paint; welcome.js adds wl-on to play it and
   wl-out to put it away. If welcome.js never runs, the paper lifts by itself. */
#welcome { display: none; }
html.wl #welcome {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 40;
  padding: 24px var(--gutter);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  animation: wl-lift 0.6s ease 2.5s forwards;
}
html.wl-on #welcome { animation: none; }
html.wl-out #welcome { pointer-events: none; }
@keyframes wl-lift { to { opacity: 0; visibility: hidden; } }
.wl-paper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 75% 70% at 50% 45%, transparent 45%, color-mix(in srgb, var(--paper-deep) 65%, transparent) 100%),
    var(--paper);
}
.wl-plate { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
html.wl:not(.wl-on) .wl-plate { visibility: hidden; }

/* the emblem: watercolour limbs, then ink stems, seals, leaves and contact threads */
.wl-tree { width: min(420px, 82vw, 56vh); height: auto; overflow: visible; margin-bottom: clamp(10px, 2.4vh, 22px); }
.wl-tree .f-a { --fam: var(--wash-sahul); }
.wl-tree .f-b { --fam: var(--wash-weurasia); }
.wl-tree .f-c { --fam: var(--wash-africa); }
.wl-wash { fill: var(--fam); opacity: 0.34; transform-box: fill-box; transform-origin: 0% 50%; }
.wl-stem { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-dasharray: 1 2; }
.wl-stem.ext { stroke: var(--ink-soft); }
.wl-stem.q { stroke: var(--ink-soft); stroke-width: 1.1; stroke-dasharray: 1.6 3; }
.wl-thread { fill: none; stroke: var(--rubric); stroke-width: 1.4; stroke-linecap: round; stroke-dasharray: 1 2; opacity: 0.85; }
.wl-leaf { fill: var(--fam); stroke: var(--ink); stroke-width: 0.7; transform-box: fill-box; transform-origin: 0% 50%; }
.wl-leaf.pale { fill: color-mix(in srgb, var(--fam) 40%, var(--paper)); }
.wl-leaf.new { fill: var(--revived); }
.wl-leaf.dead { fill: color-mix(in srgb, var(--ink-soft) 65%, var(--paper)); stroke: var(--ink-soft); }
.wl-leaf.ghost { fill: none; stroke-dasharray: 1.5 1.5; }
.wl-seal { fill: var(--fam); stroke: var(--ink); stroke-width: 1.1; transform-box: fill-box; transform-origin: center; }
.wl-seal.root { fill: var(--gold); stroke-width: 1.3; }
.wl-seal.seed { fill: var(--paper); stroke-width: 1; }

.wl-eyebrow { margin: 0 0 2px; font-family: var(--f-fell); font-style: italic; font-size: clamp(15px, 1.5vw, 20px); color: var(--rubric); }
.wl-eyebrow span { display: inline-block; letter-spacing: 0.02em; transform-origin: 0 0; }
.wl-title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(38px, min(6.4vw, 9.5vh), 92px);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.wl-line { display: block; white-space: nowrap; }
.wl-w { display: inline-block; transform-origin: 0 0; }
/* each letter is inked like the codex pages: a gold wet edge that dries to ink */
#welcome .ch {
  --cx-wet: var(--ink);
  padding: 0.24em 0.1em;
  margin: 0 -0.1em;
  color: transparent;
  background: linear-gradient(90deg, var(--cx-wet) 0 44%, var(--gold) 48%, transparent 52%) 0 0 / 230% 100% no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  animation: cx-stroke 0.22s cubic-bezier(0.3, 0.1, 0.55, 1) var(--t) backwards, cx-dry 1.4s ease-out var(--t) backwards;
}
.wl-rule { display: flex; align-items: center; gap: 12px; margin: clamp(8px, 1.8vh, 16px) 0 clamp(4px, 1vh, 10px); color: var(--rubric); }
.wl-rule span { width: clamp(44px, 8vw, 96px); height: 1px; background: color-mix(in srgb, var(--rubric) 55%, transparent); }
.wl-rule span:first-child { transform-origin: 100% 50%; }
.wl-rule span:last-child { transform-origin: 0 50%; }
.wl-rule b { font-family: var(--f-fell); font-weight: 400; font-size: 20px; line-height: 1; }
.wl-sub { margin: 0; font-style: italic; font-size: clamp(15px, 1.4vw, 18px); line-height: 1.4; color: var(--ink-soft); text-wrap: balance; }

html.wl-on .wl-wash { animation: wl-wash 1.13s cubic-bezier(0.2, 0.7, 0.3, 1) var(--d) both; }
html.wl-on .wl-stem { animation: wl-draw var(--t, 0.5s) cubic-bezier(0.3, 0.15, 0.55, 1) var(--d) both; }
html.wl-on .wl-stem.q { animation: wl-show 0.67s ease var(--d) both; }
html.wl-on .wl-thread { animation: wl-draw 0.4s cubic-bezier(0.4, 0, 0.2, 1) var(--d) both; }
html.wl-on .wl-leaf { animation: wl-leaf 0.43s cubic-bezier(0.34, 1.56, 0.64, 1) var(--d) both; }
html.wl-on .wl-seal { animation: wl-pop 0.3s cubic-bezier(0.34, 1.7, 0.64, 1) var(--d) both; }
html.wl-on .wl-eyebrow span { animation: wl-brow 1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.05s both; }
html.wl-on .wl-rule b { animation: wl-orn 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.55s both; }
html.wl-on .wl-rule span { animation: wl-rule 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.65s both; }
html.wl-on .wl-sub { animation: wl-rise 0.6s ease 0.7s both; }
@keyframes wl-wash { from { opacity: 0; transform: scaleX(0.12); } }
@keyframes wl-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes wl-show { from { opacity: 0; } }
@keyframes wl-leaf { from { transform: scale(0) rotate(-35deg); } }
@keyframes wl-pop { from { transform: scale(0); } }
@keyframes wl-brow { from { opacity: 0; letter-spacing: 0.34em; filter: blur(3px); } }
@keyframes wl-orn { from { opacity: 0; transform: rotate(-90deg) scale(0.4); } }
@keyframes wl-rule { from { transform: scaleX(0); } }
@keyframes wl-rise { from { opacity: 0; transform: translateY(6px); } }

/* leaving: the emblem and its rule fade, the paper lifts, the chrome settles in */
html.wl-out .wl-tree, html.wl-out .wl-rule, html.wl-out .wl-sub { animation: wl-away 0.4s ease forwards; }
html.wl-out .wl-paper { animation: wl-away-paper 0.53s ease 0.23s forwards; }
html.wl-on .cartouche .eyebrow, html.wl-on .cartouche h1 { visibility: hidden; text-shadow: none; }
html.wl-on #hint { animation: none; opacity: 0; }
html.wl-out .cartouche .search, html.wl-out .tools { animation: wl-chrome-down 0.47s cubic-bezier(0.2, 0.7, 0.2, 1) 0.53s both; }
html.wl-out .dock, html.wl-out .zoom, html.wl-out #axis { animation: wl-chrome-up 0.47s cubic-bezier(0.2, 0.7, 0.2, 1) 0.6s both; }
@keyframes wl-away { to { opacity: 0; transform: translateY(-8px); filter: blur(2px); } }
@keyframes wl-away-paper { to { opacity: 0; } }
@keyframes wl-chrome-down { from { opacity: 0; transform: translateY(-6px); } }
@keyframes wl-chrome-up { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------ fallback */
.fallback { display: none; position: fixed; inset: 0; place-content: center; text-align: center; padding: 24px var(--gutter); z-index: 30; }
.fallback h2 { font-family: var(--f-display); font-weight: 400; font-size: 28px; margin: 0 0 8px; }
.fallback p { max-width: 46ch; margin: 0 auto; color: var(--ink-soft); }
body.no-webgl .fallback, .fallback.show { display: grid; }
body.no-webgl #stage, body.no-webgl .dock, body.no-webgl .zoom, body.no-webgl #hint { display: none; }

/* -------------------------------------------------------------- mobile */
@media (max-width: 720px) {
  .cartouche { left: var(--gutter); right: 64px; top: calc(12px + env(safe-area-inset-top, 0px)); }
  .cartouche h1 { font-size: 23px; }
  .cartouche .eyebrow { font-size: 12px; }
  .cartouche .tagline { display: none; }
  .tools { top: calc(10px + env(safe-area-inset-top, 0px)); right: 8px; }
  .tools .tbtn[data-pop="pop-essays"] { display: none; }
  .dock .mobile-only { display: inline-flex; }
  .cartouche .search { position: fixed; left: var(--gutter); right: var(--gutter); top: calc(54px + env(safe-area-inset-top, 0px)); width: auto; margin: 0; }
  #search, #search:focus { width: 100%; }
  #search-results { width: 100%; }
  .dock { left: 8px; bottom: calc(30px + env(safe-area-inset-bottom, 0px)); }
  .dock .tbtn { font-size: 14px; }
  .dock::after { content: none; }
  .zoom { right: 10px; bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
  .zoom button { width: 38px; height: 38px; }
  #hint { white-space: normal; width: calc(100% - 32px); text-align: center; font-size: 13px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  #folio {
    top: auto;
    width: 100%;
    height: min(64vh, 640px);
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    transform: translateY(104%);
    box-shadow: 0 -14px 34px rgba(40, 28, 10, 0.2);
  }
  #folio.open { transform: none; }
  #folio-body { padding: 22px 20px calc(30px + env(safe-area-inset-bottom, 0px)); }
  #folio h2 { font-size: 28px; }
  body.has-folio .zoom, body.has-folio .tools { right: 10px; }
  body.has-folio .zoom { display: none; }
  #pop-essays { top: auto; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); right: 16px; }
  .lbl-region { font-size: 16px; }
  .lbl-fam { font-size: 13px; }
  .lbl-mile span { display: none; }
}
@media (max-width: 720px) {
  /* the language button shares the top corner with the theme toggle */
  html.multilingual .cartouche h1 { font-size: min(23px, 5.6vw); }
  #lang-btn { padding: 6px 5px; font-size: 13px; }
  .dock { gap: 0; }
  .dock .tbtn[data-pop] + .tbtn { margin-left: 0; }
}

/* the lineage tour is a film the viewer starts: it keeps its motion
   (html.tour-motion) unless they switch it to still pages */
@media (prefers-reduced-motion: reduce) {
  :root:not(.tour-motion) *, :root:not(.tour-motion) *::before, :root:not(.tour-motion) *::after { transition: none !important; animation: none !important; }
}
