/* The printable itinerary (public/js/itinerary.js): A4 pages, always light, like a printed booklet.
   On screen the pages sit on a grey desk; printed, each section starts a new page. */

body.itin-mode #map, body.itin-mode #panel { visibility: hidden; }
.itin {
  --navy: #16213a; --paper: #fffdf8; --sand: #f3eee4; --rust: #b4493a; --gold: #c9974b;
  --ink: #1b2233; --muted: #5e6472; --line: #e4dccd;
  --k-flight: #2f4a7a; --k-stay: #7a4d8c; --k-drive: #b4493a; --k-ride: #2e7d7a; --k-car: #b07d2a;
  --k-activity: #d07a2d; --k-place: #4c7f4a; --k-note: #7a7468;
  --serif: 'Source Serif 4', 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --sans: 'Barlow', 'PingFang SC', 'Noto Sans SC', system-ui, sans-serif;
  position: fixed; inset: 0; z-index: 50; overflow: auto; background: #e7e3da; color: var(--ink);
  font: 400 10.5pt/1.5 var(--sans); color-scheme: light;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.itin-loading { padding: 40px 24px; color: var(--muted); }

/* ---- toolbar (screen only) ---- */
.itin-bar {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px; background: rgba(255, 253, 248, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  font: 500 14px/1.3 var(--sans);
}
.itin-back { color: var(--ink); text-decoration: none; font-weight: 600; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.itin-opts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-left: auto; color: var(--muted); }
.itin-opts label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.itin-opts input { accent-color: var(--rust); width: 16px; height: 16px; }
.itin-save {
  border: 0; border-radius: 10px; padding: 9px 16px; background: var(--navy); color: #fff; font: 600 14px/1 var(--sans); cursor: pointer; min-height: 40px;
}
.itin-save:disabled { opacity: .6; }
.itin-hint { flex-basis: 100%; margin: 0; text-align: right; color: var(--muted); font-size: 12px; font-weight: 400; }
@media (max-width: 640px) { .itin-opts { margin-left: 0; } .itin-hint { text-align: left; } }

/* ---- pages ---- */
.itin-doc { zoom: var(--itin-zoom, 1); padding: 24px 0 48px; }
.itin-sheet, .itin-flow, .itin-credits {
  width: 210mm; margin: 0 auto 18px; background: var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08);
  box-sizing: border-box;
}
.itin-flow { padding: 16mm 18mm 14mm; }
.itin-credits { padding: 10mm 18mm 12mm; font-size: 8pt; color: var(--muted); }
.itin-credits p { margin: 0 0 4px; }

.itin-kicker, .cover-kicker, .day-kicker {
  margin: 0; font: 600 8.5pt/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--rust);
}
.itin-h { margin: 2mm 0 6mm; font: 700 25pt/1.08 var(--serif); color: var(--navy); letter-spacing: -.01em; }
.itin-part + .itin-part { margin-top: 12mm; }

