
:root {
  color-scheme: light dark;

  /* ---- geometry, type, motion: identical in both skins ---- */
  --r-sm: 4px; --r-md: 7px; --bar: 4px;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font: 'Inter Tight', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --fs-kicker: 10.5px; --fs-meta: 10.5px; --fs-body: 15px;
  --lh-body: 1.7; --lh-tight: .98; --track-kicker: 2.4px;
  --ease: cubic-bezier(.22,.61,.36,1); --t-fast: .16s;
}

/* ------------------------------------------------------------- DARK skin */
:root, [data-theme="dark"] {
  --bg: #0b0d10;
  --panel: #141a21;
  --panel-2: #10151b;
  --line: #1e232b;

  --ink: #ede9e4;
  --ink-soft: #bdb6af;
  --ink-dim: #a9a29b;
  --mut: #8c857e;

  --accent: #e63b2e;
  --accent-text: #f2564a;
  --accent-fill: #cc2b1d;
  --accent-ink: #ffffff;

  --m-intl: #8aa0b0;
  --m-flight: #f2564a;
  --m-boat: #3fa8cf;
  --m-train: #2ec48a;
  --m-road: #ffb347;
  --m-start: #ede9e4;
  --m-opt: #ffb347;
  --opt-text: #ffb347;   /* 9.83:1 on --panel */

  --shadow-pop: 0 2px 16px rgba(0,0,0,.5);
  --attrib-bg: rgba(20,26,33,.84);
}

/* ------------------------------------------------------------ LIGHT skin */
[data-theme="light"] {
  --bg: #f7f5f1;
  --panel: #fdfcfa;
  --panel-2: #f1eee9;
  --line: #ddd8d0;

  --ink: #131313;
  --ink-soft: #3c3832;
  --ink-dim: #4a453e;
  --mut: #6e6a64;

  --accent: #cc2b1d;
  --accent-text: #cc2b1d;
  --accent-fill: #cc2b1d;
  --accent-ink: #ffffff;

  --m-intl: #5d6b76;
  --m-flight: #cc2b1d;
  --m-boat: #15607e;
  --m-train: #1c7a53;
  --m-road: #8a5610;
  --m-start: #131313;
  --m-opt: #a86b12;
  --opt-text: #7f4f0d;   /* #a86b12 measured 4.29:1 as 9px text on --panel */

  --shadow-pop: 0 2px 14px rgba(19,19,19,.14);
  --attrib-bg: rgba(253,252,250,.84);
}

/* Dark is the default for everyone, not just visitors whose OS is dark.
   A visitor on a light OS still lands on dark and can opt out with the toggle;
   the choice then persists in localStorage under mm-theme. */

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { display:flex; height:100vh; overflow:hidden; }

#side {
  width: 412px; flex:0 0 412px;
  background: var(--panel);
  border-right: var(--bar) solid var(--accent);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 30px 26px 40px;
}
#map { flex:1; height:100vh; background: var(--panel-2); }

/* ---------------------------------------------------------------- header */
header { margin-bottom: 22px; }
.head-row { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 2.6vw, 36px);
  line-height: var(--lh-tight);
  letter-spacing: -.01em;
  margin: 0 0 8px;
  color: var(--ink);
}
.sub { font-size: 13.5px; line-height: 1.5; color: var(--ink-dim); margin: 0; }

#theme {
  flex:0 0 auto; margin-top:2px;
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-meta);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 9px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
#theme:hover { color: var(--accent-text); border-color: var(--accent); }
#theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----------------------------------------------------------------- stats */
.stats {
  display:grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--line);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin: 20px 0 18px;
}
.stat { background: var(--panel); padding: 11px 8px; text-align:center; }
.stat .n {
  font-family: var(--font-mono); font-weight:500;
  font-size: 17px; color: var(--ink); line-height:1.2;
}
.stat .l {
  font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut);
  margin-top: 3px; line-height:1.3;
}

