/* Upham's Corner Walking Tour guide, restyled 2026-07-29 to match the
   site page's "Main Street Wayfinding" system: Archivo only, ink chrome,
   gold route, blue active states. Variable names keep their original
   playbill-era names (--dusk = ink chrome, --marquee = gold, --brick =
   active blue); values are the tokens that matter. */

:root {
    --dusk: #21303F;
    --dusk-deep: #16202B;
    --paper: #FFFFFF;
    --ink: #21303F;
    --muted: #5B6B7A;
    --marquee: #E0B93F;
    --marquee-soft: rgba(224, 185, 63, 0.55);
    --brick: #1B75BC;
    --leaf: #5B6B7A;
    --line: rgba(33, 48, 63, 0.14);
    --card-w: min(86vw, 380px);
    --deck-h: 332px;
    --media-h: 122px;
    --bar-h: 58px;
    --display: 'Archivo', sans-serif;
    --body: 'Archivo', sans-serif;
    --mono: 'Archivo', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--body);
    color: var(--ink);
    background: var(--dusk);
}

#map {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: #e8e6e1;
}

/* ---------- top bar ---------- */

.bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 600;
    height: calc(var(--bar-h) + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 14px 0 16px;
    padding-top: env(safe-area-inset-top);
    background: rgba(255, 255, 255, 0.97);
    color: var(--ink);
    border-bottom: 3px solid var(--brick);
    box-shadow: 0 6px 18px rgba(33, 48, 63, 0.08);
}

.bar .back {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-right: 2px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink);
}
.bar .back:hover { border-color: var(--brick); color: var(--brick); }
/* Embedded in the site page: the page is right there behind the frame.
   Except in fullscreen, where the arrow returns as the way out. */
body.embedded .back { display: none; }
body.embedded.fs-embed .back { display: grid; }

.bar-text { min-width: 0; }

.eyebrow {
    display: block;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brick);
}

.bar h1 {
    margin: 1px 0 0;
    font-family: var(--display);
    font-weight: 700;
    font-size: 16.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- markers ---------- */

.pin-wrap { background: none; border: none; }

.pin {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--marquee);
    color: var(--dusk-deep);
    font: 600 15px/1 var(--body);
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(16, 19, 26, 0.4);
    transition: transform 0.22s ease, background-color 0.22s ease, color 0.22s ease;
    cursor: pointer;
}

.pin.active {
    transform: scale(1.28);
    background: var(--brick);
    color: #fff;
    z-index: 10;
}

/* the marquee: a slowly rotating ring of gold bulbs around the active stop */
.pin.active::after {
    content: '';
    position: absolute;
    inset: -9px;
    border-radius: 50%;
    border: 2.5px dotted var(--marquee);
    animation: marquee-spin 16s linear infinite;
}

@keyframes marquee-spin { to { transform: rotate(360deg); } }

.leaflet-tooltip.start-pill {
    background: var(--brick);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 4px 10px;
    box-shadow: 0 2px 8px rgba(33, 48, 63, 0.35);
}
.leaflet-tooltip.start-pill::before { display: none; }

/* walking route: gold footsteps on a pale path */
.route-flow { animation: route-walk 1.8s linear infinite; }
@keyframes route-walk { to { stroke-dashoffset: -12; } }

.you-dot { animation: you-pulse 2.4s ease-out infinite; }
@keyframes you-pulse {
    0% { stroke-opacity: 0.9; }
    50% { stroke-opacity: 0.25; }
    100% { stroke-opacity: 0.9; }
}

/* ---------- locate button ---------- */

.locate {
    position: fixed;
    right: 14px;
    bottom: calc(var(--deck-h) + 16px + env(safe-area-inset-bottom));
    z-index: 600;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 4px 14px rgba(16, 19, 26, 0.28);
    cursor: pointer;
}
.locate.on { background: var(--brick); color: #fff; border-color: var(--brick); }
body.deck-x .locate { opacity: 0; pointer-events: none; }

/* ---------- prev/next stop buttons ---------- */

.nav-btn {
    position: fixed;
    bottom: calc(var(--deck-h) / 2 + env(safe-area-inset-bottom));
    z-index: 650;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--marquee-soft);
    border-radius: 50%;
    background: rgba(22, 32, 43, 0.82);
    color: var(--marquee);
    box-shadow: 0 4px 14px rgba(16, 19, 26, 0.35);
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.nav-btn.prev { left: 8px; }
.nav-btn.next { right: 8px; }
.nav-btn[disabled] { opacity: 0.25; cursor: default; }

/* On touch devices swipe is the interaction: arrows are for screen readers
   and keyboard users only, visually hidden until keyboard-focused (an
   invisible focused control would fail WCAG 2.4.7). Mouse/trackpad devices
   keep them visible. */
@media (hover: none), (pointer: coarse) {
    .nav-btn:not(:focus-visible) {
        width: 1px;
        height: 1px;
        padding: 0;
        border: 0;
        clip-path: inset(50%);
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
    }
}

/* Expanded sheet: dock the arrows at the sheet's top corners instead of
   floating over the card text. */
body.deck-x .nav-btn {
    bottom: calc(var(--deck-h) - 50px + env(safe-area-inset-bottom));
}
body.deck-x .nav-btn.prev { left: calc((100vw - var(--card-w)) / 2 + 6px); }
body.deck-x .nav-btn.next { right: calc((100vw - var(--card-w)) / 2 + 6px); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- card deck ---------- */

.deck-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 600;
    padding-bottom: env(safe-area-inset-bottom);
    pointer-events: none;
}

.deck {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 10px calc((100vw - var(--card-w)) / 2) 14px;
    scrollbar-width: none;
    pointer-events: auto;
}
.deck::-webkit-scrollbar { display: none; }
.deck:focus-visible { outline: 3px solid var(--marquee); outline-offset: -3px; }

/* Expanded ("read it comfortably") state: the deck grows into a bottom
   sheet; heights below all key off these two variables. */
body.deck-x {
    --deck-h: min(84dvh, 660px);
    --media-h: 220px;
}

.card {
    position: relative;
    flex: 0 0 var(--card-w);
    scroll-snap-align: center;
    height: calc(var(--deck-h) - 24px);
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 26px rgba(16, 19, 26, 0.35);
    opacity: 0.72;
    transform: scale(0.97);
    transition: opacity 0.25s ease, transform 0.25s ease, height 0.35s ease;
}
.card.active { opacity: 1; transform: scale(1); }

.expand-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 6;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(22, 32, 43, 0.62);
    color: var(--paper);
    cursor: pointer;
    transition: transform 0.3s ease;
}
/* When expanded, the chevron becomes a centered sheet grab handle. */
body.deck-x .expand-btn {
    left: 50%;
    right: auto;
    transform: translateX(-50%) rotate(180deg);
}

