/* My Bus Stop on the web.
   Colours and faces come from the app (BusBus/Design/DesignTokens.swift, Typography.swift):
   Archivo at its heaviest and widest for names and numbers, Space Mono for everything the board
   labels. Dark is one ground behind everything; light is one continuous cream. */

:root {
    --bg: #08080B;
    --card: #15151B;
    --card-outline: #24242E;
    --chip: #101016;
    --field-border: #24242E;
    --ink: #FFFFFF;
    --secondary: #A0A0AE;
    --caption: #C4C4CE;
    --stop-name: #8C8C9A;
    --dim: #5E5E6C;
    --dot: #4A4A56;
    --live: #3DDC84;
    --late: #FF3B3F;
    --button: #FFFFFF;
    --button-ink: #08080B;
    --focus: #22D3EE;
    --menu: #1E1E26;

    --display: 'Archivo', system-ui, sans-serif;
    --mono: 'Space Mono', ui-monospace, monospace;
    --gutter: 20px;
    --radius-row: 20px;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #F4F2EC;
        --card: #F4F2EC;
        --card-outline: #DBD7CD;
        --chip: #F4F2EC;
        --field-border: #DBD7CD;
        --ink: #14140F;
        --secondary: #55555F;
        --caption: #45454E;
        --stop-name: #55555F;
        --dim: #8A8790;
        --dot: #B6B2A8;
        --live: #1A7F4B;
        --late: #D32029;
        --button: #14140F;
        --button-ink: #F4F2EC;
        --focus: #0E7C86;
        --menu: #E6E2D8;
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #F4F2EC;
    --card: #F4F2EC;
    --card-outline: #DBD7CD;
    --chip: #F4F2EC;
    --field-border: #DBD7CD;
    --ink: #14140F;
    --secondary: #55555F;
    --caption: #45454E;
    --stop-name: #55555F;
    --dim: #8A8790;
    --dot: #B6B2A8;
    --live: #1A7F4B;
    --late: #D32029;
    --button: #14140F;
    --button-ink: #F4F2EC;
    --focus: #0E7C86;
    --menu: #E6E2D8;
    color-scheme: light;
}

