/* trips.antonnovikov.com — public pages: map + timeline, trip page with days,
   justified photo rows and the lightbox. Tokens and components come from
   styles.css; this file only adds what the diary needs. */

/* ─── Page head extras ─────────────────────────────────────────────────────── */
.tr-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 40px;
    margin: -0.5rem 0 0.75rem;
    color: var(--fg-mid);
    font-size: var(--fs-sm);
}
.tr-back:hover { color: var(--accent); }
.tr-head-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-top: 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--fg-dim);
}
.tr-head-meta .tr-place { font-family: var(--font); font-size: var(--fs-sm); color: var(--fg-mid); }

.tr-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    margin: 0 0 1.6rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--accent);
    border-left-width: 4px;
    font-size: var(--fs-sm);
    color: var(--fg);
}
.tr-preview strong { color: var(--accent); font-weight: 600; }
.tr-preview a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    margin-left: auto;
    text-decoration: underline;
    text-underline-offset: 3px;
    border-bottom: none;
}

.tr-sec { margin-top: 2.6rem; }
.page-head + .tr-sec { margin-top: 0; }
.tr-sec-title .idx { order: 2; }
.tr-sec-title::after { order: 3; }

.tr-state {
    max-width: var(--measure);
    padding: 1.2rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--fg-mid);
    font-size: var(--fs-sm);
}

/* ─── Map ──────────────────────────────────────────────────────────────────── */
.tr-map-sec { position: relative; }
.tr-map-box { position: relative; }
.tr-map {
    position: relative;
    z-index: 0;
    isolation: isolate;          /* Leaflet panes/controls stay under the sticky header */
    height: 480px;
    border: 1px solid var(--border-strong);
    background: var(--bg-tag);
    font-family: var(--font);
    font-size: var(--fs-sm);
}
.tr-map:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 720px) {
    .tr-map { height: clamp(240px, 45vh, 380px); }
}

/* JS off or Leaflet missing: no empty box, the server-rendered list instead */
html:not(.js) .tr-map-box,
.tr-map-sec.is-failed .tr-map-box { display: none; }
.js .tr-map-sec:not(.is-failed) .tr-places-fallback { display: none; }

.tr-map-note {
    position: absolute;
    left: 50%;
    top: 12px;
    z-index: 2;
    transform: translateX(-50%);
    max-width: calc(100% - 24px);
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--fg-mid);
    font-size: var(--fs-sm);
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.tr-map-note.is-error { color: var(--err); border-color: var(--err); }
.tr-map-note[hidden] { display: none; }

.tr-map-hint {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.42);
    color: #fff;
    font-size: var(--fs-sm);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.tr-map-hint.is-shown { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tr-map-hint { transition: none; } }

/* Leaflet chrome in site tokens */
.tr-map.leaflet-container { font-family: var(--font); font-size: var(--fs-sm); background: var(--bg-tag); }
.tr-map .leaflet-bar { border: 1px solid var(--border-strong); border-radius: 3px; box-shadow: none; }
.tr-map .leaflet-bar a,
.tr-map.leaflet-touch .leaflet-bar a {
    width: 40px;
    height: 40px;
    line-height: 38px;
    background: var(--bg);
    color: var(--fg);
    border-bottom: 1px solid var(--border);
    font-size: 20px;
}
.tr-map .leaflet-bar a:last-child { border-bottom: none; }
.tr-map .leaflet-bar a:hover,
.tr-map .leaflet-bar a:focus { background: var(--bg-tag); color: var(--fg); }
.tr-map .leaflet-bar a.leaflet-disabled { background: var(--bg); color: var(--fg-dim); opacity: 0.6; }
.tr-map .leaflet-control-attribution {
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    color: var(--fg-mid);
    font-size: var(--fs-xs);
    line-height: 1.5;
    padding: 1px 6px;
}
.tr-map .leaflet-control-attribution a { color: var(--fg); text-decoration: underline; border-bottom: none; }