/* ---------------------------------------------------------------- legend */
.legend {
  display:flex; flex-wrap:wrap; gap: 4px 14px;
  font-size: var(--fs-meta); color: var(--mut);
  text-transform: uppercase; letter-spacing: 1.2px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.legend span { display:inline-flex; align-items:center; gap:5px; }
.legend i { width: 15px; height: 0; border-top: 3px solid; display:inline-block; }
/* Optional shares the gold family with Road in the dark skin, so the swatch
   carries the dash the map draws rather than relying on hue alone. */
.legend i[data-mode="opt"] { border-top-style: dashed; }
.legend i[data-mode="intl"] { border-top-style: dashed; }

/* -------------------------------------------------------------- timeline */
.eyebrow {
  font-size: var(--fs-kicker); text-transform:uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut);
  margin: 18px 0 10px;
}
.timeline { position:relative; }
.leg { position:relative; padding-left: 20px; }
.leg::before {
  content:''; position:absolute; left:4px; top:0; bottom:0;
  width:1px; background: var(--line);
}
.leg:last-child::before { bottom: 50%; }
.dot {
  position:absolute; left:0; top:15px;
  width:9px; height:9px; border-radius:50%;
  background: var(--accent); border:2px solid var(--panel);
}
.leg.opt .dot { background: var(--m-opt); }

.card {
  background: var(--panel); border:1px solid var(--line);
  border-left: var(--bar) solid transparent;
  border-radius: var(--r-md);
  padding: 10px 12px; margin: 6px 0;
  cursor:pointer;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.card:hover { background: var(--panel-2); }
.card.active { border-left-color: var(--accent); background: var(--panel-2); }

.top { display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
.place { font-weight:600; font-size:15px; color: var(--ink); line-height:1.3; }
.days {
  font-family: var(--font-mono); font-size: var(--fs-meta);
  color: var(--mut); white-space:nowrap; letter-spacing:-.02em;
}
.badge {
  font-family: var(--font); font-size:9px; font-weight:500;
  text-transform:uppercase; letter-spacing:1.4px;
  color: var(--opt-text); border:1px solid var(--m-opt);
  border-radius: var(--r-sm); padding:1px 4px; margin-left:6px;
  vertical-align: 1px;
}

/* one line: mode chip, movement, cost */
.meta {
  display:flex; align-items:center; flex-wrap:wrap; gap:6px;
  margin-top:6px;
  font-family: var(--font-mono); font-size: var(--fs-meta);
  color: var(--ink-soft); letter-spacing:-.01em; line-height:1.5;
}
.pill {
  display:inline-flex; align-items:center; gap:4px;
  background: var(--panel-2);
  border-left: 3px solid var(--ink);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 1px 6px 1px 5px;
  font-weight:500; white-space:nowrap;
}
.nights {
  color: var(--ink); font-weight: 500;
  border-bottom: 1px solid var(--accent); padding-bottom: 1px;
}
.cost { color: var(--mut); }
.cost::before { content:'· '; }

.note { margin-top:5px; font-size: 13px; line-height:1.55; color: var(--ink-dim); }

/* ---------------------------------------------------------------- footer */
.foot { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 8px; }
.foot details { border-bottom: 1px solid var(--line); }
.foot summary {
  cursor:pointer; list-style:none; padding: 10px 0;
  font-size: var(--fs-kicker); text-transform:uppercase;
  letter-spacing: var(--track-kicker); color: var(--ink-soft);
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
.foot summary::-webkit-details-marker { display:none; }
.foot summary::after {
  content:'+'; font-family: var(--font-mono); font-size:14px;
  color: var(--accent-text); line-height:1;
}
.foot details[open] summary::after { content:'\2212'; }
.foot .body { font-size: 13px; line-height:1.6; color: var(--ink-dim); padding: 0 0 12px; }
.foot .body ul { margin:0; padding-left: 16px; }
.foot .body li { margin-bottom: 4px; }
.foot .warn summary { color: var(--accent-text); }

/* ----------------------------------------------------------------- popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  border-top: 3px solid var(--accent);
  background: var(--panel); color: var(--ink);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 11px 13px; font-family: var(--font); }
.leaflet-popup-close-button { color: var(--mut) !important; }
.pop-h { font-weight:600; font-size:14.5px; color: var(--ink); margin-bottom:3px; line-height:1.3; }
.pop-m {
  font-family: var(--font-mono); font-size: var(--fs-meta);
  color: var(--mut); letter-spacing:-.01em;
}
.pop-n { margin-top:5px; font-size:12.5px; color: var(--ink-dim); line-height:1.5; }
.leaflet-container { font-family: var(--font); background: var(--panel-2); }
.leaflet-control-attribution {
  font-size: 9.5px; background: var(--attrib-bg); color: var(--mut);
}
.leaflet-control-attribution a { color: var(--mut); }
.leaflet-bar a {
  background: var(--panel); color: var(--ink); border-bottom-color: var(--line);
}
.leaflet-bar a:hover { background: var(--panel-2); color: var(--accent-text); }

/* ----------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  #app { flex-direction: column; height:auto; overflow:visible; }
  #map { height: 46vh; min-height: 300px; order:-1; flex:none;
         border-bottom: var(--bar) solid var(--accent); }
  #side { width:100%; flex:none; border-right:none; height:auto;
          overflow:visible; padding: 22px 18px 36px; }
  html, body { height:auto; }
}


/* ---------------------------------------------------------------- intake */
/* ---- screen switching -------------------------------------------------
   One class on <html> decides which of the four screens is mounted. Only the
   result view wants a locked 100vh body; the others scroll. */
#intake, #confirm, #waiting, #app { display: none; }
.screen-intake  #intake  { display: flex; }
.screen-confirm #confirm { display: flex; }
.screen-waiting #waiting { display: flex; }
.screen-result  #app     { display: flex; }

html:not(.screen-result), html:not(.screen-result) body { height: auto; overflow: auto; }

#intake, #confirm {
  min-height: 100vh; align-items: center; justify-content: center;
  padding: 48px 24px; background: var(--bg);
}

.intake-inner { width: 100%; max-width: 660px; }

.mark {
  display: block; width: 76px; height: 76px; margin-bottom: 14px; margin-left: -3px;
  /* black ink -> invert on the dark ground, leave alone on paper */
  filter: invert(1);
}
[data-theme="light"] .mark { filter: none; }

.brandline {
  font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut);
  display: flex; align-items: center; gap: 9px; margin-bottom: 20px;
}
.brandline::before {
  content: ''; width: 26px; height: 0;
  border-top: var(--bar) solid var(--accent); display: inline-block;
}

#intake h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(31px, 4.5vw, 50px); line-height: 1.04;
  letter-spacing: -.015em; margin: 0 0 14px; color: var(--ink);
}
.h1-sub { color: var(--accent-text); }
.lede {
  font-size: 17px; line-height: 1.55; color: var(--ink-soft);
  margin: 0 0 32px; max-width: 44ch;
}