/* Wall mode is always dark, whatever the theme. */
body.wall {
    --bg: #08080B;
    --card: #15151B;
    --card-outline: #24242E;
    --ink: #FFFFFF;
    --secondary: #A0A0AE;
    --caption: #C4C4CE;
    --stop-name: #8C8C9A;
    --dim: #5E5E6C;
    --dot: #4A4A56;
    --live: #3DDC84;
    --late: #FF3B3F;
    --menu: #1E1E26;
    color-scheme: dark;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    overflow-x: hidden;
    font-family: var(--display);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.4;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.icon { display: inline-flex; flex: none; }
[hidden] { display: none !important; }

.screen {
    max-width: 1280px;
    margin: 0 auto;
    padding: max(20px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

/* Shared type */
h1, .row-title, .count-title {
    font-family: var(--display);
    font-weight: 900;
    font-stretch: 112%;
    text-transform: uppercase;
    letter-spacing: -0.015em;
    line-height: 1.05;
}
.caption, .field-label, .section-head h2, .section-aside, .status, .kicker, .row-caption, .row-distance, .count-hint, .board-foot, .attribution, .map-note {
    font-family: var(--mono);
    font-weight: 700;
    text-transform: uppercase;
}

/* Badges: a line number on its colour */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--display);
    font-weight: 900;
    font-stretch: 105%;
    line-height: 1;
    white-space: nowrap;
    flex: none;
}
.badge-small { min-width: 34px; height: 34px; padding: 0 7px; border-radius: 8px; font-size: 17px; }
.badge-medium { min-width: 64px; height: 64px; padding: 0 10px; border-radius: 15px; font-size: 30px; }
.badge-big { min-width: 120px; height: 120px; padding: 0 14px; border-radius: 26px; font-size: 54px; }
.badge-big.badge-long { font-size: 40px; }
.badge-medium.badge-long { font-size: 22px; }
/* A line without a number: its mode's glyph (or a neutral dot), drawn at the size its number would be. */
.mode-glyph svg { width: 1em; height: 1em; display: block; }
.badge-glyph .mode-glyph { font-size: 1.3em; }

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 58px;
    padding: 0 26px;
    border-radius: 16px;
    font-weight: 900;
    font-stretch: 108%;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
@media (max-width: 520px) { .button { padding: 0 16px; font-size: 16px; gap: 8px; } }
.button-primary { background: var(--button); color: var(--button-ink); flex: 1; }
.button-primary:disabled { opacity: 0.35; }
.button-outline { border: 2px solid var(--card-outline); color: var(--secondary); }
.button-outline:disabled { opacity: 0.5; }
.button-secondary { background: var(--card); border: 2px solid var(--card-outline); color: var(--ink); margin-top: 14px; height: 54px; font-size: 16px; }
.round-button, .icon-button {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.round-button { width: 46px; height: 46px; border-radius: 50%; background: var(--menu); }
.icon-button { width: 44px; height: 44px; border-radius: 12px; color: var(--ink); }
.icon-button:hover, .round-button:hover { background: var(--card); }

/* ---------------------------------------------------------------- Setup */

.setup-head { display: flex; align-items: center; gap: 16px; padding: 12px 0 22px; }
.setup-head h1 { font-size: clamp(30px, 5vw, 44px); }
.home-link img { display: block; border-radius: 10px; }

.region-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 260px; }
.field-narrow { flex: 0 1 160px; }
.field-label { font-size: 11px; letter-spacing: 0.22em; color: var(--dim); }
.field select {
    appearance: none;
    height: 48px;
    padding: 0 40px 0 16px;
    border-radius: 14px;
    border: 2px solid var(--field-border);
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238C8C9A' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
    font-weight: 800;
    font-size: 16px;
}

.search {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 64px;
    padding: 0 20px;
    border: 2px solid var(--field-border);
    border-radius: 20px;
    background: var(--card);
    color: var(--secondary);
}
.search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 700;
    font-size: 19px;
}
.search-input::placeholder { color: var(--secondary); }
.search:focus-within { border-color: var(--focus); }

.results { margin-top: 24px; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 30px; }
@media (min-width: 900px) {
    .setup-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .setup-grid > :only-child { grid-column: 1 / -1; max-width: 640px; }
}

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 13px; letter-spacing: 0.24em; color: var(--secondary); }
.section-aside { font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }

