/* ==========================================================================
   travel.hmpsandbox.com, single stylesheet
   1. Tokens   2. Base & typography   3. Shell   4. Components
   5. Desk layout (wide screens)   6. Pocket notebook layout (narrow screens)

   Design intent: a personal travel diary, not a dashboard. Warm paper,
   dark ink, and two kinds of type: printed matter is set in Fraunces
   (a serif), and every annotation (dates, captions, stat labels, notes in
   the margin) is handwritten in Caveat. Per-trip colors arrive as
   --trip-color from PHP and are the only saturated marks on the page.

   Two intentional layouts, not one fluid one:
   the wide layout is a sheet of paper lying on a desk; the narrow layout
   is a pocket notebook with index tabs. The switch happens at 860px.

   Theming: the four knobs below (--paper, --card, --ink, --accent) can be
   overridden from the travel_settings table (theme_paper, theme_card,
   theme_ink, theme_accent); the layout template injects them as a :root
   style block. Everything else is derived with color-mix, so a new theme
   only needs those four values plus (optionally) trip_palette.

   Trip palette note: the default 8 trip colors live in PHP
   (helpers.php trip_palette()) and were machine-validated for CVD
   separation and >= 3:1 contrast against the default paper. If you change
   the paper or the palette, re-validate.

   HOUSE RULES (for future agents): never use em dashes, in copy or in
   comments. Do not add frameworks or CDN assets. Do not flatten the two
   layouts into one middle-ground design. See travel/docs/DESIGN.md.
   ========================================================================== */

/* --- 1. Tokens ------------------------------------------------------------ */

:root {
    /* The four DB-themeable knobs (travel_settings can override these). */
    --paper:  #f3ecdd;   /* the page itself */
    --card:   #fdfaf1;   /* a brighter loose sheet: prints, cards, panels */
    --ink:    #33291e;   /* warm dark ink */
    --accent: #a03e22;   /* the red pen */

    /* Derived tones. Percentages are chosen so text stays readable:
       ink-2 is approx 5.9:1 and ink-3 approx 4.6:1 on the default paper. */
    --paper-2:     color-mix(in srgb, var(--ink) 7%, var(--paper));
    --desk:        color-mix(in srgb, var(--ink) 16%, var(--paper));
    --ink-2:       color-mix(in srgb, var(--ink) 76%, var(--paper));
    --ink-3:       color-mix(in srgb, var(--ink) 68%, var(--paper));
    --line:        color-mix(in srgb, var(--ink) 16%, var(--paper));
    --line-strong: color-mix(in srgb, var(--ink) 32%, var(--paper));
    --tape:        color-mix(in srgb, var(--ink) 9%, var(--paper-2));
    --shadow-soft: 0 1px 3px rgba(62, 47, 27, 0.14);
    --shadow-lift: 0 2px 6px rgba(62, 47, 27, 0.12), 0 10px 34px rgba(62, 47, 27, 0.10);

    --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
    --font-body:    'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
    --font-hand:    'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;

    /* Paper grain, tiled over any theme color. */
    --grain: 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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4.5rem;

    --radius-sm: 4px;
    --radius:    8px;
    --maxw:      1180px;

    --tl-lane-h: 44px;   /* timeline lane height (wide layout) */
}

@font-face {
    font-family: 'Fraunces';
    font-weight: 600 700;
    font-display: swap;
    src: url('../fonts/fraunces-latin-var.woff2') format('woff2');
}
@font-face {
    font-family: 'Caveat';
    font-weight: 500 600;
    font-display: swap;
    src: url('../fonts/caveat-latin-var.woff2') format('woff2');
}

