/* Letopisețe: Descălecarea — semantic theme tokens, dual light/dark. */
@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("fonts/EBGaramond.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 300 800; font-display: swap; src: url("fonts/AtkinsonHyperlegibleNext.woff2") format("woff2"); }
:root {
  --bg: #ede9dc;
  --bg-raised: #f6f2e6;
  --bg-sunken: #e2ddcb;
  --ink: #1b1812;
  --ink-soft: #4d4636;
  --ink-faint: #6e6653;
  --line: #c9c2a9;
  --line-soft: #d8d2bd;
  --accent: #8c1d12;
  --accent-ink: #8c1d12;
  --accent-wash: #e7d9c4;
  --mark: #f3e3b8;
  --focus: #0f4c81;
  --radius: 10px;
  --serif: "EB Garamond", "Iowan Old Style", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --route: #8c1d12;
  --route-soft: rgba(140, 29, 18, 0.28);
  --river: rgba(88, 128, 150, 0.85);
  --dot: #2b2118;
  --halo: rgba(246, 242, 230, 0.93);
}
[data-theme="dark"] {
  --bg: #14120d;
  --bg-raised: #1e1b13;
  --bg-sunken: #0e0d09;
  --ink: #ece4cf;
  --ink-soft: #cfc5a9;
  --ink-faint: #a89d81;
  --line: #4a4433;
  --line-soft: #353023;
  --accent: #e0684e;
  --accent-ink: #f0856a;
  --accent-wash: #33231a;
  --mark: #4d3d17;
  --focus: #7fb8ef;
  --route: #f0856a;
  --route-soft: rgba(240, 133, 106, 0.3);
  --river: rgba(98, 140, 160, 0.8);
  --dot: #ece4cf;
  --halo: rgba(20, 18, 13, 0.9);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  text-wrap: pretty;
}
::selection { background: var(--mark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent-ink); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute; left: 0.75rem; top: -4rem; z-index: 60;
  background: var(--bg-raised); color: var(--ink);
  border: 2px solid var(--focus); border-radius: 6px; padding: 0.5rem 0.9rem;
  font-family: var(--sans); font-size: 0.95rem; text-decoration: none;
}
.skip:focus { top: 0.75rem; }

/* Topbar: one line tall, sideways scroll for jumps. */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 0.9rem;
  height: 3.25rem; padding: 0 1rem;
  background: var(--bg-raised); border-bottom: 1px solid var(--line);
  font-family: var(--sans); font-size: 0.95rem; white-space: nowrap;
}
.topbar .home { color: var(--ink); text-decoration: none; font-weight: 650; flex: none; }
.topbar .home:hover { color: var(--accent-ink); }
.topnav { display: flex; gap: 1rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--ink-soft); text-decoration: none; flex: none; }
.topnav a:hover { color: var(--accent-ink); }
.topnav a[aria-current="true"] { color: var(--accent-ink); font-weight: 650; }
.topbar .spacer { flex: 1 1 auto; }
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 3.25rem; row-gap: 0; }
  .topnav { order: 3; flex-basis: 100%; padding-bottom: 0.45rem; }
}
.chip {
  flex: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.2rem 0.8rem; color: var(--ink); text-decoration: none; font-size: 0.9rem;
}
.chip:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.icon-btn {
  flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

main { display: block; }
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.25rem; }
section { scroll-margin-top: 4.25rem; padding: 2.5rem 0 0.5rem; }

/* Opening. */
.kicker {
  font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint); margin: 2.5rem 0 0.75rem;
}
h1 {
  font-size: clamp(2.1rem, 6vw, 3.2rem); line-height: 1.12;
  font-weight: 650; margin: 0 0 1rem; letter-spacing: -0.01em;
}
.deck { font-size: 1.25rem; line-height: 1.55; color: var(--ink-soft); margin: 0 0 1.25rem; max-width: 38rem; }
.caveat {
  border-left: 3px solid var(--accent);
  background: var(--bg-raised);
  padding: 0.8rem 1rem; margin: 0 0 1.25rem; font-size: 1rem; color: var(--ink-soft);
}
.caveat strong { color: var(--ink); }
.source-line { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-faint); margin: 0; }
.source-line a { color: inherit; }

h2 {
  font-size: clamp(1.5rem, 4vw, 1.9rem); line-height: 1.25;
  font-weight: 650; margin: 0 0 0.75rem;
}
.section-lead { color: var(--ink-soft); margin: 0 0 1.5rem; max-width: 38rem; }
h3 { font-size: 1.15rem; margin: 1.75rem 0 0.5rem; font-weight: 650; }
p { margin: 0 0 1rem; }

