/* Exploratori medievali — portolan chart room. Light: vellum. Dark: abyssal. */
:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f6efe0;
  --bg-raise: #fffaf0;
  --bg-deep: #ece1c8;
  --ink: #232a33;
  --ink-soft: #57534a;
  --line: #d3c5a3;
  --route: #a83a2c;
  --route-ink: #7e2a1f;
  --gold: #8a6d1f;
  --sea: #e9dfc6;
  --land: #f4ecda;
  --coast: #5c5138;
  --river: #7d9aa3;
  --stipple: #b89a5b;
  --hatch: #a8957a;
  --label: #3a352a;
  --label-halo: #f2ead6;
  --grat: #c9b98f;
  --rose: #6d6046;
  --btn-ink: #fff8ea;
  --shadow: 0 1px 2px rgba(60, 48, 20, .12), 0 6px 24px rgba(60, 48, 20, .10);
  --radius: 10px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1526;
  --bg-raise: #122036;
  --bg-deep: #070e1b;
  --ink: #e9e2d0;
  --ink-soft: #b3ac99;
  --line: #2b3c5a;
  --route: #e0664f;
  --route-ink: #f0927d;
  --gold: #d3a94e;
  --sea: #0e1a2f;
  --land: #16233a;
  --coast: #8d97a8;
  --river: #3f6068;
  --stipple: #6e5a37;
  --hatch: #5c4f3e;
  --label: #e9e2d0;
  --label-halo: #0b1526;
  --grat: #22334f;
  --rose: #7e8ba0;
  --btn-ink: #101724;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
main { display: block; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.12; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); margin: .35em 0 .3em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); margin: .3em 0 .5em; }
h3 { font-size: clamp(1.35rem, 2.6vw, 1.8rem); margin: 1.4em 0 .4em; }
p { margin: 0 0 1em; }
a { color: var(--route-ink); text-underline-offset: .15em; }
[data-theme="dark"] a { color: var(--route-ink); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2.5px solid var(--route); outline-offset: 2px; border-radius: 4px; }
section { scroll-margin-top: 64px; }
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--ink); color: var(--bg); padding: .6em 1em; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Topbar: one line, house pattern. */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .9rem;
  height: 52px; padding: 0 .9rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: .95rem;
}
.topbar .home { font-family: var(--serif); font-style: italic; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar .home:hover { text-decoration: underline; }
.topnav { display: flex; gap: 1rem; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--ink-soft); text-decoration: none; }
.topnav a:hover { color: var(--ink); text-decoration: underline; }
.topnav a[aria-current="true"] { color: var(--ink); font-weight: 650; }
.spacer { flex: 1 1 auto; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: .15em .8em;
  color: var(--ink); text-decoration: none; white-space: nowrap; font-size: .9rem;
}
.chip:hover { border-color: var(--route); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--route); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

/* Reading rail: fixed section dots, desktop only. */
.rail { display: none; position: fixed; top: 50%; right: 1.1rem; transform: translateY(-50%); flex-direction: column; align-items: flex-end; gap: .5rem; z-index: 30; }
@media (min-width: 76rem) { .rail { display: flex; } }
.rail-dot { position: relative; display: flex; align-items: center; justify-content: flex-end; width: 14px; padding: .15rem 0; text-decoration: none; }
.rail-dot::after { content: ""; position: absolute; right: -6px; left: -24px; top: -4px; bottom: -4px; }
.rail-dot.sep { margin-top: .45rem; }
.rail-dot .dot { display: block; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--ink-soft); opacity: .55; transition: background-color .15s, transform .15s, opacity .15s, border-color .15s; }
.rail-dot:hover .dot, .rail-dot:focus-visible .dot { opacity: 1; background: var(--ink-soft); }
.rail-dot.active .dot { background: var(--route); border-color: var(--route); opacity: 1; transform: scale(1.45); }
.rail-label {
  position: absolute; right: 100%; top: 50%; margin-top: -.85rem; margin-right: .55rem;
  font-size: .78rem; line-height: 1.2; color: var(--ink); white-space: nowrap;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .6rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateX(6px); pointer-events: none; transition: opacity .12s, transform .12s;
}
.rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .rail-dot .dot, .rail-label { transition: none; } }
@media print { .rail { display: none; } }