/* --- 2. Base & typography --------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background-color: var(--desk);
    background-image: var(--grain);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1.03rem;
    line-height: 1.65;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.12;
    margin: 0 0 var(--space-3);
    letter-spacing: -0.005em;
}
h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.65rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 var(--space-4); }

a { color: var(--ink); text-decoration-color: var(--ink-3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

img { max-width: 100%; display: block; }

button { font: inherit; }

code {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 0.35em;
    font-size: 0.88em;
    font-family: ui-monospace, Consolas, monospace;
}

::selection { background: color-mix(in srgb, var(--accent) 24%, var(--paper)); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* Handwritten annotation, the diary's second voice. */
.kicker {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.3;
    color: var(--ink-2);
    margin-bottom: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.lede { color: var(--ink-2); font-size: 1.12rem; max-width: 56ch; }

.empty-note { color: var(--ink-3); font-size: 0.95rem; }
.section-note {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.15rem;
    color: var(--ink-3);
    margin: 0;
}

.margin-note {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.25rem;
    color: var(--ink-2);
    max-width: 40ch;
    transform: rotate(-0.5deg);
}

/* Highlighter stroke behind a title. Trip pages recolor it via --trip-color. */
.hl {
    --hl-color: var(--accent);
    background-image: linear-gradient(
        transparent 62%,
        color-mix(in srgb, var(--hl-color) 30%, transparent) 62%,
        color-mix(in srgb, var(--hl-color) 30%, transparent) 96%,
        transparent 96%);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    padding: 0 0.08em;
    margin: 0 -0.08em;
}

/* --- 3. Shell ---------------------------------------------------------------- */

.skip-link {
    position: absolute;
    left: -999px;
    top: var(--space-2);
    z-index: 100;
    background: var(--ink);
    color: var(--paper);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
}
.skip-link:focus { left: var(--space-2); }

/* The sheet: one piece of paper that carries header, content and footer. */
.sheet {
    background-color: var(--paper);
    background-image: var(--grain);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header { border-bottom: 1px solid var(--line); }

.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.brand-mark {
    width: 20px;
    height: 20px;
    color: var(--accent);
    transform: rotate(8deg);
    flex: none;
}

.nav-links a {
    position: relative;
    text-decoration: none;
    color: var(--ink-2);
    font-family: var(--font-display);
    font-weight: 600;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); }

.site-main { flex: 1; width: 100%; }

.site-footer {
    border-top: 1px dashed var(--line-strong);
    color: var(--ink-3);
    font-size: 0.92rem;
    text-align: center;
    margin-top: var(--space-8);
}
.site-footer p { margin: 0 auto; padding: var(--space-2) var(--space-4); max-width: 60ch; }
.site-footer p:first-child {
    padding-top: var(--space-5);
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.2rem;
    color: var(--ink-2);
}
.site-footer .footer-meta { padding-bottom: var(--space-5); }
.site-footer a { color: var(--ink-2); }

/* --- 4. Components ------------------------------------------------------------ */

.page-section { margin-top: var(--space-7); }
.page-section:first-child { margin-top: 0; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.section-head h2 { margin: 0; }
.see-all {
    color: var(--ink-2);
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.15rem;
    text-decoration: none;
    white-space: nowrap;
}
.see-all:hover { color: var(--accent); }

.back-link {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink-2);
    text-decoration: none;
}
.back-link:hover { color: var(--accent); }

/* Tape: the sticky strip that "fixes" prints and cards to the page. */
.tape,
.taped::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    width: 84px;
    height: 22px;
    margin-left: -42px;
    background: var(--tape);
    opacity: 0.85;
    transform: rotate(-2deg);
    clip-path: polygon(2% 0, 98% 5%, 100% 32%, 97% 100%, 3% 94%, 0 58%);
    box-shadow: var(--shadow-soft);
    pointer-events: none;
    z-index: 1;
}

/* Rubber stamp, used for the Ongoing marker. */
.stamp {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    border: 2px solid currentColor;
    border-radius: 5px;
    padding: 0.12rem 0.5rem;
    transform: rotate(-3deg);
    opacity: 0.88;
    background: color-mix(in srgb, var(--card) 65%, transparent);
}

/* Ticket stub buttons for the Drive links. */
.button-row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.ticket {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--shadow-soft);
}
.ticket:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.ticket-label { padding: 0.55rem 0.9rem; }
.ticket-stub {
    display: flex;
    align-items: center;
    padding: 0 0.7rem;
    border-left: 1px dashed var(--line-strong);
    color: var(--ink-2);
}
/* Perforation notches at the ends of the dashed line. */
.ticket::before, .ticket::after {
    content: '';
    position: absolute;
    right: calc(2.05rem - 5px);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--paper);
    border: 1px solid var(--line-strong);
}
.ticket::before { top: -6px; }
.ticket::after { bottom: -6px; }
.ticket-primary { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); }
.ticket-primary .ticket-label { color: var(--accent); }
.ticket-primary .ticket-stub { border-left-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); color: var(--accent); }
.ticket-primary::before, .ticket-primary::after { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); }

/* Color dot: the identity swatch beside trip text. A card-colored ring keeps
   it legible over anything it crosses. */
.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--trip-color, var(--ink-3));
    box-shadow: 0 0 0 2px var(--card);
    flex: none;
}

