/* Weaver tracker — app styles (layered on /assets/weaver.css) */

:root {
  --panel-w: 430px;
  --board-bg: #111412;
  --board-ink: #ffb000;
  --board-dim: #a77a14;
  --veh: #0b6b57;
  --veh-ink: #ffffff;
}
:root[data-theme="dark"] { --veh: #2fae86; --veh-ink: #06231c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --veh: #2fae86; --veh-ink: #06231c; } }

/* ---------- App shell ---------- */
.app-body { min-height: 100dvh; display: flex; flex-direction: column; }
.app-body .site-header { position: relative; }
.tracker { flex: 1; display: grid; grid-template-columns: var(--panel-w) 1fr; min-height: 0; }
@media (min-width: 861px) {
  .app-body { height: 100dvh; overflow: hidden; }
  .tracker { overflow: hidden; }
}
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-right: 1px solid var(--line); }
.panel-body { flex: 1; overflow-y: auto; padding: 0 1.1rem 2rem; overscroll-behavior: contain; }
.panel-body:focus { outline: none; }
.map-wrap { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; background: var(--bg-sunk); }

@media (max-width: 860px) {
  .tracker { display: flex; flex-direction: column; }
  .map-wrap { order: -1; height: 46dvh; min-height: 280px; flex: none; }
  .panel { border-right: 0; border-top: 1px solid var(--line); }
  .panel-body { overflow: visible; }
}

/* ---------- Search ---------- */
.panel-search { position: relative; padding: 1rem 1.1rem 0.75rem; background: var(--bg); z-index: 5; }
.search { position: relative; display: flex; align-items: center; }
.search input {
  width: 100%; font: inherit; font-size: 1.02rem; padding: 0.8rem 3.1rem 0.8rem 2.7rem; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 0.95rem; width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }
.near-btn {
  position: absolute; right: 0.35rem; width: 38px; height: 38px; border-radius: 999px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-text);
}
.near-btn:hover { background: var(--brand); color: var(--brand-ink); }
.near-btn svg { width: 20px; height: 20px; }
.near-btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-results {
  position: absolute; left: 1.1rem; right: 1.1rem; top: calc(100% - 0.4rem); max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-l); padding: 0.4rem;
}
.sr-head { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding: 0.6rem 0.7rem 0.3rem; }
.sr-item {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left; padding: 0.55rem 0.7rem; border: 0; border-radius: var(--radius-s);
  background: none; color: var(--ink); font: inherit; cursor: pointer;
}
.sr-item:hover, .sr-item[aria-selected="true"] { background: var(--bg-sunk); }
.sr-item small { display: block; color: var(--ink-3); }
.sr-empty { padding: 0.9rem; color: var(--ink-3); }
.sr-ico { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-sunk); color: var(--ink-2); }
.sr-ico svg { width: 18px; height: 18px; }

/* ---------- Badges ---------- */
.rb {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2.7rem; height: 1.9rem; padding: 0 0.5rem;
  border-radius: 7px; background: var(--veh); color: var(--veh-ink); font-family: var(--font-mono); font-weight: 700;
  font-size: 0.95rem; letter-spacing: -0.02em; flex: none; white-space: nowrap;
}
.rb-lg { min-width: 3.6rem; height: 2.6rem; font-size: 1.3rem; border-radius: 9px; }
.rb-rail { background: #1c2b4a; color: #fff; }
:root[data-theme="dark"] .rb-rail { background: #8aa6e8; color: #0b1428; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rb-rail { background: #8aa6e8; color: #0b1428; } }

.mode-chip {
  display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; font-weight: 700; padding: 0.3rem 0.7rem; border-radius: 999px;
  background: var(--bg-sunk); color: var(--ink-2); border: 1px solid var(--line);
}
.mode-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.mode-chip.live { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.mode-chip.live .dot { background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }
.mode-chip.sched .dot { background: transparent; border: 2px dashed var(--ink-3); width: 11px; height: 11px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Panel sections ---------- */
.p-head { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.4rem 0 1rem; }
.p-head h1, .p-head h2 { font-size: 1.55rem; margin: 0; letter-spacing: -0.015em; }
.p-head p { margin: 0.2rem 0 0; color: var(--ink-3); font-size: 0.95rem; }
.p-head .grow { flex: 1; min-width: 0; }
.back-btn {
  flex: none; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink);
  display: grid; place-items: center; cursor: pointer; margin-top: 0.1rem;
}
.back-btn:hover { border-color: var(--line-strong); }
.back-btn svg { width: 18px; height: 18px; }
.p-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: -0.25rem 0 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.8rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--bg-elev); color: var(--ink-2); font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer; text-decoration: none;
}
.chip:hover { border-color: var(--brand); color: var(--brand-text); }
.chip[aria-pressed="true"], .chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip svg { width: 15px; height: 15px; }

.section-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); margin: 1.4rem 0 0.6rem; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.5rem; }
.quick {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.8rem; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--ink); font: inherit; font-weight: 700; font-size: 0.93rem; cursor: pointer; text-align: left;
}
.quick:hover { border-color: var(--brand); }
.quick .thread-dot { flex: none; }
.notice { background: var(--bg-elev); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--kirklees)); border-radius: var(--radius-s); padding: 0.85rem 1rem; font-size: 0.93rem; color: var(--ink-2); margin: 0.75rem 0; }
.notice strong { color: var(--ink); }
.notice p { margin: 0 0 0.4rem; }
.notice p:last-child { margin: 0; }