.field { margin-bottom: 26px; }
.field > label {
  display: block; font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut); margin-bottom: 9px;
}
textarea {
  width: 100%; min-height: 104px; resize: vertical;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-left: var(--bar) solid var(--accent);
  border-radius: var(--r-md); padding: 13px 15px;
  font-family: var(--font); font-size: 15.5px; line-height: 1.55;
  transition: border-color var(--t-fast) var(--ease);
}
textarea::placeholder { color: var(--mut); }
textarea:focus { outline: none; border-color: var(--accent); border-left-color: var(--accent); }

.examples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.ex {
  background: none; border: 1px dashed var(--line); border-radius: var(--r-sm);
  color: var(--mut); font-family: var(--font); font-size: 12.5px;
  padding: 5px 9px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ex:hover { color: var(--accent-text); border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font); font-size: 14px; padding: 9px 14px 9px 11px;
  cursor: pointer; text-align: left;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent-fill); color: var(--accent-ink);
  border-color: var(--accent-fill);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 17px; height: 17px; flex: 0 0 auto; opacity: .75; }
.chip[aria-pressed="true"] .ico { opacity: 1; }
.chip:hover .ico { opacity: 1; }

.go-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 34px; }
#go, #confirm-go {
  background: var(--accent-fill); color: var(--accent-ink);
  border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  letter-spacing: .01em; padding: 13px 26px; cursor: pointer;
  transition: filter var(--t-fast) var(--ease);
}
#go:hover, #confirm-go:hover { filter: brightness(1.1); }
#go:focus-visible, #confirm-go:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#go[disabled], #confirm-go[disabled] { opacity: .5; cursor: default; }
.go-note { font-size: 12.5px; color: var(--mut); }

.inspo {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 38px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: var(--bar) solid var(--accent); border-radius: var(--r-md);
  text-decoration: none; color: var(--ink-soft);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.inspo:hover { background: var(--panel-2); border-color: var(--accent); }
.inspo-k {
  font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--accent-text);
}
.inspo-t { font-size: 14.5px; color: var(--ink); }
.inspo-a { margin-left: auto; color: var(--accent-text); font-size: 17px; line-height: 1; }

.mock-flag {
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.6; color: var(--mut);
}
.mock-flag b { color: var(--accent-text); font-weight: 600; }

