.home-map-card.home-log.bdx-card { --card-padding: 0; --card-border-width: 0; --card-border-style: none; position: relative; isolation: isolate; aspect-ratio: 1.15; padding: 0; overflow: hidden; border: 0; background: var(--surface-muted); }
#home-map-preview, #home-map-expand { position: absolute; inset: 0; width: 100%; height: 100%; }
#home-map-preview { z-index: 0; }
#home-map-preview .leaflet-control-attribution { display: none; }
.home-map-attribution { position: absolute; bottom: 0; right: 0; z-index: 3; background: white; padding: 2px 5px; font-size: 10px; }
#home-map-expand { z-index: 1; background: transparent; border: 0; cursor: zoom-in; padding: 16px; display: flex; align-items: start; justify-content: end; color: var(--text-strong); }
#home-map-expand span { padding: 8px 12px; background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-soft); font: 700 var(--text-sm) var(--font-ui); }
.home-map-card .home-log__mobile-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; position: absolute; z-index: 2; bottom: 0; inset-inline: 0; padding: 48px 12px 28px; background: linear-gradient(transparent, rgb(28 37 48 / .7)); pointer-events: none; }
html.bdx-can-log-buses .home-map-card .home-log__mobile-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.home-map-card .home-log__mobile-actions button { pointer-events: auto; }
.home-map-card #unknown-bus-btn { flex: 1; min-width: 0; width: auto; }
.home-map-card .home-log__manual { margin: 0; gap: 4px; flex: 0 0 auto; width: auto; }
.home-map-card .home-log__manual button { width: 44px; height: 48px; }
.home-map-card #log-progress { flex-basis: 100%; }
.home-map-card .home-log__desktop-icon { display: none; }
.home-map-card .home-log__desktop-guide { position: absolute; z-index: 2; bottom: 28px; left: 16px; max-width: 330px; padding: 16px; background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); text-align: left; pointer-events: none; }
#home-map-message { position: absolute; top: 60px; left: 12px; right: 12px; z-index: 1; font-size: var(--text-xs); pointer-events: none; }
#home-map-message:not(:empty) { background: white; padding: 8px; border-radius: var(--radius-sm); }
#live-map-popup { --popup-width: 1120px; }
#live-map-popup .live-map-body { padding: 0; position: relative; min-height: 300px; }
#live-map { height: min(70dvh, 760px); min-height: 300px; background: var(--surface-muted); }
.live-map-tools { position: absolute; top: 12px; right: 12px; z-index: 500; display: flex; gap: 8px; }
#map-status { position: absolute; top: 68px; right: 12px; left: 55px; z-index: 500; pointer-events: none; font-size: var(--text-xs); }
#map-status:not(:empty) { background: white; padding: 8px; border-radius: var(--radius-sm); }
#map-selection { position: absolute; bottom: 28px; left: 12px; right: 12px; z-index: 500; background: white; padding: 12px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); max-height: 40%; overflow-y: auto; }
#map-selection p { margin: 4px 0 8px; }
.live-bus-marker { background: none; border: 0; }
.live-bus-marker__body { display: block; min-width: 30px; padding: 5px 7px; border-radius: 8px; background: var(--action-primary); color: #000; border: 2px solid white; box-shadow: var(--shadow-soft); text-align: center; font: 700 12px var(--font-ui); position: relative; }
.live-bus-marker__direction { position: absolute; inset: -11px; transform: rotate(var(--heading)); pointer-events: none; }
.live-bus-marker__direction::before { content: ''; position: absolute; top: 0; left: calc(50% - 5px); border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--action-primary); }
.live-stop-marker { border: 2px solid white; background: var(--action-primary); border-radius: 50%; box-shadow: var(--shadow-soft); }
.map-departure { padding-block: 12px; border-bottom: 1px solid var(--border-subtle); }
.map-departure p { margin: 4px 0; }
@media (min-width: 769px) { .home-map-card.home-log.bdx-card { aspect-ratio: 5 / 2; } html:not(.bdx-can-log-buses) .home-map-card .home-log__mobile-actions { display: none; } html:not(.bdx-can-log-buses) .home-map-card.home-log.bdx-card { --card-border-width: 0; --card-border-style: none; --card-padding: 0; } }
@media (prefers-reduced-motion: no-preference) { #live-map-popup .bdx-popup__dialog { animation: map-enlarge .22s var(--ease-ui, ease-out); } @keyframes map-enlarge { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } } }
/* Full map is a navigation view, not a modal. Keep app navigation above it. */
.home-map-card.home-log.bdx-card, html:not(.bdx-can-log-buses) .home-map-card.home-log.bdx-card { --card-border-width: 2px; --card-border-style: solid; --card-border-color: white; aspect-ratio: 1.35; }
#home-map-expand { align-items: center; justify-content: center; background: rgb(16 25 34 / .26); color: white; }
#home-map-expand span { background: none; box-shadow: none; font-size: 21px; font-weight: 800; text-shadow: 0 2px 12px #0008; padding-bottom: 30px; }
.live-map-screen { position: fixed; inset: 0; z-index: 990; background: var(--surface-muted); }
.live-map-screen[hidden] { display: none; }
.live-map-screen #live-map { height: 100%; min-height: 0; }
.live-map-open { overflow: hidden; }
.live-map-tools { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
.map-icon-button { padding: 0; box-sizing: border-box; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-muted); color: var(--text-strong); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-soft); cursor: pointer; font-size: 26px; }
.map-icon-button svg { flex: 0 0 21px; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#map-back { position: absolute; z-index: 500; top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
.map-icon-button:focus-visible, .map-pill-link:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.live-map-screen .leaflet-control-attribution { margin-bottom: calc(90px + env(safe-area-inset-bottom)); }
.live-bus-marker__body { box-sizing: border-box; min-width: 0; width: 30px; height: 20px; padding: 1px 3px; position: absolute; top: 6px; left: 1px; border: 1px solid #18232b99; border-radius: 4px; transform: rotate(calc(var(--heading) - 90deg)); font: 700 11px/16px var(--font-ui); box-shadow: 0 1px 3px #0005; }
.live-bus-marker__body::after { content: ''; position: absolute; right: -4px; top: 5px; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 4px solid #18232b; }
.live-stop-marker { border: 0; background: #428cff; box-shadow: none; }
.map-info-pill .leaflet-popup-content-wrapper, .map-info-pill .leaflet-popup-tip { background: #222; color: white; box-shadow: var(--shadow-soft); }
.map-info-pill .leaflet-popup-content-wrapper { border-radius: 12px; }
.map-info-pill .leaflet-popup-content { margin: 11px 24px 11px 12px; font: 400 12px/1.4 var(--font-ui); }
.map-info-pill .leaflet-popup-content { width: max-content !important; max-width: min(560px, calc(100vw - 80px)); overflow-wrap: anywhere; }
.map-info-pill .leaflet-popup-content p { margin: 4px 0; white-space: pre-line; }
.map-info-pill .leaflet-popup-close-button { color: white; }
.map-info-pill .map-pill-link { display: inline-block; padding: 3px 0; margin-right: 9px; border: 0; background: none; color: #57d2ff; font: 600 12px/1.4 var(--font-ui); text-decoration: underline; cursor: pointer; }
@media (min-width: 769px) {
 .home-map-card.home-log.bdx-card, html:not(.bdx-can-log-buses) .home-map-card.home-log.bdx-card { aspect-ratio: 5; }
 .home-map-card .home-log__desktop-guide { inset: 0; max-width: none; padding: 60px 24px 20px; background: linear-gradient(transparent, #101922b3); border-radius: 0; box-shadow: none; display: flex; justify-content: center; align-items: center; text-align: center; color: white; }
 .home-map-card .home-log__desktop-title, .home-map-card .home-log__desktop-text { color: white; }
 .home-map-card .home-log__desktop-title { font-size: 20px; margin: 0 0 6px; }
 html:not(.bdx-can-log-buses) #home-map-expand { align-items: start; padding-top: 20px; }
 html:not(.bdx-can-log-buses) #home-map-expand span { font-size: 16px; padding: 0; }
 .live-map-screen { top: calc(64px + env(safe-area-inset-top)); }
 .live-map-screen .leaflet-control-attribution { margin-bottom: 0; }
}

.live-map-screen .leaflet-bottom.leaflet-left { bottom: calc(100px + env(safe-area-inset-bottom)); }
@media(min-width:769px) { .live-map-screen .leaflet-bottom.leaflet-left { bottom: 16px; } }
/* Home guidance attaches below the preview, matching the profile help strip. */
#home-map-expand { cursor: pointer; }
#home-map-expand span { text-shadow: 0 2px 4px #000, 0 0 20px #000, 0 0 40px #000c, 0 4px 56px #000; }
.home-map-attribution { background: rgb(255 255 255 / .78); color: var(--text-strong); font-size: 9px; padding: 1px 5px; }
.home-log__desktop-guide { display: none; }
.home-log__desktop-icon { display: none; }
.home-map-card .home-log__mobile-actions, html.bdx-can-log-buses .home-map-card .home-log__mobile-actions { align-items: stretch; }
.home-map-card .home-log__manual { align-items: stretch; }
.home-map-card .home-log__manual button { height: 100%; min-height: 54px; }
.live-bus-marker__body { transform: rotate(var(--rotation, 0deg)); }
.live-bus-marker__body.is-reversed::after { right: auto; left: -4px; border-left: 0; border-right: 4px solid #18232b; }
.live-bus-marker__body.has-no-heading::after { display: none; }
.map-info-pill .leaflet-popup-content-wrapper, .map-info-pill .leaflet-popup-tip { background: white; color: var(--text-strong); }
.map-info-pill .leaflet-popup-content-wrapper { border: 1px solid var(--border-subtle); box-shadow: var(--shadow-menu); }
.map-info-pill .leaflet-popup-close-button { color: var(--text-muted); }
.map-info-pill .map-pill-link { color: var(--action-primary); }
.map-icon-button { border-radius: 50%; width: 44px; height: 44px; background: white; box-shadow: var(--shadow-soft); }
@media (min-width: 769px) {
 .home-map-card.home-log.bdx-card { margin-bottom: 0; }
 html:not(.bdx-can-log-buses) .home-log__desktop-guide { display: block; position: relative; z-index: 0; margin: -2px 14px 20px; padding: 16px 24px; background: var(--surface-muted); color: var(--text-strong); border-radius: 0 0 var(--radius-lg) var(--radius-lg); text-align: center; box-shadow: var(--shadow-soft); }
 .home-log__desktop-title { margin: 0 0 4px; font-size: 16px; }
 .home-log__desktop-text { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
 html:not(.bdx-can-log-buses) #home-map-expand { align-items: center; padding: 16px; }
 html:not(.bdx-can-log-buses) #home-map-expand span { font-size: 24px; padding: 0; }
}

.home-map-card .home-log__manual button { height: var(--map-log-height, 56px) !important; }
@media(min-width:769px) { html:not(.bdx-can-log-buses) .home-log__desktop-guide { width: 100%; margin: -16px 0 20px; padding-top: 30px; } .home-map-card.home-log.bdx-card { z-index: 1; } }
.map-stop-heading { flex: 1; min-width: 0; }
.map-stop-heading p { margin: 5px 0 0; }
.map-departure { margin: 0 0 12px; padding: 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: white; }
.map-departure > strong { display: block; font-size: var(--text-sm); }
.map-departure > p { font-size: var(--text-sm); }
.map-bus-registration { font-weight: 400; }
.map-info-pill .map-pill-link { background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; min-height: 0; }
.map-freshness { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.map-freshness svg { flex: 0 0 15px; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.map-freshness--fresh svg { color: #287b46; }
.map-freshness--delayed svg { color: #b45309; }
.map-freshness--stale svg { color: var(--action-danger); }
.map-user-location { background: var(--action-primary); border: 3px solid white; border-radius: 50%; box-shadow: 0 0 0 7px #0879c126, 0 1px 5px #0005; box-sizing: border-box; }
.home-map-card .home-log__manual button { width: var(--map-log-height, 56px) !important; }
@media(max-width:768px) { .live-map-screen .leaflet-control-attribution { margin-bottom: env(safe-area-inset-bottom); } }

.home-map-card .home-log__manual button { flex: 0 0 var(--map-log-height, 56px); }

.live-map-tools { top: auto; right: auto; left: 16px; bottom: calc(100px + env(safe-area-inset-bottom)); }
.live-map-screen .leaflet-bottom.leaflet-left { bottom: calc(156px + env(safe-area-inset-bottom)); }
.map-pill-links { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.map-info-pill .map-pill-links .map-pill-link { margin: 0; }
@media(min-width:769px) { .live-map-tools { bottom: 16px; } .live-map-screen .leaflet-bottom.leaflet-left { bottom: 72px; } }
.live-map-tools { left: auto; right: 16px; flex-direction: column; bottom: calc(100px + env(safe-area-inset-bottom)); }
#map-refresh { order: 0; }
#map-locate { order: 1; }
.live-map-screen .leaflet-bottom.leaflet-left { bottom: calc(100px + env(safe-area-inset-bottom)); }
@media(min-width:769px) { .live-map-tools { bottom: 16px; } .live-map-screen .leaflet-bottom.leaflet-left { bottom: 16px; } }

/* Keep the attached guidance within the preview's exact outer width. */
@media(min-width:769px) {
 html:not(.bdx-can-log-buses) .home-log__desktop-guide { box-sizing: border-box; width: 100%; max-width: 100%; min-height: 0; padding: 28px 24px 16px; }
}
.map-info-pill .leaflet-popup-content > div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.map-info-pill .leaflet-popup-content p { margin: 0; }
.map-info-pill .map-pill-links { margin-top: 2px; }
/* Retain accessible status announcements without floating information boxes. */
#map-status, #home-map-message { position: absolute; width: 1px; height: 1px; padding: 0 !important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.map-info-pill .leaflet-popup-content > div > strong + p:not(:has(strong)),
.map-info-pill .map-pill-punctuality + p,
.map-info-pill p:has(> strong) + p { margin-top: -3px; }
.home-map-open-icon { display: inline-block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
@media(max-width:768px) {
 .home-map-card.home-log.bdx-card, html:not(.bdx-can-log-buses) .home-map-card.home-log.bdx-card { aspect-ratio: 1.5; }
 #home-map-expand span { padding-bottom: 46px; }
}


/* Bustimes omits color for dark-text liveries; only unstyled markers default to white. */
.map-info-pill .map-follow { position: absolute; top: 26px; right: 0; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 24px; height: 24px; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--text-muted); cursor: pointer; }
.map-info-pill .map-follow svg { width: 16px; height: 16px; }
.map-info-pill .map-follow[aria-pressed="true"] { color: var(--action-primary); }
.map-info-pill .map-follow[aria-pressed="true"] svg { stroke-width: 3; }
.map-info-pill .map-follow:hover { color: var(--text-strong); }
.map-info-pill .map-follow[aria-pressed="true"]:hover { color: var(--action-primary-hover); }
.map-info-pill .map-follow:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (max-width: 768px) { .map-info-pill .map-follow { display: none; } }
.live-bus-marker__body:not([class*="livery-"]) { color: #fff; }

@media (min-width: 769px) {
 .home-map-card.home-log.bdx-card { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
}

/* Desktop map fills the screen behind its floating navigation. */
.live-map-screen.is-desktop-map { position: fixed; inset: 0; width: auto; height: auto; }
.live-map-screen.is-desktop-map #map-back { display: none; }
#map-follow-hint { position: absolute; top: 16px; }
#map-refresh { position: relative; --refresh-remaining: 100; }
#map-refresh .map-refresh-ring { position: absolute; inset: -3px; width: 48px; height: 48px; pointer-events: none; transform: rotate(-90deg); }
.map-refresh-ring circle { fill: none; stroke: var(--action-primary); stroke-width: 2.5; stroke-dasharray: 100; transition: stroke-dashoffset 1s linear; }
#map-refresh.is-refreshing .map-refresh-ring { opacity: 0; }
#map-refresh.is-refreshing .map-refresh-icon { animation: map-refresh-spin .8s linear infinite; }
@keyframes map-refresh-spin { to { transform: rotate(360deg); } }
@media(prefers-reduced-motion:reduce) { .map-refresh-ring circle { transition: none; } #map-refresh.is-refreshing .map-refresh-icon { animation: none; color: var(--action-primary); } }

.live-map-screen.is-desktop-map .leaflet-control-attribution { margin-bottom: 0; }

/* Only the existing refresh glyph animates; suppress the generic busy spinner. */
#map-refresh[aria-busy="true"]::after { content: none; display: none; }
#map-follow-hint { width: max-content; max-width: min(760px, calc(100% - 32px)); padding: var(--space-3) var(--space-4); border-radius: 999px; background: white; color: var(--text-strong); box-shadow: var(--shadow-card); font-size: var(--text-sm); text-align: center; left: 50%; translate: -50% 0; z-index: 600; }
#map-follow-hint[hidden] { display: none; }
.is-desktop-map #map-follow-hint { top: calc(var(--map-nav-bottom, 80px) + 16px); }
@media(min-width:769px) {
 html .nav-links { position: fixed; top: 0; left: 50%; right: auto; transform: translateX(-50%); width: 100%; height: calc(64px + env(safe-area-inset-top)); box-sizing: border-box; border-radius: 0; transition: none; }
 html.live-map-open .nav-links { top: 12px; width: min(1120px, calc(100% - 32px)); padding: calc(4px + env(safe-area-inset-top)) 16px 4px; border: 1px solid #ffffff40; border-radius: 32px; box-shadow: var(--shadow-menu); }
}
@media(min-width:769px) and (prefers-reduced-motion:reduce) {
 html .nav-links { transition: none; }
}

@media(max-width:768px) { body[data-standalone-map] > .guest-navigation, body[data-standalone-map] > .guest-explore { display: none !important; } }

.live-map-leaving { overflow: hidden; }

html.live-map-restoring .nav-links,
html.live-map-restoring .nav-links *,
html.live-map-restoring .nav-links *::after,
html.live-map-restoring .live-map-screen { transition: none !important; animation: none !important; }

/* Map details reuse the shared shell as an attached, non-modal workspace. */
html { --map-panel-width: min(420px, 38vw); }
.bdx-popup[data-map-panel] {
 display: flex !important; inset: 0 0 0 auto !important;
 width: var(--map-panel-width) !important; height: 100dvh !important;
 padding: 0 !important; background: transparent !important;
 backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
 z-index: 1100 !important;
}
.bdx-popup[data-map-panel] .bdx-popup__dialog {
 width: 100% !important; max-width: none !important; height: 100% !important;
 max-height: 100% !important; border-radius: 0 !important;
 box-shadow: var(--shadow-menu); margin: 0 !important; border-left: 2px solid var(--dex-red) !important;
}
html.map-panel-open .live-map-screen { right: var(--map-panel-width); }
@media(min-width:769px) {
 html.live-map-open.map-panel-open .nav-links {
  left: calc((100% - var(--map-panel-width)) / 2);
  width: min(1120px, calc(100% - var(--map-panel-width) - 32px));
 }
}
@media(prefers-reduced-motion:no-preference) {
 .bdx-popup[data-map-panel] { animation: map-panel-enter .25s ease-out; }
 html.live-map-open .nav-links, html.live-map-leaving .nav-links {
  transition: top .3s ease, left .3s ease, width .3s ease, padding .3s ease, border-radius .3s ease, box-shadow .3s ease;
 }
 /* Match the sidebar edge so no page background appears between it and the map. */
 .live-map-screen.is-desktop-map { transition: right .25s ease-out; }
 @keyframes map-panel-enter { from { transform: translateX(100%); } to { transform: translateX(0); } }
}

/* Cross-page arrivals begin with the same full-width bar as the source page. */
@media(min-width:769px) {
 html.live-map-open.live-map-arriving .nav-links {
  top: 0; width: 100%; border-radius: 0; border: 0;
  border-bottom: 1px solid var(--border-subtle); box-shadow: var(--shadow-soft);
  padding: calc(12px + env(safe-area-inset-top)) max(16px, calc((100vw - 1120px) / 2), env(safe-area-inset-right)) 12px max(16px, calc((100vw - 1120px) / 2), env(safe-area-inset-left));
 }
}

.map-info-pill .map-bus-identity-link { color: var(--action-primary); font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.map-info-pill .map-bus-identity-link:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