.rows { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.row-item { position: relative; }
.row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 84px;
    padding: 16px 20px;
    border-radius: var(--radius-row);
    background: var(--card);
    border: 2px solid transparent;
    text-align: start;
}
:root[data-theme="light"] .row { border-color: var(--card-outline); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .row { border-color: var(--card-outline); } }
.row:hover { border-color: var(--card-outline); }
.row { flex-wrap: wrap; row-gap: 10px; }
.row-text { flex: 1 1 170px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-size: clamp(21px, 3vw, 27px); overflow-wrap: anywhere; }
.row-caption { font-size: 12px; letter-spacing: 0.08em; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-distance { flex: none; width: 66px; font-size: 15px; color: var(--live); }
.row-badges { display: flex; align-items: center; gap: 8px; flex: none; margin-inline-start: auto; }
.row-more { font-family: var(--mono); font-weight: 700; color: var(--secondary); font-size: 14px; }
.row-remove {
    position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
    display: none; align-items: center; justify-content: center; color: var(--secondary); background: var(--menu);
}
.row-item:hover .row-remove, .row-remove:focus-visible { display: inline-flex; }
@media (hover: none) { .row-remove { display: inline-flex; top: 6px; right: 6px; } }

.status { font-size: 13px; letter-spacing: 0.1em; color: var(--secondary); padding: 18px 2px; line-height: 1.6; }
.status-error { color: var(--late); }
.hint-text { color: var(--secondary); font-size: 15px; }
.note { margin-top: 28px; color: var(--secondary); font-size: 15px; max-width: 70ch; }
.setup-foot { margin-top: 44px; padding-top: 20px; border-top: 2px solid var(--card-outline); color: var(--dim); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.attribution { font-size: 11px; letter-spacing: 0.08em; }

/* ---------------------------------------------------------------- Lines */

.lines { display: flex; flex-direction: column; min-height: 100dvh; }
.lines-head { display: flex; flex-direction: column; gap: 22px; padding-bottom: 22px; }
.lines-head h1 { font-size: clamp(26px, 4.4vw, 40px); }
.caption { font-size: 12px; letter-spacing: 0.2em; color: var(--secondary); margin-top: 6px; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; align-content: start; flex: 1; }
@media (min-width: 900px) { .chips { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; } }
.chip {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    min-height: 104px;
    padding: 14px;
    border-radius: 16px;
    border: 3px solid var(--card-outline);
    background: var(--chip);
    text-align: start;
}
@media (min-width: 900px) { .chip { min-height: 150px; padding: 20px; } }
.chip:disabled { opacity: 0.4; }
.chip-number { font-weight: 900; font-stretch: 108%; font-size: clamp(30px, 4vw, 44px); line-height: 1; overflow-wrap: anywhere; }
.chip-dest { font-family: var(--mono); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.35; }
/* Its destination is an unnumbered line's name, so it reads larger; who runs it is the caption under it. */
.chip-glyph { display: flex; }
.chip-title { font-weight: 800; font-size: 16px; line-height: 1.2; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 900px) { .chip-title { font-size: 19px; } }
.chip .chip-glyph + .chip-title { margin-top: auto; }
.chip:not(.chip-on) .chip-dest { color: var(--secondary); }
.chip-check {
    position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
    background: currentColor; display: inline-flex; align-items: center; justify-content: center;
}
.chip-check .icon { color: var(--check); }

.lines-foot {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-top: 28px;
    padding: 18px 0 max(6px, env(safe-area-inset-bottom));
    background: var(--bg);
}
.count-title { font-size: 20px; }
.count-hint { font-size: 12px; letter-spacing: 0.16em; color: var(--secondary); margin-top: 6px; }
.lines-actions { display: flex; gap: 12px; flex: 1 1 380px; max-width: 560px; }

/* ---------------------------------------------------------------- Board */

.board {
    display: grid;
    grid-template-rows: auto minmax(300px, 1fr) auto auto;
    height: 100dvh;
    max-width: none;
    gap: 6px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.board-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.board-head .back { margin-left: -10px; color: var(--secondary); }
.board-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px 18px; flex-wrap: wrap; }
.board-title h1 { text-align: left; font-size: clamp(22px, 3.4vw, 36px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.board-title .caption { font-size: 12px; letter-spacing: 0.14em; color: var(--stop-name); margin: 0; }
.board-status { display: flex; align-items: center; gap: 14px; flex: none; }
.board-name-row { display: flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%; }
.board-name { display: block; max-width: 100%; text-align: inherit; }
.board-name-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.full-route-button { height: 36px; border-radius: 10px; background: var(--card); border: 2px solid var(--card-outline); }
.full-route-button:hover { background: var(--card-outline); }
.live { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 700; font-size: 12px; letter-spacing: 0.22em; color: var(--secondary); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.live[data-state="live"] .live-dot { background: var(--live); animation: pulse 2.4s ease-in-out infinite; }
.live[data-state="stale"] .live-label { color: var(--late); }
@keyframes pulse { 50% { opacity: 0.35; } }
.clock { font-family: var(--mono); font-weight: 700; font-size: clamp(16px, 2.2vw, 26px); font-variant-numeric: tabular-nums; }
.menu-wrap { position: relative; }
.menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
    min-width: 220px; padding: 6px; border-radius: 16px;
    background: var(--menu); border: 2px solid var(--card-outline);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    display: flex; flex-direction: column;
}
.menu button { display: flex; align-items: center; gap: 10px; text-align: start; padding: 12px 14px; border-radius: 10px; font-weight: 800; font-size: 16px; }
.menu button:hover { background: var(--card); }

/* The map's angled stop names rise above its box, into the gap under the header. */
.board-map { position: relative; min-height: 0; margin-top: 40px; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-note { position: absolute; left: 0; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); }
.map-note { top: 50%; width: 100%; text-align: center; transform: translateY(-50%); font-size: 13px; color: var(--secondary); padding: 0 20px; }

.readout { display: grid; gap: 14px; padding: 8px 0 4px; }
.readout-primary { display: flex; align-items: center; gap: 18px; min-width: 0; }
.readout-badge-ring { flex: none; padding: 5px; border: 4px solid var(--ink); border-radius: 33px; }
.readout-main { min-width: 0; }
/* An unnumbered line's name in the readout, where a numbered one has its number in the badge. */
.readout-service { margin: 6px 0 0; font-weight: 800; font-size: clamp(18px, 2.4vw, 26px); line-height: 1.15; overflow-wrap: anywhere; }
.readout-service small { display: block; margin-top: 3px; font-family: var(--mono); font-weight: 700; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--caption); }
.then-service { font-family: var(--display); font-weight: 800; color: var(--ink); text-transform: none; letter-spacing: 0; }
.kicker { font-size: 14px; letter-spacing: 0.18em; color: var(--caption); }
.minutes { display: flex; align-items: baseline; gap: 12px; font-weight: 900; font-stretch: 110%; line-height: 0.84; margin: 6px 0 10px; }
.minutes b { font-size: clamp(76px, 12vw, 132px); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.minutes b.now { font-size: clamp(54px, 8vw, 84px); }
.minutes small { font-size: clamp(22px, 3vw, 34px); letter-spacing: 0.02em; color: var(--secondary); }
.minutes-small { margin: 0; }
.minutes-small b { font-size: clamp(38px, 5vw, 56px); }
.minutes-small small { font-size: clamp(15px, 1.8vw, 20px); color: var(--secondary); }
.subline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-family: var(--mono); font-weight: 700; font-size: clamp(14px, 1.6vw, 17px); color: var(--secondary); text-transform: uppercase; }
.sub-stops { font-family: var(--display); font-weight: 800; color: var(--ink); letter-spacing: 0.02em; }
.sub-delay.late { color: var(--late); }
.sub-tag { font-size: 12px; letter-spacing: 0.1em; color: var(--dim); }
.sub-part { display: inline-flex; align-items: center; gap: 12px; }
.subline .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--dot); flex: none; }

.readout-then { border-radius: 24px; background: var(--card); padding: 18px 22px; border: 2px solid transparent; }
:root[data-theme="light"] .readout-then { border-color: var(--card-outline); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .readout-then { border-color: var(--card-outline); } }
.then-row { display: flex; align-items: center; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.subline-then { margin-left: auto; font-size: 14px; color: var(--caption); }
.then-none { font-family: var(--mono); font-weight: 700; color: var(--dim); font-size: 13px; letter-spacing: 0.1em; margin-top: 10px; }
.readout-then-empty { opacity: 0.8; }

.readout-empty { padding: 20px 0; }
.readout-empty-title { font-weight: 900; font-stretch: 110%; font-size: clamp(30px, 5vw, 52px); line-height: 1; text-transform: uppercase; }
.readout-empty-detail { margin-top: 10px; color: var(--secondary); font-size: 16px; max-width: 60ch; }

.board-foot { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 10px; letter-spacing: 0.08em; color: var(--dim); }

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
    .board { padding-left: 40px; padding-right: 40px; gap: 10px; }
    .readout { grid-template-columns: 1fr minmax(320px, 400px); align-items: end; }
    .readout-badge-ring { border-radius: 36px; }
    .badge-big { min-width: 136px; height: 136px; font-size: 62px; border-radius: 28px; }
}

@media (max-width: 520px) {
    .board { grid-template-rows: auto minmax(260px, 1fr) auto auto; }
    .readout-primary { gap: 14px; }
    .badge-big { min-width: 92px; height: 92px; font-size: 42px; border-radius: 20px; }
    .readout-badge-ring { border-radius: 27px; padding: 4px; border-width: 3px; }
    .readout-then { padding: 14px 16px; border-radius: 20px; }
    .badge-medium { min-width: 52px; height: 52px; font-size: 24px; border-radius: 12px; }
    .then-row { gap: 12px; }
    .live-label { display: none; }
    .full-route-button { display: none; }
    .board-head { align-items: flex-start; }
    .board-head .back, .board-status { margin-top: -6px; }
    .board-status { gap: 8px; }
    .board-title { flex-direction: column; gap: 2px; }
    .board-title h1 { font-size: 21px; white-space: normal; }
    .board-name-text {
        white-space: normal;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    }
    .board-title .caption { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* Wall mode: a bigger readout, nothing to tap but the board */
body.wall .board-foot { display: none; }
body.wall .minutes b { font-size: clamp(96px, 16vw, 220px); }

/* A stop row's ⓘ sits on the row, beside its button rather than inside it: the row picks the stop,
   the ⓘ opens its card. Bottom corner, so a history row's × keeps the top one. */
.row-item.has-info .row { padding-inline-end: 60px; }
.row-info {
    position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; color: var(--secondary);
}
.row-info:hover { background: var(--menu); color: var(--ink); }

/* Stops that open their card */
.map-stop { cursor: pointer; }
.map-stop:focus-visible { outline: none; }
.fr-stop:focus-visible > rect:first-child { fill: var(--focus); fill-opacity: 0.25; }

/* ---------------------------------------------------------------- Full lines view */

.full-route {
    position: fixed; inset: 0; z-index: 40;
    display: flex; flex-direction: column;
    background: var(--bg);
    padding: max(14px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.fr-head { display: flex; align-items: center; gap: 16px; padding-bottom: 10px; }
.fr-title { flex: 1; min-width: 0; }
.fr-title .caption { margin: 0 0 4px; font-size: 11px; letter-spacing: 0.22em; color: var(--stop-name); }
.fr-title h2 {
    font-weight: 900; font-stretch: 112%; text-transform: uppercase; letter-spacing: -0.015em; line-height: 1.05;
    font-size: clamp(20px, 3vw, 30px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fr-scroller {
    position: relative; flex: 1; min-height: 0; overflow: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--gutter));
}
.fr-scroller:focus-visible { outline-offset: -3px; border-radius: 0; }
.fr-svg { display: block; overflow: visible; }
.fr-note { position: absolute; }
.fr-foot { flex: none; display: flex; align-items: center; gap: var(--gutter); margin-top: 10px; }
.fr-nav { flex: none; display: flex; gap: 6px; }
.fr-nav-button {
    width: 44px; height: 40px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--menu); color: var(--ink);
}
.fr-nav-button .icon svg { stroke-width: 2.8; }
.fr-nav-button:hover:not(:disabled) { background: var(--card-outline); }
.fr-nav-button:disabled { opacity: 0.35; }
.flip-rtl:dir(rtl) { transform: scaleX(-1); }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.fr-mini {
    position: relative; flex: 1; min-width: 0; height: 64px;
    border-radius: 16px; background: var(--card); border: 2px solid var(--card-outline);
    touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; overflow: hidden;
}
.fr-mini-svg { position: absolute; inset: 0; display: block; }
.fr-mini-window {
    position: absolute;
    border: 2px solid var(--ink); border-radius: 5px;
    background: color-mix(in srgb, var(--ink) 10%, transparent);
    cursor: grab;
}
.fr-mini.dragging, .fr-mini.dragging .fr-mini-window { cursor: grabbing; }

/* ---------------------------------------------------------------- Stop card */

.stop-card-backdrop {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: center; justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.55);
}
.stop-card {
    width: min(520px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain;
    border-radius: 24px; background: var(--bg); border: 2px solid var(--card-outline);
    padding: 22px; display: flex; flex-direction: column; gap: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
@media (max-width: 520px) {
    .stop-card-backdrop { align-items: flex-end; padding: 0; }
    .stop-card { border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: max(22px, env(safe-area-inset-bottom)); border-bottom: 0; }
}
.stop-card-head { display: flex; align-items: flex-start; gap: 14px; }
.stop-card-title { flex: 1; min-width: 0; }
.stop-card-title .caption { margin: 0 0 6px; color: var(--stop-name); }
.stop-card-title h2 {
    font-weight: 900; font-stretch: 112%; text-transform: uppercase; letter-spacing: -0.015em; line-height: 1.05;
    font-size: clamp(24px, 4vw, 32px); overflow-wrap: anywhere;
}
.stop-card-section { display: flex; flex-direction: column; gap: 10px; }
.stop-card-label { font-family: var(--mono); font-weight: 700; font-size: 11px; letter-spacing: 0.22em; color: var(--dim); }
.stop-card-line-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.stop-card-line { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stop-card-towards { flex: 1; min-width: 0; font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-card-tag { font-family: var(--mono); font-weight: 700; font-size: 10px; letter-spacing: 0.18em; color: var(--live); flex: none; }
.stop-card-quiet { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-weight: 700; font-size: 12px; letter-spacing: 0.12em; color: var(--secondary); }
.stop-card-address { font-size: 17px; font-weight: 700; color: var(--caption); }
.stop-card-map { position: relative; height: 200px; border-radius: 16px; overflow: hidden; border: 2px solid var(--card-outline); background: var(--card); }
.stop-card-map iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stop-card-maps-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 700; font-size: 12px; letter-spacing: 0.14em; text-decoration: none; color: var(--ink); padding: 10px 0; }
.stop-card-maps-link:hover { text-decoration: underline; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--dot); border-top-color: var(--ink); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Line ⓘ */

/* A line's ⓘ, beside a line wherever lines are listed: opens the line's card. */
.line-info {
    flex: none; width: 40px; height: 40px; margin: -4px 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; color: var(--secondary);
}
.line-info:hover { background: var(--menu); color: var(--ink); }
.kicker-row { display: flex; align-items: center; gap: 4px; }
.readout-info { width: 36px; height: 36px; margin: -8px 0; }

/* In the line picker it sits on the chip, beside its button rather than inside it: bottom corner,
   so the tick keeps the top one. */
.chip-item { position: relative; display: flex; min-width: 0; }
.chip-item > .chip { flex: 1; min-width: 0; }
.chip-item .chip-dest, .chip-item .chip-title:last-child { padding-inline-end: 30px; }
.chip-info {
    position: absolute; right: 4px; bottom: 4px; width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; color: var(--secondary);
}
.chip-info:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
@media (min-width: 900px) { .chip-info { right: 8px; bottom: 8px; } }

/* ---------------------------------------------------------------- Line card */

/* The stop card's frame, with the line's colour in --line. */
.line-card .stop-card-head .badge { min-width: 44px; height: 44px; padding: 0 8px; border-radius: 11px; font-size: 20px; }
.line-card-subtitle { margin-top: 6px; font-size: 15px; font-weight: 700; color: var(--secondary); overflow-wrap: anywhere; }
.line-card-map {
    position: relative; flex: none; height: 260px; overflow: hidden;
    border-radius: var(--radius-row); border: 2px solid var(--card-outline); background: var(--card);
}
/* Two classes, to outrank MapLibre's own `.maplibregl-map { position: relative }`. */
.line-card-map > .line-card-canvas, .fr-map > .fr-map-canvas { position: absolute; inset: 0; }
.line-card-loading { position: absolute; inset: 0; justify-content: center; }
.line-card-note {
    position: absolute; left: 10px; top: 10px; z-index: 2; max-width: calc(100% - 20px);
    display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    font-family: var(--mono); font-weight: 700; font-size: 11px; letter-spacing: 0.12em; color: var(--secondary);
}
.line-card-credit { color: var(--dim); text-transform: none; letter-spacing: 0.02em; }

/* The map's own credit, in the board's colours rather than MapLibre's white. */
.line-card-map .maplibregl-ctrl.maplibregl-ctrl-attrib, .fr-map .maplibregl-ctrl.maplibregl-ctrl-attrib {
    background: color-mix(in srgb, var(--bg) 82%, transparent); color: var(--secondary); font-size: 10px; line-height: 16px;
}
.line-card-map .maplibregl-ctrl-attrib a, .fr-map .maplibregl-ctrl-attrib a { color: var(--secondary); }

/* Every stop on a strip of the line's colour, as on a route diagram. */
.line-card-stops { list-style: none; }
.line-card-stop {
    display: flex; align-items: stretch; gap: 14px; min-height: 48px;
    width: calc(100% + 16px); margin: 0 -8px; padding: 0 8px; border-radius: 10px; text-align: start;
}
.line-card-stop:hover { background: color-mix(in srgb, var(--line) 8%, transparent); }
.line-card-stop.focused { background: color-mix(in srgb, var(--line) 16%, transparent); }
.line-card-stop:focus-visible { outline-offset: -3px; }
.line-card-rail { position: relative; flex: none; width: 24px; display: flex; align-items: center; justify-content: center; }
.line-card-rail::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 5px; margin-left: -2.5px; background: var(--line); }
.line-card-rail.first::before { top: 50%; }
.line-card-rail.last::before { bottom: 50%; }
.line-card-rail.first.last::before { display: none; }
.line-card-dot { position: relative; width: 11px; height: 11px; border-radius: 50%; background: var(--bg); border: 2.5px solid var(--line); }
.line-card-stop-terminus .line-card-dot { width: 15px; height: 15px; border-width: 3.5px; }
.line-card-stop-highlighted .line-card-dot { width: 20px; height: 20px; border-width: 3.5px; background: var(--line); border-color: var(--ink); }
.line-card-stop-text { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; padding: 8px 0; }
.line-card-stop-name { font-weight: 800; font-size: 16px; line-height: 1.25; color: var(--secondary); overflow-wrap: anywhere; }
.line-card-stop-terminus .line-card-stop-name, .line-card-stop-highlighted .line-card-stop-name { color: var(--ink); }
.line-card-stop-city { font-family: var(--mono); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }

/* ---------------------------------------------------------------- Full lines view: badges, toggle, map */

.fr-badges { flex: none; display: flex; }
.fr-badge { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
button.fr-badge:hover { background: var(--card); }
.fr-badge .badge { min-width: 30px; height: 30px; padding: 0 5px; border-radius: 8px; font-size: 15px; }

/* The strip or the map: two halves of one control, at the foot's leading end. */
.fr-toggle {
    flex: none; display: inline-flex; height: 42px; padding: 3px; border-radius: 999px;
    background: color-mix(in srgb, var(--bg) 94%, transparent); border: 1px solid var(--card-outline);
}
.fr-toggle-half { width: 44px; height: 34px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--secondary); }
.fr-toggle-half[aria-pressed="true"] { background: var(--menu); color: var(--ink); }
.fr-toggle-half:hover:not([aria-pressed="true"]) { color: var(--ink); }

/* The map takes the strip's place too; the toggle keeps its corner over it, and the map's own marks
   sit above the toggle's band rather than under it. */
.fr-map { position: relative; flex: 1; min-height: 0; margin: 0 calc(-1 * var(--gutter)); overflow: hidden; }
.fr-map > .fr-toggle { position: absolute; left: max(var(--gutter), env(safe-area-inset-left)); bottom: 11px; z-index: 3; }
.fr-map .maplibregl-ctrl-bottom-left, .fr-map .maplibregl-ctrl-bottom-right { bottom: 66px; }
.fr-map > .fr-map-note { left: var(--gutter); top: 10px; }

@media (max-width: 520px) {
    .fr-head { gap: 10px; }
    .fr-foot { gap: 10px; }
    .fr-toggle-half { width: 40px; }
}

.fatal, .noscript { padding: 40px 20px; font-size: 18px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