/* Trip chip: colored dot + name, used in fallbacks, post meta, post pages. */
.trip-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.12rem 0.7rem;
    font-size: 0.85rem;
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink-2);
    text-decoration: none;
    background: var(--card);
}
a.trip-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* The tally: stat values in print, labels in handwriting. */
.stat-row { list-style: none; margin: 0; padding: 0; }
.stat-label {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--ink-2);
    line-height: 1.25;
}
.stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* Dashboard head */
.dashboard-head { margin-bottom: var(--space-6); }
.dashboard-head h1 { margin-bottom: var(--space-2); }

/* Map panel: the map pasted onto the page like a folded map, with a thick
   print border. Shared by the dashboard and trip pages. */
.map-panel {
    position: relative;
    background: var(--card);
    border: 10px solid var(--card);
    outline: 1px solid var(--line);
    border-radius: 2px;
    overflow: visible;
    box-shadow: var(--shadow-soft);
    min-height: 480px;
}
.map-canvas { position: absolute; inset: 0; background: var(--paper-2); }
.map-fallback {
    position: relative;
    z-index: 1;
    padding: var(--space-5);
    background: var(--paper-2);
    min-height: 100%;
}
.map-fallback-note { color: var(--ink-2); max-width: 52ch; }
.map-panel[data-map-ready] .map-fallback { display: none; }
.map-note {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.15rem;
    color: var(--ink-3);
    margin: var(--space-2) 0 0;
}

/* Timeline, wide layout: trips as ink strokes on one ruled time axis.
   Bars are thin marks (12px, 4px rounded ends); identity lives in the text
   label beside each bar, never in color alone. */
.timeline-section { margin-top: var(--space-7); }
.timeline { overflow-x: auto; padding-bottom: var(--space-2); }
.timeline-track {
    position: relative;
    min-width: 640px;
    height: calc(var(--lanes) * var(--tl-lane-h) + 34px);
    border-bottom: 1px solid var(--line-strong);
}
.timeline-year {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px dashed var(--line);
    color: var(--ink-3);
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.05rem;
    padding-left: var(--space-2);
    display: flex;
    align-items: flex-end;
}
.timeline-bar {
    position: absolute;
    top: calc(var(--lane) * var(--tl-lane-h) + 12px);
    height: 12px;
    min-width: 12px;
    background: var(--trip-color);
    border-radius: 4px;
    text-decoration: none;
    transition: filter 120ms ease, transform 120ms ease;
}
.timeline-bar:hover { filter: brightness(1.15); transform: translateY(-1px); }
.timeline-bar.is-ongoing {
    background: linear-gradient(90deg, var(--trip-color) 78%, transparent);
    border-radius: 4px 0 0 4px;
}
.timeline-bar-label {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: var(--space-2);
    white-space: nowrap;
    color: var(--ink-2);
    font-size: 0.9rem;
    font-family: var(--font-display);
    font-weight: 600;
}
.timeline-bar:hover .timeline-bar-label { color: var(--ink); }
.timeline-bar.label-left .timeline-bar-label {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: var(--space-2);
}

.tl-tooltip {
    position: fixed;
    z-index: 90;
    pointer-events: none;
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    font-size: 0.88rem;
    color: var(--ink);
    box-shadow: var(--shadow-lift);
    max-width: 320px;
    display: none;
}

/* Timeline, narrow layout: the same trips as a year-by-year list.
   Hidden on wide screens; the bar chart is hidden on narrow ones. */
.timeline-stack { list-style: none; margin: 0; padding: 0; }
.timeline-stack-year {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--ink-3);
    padding: var(--space-4) 0 var(--space-1);
}
.timeline-stack a {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px dashed var(--line);
    text-decoration: none;
}
.timeline-stack .stack-tick {
    flex: none;
    width: 16px;
    height: 6px;
    border-radius: 3px;
    background: var(--trip-color, var(--ink-3));
    align-self: center;
}
.timeline-stack .stack-title { font-family: var(--font-display); font-weight: 600; }
.timeline-stack .stack-dates { margin-left: auto; color: var(--ink-3); font-size: 0.85rem; white-space: nowrap; }