/* Journey: the one central gesture. */
.journey {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; margin: 0 0 1rem;
}
.prologue {
  border-bottom: 1px solid var(--line-soft); padding-bottom: 1rem; margin-bottom: 1.25rem;
  font-size: 1.02rem; color: var(--ink-soft);
}
.prologue strong { color: var(--ink); display: block; font-size: 0.85rem; font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.35rem; }
.route { display: block; width: 100%; height: auto; margin: 0 0 1rem; }
.route .track { fill: none; stroke: var(--line); stroke-width: 3; }
.route .fill { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.route .peak { fill: none; stroke: var(--line); stroke-width: 1.5; }
.route .stop-dot { fill: var(--bg-raised); stroke: var(--ink-faint); stroke-width: 2; }
.route .stop-dot.done { fill: var(--accent); stroke: var(--accent); }
.route .stop-dot.now { fill: var(--accent); stroke: var(--accent); }
.route .stop-dot.now-ring { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.55; }
.route text { font-family: var(--sans); font-size: 11px; fill: var(--ink-faint); }
.steps { margin: 0; padding: 0; }
.step {
  min-height: 46vh; display: flex; flex-direction: column; justify-content: center;
  padding: 4vh 0; opacity: 0.55; transition: opacity 0.5s ease; scroll-margin-top: 6rem;
}
.step.on, html:not(.has-js) .step { opacity: 1; }
.step .wk {
  font-family: var(--sans); font-size: 0.82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-ink);
  margin: 0 0 0.75rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
}
.step .wk .n {
  flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--accent); color: var(--bg-raised);
  font-size: 0.8rem; display: inline-flex;
  align-items: center; justify-content: center;
}
[data-theme="dark"] .step .wk .n { color: #14120d; }
.step .wk .sub {
  display: block; flex-basis: 100%; margin-left: 2.1rem;
  font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-faint);
}
.stop-panel { border-top: 1px solid var(--line-soft); padding-top: 1rem; }
.stop-panel blockquote { margin: 0 0 0.75rem; font-size: 1.2rem; line-height: 1.55; }
.stop-panel .ref { font-family: var(--sans); font-size: 0.88rem; color: var(--ink-faint); margin: 0 0 1rem; }
.stop-nav { display: flex; align-items: center; gap: 0.75rem; }
.stop-nav button {
  font-family: var(--sans); font-size: 0.92rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 8px; padding: 0.5rem 1rem; min-height: 44px;
}
.stop-nav button:hover:not(:disabled) { border-color: var(--accent-ink); color: var(--accent-ink); }
.stop-nav button:disabled { opacity: 0.45; cursor: default; }
.stop-nav .count { font-family: var(--sans); font-size: 0.88rem; color: var(--ink-faint); margin-left: auto; }
.nojs-stops { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem; }
.nojs-stops li { border-top: 1px solid var(--line-soft); padding-top: 0.75rem; }
.nojs-stops strong { display: block; font-family: var(--sans); font-size: 0.9rem; }

/* Reader. */
.edition-switch {
  display: flex; gap: 0; margin: 0 0 1.5rem; width: max-content; max-width: 100%;
  position: sticky; top: 3.75rem; z-index: 15;
  background: var(--bg); padding: 0.35rem 0;
}
@media (max-width: 35rem) { .edition-switch { top: 6.5rem; } }
.edition-switch button {
  font-family: var(--sans); font-size: 0.92rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink-soft);
  padding: 0.55rem 1.1rem; min-height: 44px;
}
.edition-switch button:first-child { border-radius: 8px 0 0 8px; }
.edition-switch button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.edition-switch button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fragment {
  scroll-margin-top: 4.25rem;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 0 0 1rem;
}
.fragment:target { border-color: var(--accent); }
.fragment h3 { margin: 0 0 0.6rem; font-size: 1.05rem; display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.fragment h3 .fid {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 700;
  background: var(--accent); color: #fff; border-radius: 4px; padding: 0.1rem 0.45rem;
}
[data-theme="dark"] .fragment h3 .fid { color: #14120d; }
.fragment h3 .page { margin-left: auto; font-family: var(--sans); font-size: 0.8rem; font-weight: 400; color: var(--ink-faint); }
.fragment p, .fragment blockquote { margin: 0 0 0.7rem; padding: 0; }
.fragment p:last-child { margin-bottom: 0; }
.fragment .orig { font-size: 1.06rem; }
.fragment .form-label {
  font-family: var(--sans); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint); margin: 0 0 0.25rem;
}
.fragment .permalink { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-faint); text-decoration: none; }
.fragment .permalink:hover { color: var(--accent-ink); }
html.has-js .fragment .hidden-form { display: none; }