/* ---------- Departures ---------- */
.deps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.deps li { margin: 0; }
.dep {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.85rem; align-items: center; padding: 0.8rem 0.25rem; border-bottom: 1px solid var(--line);
  width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.dep:hover { background: var(--bg-sunk); }
.dep-main { display: block; min-width: 0; }
.dep-dest { display: block; font-weight: 700; font-size: 1.02rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-sub { font-size: 0.84rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; margin-top: 0.15rem; }
.dep-sub .live { color: var(--ok); font-weight: 700; }
.dep-sub .late { color: var(--warn); font-weight: 700; }
.dep-time { text-align: right; font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; line-height: 1.15; white-space: nowrap; }
.dep-time small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 0.8rem; color: var(--ink-3); }
.dep-time.due { color: var(--brand-text); }
.dep-time .live-ico { display: inline-block; width: 0.85em; height: 0.85em; margin-right: 0.15em; vertical-align: -0.05em; color: var(--ok); }
.deps-foot { font-size: 0.82rem; color: var(--ink-3); margin-top: 0.75rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- Trip / route stop list ---------- */
.stoplist { list-style: none; margin: 0.5rem 0 0; padding: 0; position: relative; }
.stoplist li { position: relative; margin: 0; padding: 0 0 0 1.9rem; }
.stoplist li::before { content: ""; position: absolute; left: 0.55rem; top: 0; bottom: 0; width: 4px; background: var(--veh); }
.stoplist li:first-child::before { top: 1.1rem; }
.stoplist li:last-child::before { bottom: calc(100% - 1.1rem); }
.stoplist li::after {
  content: ""; position: absolute; left: 0.27rem; top: 0.78rem; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 3px solid var(--veh);
}
.stoplist li.minor::after { width: 8px; height: 8px; left: 0.34rem; top: 0.84rem; border-width: 2px; }
.stoplist li.passed::before { background: var(--line-strong); }
.stoplist li.passed::after { border-color: var(--line-strong); }
.stoplist li.passed .sl-btn { color: var(--ink-3); }
.stoplist li.here::after { background: var(--veh); box-shadow: 0 0 0 5px color-mix(in srgb, var(--veh) 25%, transparent); }
.sl-btn {
  display: flex; justify-content: space-between; gap: 0.75rem; width: 100%; text-align: left; padding: 0.55rem 0.4rem 0.55rem 0;
  background: none; border: 0; font: inherit; color: var(--ink); cursor: pointer; border-radius: var(--radius-s);
}
.sl-btn:hover .sl-name { text-decoration: underline; }
.sl-name { font-weight: 700; font-size: 0.97rem; line-height: 1.3; }
.minor .sl-name { font-weight: 400; }
.sl-name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 0.82rem; }
.sl-time { font-family: var(--font-mono); font-size: 0.92rem; white-space: nowrap; color: var(--ink-2); }
.vehicle-flag {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 700; color: var(--veh-ink); background: var(--veh);
  padding: 0.12rem 0.5rem; border-radius: 999px; margin: 0.15rem 0 0.35rem;
}

/* ---------- Rail board ---------- */
.board { background: var(--board-bg); color: var(--board-ink); border-radius: var(--radius); padding: 0.4rem 0.9rem 0.8rem; font-family: var(--font-mono); box-shadow: var(--shadow-l); }
.board-row { display: grid; grid-template-columns: 3.4rem 1fr auto; gap: 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid #2a2f2b; align-items: baseline; cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; color: inherit; font: inherit; text-align: left; }
.board-row:last-child { border-bottom: 0; }
.board-row:hover .board-dest { text-decoration: underline; }
.board-time { font-weight: 700; }
.board-dest { font-weight: 700; color: var(--board-ink); }
.board-dest small { display: block; color: var(--board-dim); font-weight: 400; font-size: 0.78rem; }
.board-plat { font-size: 0.8rem; color: var(--board-dim); text-align: right; }
.board-etd { display: block; font-weight: 700; font-size: 0.9rem; text-align: right; }
.board-etd.bad { color: #ff6b5e; }
.board-head { display: flex; justify-content: space-between; color: var(--board-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; padding: 0.4rem 0; border-bottom: 1px solid #2a2f2b; }
.board-calling { grid-column: 1 / -1; font-family: var(--font-body); font-size: 0.85rem; color: #e9d9b0; line-height: 1.5; padding-top: 0.25rem; }
.board-calling b { color: var(--board-ink); }

/* ---------- Map bits ---------- */
.map-status {
  position: absolute; z-index: 500; top: 0.75rem; left: 50%; transform: translateX(-50%); max-width: calc(100% - 1.5rem);
  pointer-events: none; display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center;
}
.map-status .mode-chip { box-shadow: var(--shadow); background: var(--bg-elev); pointer-events: auto; }
.map-status .mode-chip.live { background: var(--ok-tint); }
.map-legend {
  position: absolute; z-index: 500; left: 0.75rem; bottom: 1.6rem; display: flex; gap: 0.9rem; flex-wrap: wrap;
  background: var(--bg-elev); border: 1px solid var(--line); padding: 0.4rem 0.75rem; border-radius: 999px; font-size: 0.78rem; color: var(--ink-2); box-shadow: var(--shadow);
}
.map-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.lg-live { background: var(--veh); }
.lg-sched { border: 2px dashed var(--veh); background: var(--bg-elev); }
.lg-rail { border-radius: 3px; background: #1c2b4a; }
@media (max-width: 560px) { .map-legend { display: none; } }

.leaflet-container { font-family: var(--font-body); background: var(--bg-sunk); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--bg-elev); color: var(--ink); border-color: var(--line); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg-elev); color: var(--ink); }
.leaflet-popup-content { margin: 0.7rem 0.9rem; font-size: 0.92rem; }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgb(22 31 28 / 0.8); color: var(--ink-3); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--ink-2); }

/* Vehicles */
.veh-icon { background: none; border: 0; }
.veh-icon, .leaflet-marker-icon.veh-icon { transition: transform 1.2s linear; }
.leaflet-zoom-anim .veh-icon, .no-anim .veh-icon { transition: none !important; }
.veh {
  display: flex; align-items: center; justify-content: center; height: 22px; min-width: 22px; padding: 0 5px;
  border-radius: 11px; background: var(--veh); color: var(--veh-ink); font: 700 11px/1 var(--font-mono); letter-spacing: -0.03em;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35); border: 1.5px solid var(--bg-elev); white-space: nowrap; transform: translate(-50%, -50%);
  position: absolute; left: 0; top: 0;
}
.veh.sched { background: var(--bg-elev); color: var(--veh); border: 2px dashed var(--veh); box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); }
.veh.dim { opacity: 0.28; }
.veh.sel { outline: 3px solid var(--kirklees); outline-offset: 1px; z-index: 10; }
.veh-arrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.veh-arrow::before {
  content: ""; position: absolute; left: -5px; top: -21px; border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 7px solid var(--veh);
}
.veh-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--veh); border: 1.5px solid var(--bg-elev); box-shadow: 0 0 0 0.5px rgb(0 0 0 / 0.25); transform: translate(-50%, -50%); position: absolute; }
.veh-dot.sched { background: var(--bg-elev); border: 2px solid var(--veh); }
.veh-dot.dim { opacity: 0.25; }