/* Trip cards: photo prints fixed to the page with tape. */
.trip-grid { display: grid; gap: var(--space-5); }
.trip-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 10px 10px 0;
    text-decoration: none;
    box-shadow: var(--shadow-soft);
    transition: transform 140ms ease, box-shadow 140ms ease;
}
.trip-card:hover { box-shadow: var(--shadow-lift); }
.trip-card.taped::before { top: -9px; }
.trip-card-cover {
    position: relative;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: 2px;
    /* No cover photo: a sun-faded swatch of the trip color, zero disk cost. */
    background:
        repeating-linear-gradient(-45deg,
            color-mix(in srgb, var(--trip-color) 9%, transparent) 0 3px,
            transparent 3px 9px),
        radial-gradient(120% 140% at 15% 0%,
            color-mix(in srgb, var(--trip-color) 32%, var(--paper-2)) 0%,
            color-mix(in srgb, var(--trip-color) 10%, var(--paper-2)) 75%);
}
.trip-card-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.trip-card-cover .stamp { position: absolute; top: var(--space-3); right: var(--space-3); }
.trip-card-body { padding: var(--space-3) var(--space-2) var(--space-4); }
.trip-card-title { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 0; font-size: 1.2rem; }
.trip-card-meta {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.15rem;
    color: var(--ink-2);
    margin-bottom: var(--space-2);
}
.trip-card-summary { color: var(--ink-2); font-size: 0.95rem; margin-bottom: var(--space-2); }
.trip-card-stats {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--ink-3);
    margin: 0;
}

/* Journal: dated entries, one ruled line between each. */
.post-list { max-width: 46rem; }
.post-card { padding: var(--space-4) 0; border-top: 1px dashed var(--line-strong); }
.post-card:first-child { border-top: 0; }
.post-when {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.2rem;
    line-height: 1.25;
    color: var(--ink-2);
    white-space: nowrap;
}
.post-when .post-year { margin-left: 0.35em; font-weight: 500; font-size: 1rem; color: var(--ink-3); }
.post-card-title { margin-bottom: var(--space-1); font-size: 1.2rem; }
.post-card-title a { text-decoration: none; }
.post-card-title a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.post-card-tags { margin: 0 0 var(--space-1); }
.post-card-excerpt { color: var(--ink-2); font-size: 0.95rem; margin: 0; }

.post-article .post-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink-2);
}

/* Trip page head: the trip's title page. */
.trip-head { display: grid; gap: var(--space-5); }
.trip-head h1 { margin-bottom: var(--space-3); }
.trip-head .hl { --hl-color: var(--trip-color, var(--accent)); }
.trip-head .stat-row { margin: var(--space-4) 0 var(--space-5); }
.trip-head-photo {
    position: relative;
    margin: var(--space-3) 0 0;
    background: var(--card);
    border: 1px solid var(--line);
    padding: 10px;
    box-shadow: var(--shadow-soft);
    align-self: start;
}
.trip-head-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; }

/* Trip page: map + itinerary */
.itinerary h2 { margin-bottom: var(--space-4); }
.itinerary-list { list-style: none; margin: 0; padding: 0; position: relative; }
.itinerary-list li { position: relative; }
/* The route line through the stop numbers, dashed like a route on a map. */
.itinerary-list li::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 0;
    bottom: 0;
    border-left: 2px dashed color-mix(in srgb, var(--trip-color, var(--ink-3)) 45%, var(--paper));
}
.itinerary-list li:first-child::before { top: 12px; }
.itinerary-list li:last-child::before { bottom: auto; height: 12px; }
.itinerary-stop {
    position: relative;
    display: flex;
    gap: var(--space-3);
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    color: inherit;
    padding: var(--space-2) var(--space-2) var(--space-2) 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.itinerary-stop:hover, .itinerary-stop.is-active { background: var(--paper-2); }
.itinerary-index {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--trip-color, var(--ink-3));
    background: var(--card);
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    display: grid;
    place-items: center;
}
.itinerary-body { display: block; min-width: 0; }
.itinerary-name { font-family: var(--font-display); font-weight: 600; margin-right: var(--space-2); }
.itinerary-date { color: var(--ink-3); font-family: var(--font-hand); font-weight: 500; font-size: 1.05rem; }
.itinerary-desc { display: block; color: var(--ink-2); font-size: 0.92rem; }

/* Photos: prints with handwritten captions. */
.photo-grid { display: grid; gap: var(--space-5); }
.photo-item {
    position: relative;
    margin: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 10px 10px var(--space-2);
    box-shadow: var(--shadow-soft);
}
.photo-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}
.photo-open img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; }
.photo-item figcaption {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.15rem;
    color: var(--ink-2);
    margin-top: var(--space-2);
    line-height: 1.3;
}