.tr-map .leaflet-popup-content-wrapper,
.tr-map .leaflet-popup-tip {
    background: var(--bg);
    color: var(--fg);
    border-radius: 3px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.tr-map .leaflet-popup-content-wrapper { border: 1px solid var(--border-strong); }
.tr-map .leaflet-popup-content { margin: 0.8rem 2.6rem 0.8rem 0.9rem; font-size: var(--fs-sm); line-height: 1.45; }
.tr-map a.leaflet-popup-close-button {
    width: 40px;
    height: 40px;
    font: 22px/40px var(--font);
    color: var(--fg-mid);
    border-bottom: none;
}
.tr-map a.leaflet-popup-close-button:hover { color: var(--fg); }

[data-theme="dark"] .tr-map .leaflet-tile-pane { filter: brightness(0.72) contrast(1.08) saturate(0.85); }

/* markers: divIcon, no PNGs; the box is the hit area, the dot is the mark */
.tr-map .tr-pin {
    display: grid;
    place-items: center;
    background: none;
    border: none;
}
.tr-map .tr-pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px var(--accent), 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s;
}
.tr-map .tr-pin:hover .tr-pin-dot,
.tr-map .tr-pin:focus-visible .tr-pin-dot { transform: scale(1.2); }
.tr-map .tr-pin.is-multi .tr-pin-dot { width: 22px; height: 22px; }
.tr-map .tr-pin-n {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: var(--on-accent);
    pointer-events: none;
}
.tr-map .tr-pin:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-radius: 50%; }

/* popup content */
.tr-map .tr-pop-name { font-weight: 600; color: var(--fg); margin: 0; }
.tr-map .tr-pop-meta { margin: 0.15rem 0 0; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-dim); }
.tr-map .tr-pop-trip { margin: 0.2rem 0 0; color: var(--fg-mid); }
.tr-map .tr-pop-trip a { color: var(--fg-mid); text-decoration: underline; text-underline-offset: 3px; border-bottom: none; }
.tr-map .tr-pop-trip a:hover { color: var(--accent); }
.tr-map .tr-pop-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    margin-top: 0.15rem;
    color: var(--fg);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 3px;
    border-bottom: none;
}
.tr-map .tr-pop-link:hover { color: var(--accent); }
.tr-map .tr-pop-n { margin: 0 0 0.3rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-dim); }
.tr-map .tr-pop-list {
    list-style: none;
    max-height: min(15rem, 40vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 1px solid var(--border);
}
.tr-map .tr-pop-list li { padding: 0.45rem 0 0.1rem; border-bottom: 1px solid var(--border); }
.tr-map .tr-pop-list .tr-pop-link { min-height: 36px; }
@media (pointer: coarse) { .tr-map .tr-pop-list .tr-pop-link, .tr-map .tr-pop-link { min-height: 44px; } }

/* places list: fallback when the map cannot load + trip places not tied to a day */
.tr-places-fallback { margin-top: 0.4rem; }
.tr-places-fallback .rows li,
.tr-loose .rows li { grid-template-columns: 9rem 1fr; padding: 0.5rem 0; }
.tr-places-fallback .rows a,
.tr-loose .rows a { display: inline-flex; align-items: center; min-height: 32px; }
.tr-places-fallback .tr-pl-trip { color: var(--fg-dim); font-size: var(--fs-sm); }
.tr-loose { margin-top: 1.4rem; }
.tr-loose-title { margin: 0 0 0.4rem; font-size: var(--fs-sm); font-weight: 600; color: var(--fg-mid); letter-spacing: 0; text-transform: none; }
@media (max-width: 520px) {
    .tr-places-fallback .rows li, .tr-loose .rows li { grid-template-columns: 1fr; gap: 0; }
}

/* ─── Timeline (home) ──────────────────────────────────────────────────────── */
.tr-year { margin-top: 2.2rem; }
.tr-year:first-child { margin-top: 0; }
.tr-year-title {
    margin: 0 0 0.2rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--fg-dim);
    text-transform: none;
}
.tr-timeline { list-style: none; border-top: 1px solid var(--border-strong); }
.tr-item {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    grid-template-areas: "cover head" "cover body";
    grid-template-rows: auto 1fr;
    gap: 0.35rem 1.5rem;
    padding: 1.2rem 0;
    border-bottom: 1px solid var(--border);
}
.tr-cover {
    grid-area: cover;
    display: block;
    position: relative;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: var(--bg-tag);
    border-bottom: none;
}
.tr-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s;
}
.tr-cover:hover img { opacity: 0.88; }
.tr-cover-empty {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--fg-dim);
    border: 1px dashed var(--border-strong);
}
.tr-item-head { grid-area: head; min-width: 0; }
.tr-item-dates { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--fg-dim); }
.tr-item-title {
    margin: 0.15rem 0 0;
    font-size: 1.25rem;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--fg);
    overflow-wrap: anywhere;
}
.tr-item-title a { color: var(--fg); border-bottom: none; }
.tr-item-title a:hover { color: var(--accent); }
/* the whole row is clickable through the title link, keyboard focus stays on the title */
.tr-item { position: relative; }
.tr-item-title a::after { content: ''; position: absolute; inset: 0; }
.tr-cover { z-index: 1; }
.tr-item-place { margin-top: 0.1rem; color: var(--fg-mid); font-size: var(--fs-sm); }
.tr-item-body { grid-area: body; min-width: 0; }
.tr-item-summary {
    max-width: var(--measure);
    color: var(--fg-mid);
    font-size: 0.9375rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tr-counts { margin-top: 0.45rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-dim); }