/* ---------------------------------------------------------------- waiting */
#waiting {
  position: fixed; inset: 0; z-index: 900;
  background: var(--bg);
  align-items: center; justify-content: center; padding: 24px;
}
.wait-inner { width: 100%; max-width: 420px; }
.wait-inner h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 26px;
  margin: 0 0 22px; color: var(--ink); line-height: 1.15;
}
.step {
  display: flex; align-items: center; gap: 11px;
  font-size: 14px; color: var(--mut); padding: 7px 0;
  transition: color var(--t-mid, .4s) var(--ease);
}
.step i {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
  background: var(--line); transition: background var(--t-fast) var(--ease);
}
.step.on { color: var(--ink); }
.step.on i { background: var(--accent); }
.step.done { color: var(--ink-dim); }
.step.done i { background: var(--m-train); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 22px; overflow: hidden; }
.bar span {
  display: block; height: 100%; width: 0%; background: var(--accent);
  transition: width .5s var(--ease);
}

/* ------------------------------------------------------------- result nav */
#backbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
#back {
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-meta);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 9px; cursor: pointer;
}
#back:hover { color: var(--accent-text); border-color: var(--accent); }

@media (max-width: 620px) {
  #intake { padding: 34px 18px; align-items: flex-start; }
  .chip { font-size: 13.5px; padding: 8px 11px; }
}


/* ------------------------------------------------------- confirm screen */
.confirm-h {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(27px, 3.4vw, 38px); line-height: 1.06;
  letter-spacing: -.012em; margin: 0 0 12px; color: var(--ink);
}
.cgrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px;
}
.cfield label {
  display: block; font-size: var(--fs-kicker); text-transform: uppercase;
  letter-spacing: var(--track-kicker); color: var(--mut); margin-bottom: 7px;
}
.cfield input {
  width: 100%; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-left: var(--bar) solid var(--accent);
  border-radius: var(--r-md); padding: 11px 13px;
  font-family: var(--font); font-size: 15px;
  transition: border-color var(--t-fast) var(--ease);
}
.cfield input:focus { outline: none; border-color: var(--accent); }
.cread {
  font-size: 13px; line-height: 1.6; color: var(--mut);
  border-left: 1px solid var(--line); padding-left: 12px; margin: 0 0 4px;
}
.ghost {
  background: none; color: var(--mut);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font); font-size: 14px; padding: 12px 18px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ghost:hover { color: var(--ink); border-color: var(--accent); }

/* --------------------------------------------------------------- errors */
.err {
  margin: 16px 0 0; padding: 11px 14px;
  background: var(--panel); border: 1px solid var(--accent);
  border-left: var(--bar) solid var(--accent); border-radius: var(--r-md);
  font-size: 14px; line-height: 1.5; color: var(--ink);
}
.wait-note { margin: 18px 0 0; font-size: 12.5px; color: var(--mut); }

/* -------------------------------------------------------------- backbar */
#backbar { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
#back, #theme, #pdf {
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: var(--fs-meta);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 5px 9px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
#back:hover, #theme:hover, #pdf:hover { color: var(--accent-text); border-color: var(--accent); }
#theme { margin-left: auto; }
#back:focus-visible, #theme:focus-visible, #pdf:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 620px) {
  #confirm { padding: 34px 18px; align-items: flex-start; }
  .cgrid { grid-template-columns: 1fr; }
}


/* ============================================================= printing ===
   The PDF is the browser's own print output. The screen layout is a fixed
   two-column app with its own scrolling sidebar; on paper that has to become
   one flowing document, or everything past the first page is lost. */
/* The print rules below only take effect once the browser is ACTUALLY
   printing. That is too late: the map has to be re-measured and re-fitted
   BEFORE the print dialog opens, and Leaflet can only measure a box that
   exists. So the same layout is mirrored onto html.printing, which the button
   applies first. Without this the map is fitted at screen size and then
   printed at a completely different one, which is why the first printed map
   showed one marker and a line running off the page. */
