/* Route details keep the map in view while the overview and stops slide horizontally. */
html:has(body.route-detail-page [data-route-detail]) { overflow: hidden !important; }
body.route-detail-page:has([data-route-detail]) { overflow: hidden; margin: 0 auto; }
.route-detail-page .route-detail-shell {
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: calc(100dvh - var(--route-shell-top, 136px));
    min-height: 0;
    max-width: 100%;
    overflow: hidden;
    background: #f6f5f2;
}
.route-detail-page .route-detail-header { margin: 0; padding: 10px 16px; background: #fff; z-index: 2; }
.route-detail-page .route-detail-header h1 { font-size: 17px; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.route-map-viewer { min-height: 0; position: relative; overflow: hidden; isolation: isolate; }
.route-detail-page .route-detail-map {
    position: absolute; inset: 0; width: 100%; height: 100% !important;
    min-height: 0 !important; max-height: none !important; z-index: 0;
}
.route-detail-page .route-detail-map .plan-google-map,
.route-detail-page .route-leaflet-map,
.route-detail-page .route-static-map { height: 100%; width: 100%; }
.route-map-tools { position: absolute; right: 14px; top: 12px; z-index: 3; }
.route-overview-button { border: 1px solid #e5e7eb; border-radius: 24px; padding: 10px 14px; background: #fff; color: #27273b; font-family: inherit; font-size: 13px; font-weight: 700; box-shadow: 0 3px 16px #20263615; cursor: pointer; }
.route-card-deck {
    position: absolute; z-index: 4; bottom: 12px; left: 0; right: 0;
    display: flex; align-items: flex-end; gap: 12px; height: var(--route-collapsed-deck-height, 280px); min-height: 0;
    padding: 8px 20px 6px; box-sizing: border-box;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-padding-inline: 20px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.route-card-deck::-webkit-scrollbar { display: none; }
.route-card-deck .route-deck-card {
    flex: 0 0 min(380px, calc(100% - 14px)); width: min(380px, calc(100% - 14px));
    min-width: 0; height: calc(var(--route-collapsed-deck-height, 280px) - 14px); min-height: 0; box-sizing: border-box;
    scroll-snap-align: start; scroll-snap-stop: always; overflow-x: hidden; overflow-y: hidden;
    overscroll-behavior-y: contain; border: 1px solid #ececf1; border-radius: 22px;
    background: #fff; padding: 16px; box-shadow: 0 5px 22px #24243712;
    align-content: start; position: relative;
}
.route-card-deck .route-deck-card.is-selected { border-color: #ff642d66; }
.route-card-deck .route-overview-card { display: grid; gap: 8px; margin: 0; }
.route-card-deck .route-overview-card h2 { font-size: 19px; margin: 0; line-height: 1.25; }
.route-card-deck .route-detail-profile { padding: 0; gap: 10px; }
.route-card-deck .route-detail-avatar, .route-card-deck .route-detail-avatar img { width: 36px; height: 36px; }
.route-card-deck .route-detail-profile strong { font-size: 14px; }
.route-card-deck .route-detail-profile small { font-size: 11px; }
.route-card-deck .route-detail-description { font-size: 13px; margin: 0; line-height: 1.5; }
.route-card-deck .route-detail-type-links { margin: 0; gap: 6px; }
.route-card-deck .route-detail-type-links a { font-size: 11px; padding: 5px 8px; }
.route-card-deck .route-detail-meta-row { margin: 0; }
.route-deck-hint { margin: 0; color: #74748a; font-size: 12px; line-height: 1.45; }
.route-explore-button { border: 0; border-radius: 12px; background: #fff1eb; color: #c64412; padding: 10px 12px; display: flex; justify-content: space-between; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.route-card-deck .route-detail-stop { grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: 56px var(--route-media-height, 132px) auto; gap: 10px; }
.route-card-deck .route-detail-stop > span { width: 30px; height: 36px; font-size: 14px; }
.route-card-deck .route-detail-stop-head { padding-right: 30px; align-content: center; }
.route-card-deck .route-detail-stop-head strong { font-size: 16px; }
.route-card-deck .route-detail-stop-head small { color: #8b8b9a; font-size: 11px; }
.route-card-deck .route-detail-stop-more { top: 16px; right: 12px; width: 30px; height: 30px; padding: 0; }
.route-card-deck .route-detail-stop-media { display: flex; overflow-x: auto; overflow-y: hidden; gap: 8px; grid-column: 1 / -1; grid-row: 2; min-width: 0; height: var(--route-media-height, 132px); min-height: var(--route-media-height, 132px); }
.route-card-deck .route-detail-stop-media:empty { display: none; }
.route-card-deck .route-detail-stop-media a { flex: 0 0 var(--route-media-height, 132px); height: var(--route-media-height, 132px); min-height: var(--route-media-height, 132px); border-radius: 13px; background: #f8f8fb; }
.route-card-deck .route-detail-stop-media img { display: block; width: 100%; height: 100%; max-width: none; max-height: none; aspect-ratio: auto; object-fit: cover; object-position: center; border-radius: 13px; }
.route-card-deck .route-detail-stop p { grid-column: 1 / -1; font-size: 13px; line-height: 1.5; color: #74748a; }
.route-viewer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #ececf1; z-index: 5; }
.route-viewer-footer .route-detail-social-actions { border: 0; padding: 0; gap: 16px; }
.route-viewer-footer .route-detail-social-actions svg { width: 23px; height: 23px; }
.route-deck-navigation { display: flex; align-items: center; gap: 8px; }
.route-deck-navigation button { border: 0; background: #fff1eb; color: #d64d1b; border-radius: 50%; width: 32px; height: 32px; font-size: 25px; cursor: pointer; }
.route-deck-navigation button:disabled { color: #b7b7c2; background: #f5f5f8; cursor: default; }
.route-deck-navigation span { font-size: 11px; font-weight: 600; color: #6f6f82; white-space: nowrap; }
.route-static-map-pin { border: 0; padding: 0; cursor: pointer; }
.route-static-map-pin.is-selected { filter: drop-shadow(0 0 4px #ff642d); }
.route-deck-card:focus-visible, .route-card-deck:focus-visible,
.route-map-tools button:focus-visible, .route-deck-navigation button:focus-visible { outline: 3px solid #ff642d; outline-offset: -3px; }
@media (min-width: 900px) {
    .route-card-deck { gap: 18px; padding-left: 32px; padding-right: 32px; scroll-padding-inline: 32px; }
    .route-viewer-footer { padding-inline: 32px; }
}
@media (max-width: 360px) {
    .route-viewer-footer { padding-inline: 10px; gap: 6px; }
    .route-viewer-footer .route-detail-social-actions { gap: 10px; }
    .route-deck-navigation { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { .route-card-deck { scroll-behavior: auto; } }
.route-card-deck .route-deck-card:last-child:not(:first-child) { margin-inline-end: 14px; }
.route-map-fallback-note { position: absolute; top: 58px; left: 12px; right: 12px; margin: 0; padding: 8px 10px; border-radius: 10px; background: #fffffff0; color: #626275; font-size: 11px; z-index: 2; pointer-events: none; }
.route-leaflet-pin-shell.is-selected { filter: drop-shadow(0 0 5px #ff642d); }

.route-detail-page .route-leaflet-map, .route-detail-page .route-static-map { min-height: 0; }

.route-map-selection-note { position: absolute; top: 60px; left: 14px; right: 14px; z-index: 3; margin: 0; padding: 8px 12px; background: #fffffff2; border-radius: 10px; color: #66667a; font-size: 12px; pointer-events: none; }
.route-map-selection-note[hidden], .route-map-fallback-note[hidden] { display: none; }

/* Collapsed cards reserve the entire image row; text no longer squeezes photographs. */
.route-card-deck .route-card-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 8px; min-width: 0; grid-column: 1 / -1; }
.route-card-deck .route-detail-stop .route-card-copy { grid-row: 3; }
.route-card-deck .route-card-copy [data-route-text] { display: block; min-width: 0; margin: 0; grid-column: auto; grid-row: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; }
.route-copy-toggle { border: 0; background: transparent; padding: 2px 0; color: #252537; font: inherit; font-size: 13px; font-weight: 750; white-space: nowrap; cursor: pointer; }
.route-copy-toggle:focus-visible { outline: 2px solid #ff642d; outline-offset: 3px; border-radius: 3px; }
.route-card-deck.is-expanded { height: calc(100% - 74px); }
.route-card-deck .route-deck-card.is-expanded { height: 100%; overflow-y: auto; }
.route-card-deck .route-deck-card.is-expanded .route-card-copy { grid-template-columns: minmax(0, 1fr); align-items: start; }
.route-card-deck .route-deck-card.is-expanded [data-route-text] { white-space: pre-line; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.route-card-deck .route-deck-card.is-expanded .route-copy-toggle { justify-self: start; }
.route-card-deck .route-detail-stop-head strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.2; }
.route-card-deck .route-detail-stop:has(.route-detail-stop-media:empty) { grid-template-rows: 56px auto; }
.route-card-deck .route-detail-stop:has(.route-detail-stop-media:empty) .route-card-copy { grid-row: 2; }
.route-card-deck .route-deck-hint { display: none; }

@media (max-height: 700px) {
    .route-overview-card:not(.is-expanded) h2,
    .route-overview-card:not(.is-expanded) .route-explore-button { display: none; }
}

/* The overview uses all remaining card space; stop notes keep their single-line summary. */
.route-card-deck .route-overview-card { display: flex; flex-direction: column; }
.route-card-deck .route-overview-card > :not(.route-card-copy) { flex-shrink: 0; }
.route-card-deck .route-overview-card .route-card-copy { display: flex; flex-direction: column; align-items: stretch; flex: 1 1 auto; min-height: 46px; gap: 4px; }
.route-card-deck .route-overview-card .route-card-copy [data-route-text] {
    flex: 0 0 auto; display: -webkit-box; -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--route-overview-lines, 3);
    max-height: calc(var(--route-overview-lines, 3) * 1.5em);
    white-space: pre-line; overflow: hidden; text-overflow: ellipsis; line-height: 1.5;
}
.route-card-deck .route-overview-card .route-copy-toggle { align-self: flex-end; flex: 0 0 auto; }
.route-copy-toggle[hidden] { display: none; }
.route-card-deck .route-overview-card.is-expanded .route-card-copy { flex: 0 0 auto; }
.route-card-deck .route-overview-card.is-expanded [data-route-text] { display: block; -webkit-line-clamp: unset; max-height: none; overflow: visible; }
.route-card-deck .route-overview-card.is-expanded .route-copy-toggle { align-self: flex-start; }