@media (max-width: 720px) {
    .tr-item { grid-template-columns: 9rem minmax(0, 1fr); gap: 0.3rem 1rem; }
    .tr-item-title { font-size: 1.0625rem; }
}
@media (max-width: 520px) {
    .tr-item {
        grid-template-columns: 7.5rem minmax(0, 1fr);
        grid-template-areas: "cover head" "body body";
        grid-template-rows: auto auto;
        gap: 0.6rem 0.9rem;
        padding: 1rem 0;
    }
    .tr-cover { align-self: start; }
    .tr-item-summary { -webkit-line-clamp: 4; font-size: var(--fs-sm); }
}

/* ─── Trip page: days ──────────────────────────────────────────────────────── */
.tr-days { margin-top: 2.6rem; }
.tr-day {
    padding: 1.4rem 0 1.8rem;
    border-top: 1px solid var(--border-strong);
}
.tr-day-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.2rem 0.7rem;
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 650;
    letter-spacing: -0.005em;
    text-transform: none;
    color: var(--fg);
}
.tr-day-title:focus { outline: none; }
.tr-day-n { color: var(--accent); }
.tr-day-date { font-family: var(--font-mono); font-size: 0.8125rem; font-weight: 400; color: var(--fg-dim); }
.tr-day-places { margin: 0 0 0.6rem; font-size: var(--fs-sm); color: var(--fg-mid); }
.tr-day-places .tr-pin-ico {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: 0.05em;
}
.tr-day-note {
    max-width: var(--measure);
    margin: 0 0 1rem;
    color: var(--fg);
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.tr-day-empty { margin: 0; font-size: var(--fs-sm); color: var(--fg-dim); }

/* arriving from the map or a link: briefly mark the day */
@keyframes tr-flash {
    0%, 35% { background-color: color-mix(in srgb, var(--accent) 12%, transparent); }
    100% { background-color: transparent; }
}
.tr-day:target,
.tr-day.is-flash { animation: tr-flash 1.8s ease-out; }
@media (prefers-reduced-motion: reduce) {
    .tr-day:target, .tr-day.is-flash { animation: none; box-shadow: inset 3px 0 0 var(--accent); }
}

/* ─── Gallery: justified rows, nothing cropped ─────────────────────────────── */
/* Every item grows in proportion to its aspect ratio, so all photos in a row
   end up the same height; the trailing pseudo-element soaks up the free space
   of the last row so it is not blown up. Vertical photos keep their shape. */
.tr-gallery {
    --row-h: 220px;
    --gap: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    list-style: none;
}
.tr-gallery::after { content: ''; flex-grow: 1e4; }
.tr-ph {
    position: relative;
    flex: calc(var(--ar) * 100) 1 calc(var(--ar) * var(--row-h));
    min-width: 0;
    /* a lone photo never grows taller than ~1.6 rows */
    max-width: calc(var(--ar) * var(--row-h) * 1.6);
    margin: 0;
}
.tr-ph-link {
    display: block;
    border-bottom: none;
    background: var(--bg-tag);
    cursor: zoom-in;
}
.tr-ph-link img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: var(--ar);
    transition: opacity 0.2s;
}
.tr-ph-link:hover img { opacity: 0.9; }
.tr-ph-link:focus-visible { outline-offset: 2px; }
.tr-ph-cap {
    margin-top: 0.3rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--fg-mid);
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
@media (max-width: 720px) {
    .tr-gallery { --row-h: 150px; --gap: 4px; }
    .tr-ph-cap { font-size: var(--fs-xs); }
}