.lightbox {
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--card);
    color: var(--ink);
    padding: var(--space-4);
    max-width: min(92vw, 1100px);
    box-shadow: var(--shadow-lift);
}
.lightbox::backdrop { background: rgba(46, 35, 20, 0.6); }
.lightbox img { max-width: 100%; max-height: 78vh; margin: 0 auto; border-radius: 2px; }
.lightbox-caption {
    font-family: var(--font-hand);
    font-weight: 500;
    font-size: 1.2rem;
    color: var(--ink-2);
    text-align: center;
    margin: var(--space-3) 0 0;
}
.lightbox-close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink);
    font-size: 1.2rem;
    cursor: pointer;
}
.lightbox-close:hover { background: var(--paper-2); }

/* Long-form text (trip stories, journal posts) */
.prose { max-width: 62ch; }
.prose a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 55%, var(--paper)); }
.prose h2 { margin-top: var(--space-6); }
.prose ul, .prose ol { color: var(--ink-2); padding-left: 1.2rem; }
.prose li { margin-bottom: var(--space-1); }
.prose blockquote {
    margin: var(--space-4) 0;
    padding: var(--space-2) var(--space-4);
    border-left: 3px solid color-mix(in srgb, var(--accent) 45%, var(--paper));
    color: var(--ink-2);
    font-style: italic;
}
.prose img { border-radius: 2px; border: 1px solid var(--line); }

/* Notices (kept for future forms) */
.notice {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--card);
}
.notice-error { border-color: #96381e; }
.notice-success { border-color: #4d7522; }

/* ==========================================================================
   5. THE DESK (wide screens): a sheet of paper on a wooden desk. Cards and
      prints sit slightly askew; the journal keeps its date in the margin.
   ========================================================================== */

@media (min-width: 861px) {
    .sheet {
        max-width: var(--maxw);
        margin: var(--space-6) auto var(--space-7);
        min-height: 0;
        border-radius: 3px;
        box-shadow: var(--shadow-lift);
    }

    .site-nav { padding: var(--space-5) var(--space-7) var(--space-4); }
    .nav-links { display: flex; gap: var(--space-5); }
    .nav-links a { padding: var(--space-1) 0; }
    /* A slightly crooked pen stroke under the current page. */
    .nav-links a[aria-current="page"]::after {
        content: '';
        position: absolute;
        left: -3px;
        right: -3px;
        bottom: -5px;
        height: 3px;
        background: var(--accent);
        border-radius: 2px 4px 2px 4px;
        transform: rotate(-1deg);
    }

    .site-main { padding: var(--space-6) var(--space-7) 0; }
    .site-footer { margin-left: var(--space-7); margin-right: var(--space-7); }

    .dashboard-head {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: var(--space-6);
        flex-wrap: wrap;
    }
    .stat-row { display: flex; flex-wrap: wrap; gap: var(--space-3) 0; }
    .stat-tile { display: flex; flex-direction: column; padding: 0 var(--space-5); border-left: 1px solid var(--line); }
    .stat-row .stat-tile:first-child { border-left: 0; padding-left: 0; }

    .dashboard-grid {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
        gap: var(--space-6);
        align-items: start;
    }
    .dashboard-rail { min-width: 0; }
    .dashboard-rail .post-card { grid-template-columns: 1fr; gap: 0; }
    .dashboard-rail .post-card:first-of-type { border-top: 0; padding-top: 0; }

    /* In the margin-date layout the year stacks under the day. */
    .post-list .post-when .post-year { display: block; margin-left: 0; }

    .map-panel { min-height: 520px; }
    /* Two bits of tape hold the map down. */
    .map-panel::before, .map-panel::after {
        content: '';
        position: absolute;
        top: -18px;
        width: 84px;
        height: 22px;
        background: var(--tape);
        opacity: 0.85;
        clip-path: polygon(2% 0, 98% 5%, 100% 32%, 97% 100%, 3% 94%, 0 58%);
        box-shadow: var(--shadow-soft);
        z-index: 2;
        pointer-events: none;
    }
    .map-panel::before { left: 8%; transform: rotate(-5deg); }
    .map-panel::after { right: 8%; transform: rotate(4deg); }

    .timeline-stack { display: none; }

    .trip-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    /* Prints never lie perfectly straight on a desk. */
    .trip-grid .trip-card:nth-child(3n+1) { transform: rotate(-0.6deg); }
    .trip-grid .trip-card:nth-child(3n+2) { transform: rotate(0.45deg); }
    .trip-grid .trip-card:nth-child(3n)   { transform: rotate(-0.25deg); }
    .trip-grid .trip-card:hover { transform: rotate(0deg) translateY(-3px); }

    /* Journal entries: the date lives in the margin, like a real diary. */
    .post-card { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--space-4); }

    .trip-head.has-cover {
        grid-template-columns: minmax(0, 7fr) minmax(280px, 5fr);
        gap: var(--space-7);
        align-items: start;
    }
    .trip-head-photo { transform: rotate(1.1deg); }

    .trip-map-grid {
        display: grid;
        grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr);
        gap: var(--space-6);
        align-items: start;
    }

    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .photo-grid .photo-item:nth-child(3n+1) { transform: rotate(-0.7deg); }
    .photo-grid .photo-item:nth-child(3n+2) { transform: rotate(0.5deg); }
    .photo-grid .photo-item:nth-child(3n)   { transform: rotate(-0.2deg); }
    .photo-grid .photo-item { transition: transform 140ms ease; }
    .photo-grid .photo-item:hover { transform: rotate(0deg); }
}

