@font-face { font-family: "IM Fell"; src: url(fonts/imfell-regular.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell"; font-style: italic; src: url(fonts/imfell-italic.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell SC"; src: url(fonts/imfell-sc.woff2) format("woff2"); font-display: swap; }

:root {
  --paper: #efe2c0;
  --paper-2: #e6d4a8;
  --paper-dark: #d6bf8a;
  --ink: #3b2614;
  --ink-soft: #6b4b2b;
  --red: #9e2f1c;
  --sea-line: rgba(120, 80, 40, .22);
  --land: #e2cc96;
  --land-edge: #8a6536;
  --nut: #7a4a1f;
  --seed: #5c6b2a;
  --pulse: #9e2f1c;
  --quinoa: #b07a1a;
  --dried: #7d2a4a;
  --panel-w: min(420px, 38vw);
  --serif: "IM Fell", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sc: "IM Fell SC", "IM Fell", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--serif);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(255, 250, 230, .55), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(150, 100, 40, .18), transparent 60%),
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(110, 70, 25, .22) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--red); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: .4em .8em; z-index: 10; }
.skip:focus { left: .5em; }

/* Cartouche */
.cartouche { position: relative; display: flex; justify-content: center; padding: 1rem 1rem .4rem; }
.cartouche-inner {
  text-align: center; padding: .5rem 2.2rem .6rem; max-width: 760px;
  border: 1px solid var(--ink-soft); outline: 3px double var(--ink-soft); outline-offset: 4px;
  background: rgba(245, 235, 205, .6);
  border-radius: 50% / 18%;
}
.kicker { font-family: var(--serif); font-style: italic; margin: 0; color: var(--ink-soft); font-size: .9rem; letter-spacing: .04em; }
h1 { font-family: var(--sc); font-weight: normal; margin: 0; font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: .06em; color: var(--red); }
.subtitle { margin: .1rem 0 0; font-style: italic; font-size: clamp(.95rem, 2vw, 1.1rem); }
.lang { position: absolute; right: 1rem; top: 1rem; display: flex; gap: .2rem; }
.lang button, .toolbar button {
  font: inherit; font-family: var(--sc); font-size: .95rem; color: var(--ink);
  background: transparent; border: 1px solid var(--ink-soft); padding: .15rem .55rem; cursor: pointer; border-radius: 2px;
}
.lang button[aria-pressed="true"], .toolbar button[aria-pressed="true"], .toolbar button[aria-selected="true"] {
  background: var(--ink); color: var(--paper);
}

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; justify-content: center; padding: .5rem 1rem; }
.toolbar > div { display: flex; flex-wrap: wrap; gap: .3rem; }

main { position: relative; flex: 1; display: flex; min-height: 0; }