html.printing, html.printing body { height: auto !important; overflow: visible !important; }
html.printing #intake,
html.printing #confirm,
html.printing #waiting { display: none !important; }
html.printing #app {
  display: block !important;
  height: auto !important; overflow: visible !important;
  /* Pinned close to the printable width so tiles preload at roughly the right
     scale, but 4mm under it: at exactly 186mm Chrome decided the content was
     wider than the page and scaled the whole document to 61%. beforeprint does
     the exact fit afterwards. */
  width: 182mm !important; max-width: 100% !important; margin: 0 auto !important;
}
html.printing #map {
  flex: none !important;
  /* Same shape on screen and on paper, whatever width the page turns out to
     be. The fit is computed from the aspect ratio, so it survives scaling. */
  width: 100% !important; height: auto !important;
  aspect-ratio: 186 / 138;
}
html.printing #side {
  width: 100% !important; flex: none !important;
  border-right: none !important; height: auto !important;
  overflow: visible !important; padding: 0 !important;
}
html.printing #backbar { display: none !important; }

/* The masthead already carries the trip name, so the screen h1 is a duplicate
   on paper. The subtitle stays: it explains the shape of the trip. */
html.printing #side header h1 { display: block; }
html.printing #side header { margin-bottom: 5mm; }
html.printing #side .sub { font-size: 10.5pt; color: var(--ink-dim); }


@media print {
  @page { margin: 14mm 12mm; }

  html, body { height: auto !important; overflow: visible !important; background: #fff; }
  #intake, #confirm, #waiting { display: none !important; }

  /* The map is AFTER the sidebar in the DOM, because on screen it is the
     right-hand column. display:block would print it at the very bottom, which
     is the wrong way round for a document. Column flex plus order keeps the
     map at the top where a reader expects the overview. */
  #app {
    display: block !important;
    height: auto !important; overflow: visible !important;
  }

  /* the map becomes a figure at the top rather than a viewport-filling pane */
  #map {
    /* flex:1 from the screen layout has a zero basis, which in a column
       container collapses this to 2px however tall you declare it. */
    flex: none !important;
    width: 100% !important; height: auto !important;
    aspect-ratio: 186 / 138;
    border: 1px solid var(--line); border-radius: var(--r-md);
    page-break-inside: avoid; break-inside: avoid;
    margin-bottom: 8mm;
  }
  .leaflet-control-zoom, .leaflet-control-attribution { display: none !important; }

  #side {
    width: 100% !important; flex: none !important;
    border-right: none !important; height: auto !important;
    overflow: visible !important; padding: 0 !important;
  }
  /* Page one is a cover: map, title, subtitle, figures. The day-by-day starts
     on page two. */
  #side .eyebrow {
    break-before: page; page-break-before: always; padding-top: 2mm;
    /* never leave the word ROUTE stranded at the foot of a page */
    break-after: avoid; page-break-after: avoid;
  }
  .foot { break-before: auto; }
  /* the colophon must not be the only thing on a final page */
  .print-foot { break-before: avoid; page-break-before: avoid; }
  /* the title belongs at the top of the itinerary page now that it is not
     sharing a page with the map */
  #side header h1 { display: block !important; font-size: 22pt !important; margin-bottom: 3mm; }
  /* chrome that means nothing on paper */
  #backbar { display: none !important; }

  /* a card split across a page break is the main way a printed itinerary
     turns unreadable */
  .leg, .card, .stat, .foot details { page-break-inside: avoid; break-inside: avoid; }
  .foot details { border-bottom: 1px solid var(--line); }
  .foot summary::after { content: '' !important; }
  .foot summary { cursor: default; }

  .note { color: #333 !important; }
  .card { border: 1px solid var(--line) !important; }
  .card.active { background: transparent !important; }

  /* Chrome drops background colours by default, so anything that carries
     meaning through fill has to survive as ink instead */
  .stats { border-top: 2px solid #131313; border-bottom: 2px solid #131313; }
  h1 { font-size: 26pt !important; }
  a[href]::after { content: '' !important; }

  .print-head { display: block !important; order: -2; }
  .print-foot {
    display: block !important;
    margin-top: 8mm; padding-top: 3mm;
    border-top: 1px solid var(--line);
    font-size: 8pt; color: #666;
  }
}
.print-head, .print-foot { display: none; }

/* masthead + colophon, print only */
html.printing .print-head, html.printing .print-foot { display: block; }
.print-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 3mm; margin-bottom: 5mm;
}
.print-head .ph-row { justify-content: space-between; }
.print-head .ph-brand {
  font-size: 8.5pt; text-transform: uppercase; letter-spacing: 2.2px;
  color: var(--accent-text); margin-bottom: 2.5mm;
}
.print-head .ph-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8mm;
}
.print-head .ph-title { display: none; }
.print-head .ph-dates {
  font-family: var(--font-mono); font-size: 9.5pt;
  color: var(--mut); white-space: nowrap;
}