/* Layout rhythm. */
main > section, .footer { padding-inline: max(1.1rem, 50vw - 34rem); }
main > section { padding-block: 3.2rem 1rem; }
.kicker {
  font-family: var(--serif); font-style: italic; font-size: 1.12rem;
  color: var(--route-ink); margin: 0 0 .2em;
}
.lede { font-size: 1.16rem; color: var(--ink-soft); max-width: 44rem; }
[data-theme="dark"] .kicker { color: var(--route-ink); }
.note { color: var(--ink-soft); font-size: .95rem; }
.prose { max-width: 44rem; }
.prose p { margin-bottom: 1.05em; }

/* Buttons. */
.btn {
  display: inline-block; font-weight: 650; font-size: 1rem;
  background: var(--route); color: var(--btn-ink) !important;
  border: 1.5px solid var(--route); border-radius: var(--radius);
  padding: .62em 1.25em; text-decoration: none; cursor: pointer; line-height: 1.35;
}
[data-theme="dark"] .btn { color: #101724 !important; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink) !important; border-color: var(--ink-soft); }
.btn.small { font-size: .92rem; padding: .45em 1em; }
.cta-row { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.4em 0; }

/* Hero: copy on top, full-width map below. */
.hero { padding-top: 2.2rem; }
.hero-copy { max-width: 46rem; }
.deck { font-size: 1.22rem; color: var(--ink-soft); max-width: 38rem; }
.stats { list-style: none; display: flex; gap: 1.6rem; padding: 0; margin: 1.6em 0 0; flex-wrap: wrap; }
.stats li { display: grid; }
.stats strong { font-family: var(--serif); font-size: 1.9rem; line-height: 1; color: var(--ink); }
.stats span { font-size: .92rem; color: var(--ink-soft); }
.hero-fig { margin: 0; }
.hero-fig figcaption, .atlas-fig figcaption { font-size: .88rem; color: var(--ink-soft); margin-top: .5em; max-width: 60ch; }

/* Maps. */
.bm-sea { fill: var(--sea); }
.bm-grat { fill: none; stroke: var(--grat); stroke-width: .7; vector-effect: non-scaling-stroke; }
.bm-land { fill: var(--land); stroke: var(--coast); stroke-width: .8; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.bm-desert { fill: url(#stipple); }
.stip { fill: var(--stipple); }
.bm-mount { fill: url(#hatch); }
.hatchline { stroke: var(--hatch); stroke-width: 1.1; }
.bm-lake { fill: var(--sea); stroke: var(--coast); stroke-width: .6; vector-effect: non-scaling-stroke; }
.bm-river { fill: none; stroke: var(--river); stroke-width: .9; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.bm-frame { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.map { display: block; width: 100%; height: auto; background: var(--sea); border: 1px solid var(--line); border-radius: 6px; }
.map .rose { color: var(--rose); }
.map .route { fill: none; stroke: var(--route); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.map.master .route { stroke-width: 2.4; opacity: .8; transition: opacity .25s ease; }
.map.master.focus .route { opacity: .14; }
.map.master.focus .route.lit { opacity: 1; stroke-width: 3.2; }
.map .dot { fill: var(--route); opacity: .45; }
.map.master.focus .dot { opacity: .1; }
.map.master.focus .dot.lit { opacity: .9; }
.map .stop circle { fill: var(--bg-raise); stroke: var(--route); stroke-width: 2; }
.map .stop.hit circle { fill: var(--route); }
.map .stop text { font-family: var(--sans); font-size: 11.5px; font-weight: 650; fill: var(--label); paint-order: stroke; stroke: var(--label-halo); stroke-width: 3.2px; stroke-linejoin: round; }
.regions text { font-family: var(--serif); font-style: italic; font-size: 13px; fill: var(--ink-soft); letter-spacing: .1em; text-anchor: middle; paint-order: stroke; stroke: var(--label-halo); stroke-width: 3px; stroke-linejoin: round; }
.regions .sea text { font-size: 12px; }
.marker-dot { fill: var(--route); stroke: var(--bg-raise); stroke-width: 2; }
.marker-halo { fill: var(--route); opacity: .22; }
.map-fig { position: relative; margin: 0 0 1rem; }
.hero-stage, .atlas-stage { position: relative; }
.hero-fig { margin: 1.8rem 0 0; }
.hero-bar { display: flex; align-items: center; gap: 1rem; margin-top: .55rem; }
.hero-year { display: flex; align-items: baseline; gap: .8rem; line-height: 1.2; pointer-events: none; min-width: 0; }
.hero-year-num { font-family: var(--serif); font-weight: 700; font-size: clamp(1.4rem, 2.8vw, 1.9rem); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-year-name { font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-bar .replay { position: static; margin-left: auto; flex: 0 0 auto; }
.hud { position: absolute; left: .6rem; top: .6rem; display: none; align-items: center; gap: .55rem; background: color-mix(in srgb, var(--bg-raise) 93%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; box-shadow: var(--shadow); max-width: calc(100% - 1.2rem); }
.hud.show { display: flex; }
.hud-main { display: flex; flex-direction: column; line-height: 1.25; }
.hud-name { font-family: var(--serif); font-weight: 700; font-size: 1rem; }
.hud-years { font-size: .75rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.hud-km { border-left: 1px solid var(--line); padding-left: .55rem; }
.hud-km-num { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--route-ink); white-space: nowrap; }

/* Quiz. */
.quiz-sec { padding-top: 1rem; }
.quiz {
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 1.4rem 1.5rem; max-width: 46rem;
}
.quiz h2 { font-size: 1.25rem; margin: 0 0 .2em; font-family: var(--sans); font-weight: 700; }
.quiz-q { font-family: var(--serif); font-size: 1.45rem; margin: 0 0 .7em; }
.quiz-opts { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.quiz-opt {
  width: 100%; text-align: left; font-size: 1.02rem; cursor: pointer;
  background: var(--bg); color: var(--ink); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: .55em .9em;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--route); }
.quiz-opt:disabled { cursor: default; opacity: .75; }
.quiz-opt.right { border-color: var(--route); background: color-mix(in srgb, var(--route) 12%, var(--bg)); opacity: 1; }
.quiz-opt.wrong-pick { opacity: .45; text-decoration: line-through; }
.quiz-msg { min-height: 1.6em; margin: .6em 0 0; color: var(--ink-soft); }
.quiz-reveal { border-top: 1px dashed var(--line); margin-top: .7em; padding-top: .7em; }
.quiz-reveal p { margin-bottom: .5em; }

/* Atlas. */
.atlas-chips { display: flex; flex-wrap: wrap; gap: .5rem; row-gap: .55rem; margin: 1em 0 1.2em; }
.atlas-btn {
  flex: 0 0 auto; font-size: .93rem; cursor: pointer;
  background: var(--bg-raise); color: var(--ink); border: 1.5px solid var(--line);
  border-radius: 999px; padding: .35em 1em;
}
.atlas-btn.on { border-color: var(--route); background: color-mix(in srgb, var(--route) 12%, var(--bg-raise)); font-weight: 650; }
.atlas-info { min-height: 4.2em; }
.atlas-sum { font-size: 1.05rem; }
.atlas-sum span { color: var(--ink-soft); }

/* Chapters. */
.voyages-sec > .lede { margin-bottom: 2.5rem; }
.chapter {
  border-top: 2px solid var(--line); padding: 2.6rem 0 2.2rem;
  display: grid; gap: 0; scroll-margin-top: 60px;
}
.chapter > * { min-width: 0; }
.ch-head h3 { font-size: clamp(2rem, 4.6vw, 3rem); margin: 0 0 .1em; }
.dates { font-family: var(--serif); font-size: 1.3rem; color: var(--route-ink); margin: 0 0 .4em; }
.hook { font-size: 1.18rem; max-width: 44rem; }
.meta { display: flex; gap: 1.4rem; flex-wrap: wrap; color: var(--ink-soft); margin-bottom: .2em; }
.meta strong { color: var(--ink); }
.src-line, .alt-dates { font-size: .92rem; color: var(--ink-soft); }
.player { background: var(--bg-raise); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.1rem; margin: 1.4em 0; }
.p-controls { display: flex; gap: .9rem; align-items: center; margin-top: .9rem; }
.p-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--bg-deep); border: 1px solid var(--line); overflow: hidden; }
.p-bar > span { display: block; height: 100%; width: 0; background: var(--route); border-radius: 999px; }
.p-status { margin: .6em 0 0; font-variant-numeric: tabular-nums; }
.p-cap { font-size: 1.08rem; margin: .3em 0 0; min-height: 2.2em; }
.stops-wrap { margin-top: .8em; border-top: 1px dashed var(--line); padding-top: .6em; }
.stops-wrap summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; }
.stops { margin: .7em 0 0; padding-left: 1.4em; columns: 2; column-gap: 2.5rem; font-size: .96rem; }
.stops li { margin-bottom: .4em; break-inside: avoid; }
.stops .yr { color: var(--ink-soft); }
.brought {
  border-left: 4px solid var(--route); background: var(--bg-raise);
  padding: 1rem 1.2rem; margin: 1.6em 0; max-width: 46rem; border-radius: 0 12px 12px 0;
  overflow: hidden;
}
.brought p { margin: 0; font-size: 1.06rem; }
.fig { margin: 1.8em 0; max-width: 46rem; }
.fig img { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.fig figcaption { font-size: .9rem; color: var(--ink-soft); margin-top: .55em; }
.credit { opacity: .85; }
.fig.inset { float: right; width: min(220px, 42%); margin: .2em 0 .8em 1.2em; }
.close { font-size: 1.12rem; max-width: 44rem; }
.next { font-size: 1.1rem; font-weight: 600; }

/* Timeline. */
.tl { list-style: none; margin: 1.4em 0; padding: 0; display: grid; gap: .5rem; max-width: 56rem; }
.tl li { display: grid; grid-template-columns: 5.2rem 1fr 8.5rem; gap: .8rem; align-items: center; }
.tl-name { font-weight: 650; font-size: .95rem; }
.tl-years { font-size: .9rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tl-track { position: relative; height: 22px; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 999px; }
.tl-bar { position: absolute; top: 3px; bottom: 3px; background: var(--route); border-radius: 999px; }
.tl-bar:hover { filter: brightness(1.15); }
.tl-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--route); border-radius: 50%; }

/* Myths. */
.myths { display: grid; gap: 1.2rem; max-width: 52rem; }
.myth { border-top: 1px solid var(--line); padding-top: 1rem; }
.myth h3 { margin: 0 0 .3em; font-size: 1.3rem; }
.myth p { margin: 0; color: var(--ink-soft); max-width: 44rem; }
.myth p:first-of-type { color: var(--ink); }

/* Logbook. */
.seals { list-style: none; margin: 1.2em 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; max-width: 56rem; }
.seal { display: flex; gap: .7rem; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem; background: var(--bg-raise); }
.seal-disc {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 1.25rem;
  border: 2px dashed var(--ink-soft); color: var(--ink-soft); opacity: .55;
}
.seal.on .seal-disc {
  border: 2px solid var(--route-ink); color: #fff8ea; opacity: 1;
  background: radial-gradient(circle at 35% 30%, var(--route), var(--route-ink));
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.seal.on .seal-disc.pop { animation: stamp .5s ease-out; }
@keyframes stamp { 0% { transform: scale(1.7) rotate(-14deg); opacity: 0; } 60% { transform: scale(.93) rotate(2deg); opacity: 1; } 100% { transform: none; } }
.seal-name { font-size: .92rem; line-height: 1.35; }
.log-progress { font-size: 1.2rem; font-weight: 700; }
.log-empty a { font-weight: 600; }
.share { list-style: none; display: flex; gap: .6rem; flex-wrap: wrap; padding: 0; margin: 0; }
.copy-msg { color: var(--ink-soft); }

/* Method + footer + 404. */
.srclist { columns: 2; column-gap: 2.5rem; max-width: 56rem; padding-left: 1.3em; }
.srclist li { margin-bottom: .45em; break-inside: avoid; font-size: .98rem; }
.footer { border-top: 2px solid var(--line); margin-top: 3rem; padding-block: 2rem 3rem; }
.footer p { margin: 0 0 .5em; }
.flinks { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.missing { max-width: 40rem; margin: 18vh auto; padding: 0 1.2rem; text-align: left; }

@media (max-width: 920px) {
  .stops { columns: 1; }
  .srclist { columns: 1; }
  .tl li { grid-template-columns: 4.6rem 1fr; }
  .tl-years { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 1rem; }
  main > section { padding-block: 2.4rem .8rem; }
  .p-controls { flex-direction: column; align-items: stretch; }
  .p-bar { min-height: 12px; }
  .fig.inset { float: none; width: 100%; margin: 1em 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .map.master .route { transition: none; }
  .seal.on .seal-disc.pop { animation: none; }
}