/* Map */
.map-wrap { position: relative; flex: 1; min-height: 60vh; }
#map { display: block; width: 100%; height: 100%; min-height: 60vh; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
.land, .borders, .graticule, .rhumb, .frame { vector-effect: non-scaling-stroke; }
.sphere-bg { fill: rgba(239, 226, 192, .35); }
.frame { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.frame-2 { fill: none; stroke: var(--ink-soft); stroke-width: .6; }
.graticule { fill: none; stroke: rgba(90, 60, 30, .18); stroke-width: .5; stroke-dasharray: 2 3; }
.rhumb { stroke: var(--sea-line); stroke-width: .6; }
.rhumb.main { stroke: rgba(158, 47, 28, .28); }
.coast-halo { fill: none; stroke: rgba(110, 75, 35, .16); stroke-width: 7; stroke-linejoin: round; }
.land { fill: var(--land); stroke: var(--land-edge); stroke-width: .7; }
.land-hatch { fill: url(#hatch); stroke: none; pointer-events: none; }
.borders { fill: none; stroke: rgba(110, 75, 35, .5); stroke-width: .45; stroke-dasharray: 1.5 1.5; }
.sea-label { font-family: var(--serif); font-style: italic; fill: rgba(90, 60, 30, .55); font-size: 15px; letter-spacing: .3em; text-anchor: middle; pointer-events: none; }
.rose { pointer-events: none; }
.home-port text { font-family: var(--serif); font-style: italic; font-size: 13px; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; }

.pin { cursor: pointer; }
.pin circle.dot { stroke: #2a1a0c; stroke-width: 1; transition: r .15s; }
.pin.ambiguous circle.dot { stroke-dasharray: 2 1.5; fill-opacity: .75; }
.pin circle.hit { fill: transparent; }
.pin:hover circle.dot, .pin:focus circle.dot { r: 7.5; }
.pin.selected circle.dot { stroke: var(--red); stroke-width: 2.4; r: 8; }
.pin.dim { opacity: .18; }
.pin:focus { outline: none; }
.g-nut { fill: var(--nut); background: var(--nut); } .g-seed { fill: var(--seed); background: var(--seed); }
.g-pulse { fill: var(--pulse); background: var(--pulse); } .g-quinoa { fill: var(--quinoa); background: var(--quinoa); }
.g-dried { fill: var(--dried); background: var(--dried); }
.panel:focus { outline: none; }

.tooltip {
  position: absolute; pointer-events: none; background: var(--paper); border: 1px solid var(--ink-soft);
  padding: .1rem .5rem; font-size: .95rem; white-space: nowrap; box-shadow: 1px 2px 0 rgba(60, 40, 20, .2); z-index: 3;
}
.legend { position: absolute; left: 1rem; bottom: 1rem; background: rgba(239, 226, 192, .85); border: 1px solid var(--ink-soft); padding: .35rem .6rem; font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; margin-right: .6rem; }
.legend i { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block; border: 1px solid #2a1a0c; }

/* Panel: desktop side, mobile bottom sheet */
.panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: var(--panel-w); overflow-y: auto;
  background: var(--paper); border-left: 1px solid var(--ink-soft);
  box-shadow: -4px 0 14px rgba(60, 40, 20, .18); padding: 1rem 1.2rem 2rem; z-index: 4;
}
.panel-close { position: sticky; top: 0; float: right; font-size: 1.6rem; line-height: 1; background: none; border: none; color: var(--ink); cursor: pointer; }
.panel h2 { font-family: var(--sc); font-weight: normal; color: var(--red); margin: .2rem 0 .1rem; font-size: 1.7rem; }
.panel .group { font-style: italic; color: var(--ink-soft); margin: 0 0 .6rem; }
.panel h3 { font-family: var(--sc); font-weight: normal; font-size: 1.05rem; letter-spacing: .05em; border-bottom: 1px solid var(--paper-dark); margin: 1.1rem 0 .4rem; }
.origin { margin: .3rem 0; }
.origin .where { font-size: 1.05rem; }
.origin .who { font-style: italic; }
.flag { display: inline-block; font-family: var(--sc); font-size: .8rem; border: 1px solid currentColor; padding: 0 .35rem; margin-left: .3rem; color: var(--red); }
.engravings { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .6rem 0; }
.engravings figure { margin: 0; }
.engravings img { width: 100%; aspect-ratio: 1; object-fit: contain; border: 1px solid var(--ink-soft); mix-blend-mode: multiply; }
.engravings figcaption { font-size: .78rem; font-style: italic; color: var(--ink-soft); }
.engraving-empty {
  aspect-ratio: 1; border: 1px dashed var(--ink-soft); display: grid; place-items: center; text-align: center; padding: .4rem;
  font-size: .8rem; font-style: italic; color: var(--ink-soft);
  background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(90, 60, 30, .08) 5px 6px);
}
.card { border: 1px solid var(--paper-dark); background: rgba(255, 250, 235, .45); padding: .55rem .75rem; margin: .5rem 0; }
.card .tag { font-family: var(--sc); font-size: .78rem; color: var(--ink-soft); letter-spacing: .05em; }
.card h4 { margin: .05rem 0 .2rem; font-weight: normal; font-size: 1.12rem; }
.card p { margin: 0; }
.card .src { font-size: .82rem; margin-top: .3rem; color: var(--ink-soft); }
.video-slot button {
  width: 100%; aspect-ratio: 16 / 9; font: inherit; cursor: pointer; border: 1px solid var(--ink-soft); color: var(--ink);
  background: repeating-linear-gradient(45deg, rgba(90, 60, 30, .06) 0 6px, transparent 6px 12px), var(--paper-2);
  display: grid; place-items: center; text-align: center; padding: 1rem;
}
.video-slot button .play { font-size: 2.2rem; color: var(--red); display: block; }
.video-slot iframe { width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--ink-soft); }
.video-slot .note { font-size: .8rem; font-style: italic; color: var(--ink-soft); }
.links li, .sources li { margin: .15rem 0; }
.links, .sources { padding-left: 1.1rem; margin: .2rem 0; }
.small { font-size: .85rem; }

/* List view */
.list-view { flex: 1; padding: .5rem clamp(1rem, 4vw, 3rem) 2rem; max-width: 1000px; margin: 0 auto; }
.list-view h2 { font-family: var(--sc); font-weight: normal; color: var(--red); border-bottom: 1px solid var(--ink-soft); margin: 1.2rem 0 .3rem; }
.list-view h3 { font-weight: normal; font-style: italic; margin: .7rem 0 .2rem; font-size: 1.1rem; }
.list-view ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .3rem .5rem; }
.list-view li button {
  font: inherit; background: transparent; border: none; border-bottom: 1px dotted var(--ink-soft); color: var(--ink); cursor: pointer; padding: 0 .1rem;
}
.list-view li button:hover { color: var(--red); }
.list-view li .dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .3rem; vertical-align: middle; border: 1px solid #2a1a0c; }
.terra { margin-top: 1.5rem; padding: .6rem 1rem; border: 1px dashed var(--ink-soft); }
.terra h2 { border: none; margin-top: 0; }

.colophon { text-align: center; padding: .8rem 1rem 1.2rem; color: var(--ink-soft); }
.colophon p { margin: .2rem auto; max-width: 900px; }

@media (max-width: 860px) {
  body { font-size: 17px; }
  .lang { position: static; justify-content: center; margin-top: .5rem; }
  .cartouche { flex-direction: column; align-items: center; }
  .cartouche-inner { padding: .4rem 1.2rem; border-radius: 40% / 14%; }
  .panel {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 72vh;
    border-left: none; border-top: 1px solid var(--ink-soft); border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 16px rgba(60, 40, 20, .25);
  }
  .panel::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 2px; background: var(--ink-soft); margin: -.4rem auto .6rem; opacity: .5; }
  .legend { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