/* ====================================================== dancing pyramid ===
   The wait is 20-40 seconds. A static screen reads as frozen; this reads as
   working. Black ink on transparency, so it inverts on the dark ground exactly
   like every other placement of the mark. */
.mark-dance {
  display: block; width: 84px; height: 84px; margin: 0 0 22px -4px;
  filter: invert(1);
  transform-origin: 50% 78%;              /* pivot at the pyramid's base */
  animation: monki-dance 2.6s var(--ease) infinite;
}
[data-theme="light"] .mark-dance { filter: none; }

@keyframes monki-dance {
   0%   { transform: translateY(0)     rotate(0deg)    scale(1);    opacity: .92; }
  18%   { transform: translateY(-7px)  rotate(-5deg)   scale(1.04); opacity: 1;   }
  36%   { transform: translateY(0)     rotate(0deg)    scale(.99);  opacity: .92; }
  54%   { transform: translateY(-7px)  rotate(5deg)    scale(1.04); opacity: 1;   }
  72%   { transform: translateY(0)     rotate(0deg)    scale(.99);  opacity: .92; }
  86%   { transform: translateY(-3px)  rotate(0deg)    scale(1.02); opacity: .97; }
 100%   { transform: translateY(0)     rotate(0deg)    scale(1);    opacity: .92; }
}

/* Someone who has asked their system to stop moving things means it. */
@media (prefers-reduced-motion: reduce) {
  .mark-dance { animation: monki-breathe 3.2s ease-in-out infinite; }
  @keyframes monki-breathe { 0%,100% { opacity:.7 } 50% { opacity:1 } }
}

/* ============================================================== pdf gate ===
   A panel over the result, not a new screen: the trip stays visible behind it,
   which is the whole reason someone is willing to type their name. */
#gate {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#gate[hidden] { display: none; }
[data-theme="light"] #gate { background: rgba(19,19,19,.42); }

.gate-card {
  position: relative;
  width: 100%; max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: var(--bar) solid var(--accent);
  border-radius: var(--r-md);
  padding: 26px 26px 22px;
  box-shadow: var(--shadow-pop);
}
.gate-h {
  font-family: var(--font-display); font-weight: 700;
  font-size: 24px; line-height: 1.1; margin: 0 0 10px; color: var(--ink);
}
.gate-p { font-size: 14.5px; line-height: 1.55; color: var(--ink-dim); margin: 0 0 20px; }
.gate-fields { display: grid; gap: 12px; margin-bottom: 4px; }
.gate-fine {
  margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 11.5px; line-height: 1.55; color: var(--mut);
}
#gate-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; cursor: pointer;
  color: var(--mut); font-size: 22px; line-height: 1; padding: 4px 8px;
}
#gate-close:hover { color: var(--accent-text); }
#gate .go-row { margin-top: 18px; }
#gate-go {
  background: var(--accent-fill); color: var(--accent-ink);
  border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  padding: 12px 24px; cursor: pointer;
}
#gate-go:hover { filter: brightness(1.1); }
#gate-go[disabled] { opacity: .5; cursor: default; }

/* the gate must never appear on paper */
@media print { #gate { display: none !important; } }
html.printing #gate { display: none !important; }


/* ------------------------------------------------- printed map, tidied ---
   Unstyled, a Leaflet pane on paper looks like a screenshot: hard edges, a
   visible tile grid where anything failed to load, and controls that mean
   nothing in print. */
html.printing #map,
@media print { #map { } }

html.printing #map {
  border: 1px solid var(--line) !important;
  border-radius: var(--r-md);
  background: var(--panel-2);
  overflow: hidden;
}
html.printing .leaflet-control-zoom,
html.printing .leaflet-control-attribution { display: none !important; }
/* Attribution still has to appear somewhere, so it moves into the colophon. */
html.printing .print-foot::after {
  content: ' Map data \00a9 OpenStreetMap contributors, tiles by CARTO.';
}
/* Tile seams show as pale lines when a tile is a fraction of a pixel out. */
html.printing .leaflet-tile { outline: none; }
html.printing #map + * { margin-top: 6mm; }

@media print {
  #map { border: 1px solid var(--line) !important; border-radius: var(--r-md);
         background: var(--panel-2); overflow: hidden; }
  .leaflet-control-zoom, .leaflet-control-attribution { display: none !important; }
  .print-foot::after { content: ' Map data \00a9 OpenStreetMap contributors, tiles by CARTO.'; }
}