/* ==========================================================================
   6. THE POCKET NOTEBOOK (narrow screens): full-bleed paper, index tabs
      under the cover title, everything in one column, the timeline as a
      year-by-year list, the tally as a written ledger.
   ========================================================================== */

@media (max-width: 860px) {
    body { background: var(--paper); }
    .sheet { background: none; }

    .site-header { background-color: var(--paper); }
    .site-nav {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
        padding: var(--space-4) var(--space-4) 0;
    }
    .brand { justify-content: center; font-size: 1.4rem; }
    /* Index tabs, like the cut tabs on a notebook's edge. */
    .nav-links {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .nav-links a {
        text-align: center;
        background: var(--paper-2);
        border: 1px solid var(--line);
        border-bottom: 0;
        border-radius: 8px 8px 0 0;
        padding: 0.5rem 0.25rem 0.55rem;
        font-size: 0.95rem;
        color: var(--ink-2);
    }
    .nav-links a[aria-current="page"] {
        background: var(--card);
        color: var(--ink);
    }
    .nav-links a[aria-current="page"]::after {
        content: '';
        display: block;
        width: 30px;
        height: 3px;
        margin: 3px auto 0;
        background: var(--accent);
        border-radius: 2px;
        transform: rotate(-1.5deg);
    }

    .site-main { padding: var(--space-5) var(--space-4) 0; }

    .page-section { margin-top: var(--space-6); }

    /* The tally reads as a written ledger: label left, number right. */
    .dashboard-head { display: block; }
    .dashboard-head .stat-row { margin-top: var(--space-4); }
    .stat-row { display: block; max-width: 24rem; }
    .stat-tile {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: var(--space-3);
        padding: var(--space-1) 0;
        border-bottom: 1px dashed var(--line);
    }
    .stat-value { font-size: 1.25rem; }

    .dashboard-grid { display: block; }
    .dashboard-rail { margin-top: var(--space-6); }
    .dashboard-rail .post-card:first-of-type { border-top: 0; }

    .map-panel { min-height: 340px; border-width: 8px; }

    .timeline { display: none; }

    .trip-grid { grid-template-columns: 1fr; gap: var(--space-6); }
    .trip-card { transform: rotate(-0.3deg); }
    .trip-card:nth-child(2n) { transform: rotate(0.3deg); }

    .trip-head.has-cover .trip-head-photo { transform: rotate(0.6deg); margin-top: var(--space-2); }
    .trip-map-grid { display: block; }
    .trip-map-grid .itinerary { margin-top: var(--space-5); }
    .trip-head .stat-row { max-width: none; }
    .trip-head .stat-row .stat-tile { border-bottom-color: color-mix(in srgb, var(--trip-color, var(--ink)) 25%, var(--paper)); }

    .photo-grid { grid-template-columns: 1fr; gap: var(--space-6); }
    .photo-item { transform: rotate(-0.3deg); }
    .photo-item:nth-child(2n) { transform: rotate(0.35deg); }

    .site-footer { margin-top: var(--space-7); }
}

@media (max-width: 420px) {
    h1 { font-size: 1.85rem; }
    .site-main { padding-left: var(--space-3); padding-right: var(--space-3); }
    .ticket { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