/* ─── Lightbox ─────────────────────────────────────────────────────────────── */
/* Always dark (photo viewer), regardless of the page theme. */
html.tr-lb-lock { overflow: hidden; }
html.tr-lb-lock body { padding-right: var(--tr-sbw, 0px); }

.tr-lb:not([open]) { display: none; }
.tr-lb {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: none;
    background: #0c0d10;
    color: #e6e8eb;
    overflow: hidden;
}
.tr-lb[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.tr-lb::backdrop { background: rgba(0, 0, 0, 0.9); }
.tr-lb :focus-visible { outline: 2px solid #7aa7ff; outline-offset: 2px; }

.tr-lb-bar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 56px;
    padding: 0 0.4rem 0 1rem;
    padding-top: env(safe-area-inset-top, 0px);
}
.tr-lb-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: rgba(230, 232, 235, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tr-lb-pos { color: #fff; margin-right: 0.7rem; }
.tr-lb-btn {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 3px;
    background: none;
    color: #e6e8eb;
    cursor: pointer;
}
.tr-lb-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.tr-lb-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tr-lb-btn:disabled { opacity: 0.25; cursor: default; background: none; }
.tr-lb-file {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.6rem;
    color: rgba(230, 232, 235, 0.85);
    font-size: var(--fs-sm);
    text-decoration: underline;
    text-underline-offset: 3px;
    border-bottom: none;
}
.tr-lb-file:hover { color: #fff; }

.tr-lb-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    touch-action: pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
}
.tr-lb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.15s;
    -webkit-user-drag: none;
}
.tr-lb-stage.is-loading .tr-lb-img,
.tr-lb-stage.is-error .tr-lb-img { opacity: 0; }
.tr-lb-status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: calc(100% - 140px);
    margin: 0;
    font-size: var(--fs-sm);
    color: rgba(230, 232, 235, 0.85);
    text-align: center;
    pointer-events: none;
}
.tr-lb-stage:not(.is-loading):not(.is-error) .tr-lb-status { display: none; }
.tr-lb-stage.is-error .tr-lb-status { color: #f39b9b; pointer-events: auto; flex-direction: column; }
.tr-lb-stage.is-loading .tr-lb-status::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tr-spin 0.8s linear infinite;
}
@keyframes tr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tr-lb-stage.is-loading .tr-lb-status::before { animation-duration: 2.4s; } }

.tr-lb-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 52px;
    height: 72px;
    background: rgba(12, 13, 16, 0.45);
}
.tr-lb-nav:hover { background: rgba(12, 13, 16, 0.75); }
.tr-lb-nav:disabled { display: none; }
.tr-lb-prev { left: 8px; }
.tr-lb-next { right: 8px; }

.tr-lb-foot {
    min-height: 3.2rem;
    padding: 0.6rem 1rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
}
.tr-lb-cap {
    max-width: var(--measure);
    margin: 0 auto;
    max-height: 4.8em;
    overflow-y: auto;
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: #e6e8eb;
    text-align: center;
    overflow-wrap: anywhere;
}
.tr-lb-cap:empty { display: none; }

@media (max-width: 720px) {
    .tr-lb-bar { min-height: 52px; padding-left: 0.8rem; }
    .tr-lb-nav { width: 44px; height: 64px; background: rgba(12, 13, 16, 0.35); }
    .tr-lb-prev { left: 2px; }
    .tr-lb-next { right: 2px; }
    .tr-lb-foot { padding: 0.5rem 0.8rem; padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
}
@media (pointer: coarse) {
    /* swipe is the main gesture on phones; keep the buttons quieter */
    .tr-lb-nav { opacity: 0.75; }
}
