/* Route 66 Copilot: the trip book. On screen: paper sheets in a full-screen overlay. In print: US Letter pages,
   no app chrome. Sizes inside the book are in em, so the print size is set in one place (.tb-book font-size). */
body.tb-open { overflow: hidden; }
.tb-overlay { position: fixed; inset: 0; z-index: 300; overflow-y: auto; background: var(--shell); padding: 0 16px 48px; }
.tb-tools {
  position: sticky; top: 0; z-index: 2; max-width: 816px; margin: 0 auto 18px; padding: 12px 0 10px;
  background: var(--shell); border-bottom: 1px solid var(--hair);
}
.tb-tools-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.tb-tools-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; margin-top: 12px; }
.tb-tools-fields .field { margin-bottom: 8px; background: var(--paper); }
.tb-help { margin: 0; font-size: 0.95rem; color: var(--ink-2); }
.tb-tools .inline-error { margin-top: 8px; }
.tb-wait { max-width: 816px; margin: 0 auto 18px; }
.tb-empty { padding: 24px; border-radius: var(--r-core); background: var(--paper); font-weight: 600; }

/* ---------- The book ---------- */
.tb-book { max-width: 816px; margin: 0 auto; font-size: 1rem; color: var(--ink); }
.tb-page {
  position: relative; background: #FFFCF4; margin: 0 0 24px; padding: 3.2em 3em; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(92, 58, 28, 0.12), 0 18px 40px -20px rgba(92, 58, 28, 0.45);
}
.tb-eyebrow { margin: 0; font-weight: 700; font-size: 0.82em; letter-spacing: 0.16em; text-transform: uppercase; color: var(--rust-ink); }
.tb-dot { margin: 0 .3em; }
.tb-title { margin: .2em 0 .25em; font-family: var(--head); font-weight: 800; font-size: 3.6em; line-height: .95; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tb-rule { display: block; width: 9em; height: 4px; margin: .4em 0 .9em; background: repeating-linear-gradient(90deg, var(--yellow) 0 1.3em, transparent 1.3em 2.1em); }
.tb-dates { margin: 0; font-weight: 700; font-size: 1.2em; }
.tb-route { margin: .2em 0 0; font-size: 1.1em; color: var(--ink-2); }
.tb-by { margin: .9em 0 0; font-family: var(--head); font-weight: 800; font-size: 1.6em; color: var(--rust-ink); }
.tb-small-head { margin: 0 0 .5em; font-weight: 700; font-size: 0.8em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }

/* Cover: framed photo on top, title below, double rust border */
.tb-cover { aspect-ratio: 8.5 / 11; display: flex; flex-direction: column; padding: 2.2em; border: 6px double var(--rust-strong); }
.tb-cover-photo { flex: 1 1 58%; min-height: 0; padding: .5em; background: #fff; box-shadow: 0 2px 10px -4px rgba(92, 58, 28, .4); }
.tb-cover-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tb-cover-text { flex: 0 0 auto; padding: 1.6em .4em 0; }

/* At a glance */
.tb-figures { list-style: none; margin: 1.2em 0 1.6em; padding: 0; display: flex; flex-wrap: wrap; gap: .6em 2.2em; }
.tb-figures li { font-size: 1.05em; color: var(--ink-2); }
.tb-figures strong { display: block; font-family: var(--head); font-weight: 800; font-size: 2.4em; line-height: 1; color: var(--ink); }
.tb-toc { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.tb-toc li { display: grid; grid-template-columns: 5em 1fr auto; gap: 1em; padding: .55em 0; border-bottom: 1px dashed var(--line); break-inside: avoid; }
.tb-toc-day { font-weight: 700; color: var(--rust-ink); }
.tb-toc-what { overflow-wrap: anywhere; }
.tb-toc-when { color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Day pages */
.tb-day-head { margin-bottom: 1.4em; padding-bottom: .9em; border-bottom: 2px solid var(--ink); }
.tb-day-title { margin: .15em 0 .1em; font-family: var(--head); font-weight: 800; font-size: 2.5em; line-height: 1; overflow-wrap: anywhere; }
.tb-day-meta { margin: .3em 0 0; font-weight: 600; color: var(--ink-2); white-space: pre-wrap; }
.tb-entry { margin: 0 0 1.8em; break-inside: avoid; page-break-inside: avoid; }
.tb-place { margin: 0 0 .5em; font-family: var(--head); font-weight: 800; font-size: 1.45em; line-height: 1.1; color: var(--rust-ink); }
.tb-stopno { font-family: var(--body); font-weight: 600; font-size: .6em; color: var(--ink-2); letter-spacing: .02em; }
.tb-text { margin: .2em 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.08em; line-height: 1.7; }
.tb-text::first-letter { font-family: var(--head); font-weight: 800; font-size: 2.6em; float: left; line-height: .9; margin: .06em .1em 0 0; color: var(--rust-ink); }
.tb-photos { display: grid; gap: .8em; margin: .4em 0 1em; }
.tb-photos-1 { grid-template-columns: 1fr; }
.tb-photos-1.is-portrait { width: 62%; margin-left: auto; margin-right: auto; }
.tb-photos-2, .tb-photos-3, .tb-photos-4 { grid-template-columns: 1fr 1fr; }
.tb-photos-3 .tb-photo:first-child { grid-column: 1 / -1; }
.tb-photo { margin: 0; padding: .45em; background: #fff; box-shadow: 0 1px 2px rgba(92, 58, 28, .16), 0 8px 18px -10px rgba(92, 58, 28, .45); break-inside: avoid; }
.tb-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--sand); }
.tb-photos-1 .tb-photo img { aspect-ratio: 3 / 2; }
.tb-photos-1.is-portrait .tb-photo img { aspect-ratio: 4 / 5; }
.tb-photos-2 .tb-photo img { aspect-ratio: 4 / 5; }
.tb-photos-3 .tb-photo:first-child img { aspect-ratio: 16 / 9; }
.tb-photos-2 .tb-photo:nth-child(2) { transform: rotate(1.2deg); }
.tb-photos-1 .tb-photo { transform: rotate(-.6deg); }
.tb-plan-stops ul { margin: 0 0 1.6em; padding-left: 1.2em; }
.tb-plan-stops li { margin: 0 0 .25em; }
.tb-page-ref { color: var(--ink-2); }
.tb-lines span { display: block; height: 2.2em; border-bottom: 1px solid var(--line); }

/* Passport page */
.tb-seals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2em .8em; margin: 0 0 1.6em; }
.tb-seal { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .2em; }
.tb-seal .seal { width: 6em !important; height: 6em !important; }
.tb-seal-name { font-weight: 700; font-size: .95em; }
.tb-seal-count { font-size: .85em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tb-cert { margin: 0 0 1.4em; padding: .9em 1.1em; border: 1px dashed var(--line-strong); border-radius: 8px; }
.tb-cert.is-earned { border: 3px double var(--rust-strong); }
.tb-stamps { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 2em; font-size: .92em; }
.tb-stamps li { break-inside: avoid; padding: .2em 0; border-bottom: 1px dotted var(--line); }
.tb-stamp-n { display: inline-block; min-width: 2.2em; font-weight: 700; color: var(--rust-ink); font-variant-numeric: tabular-nums; }
.tb-stamp-date { color: var(--ink-2); }

/* Closing page */
.tb-end { aspect-ratio: 8.5 / 11; display: flex; align-items: center; border: 6px double var(--rust-strong); }
.tb-end-inner { width: 100%; }
.tb-end-title { font-size: 3em; }
.tb-lines-end { margin: 2.2em 0 2em; }
.tb-colophon { margin: 0; font-size: .85em; color: var(--ink-2); }

@media (max-width: 640px) {
  .tb-overlay { padding: 0 12px 40px; }
  .tb-tools { position: static; }
  .tb-book { font-size: 0.8rem; }
  .tb-page { padding: 2em 1.4em; }
  .tb-cover, .tb-end { aspect-ratio: auto; min-height: 0; }
  .tb-cover-photo { flex: none; aspect-ratio: 4 / 3; }
  .tb-title { font-size: 3em; }
  .tb-seal .seal { width: 4.6em !important; height: 4.6em !important; }
  .tb-stamps { columns: 1; }
  .tb-toc li { grid-template-columns: 4em 1fr; }
  .tb-toc-when { grid-column: 2; }
}

/* ---------- Print: only the book, one Letter page per section ---------- */
@page book { size: Letter; margin: 0.55in; }
.tb-page { page: book; }
@media print {
  body.printing-book #root, body.printing-book .toast-wrap, body.printing-book .tb-tools,
  body.printing-book .tb-wait, body.printing-book .j-viewer { display: none !important; }
  body.printing-book::before { display: none; }
  html:has(body.printing-book), body.printing-book { height: auto; overflow: visible; background: #fff; }
  body.printing-book .tb-overlay { position: static; overflow: visible; padding: 0; background: #fff; }
  body.printing-book .tb-book { max-width: none; font-size: 11.5pt; }
  body.printing-book .tb-page {
    margin: 0; padding: 0; box-shadow: none; border-radius: 0; background: #fff;
    break-after: page; page-break-after: always;
  }
  body.printing-book .tb-page:last-child { break-after: auto; page-break-after: auto; }
  body.printing-book .tb-cover, body.printing-book .tb-end { aspect-ratio: auto; height: 9.8in; padding: .35in; overflow: hidden; }
  body.printing-book .tb-photo { box-shadow: none; border: 1px solid #ddd; transform: none !important; }
  body.printing-book .tb-photo img { max-height: 4.4in; }
  body.printing-book .tb-photos-2 .tb-photo img, body.printing-book .tb-photos-4 .tb-photo img { max-height: 3.3in; }
  body.printing-book * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