/* Method + share + footer. */
.method-block { margin: 0 0 0.5rem; }
.method-block p { max-width: 38rem; }
.share-row {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin: 2.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line-soft);
  font-family: var(--sans); font-size: 0.9rem; color: var(--ink-faint);
}
.share-row a, .share-row button {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-soft); background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; cursor: pointer;
}
@media (pointer: coarse) { .share-row a, .share-row button { width: 44px; height: 44px; } }
.share-row a:hover, .share-row button:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
.share-row svg { display: block; }
.copy-status { font-size: 0.85rem; min-height: 1.2em; }
footer.site {
  margin-top: 2.5rem; border-top: 1px solid var(--line);
  padding: 1.5rem 0 3rem; font-family: var(--sans); font-size: 0.88rem; color: var(--ink-faint);
}
footer.site p { margin: 0 0 0.5rem; max-width: 38rem; }
footer.site a { color: inherit; }

.to-top {
  position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink);
  font-family: var(--sans); font-size: 0.8rem; cursor: pointer; z-index: 40;
  display: none; align-items: center; justify-content: center;
}
.to-top.show { display: inline-flex; }
.to-top:hover { border-color: var(--accent-ink); color: var(--accent-ink); }

@media (min-width: 64rem) {
  .wrap { max-width: 46rem; }
  .journey { padding: 1.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .route .fill { transition: none; }
  * { animation: none !important; transition: none !important; }
}

/* Evidence wider than prose; maps and figures break out of the reading column. */
.wrap-wide { max-width: 44rem; margin: 0 auto; padding: 0 1.25rem; }
@media (min-width: 64rem) { .wrap-wide { max-width: 70rem; } }

/* Map: relief canvas with routes, rivers and places drawn from map.json. */
.map-wrap {
  position: relative; margin: 0 0 1.25rem;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.map-wrap canvas.map {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3;
  max-height: 76vh; touch-action: pan-y;
}
.map-wrap canvas.map.dragging { cursor: grabbing; }
.map-wrap canvas.map.over-pin { cursor: pointer; }
.map-fallback { display: block; width: 100%; height: auto; }
.map-fallback .track { fill: none; stroke: var(--line); stroke-width: 3; }
.map-fallback .fill { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 7 5; }
.map-fallback .stop-dot { fill: var(--bg-raised); stroke: var(--ink-faint); stroke-width: 2; }
.map-fallback text { font-family: var(--sans); font-size: 12px; fill: var(--ink-soft); }
html.has-js .map-live .map-fallback { display: none; }
html.map-failed .map-live .map-fallback { display: block; }
html.map-failed canvas.map { display: none; }
.map-tools {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 3;
  display: flex; gap: 0.4rem;
}
html.map-failed .map-tools { display: none; }
.map-tools button {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink);
  font-size: 1.25rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.map-tools button:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.map-tools button:disabled { opacity: 0.4; cursor: default; }
.map-credit {
  margin: 0; padding: 0.45rem 0.9rem;
  font-family: var(--sans); font-size: 0.75rem; color: var(--ink-faint);
  border-top: 1px solid var(--line-soft);
}
.map-credit a { color: inherit; }
.pin-tip {
  position: fixed; z-index: 70; max-width: 17rem;
  background: var(--bg-raised); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.55rem 0.75rem; font-family: var(--sans); font-size: 0.85rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.pin-tip[hidden] { display: none; }
.pin-tip b { display: block; font-size: 0.92rem; }
.pin-tip .d { display: block; color: var(--ink-faint); font-size: 0.78rem; margin-top: 0.1rem; }

/* Journey over the map: the map sticks while the steps scroll past it. */
.journey-map .stop-panel blockquote { font-size: 1.15rem; }
@media (min-width: 64rem) {
  .journey-cols { display: grid; grid-template-columns: 7fr 5fr; gap: 1.25rem; align-items: start; }
  .journey-cols .map-wrap { margin-bottom: 0; position: sticky; top: 4.25rem; }
  .step { min-height: 58vh; }
}
@media (max-width: 63.99rem) {
  .journey-cols .map-wrap { position: sticky; top: 6rem; z-index: 5; }
}

/* Waves. */
.wave { scroll-margin-top: 4.25rem; margin: 0 0 0.5rem; }
.wave h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.wave h3 .when { font-family: var(--sans); font-size: 0.85rem; font-weight: 400; color: var(--ink-faint); }
.wave-note {
  border-left: 3px solid var(--accent);
  background: var(--bg-raised);
  padding: 0.7rem 1rem; margin: 0 0 1.25rem; font-size: 0.95rem; color: var(--ink-soft);
}
.wave-note strong { color: var(--ink); }

/* Source-page figures. */
.fig-group { margin: 0 0 1.5rem; }
.fig-group > h3 { font-size: 1.05rem; margin: 1.5rem 0 0.75rem; }
.fig-grid { display: grid; gap: 1rem; margin: 0 0 1rem; }
@media (min-width: 40rem) { .fig-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .fig-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 64rem) { .fig-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.fig-grid figure {
  margin: 0; background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.7rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.fig-grid img {
  display: block; width: 100%; height: auto; border-radius: 4px;
  border: 1px solid var(--line-soft); background: #fff;
}
.fig-grid figcaption { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-soft); }
.fig-grid figcaption .pg { font-weight: 700; color: var(--ink); }
.zoom-btn {
  align-self: flex-start; font-family: var(--sans); font-size: 0.85rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 8px; padding: 0.45rem 0.9rem; min-height: 40px;
}
.zoom-btn:hover { border-color: var(--accent-ink); color: var(--accent-ink); }

/* Figure viewer dialog. */
.fig-viewer { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--bg); color: var(--ink); max-width: min(70rem, 96vw); width: max-content; }
.fig-viewer::backdrop { background: rgba(10, 8, 5, 0.72); }
.fig-viewer .viewer-bar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line-soft);
  font-family: var(--sans); font-size: 0.88rem;
}
.fig-viewer .viewer-bar .spacer { flex: 1 1 auto; }
.fig-viewer .viewer-bar button {
  font-family: var(--sans); font-size: 0.88rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink);
  border-radius: 8px; padding: 0.4rem 0.8rem; min-height: 40px; min-width: 2.75rem;
}
.fig-viewer .viewer-bar button:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.fig-viewer .viewer-stage { overflow: hidden; max-height: 78vh; touch-action: none; background: var(--bg-sunken); }
.fig-viewer .viewer-stage img { display: block; max-width: none; transform-origin: 0 0; }