.rail-icon {
  width: 22px; height: 22px; border-radius: 6px; background: #1c2b4a; color: #fff; display: grid; place-items: center;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35); border: 1.5px solid #fff; transform: translate(-50%, -50%); position: absolute;
}
.rail-icon svg { width: 14px; height: 14px; }
.stop-icon {
  width: 14px; height: 14px; border-radius: 50%; background: var(--bg-elev); border: 3px solid var(--ink-2); transform: translate(-50%, -50%); position: absolute;
}
.stop-icon.hub { width: 18px; height: 18px; border-color: var(--brand); }
.stop-icon.sel { border-color: var(--kirklees); background: var(--kirklees); }
.map-label { background: var(--bg-elev); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); font: 700 12px var(--font-body); padding: 2px 6px; }
.map-label::before { display: none; }

/* ---------- Misc ---------- */
.skeleton { height: 3.4rem; border-radius: var(--radius-s); margin: 0.5rem 0; background: linear-gradient(90deg, var(--bg-sunk), var(--bg-elev), var(--bg-sunk)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 1.5rem 0.25rem; color: var(--ink-3); }
.fav-btn[aria-pressed="true"] svg { fill: var(--kirklees); stroke: var(--kirklees); }
.small-print { font-size: 0.8rem; color: var(--ink-3); margin-top: 1.5rem; line-height: 1.5; }
.small-print a { color: var(--ink-2); }

/* Map tiles: OSM, toned down so the network reads first; inverted for dark mode */
.leaflet-tile-pane { filter: saturate(0.55) contrast(0.95); }
.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.88) contrast(0.88) saturate(0.35); }
.map-dark { background: #1b211f; }
.z-low .rail-icon { width: 13px; height: 13px; border-radius: 4px; border-width: 1.5px; }
.z-low .rail-icon svg { display: none; }

/* Long stand lists scroll sideways instead of taking over the panel */
.chip-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.35rem; scrollbar-width: thin; margin-right: -1.1rem; padding-right: 1.1rem; }
.chip-row .chip { flex: none; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
