/* =============================================================================
   Public Map Widget. The page frame (pm-*) and the bus and stop panels (bus-tile,
   bt-*), whose look, tokens and class names are TF Cloud's own map panels, so the two
   maps read as one product. DM Sans is served by this server (/fonts).
   ============================================================================= */
@font-face { font-family: 'DM Sans'; src: url('/fonts/DMSans-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('/fonts/DMSans-Medium.ttf') format('truetype'); font-weight: 500 700; font-display: swap; }

:root {
	--pm-navy: #0c1b3a;
	--pm-blue: #0870c8;          /* TransitFare brand blue: 4.6:1 or more on white */
	--pm-ink: #1f2937;
	--pm-muted: #5b6472;         /* 5.9:1 on white */
	--pm-line: #e3e7ec;
	--pm-surface: #f6f8fa;
	--pm-ok: #2f9e44;
	--pm-ok-ink: #047857;
	--pm-ok-tint: #e9f7ec;
	--pm-warn: #b45309;
	--pm-alert: #e6087e;
	--pm-alert-ink: #b30662;
	--pm-alert-tint: #fdecf5;
	--pm-shadow: 0 2px 10px rgba(12, 27, 58, 0.22);
}

html, body { margin: 0; height: 100%; }
/* The hidden attribute always wins over a component's own display value. */
[hidden] { display: none !important; }
body { font-family: 'DM Sans', system-ui, sans-serif; font-size: 14px; color: var(--pm-ink); background: #e5e3df; }

.pm { position: relative; height: 100%; overflow: hidden; }
.pm-map { position: absolute; inset: 0; }
.pm-visually-hidden {
	position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pm-empty { display: flex; align-items: center; justify-content: center; min-height: 100%; background: #fff; }
.pm-map-message { margin: 0; padding: 24px; display: flex; align-items: center; justify-content: center; height: 100%; box-sizing: border-box; background: #fff; text-align: center; font-size: 15px; }
.pm-noscript { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; background: #fff; }

/* Top-left: the agency logo, then the live status. */
.pm-top { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: calc(100% - 70px); pointer-events: none; }
.pm-top > * { pointer-events: auto; }
.pm-logo { max-width: 220px; max-height: 90px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; box-shadow: var(--pm-shadow); }
.pm-status { display: inline-flex; align-items: center; gap: 8px; margin: 0; min-height: 32px; padding: 0 12px; border-radius: 16px; background: #fff; box-shadow: var(--pm-shadow); font-size: 13px; font-weight: 500; }
.pm-status-dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa3af; flex: none; }
.pm-status[data-state="live"] .pm-status-dot { background: var(--pm-ok); }
.pm-status[data-state="quiet"] .pm-status-dot { background: #9aa3af; }
.pm-status[data-state="stale"] .pm-status-dot { background: var(--pm-warn); }
.pm-status[data-state="error"] .pm-status-dot { background: var(--pm-alert); }

/* Bottom-right: the three map controls. Google's zoom and Street View sit bottom-left. */
.pm-controls { position: absolute; right: 10px; bottom: 28px; z-index: 2; display: flex; gap: 8px; }
.pm-control {
	position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-width: 44px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 22px;
	background: var(--pm-blue); color: #fff; font: 600 14px 'DM Sans', system-ui, sans-serif;
	box-shadow: var(--pm-shadow); cursor: pointer;
}
.pm-control:hover { background: #075ea8; }
.pm-control[aria-expanded="true"] { background: var(--pm-navy); }
.pm-icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.pm-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #fff; color: var(--pm-blue); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.pm-control[aria-expanded="true"] .pm-count { color: var(--pm-navy); }

.pm-control:focus-visible,
.pm-drawer-close:focus-visible,
.pm-link:focus-visible,
.pm-row-button:focus-visible,
.bt-btn:focus-visible {
	outline: 3px solid var(--pm-blue); outline-offset: 2px;
}
.pm-control:focus-visible { outline-color: var(--pm-navy); box-shadow: 0 0 0 2px #fff, var(--pm-shadow); }

/* Drawers: Alerts and Routes. A bottom sheet on a phone. */
.pm-drawer {
	position: absolute; right: 10px; bottom: 84px; z-index: 3; display: flex; flex-direction: column;
	width: 360px; max-width: calc(100% - 20px); max-height: calc(100% - 150px);
	background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(12, 27, 58, 0.28);
}
.pm-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--pm-line); }
.pm-drawer-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--pm-navy); }
.pm-drawer-close { width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; color: var(--pm-muted); font-size: 26px; line-height: 1; cursor: pointer; }
.pm-drawer-close:hover { background: var(--pm-surface); color: var(--pm-ink); }
.pm-drawer-body { overflow-y: auto; padding: 10px 12px 12px; }
.pm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pm-empty-note { margin: 8px 4px; color: var(--pm-muted); }
.pm-link { display: inline-flex; align-items: center; min-height: 36px; margin: 0 0 6px; padding: 0 4px; border: 0; background: none; color: var(--pm-blue); font: 600 13px 'DM Sans', system-ui, sans-serif; cursor: pointer; }
.pm-link:hover { text-decoration: underline; }

/* One alert card */
.pm-alert { padding: 10px 12px; border-radius: 8px; background: var(--pm-surface); border-left: 3px solid var(--pm-ok); }
.pm-alert[data-status="scheduled"] { border-left-color: #f0b400; }
.pm-alert-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.pm-alert-title { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--pm-navy); line-height: 1.3; }
.pm-alert-body { margin: 0 0 6px; font-size: 13px; line-height: 1.45; color: var(--pm-ink); overflow-wrap: anywhere; }
.pm-alert-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.pm-alert-links a { color: var(--pm-blue); font-weight: 600; }
.pm-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.pm-tag-banner { background: #3949ab; color: #fff; }
.pm-tag-plain { background: #e8eaf0; color: #3b4454; }
.pm-alert-when { margin-left: auto; color: var(--pm-muted); font-size: 12px; }
.pm-alert-routes { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; }

/* One route in the Routes drawer */
.pm-route { border-radius: 8px; background: var(--pm-surface); border-left: 4px solid var(--pm-navy); overflow: hidden; }
.pm-route-head { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 6px 4px 8px; }
.pm-route-name { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-row-button { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 36px; padding: 0 10px; border: 1px solid var(--pm-line); border-radius: 18px; background: #fff; color: var(--pm-ink); font: 600 12px 'DM Sans', system-ui, sans-serif; cursor: pointer; white-space: nowrap; }
.pm-row-button[aria-pressed="true"] { background: var(--pm-blue); border-color: var(--pm-blue); color: #fff; }
.pm-row-button:hover { border-color: var(--pm-blue); }
.pm-route-more { border-top: 1px solid var(--pm-line); padding: 4px 6px 8px; background: #fff; }
.pm-sub { margin: 8px 6px 2px; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--pm-muted); }
.pm-stop-button { display: flex; align-items: baseline; gap: 6px; width: 100%; min-height: 36px; padding: 6px; border: 0; border-radius: 6px; background: none; font: 13px 'DM Sans', system-ui, sans-serif; color: var(--pm-ink); text-align: left; cursor: pointer; }
.pm-stop-button:hover { background: var(--pm-surface); }
.pm-stop-button:focus-visible { outline: 3px solid var(--pm-blue); outline-offset: -3px; }
.pm-stop-code { flex: none; color: var(--pm-muted); font-weight: 600; }

/* ---- Bus and stop panels (TF Cloud's map panel, in a Google info window) ---- */
.bus-tile { width: 300px; max-width: 100%; box-sizing: border-box; padding: 4px 4px 2px; font-family: 'DM Sans', system-ui, sans-serif; font-size: 13px; line-height: 1.4; color: var(--pm-ink); }
.bus-tile * { box-sizing: border-box; }
.bt-bus { margin: 0; font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--pm-navy); }
.bt-bus:focus-visible { outline: 3px solid var(--pm-blue); outline-offset: 2px; }
.bt-chip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.bt-chip .bt-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.bt-info { background: #e7f1fb; color: #0b5ea8; }
.bt-adh-ok { background: var(--pm-ok-tint); color: var(--pm-ok-ink); } .bt-adh-ok .bt-dot { background: var(--pm-ok); }
.bt-adh-alert { background: var(--pm-alert-tint); color: var(--pm-alert-ink); } .bt-adh-alert .bt-dot { background: var(--pm-alert); }
.bt-l2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.bt-first { margin-top: 0; padding-right: 18px; }
.bt-route { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px; background: var(--pm-navy); color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; }
.bt-routelong { color: var(--pm-navy); font-weight: 600; }
.bt-l3 { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px; }
.bt-noroute { display: inline-flex; align-items: center; min-height: 20px; padding: 0 7px; border-radius: 4px; border: 1px solid var(--pm-line); color: var(--pm-muted); font-size: 11px; }
.bt-next { display: flex; align-items: baseline; column-gap: 6px; margin-top: 9px; }
.bt-next-status { flex: none; color: var(--pm-muted); white-space: nowrap; }
.bt-next-link { min-width: 0; padding: 0; border: 0; background: none; color: var(--pm-blue); font: 600 13px 'DM Sans', system-ui, sans-serif; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-next-link:hover { text-decoration: underline; }
.bt-next-note { margin-top: 4px; color: var(--pm-muted); font-size: 12px; }
.bt-telemetry { margin-top: 7px; color: var(--pm-muted); font-size: 12px; line-height: 1.45; }
.bt-seclabel { font-size: 11px; font-weight: 700; color: var(--pm-muted); text-transform: uppercase; letter-spacing: .4px; }
.bt-up { margin-top: 10px; }
.bt-up-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px; }
.bt-up-cols { color: var(--pm-muted); font-size: 11px; }
.bt-up-row { display: grid; grid-template-columns: max-content 1fr max-content; gap: 10px; align-items: baseline; margin-top: 3px; font-size: 12.5px; line-height: 1.3; }
.bt-up-name { min-width: 0; color: var(--pm-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-up-time { font-weight: 600; font-variant-numeric: tabular-nums; }
/* Stop panel arrivals: one line each in fixed columns (route, bus or Scheduled, early/late chip, when), so chips
   and times line up down the list, as on TF Cloud's map; hairlines between rows. */
.bt-arrival { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content 56px; align-items: center; column-gap: 8px; min-height: 28px; font-size: 12.5px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.bt-arrival + .bt-arrival { box-shadow: inset 0 1px 0 var(--pm-line); }
.bt-arr-who { min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-notservice { color: var(--pm-muted); }
.bt-arr-who.bt-notservice { font-weight: 400; }
.bt-arr-status { display: flex; justify-content: flex-end; }
.bt-arr-when { text-align: right; font-size: 13px; font-weight: 700; white-space: nowrap; }
/* A stop panel route badge with where it goes beside it */
.bt-routename { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.bt-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; margin-top: 6px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--pm-line); background: #fff; color: var(--pm-ink); font: 600 12px 'DM Sans', system-ui, sans-serif; cursor: pointer; }
.bt-btn:hover { background: var(--pm-surface); }

/* Google's info window chrome: room for our panel, and its close button kept visible. Google caps the window at
   the map's width less 126 px (170 px of panel on a 320 px phone, too narrow for an arrival row); the cap here is
   the panel plus the window's 24 px padding, and never more than the screen less 12 px each side. */
.gm-style .gm-style-iw-c { padding: 12px 12px 10px !important; border-radius: 12px !important; max-width: min(324px, calc(100vw - 24px)) !important; }
.gm-style .gm-style-iw-d { overflow: auto !important; }

/* Phone: icon-only controls, drawers as a bottom sheet. */
@media (max-width: 520px) {
	.pm-control { padding: 0; width: 48px; height: 48px; border-radius: 24px; }
	.pm-control-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.pm-count { position: absolute; top: -4px; right: -4px; }
	/* Above the controls, never over them: they stay reachable, and a focused control is never hidden (WCAG 2.4.11). */
	.pm-drawer { left: 8px; right: 8px; bottom: 84px; width: auto; max-width: none; max-height: calc(100% - 150px); border-radius: 14px; }
	/* The desktop panel where the phone has room for it (a 390 px phone), else the screen less 48 px, so the
	   window (the panel plus its 24 px padding) keeps 12 px from each edge. */
	.bus-tile { width: min(300px, calc(100vw - 48px)); }
	.bt-arrival { column-gap: 6px; }
	.pm-logo { max-width: 150px; max-height: 60px; }
}
@media (max-height: 420px) {
	.pm-drawer { max-height: calc(100% - 96px); }
}