.media-wrap {
    position: relative;
    flex: 0 0 auto;
    background: var(--dusk-deep);
}

.media {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    height: var(--media-h);
    transition: height 0.35s ease;
}
/* Multi-slide sliders keep their swipes to themselves; single-image strips
   let the gesture fall through to the deck. */
.media.multi { overscroll-behavior-x: contain; }
.media::-webkit-scrollbar { display: none; }

.slide {
    position: relative;
    flex: 0 0 100%;
    scroll-snap-align: center;
    height: 100%;
    overflow: hidden;
}
.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.slide.yt { cursor: pointer; }
.slide.yt .play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(22, 32, 43, 0.78);
    border: 2px solid var(--marquee);
    box-shadow: 0 4px 14px rgba(16, 19, 26, 0.5);
}
.slide.yt .play::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-left: 16px solid var(--marquee);
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}
.slide.yt .yt-label {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 8px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--paper);
    text-shadow: 0 1px 3px rgba(16, 19, 26, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slide iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* photo-slider arrows: desktop affordance for "there are more photos".
   Hidden on touch (swiping a photo strip is natural there). */
.m-arrow {
    display: none;
    position: absolute;
    top: calc(var(--media-h) / 2);
    transform: translateY(-50%);
    z-index: 6;
    width: 34px;
    height: 34px;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(22, 32, 43, 0.72);
    color: var(--marquee);
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.m-arrow.prev { left: 8px; }
.m-arrow.next { right: 8px; }

@media (hover: hover) and (pointer: fine) {
    .m-arrow { display: grid; opacity: 0; }
    .media-wrap:hover .m-arrow:not(.off),
    .m-arrow:focus-visible:not(.off) { opacity: 1; }
    .media-wrap:hover .m-arrow.off { opacity: 0.25; }
    .m-arrow.off { pointer-events: none; }

    /* clicking a photo grows the card; hint it */
    body:not(.deck-x) .card.active .slide:not(.yt) { cursor: zoom-in; }
}

.dots {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    z-index: 5;
    display: flex;
}
/* 28px hit target around an 8px visual dot (WCAG 2.5.8) */
.dot {
    position: relative;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}
.dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 3px rgba(16, 19, 26, 0.6);
}
.dot.on::after { background: var(--marquee); }

/* Only contain vertical overscroll: horizontal swipes must chain up to
   the deck, or dragging between cards only works from the edges. */
.card-body {
    padding: 12px 16px 10px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--marquee-soft) transparent;
}

.card-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.token {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--marquee);
    color: var(--dusk-deep);
    font: 600 13px/1 var(--body);
    transform: translateY(4px);
}
.card.active .token { background: var(--brick); color: #fff; }

.card h2 {
    margin: 0;
    font-family: var(--display);
    font-weight: 800;
    font-size: 18px;
    line-height: 1.25;
}

.card .sub {
    margin: 3px 0 0 36px;
    font: 600 13px/1.4 var(--body);
    color: var(--leaf);
}

.card .addr {
    margin: 8px 0 0 36px;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.card .desc { margin-top: 6px; }
.card .desc p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; }
.card .desc strong { color: var(--brick); font-weight: 700; }

.card .credit {
    margin: 10px 0 2px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--muted);
}

/* ---------- toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--deck-h) + 18px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(8px);
    z-index: 700;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid #D8D2C4;
    box-shadow: 0 4px 14px rgba(33, 48, 63, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 86vw;
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- focus, motion, larger screens ---------- */

button:focus-visible, a:focus-visible {
    outline: 3px solid var(--marquee);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .route-flow, .pin.active::after, .you-dot { animation: none; }
    .card, .pin, .media, .expand-btn { transition: none; }
}

@media (min-width: 760px) {
    :root { --card-w: 400px; }
    .bar h1 { font-size: 22px; }
    .deck { gap: 16px; }
}

/* leaflet attribution, quieted */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.85) !important;
    font-size: 9.5px;
    color: var(--muted);
}