/* Reading progress: a hairline under the top edge. */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none; }
.progress i { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }

/* Reading rail: chapter dots on wide screens. */
.rail {
  position: fixed; right: 1rem; top: 50%; transform: translateY(-50%); z-index: 30;
  display: none; flex-direction: column; gap: 0.6rem;
}
@media (min-width: 80rem) { .rail { display: flex; } }
.rail a {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem;
  text-decoration: none; color: var(--ink-faint); font-family: var(--sans); font-size: 0.8rem;
  min-height: 24px;
}
.rail a span {
  opacity: 0; transform: translateX(6px); transition: opacity 0.2s, transform 0.2s;
  background: var(--bg-raised); color: var(--ink); padding: 0.15rem 0.55rem;
  border-radius: 4px; border: 1px solid var(--line); white-space: nowrap;
}
.rail a:hover span, .rail a:focus-visible span { opacity: 1; transform: none; }
.rail i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink-faint); flex: none; transition: background 0.2s, transform 0.2s; }
.rail a[aria-current="true"] { color: var(--accent-ink); }
.rail a[aria-current="true"] i { background: var(--accent); border-color: var(--accent); transform: scale(1.35); }

/* Hero calls to action. */
.cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1.25rem 0 0; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 650;
  border-radius: 999px; padding: 0.6rem 1.2rem; min-height: 44px;
  border: 1px solid var(--accent-ink);
}
.btn-solid { background: var(--accent-ink); color: var(--bg); }
.btn-solid:hover { color: var(--bg); filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--accent-ink); }
.btn-ghost:hover { background: var(--accent-wash); }

/* Next-fragment bridges. */
.next-frag { font-family: var(--sans); font-size: 0.88rem; margin: 0.9rem 0 0; }
.next-frag a { color: var(--accent-ink); text-decoration: none; }
.next-frag a:hover { text-decoration: underline; }

/* FAQ. */
.faq details {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); margin: 0 0 0.6rem; padding: 0.85rem 1.1rem;
}
.faq summary { cursor: pointer; font-weight: 650; font-size: 1.02rem; }
.faq summary:hover { color: var(--accent-ink); }
.faq details p { margin: 0.6rem 0 0; color: var(--ink-soft); }
.faq details p a { color: var(--accent-ink); }