/* ---- cover ---- */
.itin-cover { height: 297mm; display: flex; flex-direction: column; overflow: hidden; background: var(--navy); }
.cover-photos { flex: 0 0 59%; display: grid; gap: 2px; background: var(--navy); overflow: hidden; }
.cover-photos.n2 { grid-template-columns: 1.6fr 1fr; }
.cover-photos.n3 { grid-template-columns: 1.6fr 1fr; grid-template-rows: 1.15fr 1fr; }
.cover-photos.n3 .cp0 { grid-row: 1 / 3; }
.cover-photos img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 0; }
.cover-photos.n0 { display: flex; align-items: center; justify-content: center; padding: 14mm; background: #1d2a47; }
.cover-text { flex: 1; padding: 14mm 18mm 12mm; color: #fff; display: flex; flex-direction: column; }
.cover-kicker { color: var(--gold); }
.itin-cover h1 { margin: 5mm 0 0; font: 700 38pt/1.02 var(--serif); letter-spacing: -.015em; color: #fff; }
.cover-route { margin: 5mm 0 0; font: 400 15pt/1.3 var(--serif); color: #e9dcc4; }
.cover-stats { margin: 7mm 0 0; display: flex; align-items: center; gap: 5mm; font-size: 10.5pt; color: #dde3ee; }
.cover-stats .rule { flex: 0 0 22mm; height: 2px; background: var(--rust); }
.cover-dates { margin-top: auto; margin-bottom: 0; font: 500 9pt/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #aeb7c8; }

/* ---- at a glance ---- */
.glance-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10mm; }
.glance-head .itin-h { margin-bottom: 5mm; }
.glance-dates { margin: 0 0 6mm; color: var(--muted); text-align: right; font-size: 9.5pt; white-space: nowrap; }
.itin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6mm; margin: 0 0 7mm; }
.itin-stats div { border-top: 2px solid var(--rust); padding-top: 3mm; display: flex; flex-direction: column; min-width: 0; }
.itin-stats dd { margin: 0; font: 700 17pt/1.1 var(--serif); color: var(--navy); white-space: nowrap; }
.itin-stats dt { order: 2; color: var(--muted); font-size: 9pt; }
.glance-map { margin: 0 0 7mm; background: var(--sand); border-radius: 3mm; padding: 3mm; break-inside: avoid; }
.glance-map figcaption { font-size: 8pt; color: var(--muted); padding: 1mm 1mm 0; }
/* Two columns read top to bottom (grid rows set by the script: columns don't survive printing in Safari). */
.stages { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-template-columns: 1fr 1fr; column-gap: 10mm; align-content: start; }
.stages.few { grid-auto-flow: row; grid-template-columns: 1fr; }
.stage { position: relative; margin: 0; padding: 0 0 2.6mm 7mm; border-left: 1px solid #cdbfa8; break-inside: avoid; }
.stage::before { content: ''; position: absolute; left: -5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--rust); }
.stage-flight::before { background: var(--k-flight); }
.stage-car::before { background: var(--k-car); }
.stage h3 { margin: 0; font: 600 12pt/1.25 var(--serif); color: var(--navy); }
.stage h3 span { display: block; font: 500 8.5pt/1.4 var(--sans); color: var(--rust); letter-spacing: .04em; }
.stage p { margin: 1mm 0 0; color: var(--muted); font-size: 9pt; }

/* ---- map ---- */
.mm { width: 100%; height: auto; display: block; font-family: var(--sans); }
.mm-drive { fill: none; stroke: var(--rust); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mm-ride { fill: none; stroke: var(--k-ride); stroke-width: 2.2; stroke-dasharray: 5 4; stroke-linecap: round; }
.mm-flight { fill: none; stroke: #55617a; stroke-width: 1.6; stroke-dasharray: 2 5; stroke-linecap: round; }
.mm-stay { fill: var(--rust); stroke: #fff; stroke-width: 2; }
.mm-dot { fill: var(--navy); stroke: #fff; stroke-width: 1.2; }
.mm-activity { fill: var(--k-activity); }
.mm-place { fill: var(--k-place); }
.mm-car { fill: var(--k-car); }
.mm-ap { fill: #fff; stroke: var(--navy); stroke-width: 2; }
.mm-label { font-size: 11px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--sand); stroke-width: 3px; }
.mm-aplabel { font-size: 10px; font-weight: 700; fill: var(--navy); paint-order: stroke; stroke: var(--sand); stroke-width: 3px; }
.mm-far { font-size: 10px; fill: var(--muted); font-style: italic; paint-order: stroke; stroke: var(--sand); stroke-width: 3px; }
.mm-scale path { stroke: var(--muted); stroke-width: 1.5; }
.mm-scale text { font-size: 9px; fill: var(--muted); }
.mm-cover .mm-label, .mm-cover .mm-aplabel, .mm-cover .mm-far { stroke: #1d2a47; fill: #e9dcc4; }
.mm-cover .mm-scale text { fill: #aeb7c8; }

/* ---- days ---- */
.itin-days .itin-h { margin-bottom: 4mm; }
/* Block layout, not grid: Safari only keeps things together on a page in block layout. */
.itin-day { position: relative; padding: 6mm 0 6mm 20mm; border-top: 1px solid var(--line); }
.day-no {
  position: absolute; left: 0; top: 6mm;
  width: 13mm; height: 13mm; border-radius: 50%; background: var(--rust); color: #fff;
  display: grid; place-items: center; font: 700 12pt/1 var(--sans);
}
.day-no-more { background: var(--gold); }
.day-kicker { color: #7b5a3a; }
.day-kicker span { color: var(--muted); }
.day-title { margin: 1.5mm 0 3mm; font: 700 15.5pt/1.2 var(--serif); color: var(--navy); }
/* A day's heading never ends a page on its own: it keeps its first event with it. */
.day-lead { break-inside: avoid; }
.day-body::after { content: ''; display: block; clear: both; }
.day-photo { float: right; width: 62mm; margin: 0 0 3mm 6mm; break-inside: avoid; }
.day-photo img { width: 100%; height: 44mm; object-fit: cover; border-radius: 2mm; display: block; background: var(--sand); }
.day-photo figcaption { font-size: 7.5pt; color: var(--muted); margin-top: 1mm; }
.day-free { margin: 0; color: var(--muted); font-style: italic; }
.day-events { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 7mm 1fr; gap: 2.5mm; padding: 1.6mm 0; break-inside: avoid; }
.ev-dot {
  width: 6.2mm; height: 6.2mm; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--k-note); margin-top: .4mm;
}
.ev-dot svg { width: 3.6mm; height: 3.6mm; }
.k-flight .ev-dot { background: var(--k-flight); }
.k-stay .ev-dot { background: var(--k-stay); }
.k-drive .ev-dot { background: var(--k-drive); }
.k-ride .ev-dot { background: var(--k-ride); }
.k-car .ev-dot { background: var(--k-car); }
.k-activity .ev-dot { background: var(--k-activity); }
.k-place .ev-dot { background: var(--k-place); }
.ev p { margin: 0; }
.ev-t { font-weight: 600; font-size: 10.5pt; }
.ev-cost { float: right; margin-left: 4mm; font-weight: 500; color: var(--muted); font-size: 9.5pt; }
.ev-s { color: var(--muted); font-size: 9pt; }
.ev-n { margin-top: 1mm !important; font-size: 8.8pt; color: #3d4352; background: var(--sand); border-left: 2px solid var(--gold); padding: 1.4mm 2.5mm; border-radius: 0 1.5mm 1.5mm 0; }
.ev-end .ev-t { font-weight: 500; color: var(--muted); }

/* ---- bookings, costs, lists ---- */
.itin-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.itin-table th { text-align: left; font: 600 7.8pt/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 2mm 2mm; border-bottom: 1.5px solid var(--navy); }
.itin-table td { padding: 2.4mm 2mm; border-bottom: 1px solid var(--line); vertical-align: top; }
.itin-table tr { break-inside: avoid; }
.itin-table .when { color: var(--muted); width: 24%; }
.itin-table strong { display: block; font-weight: 600; color: var(--ink); }
.itin-table small { display: block; color: var(--muted); font-size: 8.3pt; }
.itin-table .code { font: 600 9pt/1.3 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .03em; white-space: nowrap; }
.itin-table .num { text-align: right; white-space: nowrap; }
.tag { display: inline-block; margin: 0 0 1mm; font: 600 7pt/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; padding: 1mm 1.6mm; border-radius: 1mm; color: #fff; background: var(--k-note); }
.k-flight .tag { background: var(--k-flight); }
.k-stay .tag { background: var(--k-stay); }
.k-car .tag { background: var(--k-car); }
.k-activity .tag { background: var(--k-activity); }
.k-place .tag { background: var(--k-place); }
.k-drive .tag { background: var(--k-drive); }
.k-ride .tag { background: var(--k-ride); }
.cost-grid { display: grid; grid-template-columns: 60mm 1fr; gap: 10mm; align-items: start; }
.cost-big { background: var(--sand); border-radius: 3mm; padding: 6mm; display: flex; flex-direction: column; gap: 1mm; color: var(--muted); font-size: 9pt; }
.cost-big strong { font: 700 22pt/1.1 var(--serif); color: var(--navy); }
.cost-cats { list-style: none; margin: 0; padding: 0; }
.cost-cats li { display: grid; grid-template-columns: 1fr auto; gap: 1mm 4mm; padding: 2mm 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.cost-cats b { font-weight: 600; }
.cost-cats i { grid-column: 1 / -1; height: 2mm; border-radius: 1mm; background: var(--rust); opacity: .8; }
.list-grid { columns: 2; column-gap: 10mm; }
.itin-list { break-inside: avoid; margin-bottom: 6mm; }
.itin-list h3 { margin: 0 0 2mm; font: 600 12pt/1.2 var(--serif); color: var(--navy); }
.itin-list ul { list-style: none; margin: 0; padding: 0; }
.itin-list li { display: flex; gap: 2.5mm; padding: 1mm 0; font-size: 9.5pt; }
.itin-list li.done { color: var(--muted); }
.box { flex: 0 0 3.6mm; height: 3.6mm; border: 1.2px solid var(--navy); border-radius: .8mm; font-size: 7pt; line-height: 3.6mm; text-align: center; margin-top: .6mm; }

/* ---- print ---- */
@page { size: A4; margin: 14mm 0 13mm; @bottom-right { content: counter(page); font: 8pt sans-serif; color: #8a8070; margin-right: 18mm; } }
@page cover { margin: 0; @bottom-right { content: none; } }
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body.itin-mode > :not(#itin) { display: none !important; }
  .itin { position: static; overflow: visible; background: none; font-size: 10.5pt; }
  .itin-bar { display: none; }
  .itin-doc { zoom: 1; padding: 0; }
  .itin-sheet, .itin-flow, .itin-credits { width: auto; margin: 0; box-shadow: none; }
  .itin-flow, .itin-credits { background: none; }
  .itin-flow { padding: 0 18mm; }
  /* Full-bleed where the browser gives the cover a page without margins (Chrome, Edge, Firefox); elsewhere
     (Safari) it keeps the page margins, so it's made to fit inside them. */
  .itin-cover { height: 246mm; margin: 0 12mm; border-radius: 2mm; break-after: page; }
  .itin.named-pages .itin-cover { page: cover; height: 297mm; margin: 0; border-radius: 0; }
  .itin-glance, .itin-break { break-before: page; }
  .itin-days { break-before: page; }
  .itin-credits { padding: 8mm 18mm 0; }
  .itin-day { break-inside: auto; }
  .day-title, .day-kicker { break-after: avoid; }
}
