/* Trains and metro of SFM on the map of /tib/ (assets/rail.js). They look unlike the buses on purpose: a bus is a disc; a train is a
   rounded rectangle with a train glyph, the metro a round badge, both in the line's colour with the line written on them (colour-blind
   safe); a station is a small rounded square, white with a coloured frame (dark in the dark theme), on top of thin tracks drawn under
   everything else. */
.rail-train-icon, .rail-station-icon { background: none; border: 0; }

/* stations */
.rail-station {
  display: block; box-sizing: border-box; width: 14px; height: 14px; margin: 1px; border-radius: 4px;
  background: #fff; border: 3px solid #005192; box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
/* the metro: the yellow of its badges everywhere (#ffdd00, the owner, 14 Nov 2026), with a thin dark ring so it shows on a light map */
.rail-station-metro { border-color: #ffdd00; box-shadow: 0 0 0 1px #1b1d21, 0 1px 3px rgba(0, 0, 0, .35); }
/* a station of trains and metro: the frame of the trains, the colour of the metro inside */
.rail-station-both { background: radial-gradient(circle, #ffdd00 0 2.5px, #fff 3px); }
.zoom-far .rail-station { width: 10px; height: 10px; margin: 3px; border-width: 2.5px; border-radius: 3px; }
.leaflet-marker-icon:focus-visible .rail-station { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail-station.rail-inline { display: inline-block; vertical-align: -2px; width: 12px; height: 12px; margin: 0 6px 0 0; border-width: 2.5px; }

/* trains: a rounded rectangle; metro: a round badge */
.rail-train, .rail-metro {
  display: flex; align-items: center; justify-content: center; gap: 2px; box-sizing: border-box;
  background: var(--line-color); color: var(--line-text); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45); font: 800 11.5px/1 var(--db-display, system-ui); letter-spacing: -.01em;
  transition: transform .15s ease;
}
.rail-train { width: 44px; height: 24px; border-radius: 7px; padding: 0 5px 0 3px; }
.rail-metro { width: 28px; height: 28px; border-radius: 50%; font-size: 11px; }
.rail-glyph { width: 13px; height: 13px; flex: none; fill: currentColor; }
.rail-train-icon:hover .rail-train, .rail-train-icon:hover .rail-metro { transform: scale(1.12); }
.leaflet-marker-icon:focus-visible .rail-train, .leaflet-marker-icon:focus-visible .rail-metro { outline: 2px solid var(--accent); outline-offset: 2px; }
.zoom-far .rail-train { transform: scale(.85); }
.zoom-far .rail-metro { transform: scale(.85); }
/* a train waiting at its first station, or just arrived: paler */
.rail-waiting .rail-train, .rail-waiting .rail-metro { opacity: .72; }

/* the legend of the panel and the button on the map */
.rail-sample {
  display: inline-flex; align-items: center; justify-content: center; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 800 10px/1 var(--db-display, system-ui); color: #fff; background: #005192; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.rail-sample-train { width: 30px; height: 18px; border-radius: 5px; }
.rail-sample-metro { width: 22px; height: 22px; border-radius: 50%; background: #ffdd00; color: #000; }
.rail-control { background: var(--bg); }
.leaflet-bar.rail-control { border: 2px solid rgba(0, 0, 0, .2); }
.rail-control-button {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 4px;
  background: var(--bg); color: #005192; cursor: pointer;
}
.rail-control-button svg { width: 20px; height: 20px; fill: currentColor; }
.rail-control-button[aria-expanded="true"] { background: #005192; color: #fff; }
.rail-control-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail-control-menu {
  position: absolute; right: 0; bottom: calc(100% + 6px); min-width: 200px; padding: 6px 12px 8px; border-radius: 8px;
  background: var(--bg); color: var(--fg); box-shadow: var(--shadow); font-size: 14px;
}
.rail-control-menu[hidden] { display: none; }
.rail-control-title { margin: 4px 0; font-weight: 700; }
.rail-control-menu .legend-row { min-height: 44px; } /* thumb-sized rows on a phone */

/* popups */
.rail-pop .pop-head { min-height: 44px; }
.rail-estimated { font-style: italic; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pop-actions .follow { flex: 1 1 auto; width: auto; }
a.follow { display: inline-block; box-sizing: border-box; text-align: center; text-decoration: none; }
.rail-station-head { display: flex; align-items: center; gap: 8px; font: 800 16px/1.2 var(--db-display, system-ui); }
.rail-station-head .rail-station { flex: none; margin: 0; }
.rail-station-kind { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; color: var(--muted); }
.rail-dep-title { font-weight: 700; margin: 6px 0 4px; }
.rail-deps { list-style: none; margin: 0; padding: 0; }
/* «Reforç»: the extra trains of an SFM special timetable */
.rail-label { display: inline-block; margin-left: 4px; padding: 0 6px; border: 1px solid currentColor; border-radius: 999px; font-size: 11px;
  font-weight: 700; line-height: 16px; vertical-align: 1px; white-space: nowrap; letter-spacing: 0.01em; }
.rail-label-note .rail-label { margin-left: 0; margin-right: 2px; }
.rail-deps li { display: grid; grid-template-columns: 3.2em auto 1fr auto; align-items: center; gap: 6px; padding: 4px 0; border-top: 1px solid var(--line); }
.rail-deps li.hint { display: block; color: var(--muted); }
.rail-dep-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.rail-dep-to { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-dep-in { color: var(--muted); font-size: 12px; white-space: nowrap; }
.rail-badge { display: inline-block; padding: 1px 6px; border-radius: 5px; font: 800 12px/1.35 var(--db-display, system-ui); }
.rail-badge-metro { border-radius: 999px; }

/* the dark theme: stations dark inside, a light frame where the line colour would vanish */
:root[data-theme="dark"] .rail-station { background: #1b1d21; border-color: #5aa5e6; box-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .rail-station-metro { border-color: #ffdd00; }
:root[data-theme="dark"] .rail-station-both { background: radial-gradient(circle, #ffdd00 0 2.5px, #1b1d21 3px); }
:root[data-theme="dark"] .rail-train, :root[data-theme="dark"] .rail-metro { border-color: #1b1d21; }
:root[data-theme="dark"] .rail-control-button { color: #5aa5e6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .rail-station { background: #1b1d21; border-color: #5aa5e6; box-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
  :root:not([data-theme="light"]) .rail-station-metro { border-color: #ffdd00; }
  :root:not([data-theme="light"]) .rail-station-both { background: radial-gradient(circle, #ffdd00 0 2.5px, #1b1d21 3px); }
  :root:not([data-theme="light"]) .rail-train, :root:not([data-theme="light"]) .rail-metro { border-color: #1b1d21; }
  :root:not([data-theme="light"]) .rail-control-button { color: #5aa5e6; }
}
@media (prefers-reduced-motion: reduce) {
  .rail-train, .rail-metro { transition: none; }
}

/* the page of a station (/tib/estacion/?code=…): its name with the station's symbol, its lines, the next departures as rows that fit a
   phone (time, line, destination, minutes; where it stops folded; the link to the train on the map), the timetable by kind of day */
.station-hero { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; }
.station-hero .rail-station { flex: none; width: 26px; height: 26px; border-width: 5px; border-radius: 7px; margin: 0; }
.station-hero h1 { margin: 0; }
.station-kind { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 0; color: var(--db-muted); }
.station-kind .line-badge { min-width: 38px; height: 26px; font-size: 13px; border-radius: 7px; text-decoration: none; }
.station-kind a.line-badge, .station-kind a.line-badge:hover { color: var(--line-text) !important; } /* a link, in the line's colours */
.station-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.station-deps { list-style: none; margin: 8px 0; padding: 0; }
.station-deps li {
  display: grid; grid-template-columns: 3.4em auto 1fr auto; grid-template-areas: 'time line to in' 'live live live live' 'stops stops stops where';
  align-items: center; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--db-border); line-height: 1.3;
}
.station-deps li:last-child { border-bottom: 1px solid var(--db-border); }
.station-deps time { grid-area: time; font: 800 18px/1 var(--db-display, system-ui); font-variant-numeric: tabular-nums; }
.station-deps .line-badge { grid-area: line; min-width: 38px; height: 26px; font-size: 13px; border-radius: 7px; }
.station-deps .dep-to { grid-area: to; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.station-deps .dep-in { grid-area: in; color: var(--db-muted); white-space: nowrap; font-size: 14px; }
.station-deps .dep-stops { grid-area: stops; font-size: 14px; color: var(--db-muted); }
.station-deps .dep-stops summary { cursor: pointer; min-height: 30px; display: flex; align-items: center; }
.station-deps .dep-stops p { margin: 2px 0 0; }
/* SFM's board (api/sfm.php): platform, its change, delay, on their own row; empty rows take no room */
.station-deps .dep-live { grid-area: live; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 13.5px; }
.station-deps .dep-where { grid-area: where; justify-self: end; font-size: 14px; font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.station-kind-tt { margin: 10px 0; border: 1px solid var(--db-border); border-radius: 10px; padding: 0 14px; }
.station-kind-tt > summary { cursor: pointer; font-weight: 800; min-height: 48px; display: flex; align-items: center; }
.station-kind-tt h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 12px 0 6px; }
.station-kind-tt h3 .line-badge { min-width: 34px; height: 24px; font-size: 12.5px; border-radius: 6px; }
@media (max-width: 420px) {
  /* a phone: time, line and destination; then the minutes and the link to the train; then where it stops, folded */
  .station-deps li { grid-template-columns: 3.1em auto 1fr; grid-template-areas: 'time line to' 'live live live' 'in in where' 'stops stops stops'; }
  .station-deps .dep-in { justify-self: start; }
}
/* where a train stops: folded, with its arrow (the summary is a flex box, which hides the browser's own marker) */
.station-deps .dep-stops { margin: 0; }
.station-deps .dep-stops summary::before { content: '▸'; display: inline-block; width: 1em; }
.station-deps .dep-stops[open] summary::before { content: '▾'; }
