/* Upham's Corner Walking Tour demo — "civic playbill" direction.
   Chrome in dusk blue, marquee gold route, playbill serif display type. */

:root {
    --dusk: #232936;
    --dusk-deep: #1a1f2a;
    --paper: #faf7f0;
    --ink: #23252a;
    --muted: #6b6f76;
    --marquee: #e0a63a;
    --marquee-soft: rgba(224, 166, 58, 0.55);
    --brick: #bf4934;
    --leaf: #47705a;
    --line: rgba(35, 37, 42, 0.12);
    --card-w: min(86vw, 380px);
    --deck-h: 332px;
    --media-h: 122px;
    --bar-h: 58px;
    --display: 'Instrument Serif', Georgia, serif;
    --body: 'Public Sans', system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { 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: linear-gradient(to bottom, rgba(26, 31, 42, 0.96), rgba(26, 31, 42, 0.88));
    color: var(--paper);
    box-shadow: 0 1px 0 rgba(224, 166, 58, 0.35), 0 6px 18px rgba(16, 19, 26, 0.25);
}

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

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

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

.chip {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--paper);
    background: transparent;
    border: 1px solid rgba(250, 247, 240, 0.35);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
}
.chip:hover { border-color: var(--marquee); color: var(--marquee); }

/* ---------- 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(--dusk-deep);
    color: var(--marquee);
    border: 1px solid var(--marquee-soft);
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 9px;
    box-shadow: 0 2px 8px rgba(16, 19, 26, 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(--dusk); color: var(--marquee); border-color: var(--dusk); }
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(26, 31, 42, 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; }

/* Swipe is the primary sighted interaction; the arrows exist for screen
   readers and keyboard users. Visually hidden until keyboard-focused
   (an invisible focused control would fail WCAG 2.4.7). */
.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: 14px;
    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(26, 31, 42, 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(26, 31, 42, 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;
}

.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(250, 247, 240, 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: 400;
    font-size: 22px;
    line-height: 1.1;
}

.card .sub {
    margin: 3px 0 0 36px;
    font-family: var(--display);
    font-style: italic;
    font-size: 14.5px;
    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);
}

/* ---------- intro overlay ---------- */

.intro {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 22px;
    background: linear-gradient(160deg, rgba(26, 31, 42, 0.93), rgba(35, 41, 54, 0.97));
    transition: opacity 0.35s ease;
}
.intro.hidden { opacity: 0; pointer-events: none; }

.intro-card {
    max-width: 430px;
    max-height: 88vh;
    overflow-y: auto;
    text-align: center;
    color: var(--paper);
    border: 1px solid var(--marquee-soft);
    outline: 1px solid rgba(224, 166, 58, 0.25);
    outline-offset: 5px;
    border-radius: 4px;
    padding: 30px 26px 22px;
}

.intro-card .eyebrow { font-size: 11px; }

.intro-card h2 {
    margin: 10px 0 0;
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(30px, 8vw, 40px);
    line-height: 1.05;
}

.intro-card p {
    margin: 16px 0 0;
    font-size: 14.5px;
    line-height: 1.6;
    color: rgba(250, 247, 240, 0.88);
    text-align: left;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.stats span {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--marquee);
    border: 1px solid rgba(224, 166, 58, 0.4);
    border-radius: 999px;
    padding: 5px 12px;
}

.start {
    margin-top: 20px;
    width: 100%;
    padding: 13px 20px;
    border: none;
    border-radius: 10px;
    background: var(--marquee);
    color: var(--dusk-deep);
    font: 700 15px var(--body);
    letter-spacing: 0.02em;
    cursor: pointer;
}
.start:hover { background: #eab54e; }

.intro-card .fine {
    margin-top: 16px;
    font-size: 11.5px;
    line-height: 1.5;
    color: rgba(250, 247, 240, 0.6);
    text-align: center;
}
.intro-card .fine a { color: var(--marquee); }

/* ---------- 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: var(--dusk-deep);
    color: var(--paper);
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--marquee-soft);
    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(250, 247, 240, 0.85) !important;
    font-size: 9.5px;
    color: var(--muted);
}
