/* The public pages of the fleet and the statistics of EMT Palma (/emt/flota/, /emt/flota/<number>/, /emt/stats/; Emt\FleetPages), on the
   theme of the platform (theme.css tokens: light and dark come with them) and the frame of the line pages (pages.css). Made for a phone
   first: two cards a row, nothing wider than the screen at 360 px, buttons at least 44 px, inputs at 16 px (no zoom on an iPhone).
   No inline styles (the CSP forbids them): the line colours come from line-colors.css (class lc-<line> sets --line-color). */

.fleet-page, .bus-page, .stats-page-emt { max-width: 1080px; }
.fleet-note { margin-top: 18px; }
.fleet-body .more .db-btn { min-height: 44px; }

/* the numbers on top of the list */
.fleet-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; list-style: none; padding: 0; margin: 4px 0 18px; color: var(--db-muted); font-size: 15px; }
.fleet-summary strong { color: var(--db-text); font: 800 22px/1 var(--db-display); margin-right: 4px; }
.fleet-summary .is-live strong { color: var(--db-success); }

/* the search and the filters */
.fleet-filter { display: grid; gap: 10px; margin: 0 0 8px; }
.fleet-search-label { font-weight: 800; font-size: 15px; }
.fleet-search { font: 700 22px/1.2 var(--db-font); min-height: 52px; letter-spacing: .02em; }
.fleet-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fleet-chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--db-border-strong); background: var(--db-surface); color: var(--db-text); font: 700 15px/1 var(--db-font);
}
.fleet-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--db-success); }
.fleet-chip[aria-pressed="true"] { background: var(--db-accent-soft); border-color: var(--db-accent); color: var(--db-accent-soft-text); }
.fleet-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fleet-selects label { display: grid; gap: 4px; min-width: 0; font-size: 13px; color: var(--db-muted); font-weight: 700; }
.fleet-selects .db-select { min-width: 0; }
.fleet-count { margin: 4px 0 10px; color: var(--db-muted); font-size: 14px; }
.fleet-none { margin: 12px 0; }

/* the cards: two a row on a phone */
.fleet-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .fleet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 900px) { .fleet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fleet-grid li[hidden] { display: none; }
.fleet-card {
  display: grid; gap: 2px; height: 100%; box-sizing: border-box; padding: 0 0 10px; overflow: hidden; border-radius: var(--db-radius);
  border: 1px solid var(--db-border); background: var(--db-surface); color: var(--db-text) !important; text-decoration: none !important;
}
.fleet-card:hover { border-color: var(--db-border-strong); }
.fleet-card:focus-visible { outline: 2px solid var(--db-accent); outline-offset: 2px; }
.fleet-photo { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--db-surface-2); overflow: hidden; margin-bottom: 6px; }
.fleet-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fleet-photo small {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 6px 3px; font-size: 11px; line-height: 1.2; color: #fff; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; background: linear-gradient(transparent, rgba(0, 0, 0, .55));
}
.fleet-photo.is-empty { display: grid; place-items: center; }
.fleet-photo.is-empty small { background: none; color: var(--db-muted); text-align: center; }
.fleet-silhouette { width: 62%; height: auto; aspect-ratio: 2 / 1; color: var(--db-surface-3); margin-bottom: 10px; }
.fleet-num { padding: 0 10px; font: 800 26px/1.05 var(--db-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fleet-plate { padding: 0 10px; font: 700 13px/1.3 var(--db-mono); color: var(--db-muted); letter-spacing: .03em; }
.fleet-model { padding: 0 10px; font-size: 13.5px; line-height: 1.3; overflow-wrap: anywhere; }
.fleet-status { padding: 4px 10px 0; font-size: 12.5px; line-height: 1.3; color: var(--db-muted); }
.fleet-status.is-live { color: var(--db-success); font-weight: 700; }
.fleet-status i, .bus-now i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--db-success); vertical-align: 1px; }
@media (prefers-reduced-motion: no-preference) {
  .fleet-status.is-live i, .bus-now.is-live i { animation: fleet-pulse 2s ease-in-out infinite; }
}
@keyframes fleet-pulse { 50% { opacity: .35; } }

/* one bus */
.bus-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 12px; }
.bus-head h1 { margin: 0; font-size: clamp(34px, 9vw, 52px); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bus-sub { margin: 0; color: var(--db-muted); font-size: 16px; }
.bus-grid { display: grid; gap: 14px; }
@media (min-width: 980px) { .bus-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }
.bus-col { display: grid; gap: 14px; min-width: 0; }
.bus-card { background: var(--db-surface); border: 1px solid var(--db-border); border-radius: var(--db-radius); padding: 16px; min-width: 0; }
.bus-card + .bus-card { margin-top: 14px; }
.bus-col .bus-card + .bus-card { margin-top: 0; }
.bus-card h2 { font-size: 20px; margin: 0 0 10px; }
.pages-body .bus-card h2 { margin-top: 0; }
.bus-card h3 { font-size: 15px; margin: 18px 0 8px; }
.bus-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.bus-card-head h2 { margin: 0; }

/* its photos: a strip to swipe; a tap opens one full size */
.bus-gallery { margin: 0; min-width: 0; }
.bus-slides { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; list-style: none; padding: 0; margin: 0; border-radius: var(--db-radius); scrollbar-width: none; }
.bus-slides::-webkit-scrollbar { display: none; }
.bus-slides li { flex: 0 0 100%; scroll-snap-align: start; }
.bus-slides figure { margin: 0; }
.bus-photo { display: block; aspect-ratio: 4 / 3; background: var(--db-surface-2); border-radius: var(--db-radius); overflow: hidden; }
.bus-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bus-slides figcaption { padding: 6px 2px 0; font-size: 13px; color: var(--db-muted); overflow-wrap: anywhere; }
.bus-slides figcaption a { color: inherit; }
.bus-gallery-hint { margin: 6px 2px 0; font-size: 13px; color: var(--db-muted); }
.bus-gallery.is-empty { display: grid; place-items: center; gap: 6px; aspect-ratio: 4 / 3; max-height: 320px; border-radius: var(--db-radius); background: var(--db-surface-2); color: var(--db-muted); text-align: center; padding: 12px; }
.bus-gallery.is-empty p { margin: 0; font-size: 14px; }
.bus-gallery.is-empty .fleet-silhouette { width: 46%; max-width: 220px; margin: 0; }
.bus-viewer { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; padding: 0; border: 0; background: #000; color: #fff; }
.bus-viewer[open] { display: grid; grid-template-rows: 1fr auto; }
.bus-viewer::backdrop { background: rgba(0, 0, 0, .9); }
.bus-viewer img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.bus-viewer p { margin: 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); font-size: 14px; text-align: center; }
.bus-viewer-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, .16); color: #fff; font: 700 15px/1 var(--db-font); cursor: pointer; }
.bus-viewer-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.bus-viewer-btn.prev { left: 8px; }
.bus-viewer-btn.next { right: 8px; }

/* its details */
.bus-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.bus-facts div { min-width: 0; }
.bus-facts dt { font-size: 12.5px; color: var(--db-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.bus-facts dd { margin: 2px 0 0; font-size: 16px; overflow-wrap: anywhere; }
.bus-facts dd.is-unknown { color: var(--db-faint); }
.bus-now { font-size: 17px; margin: 0 0 8px; }
.bus-now.is-live { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bus-now .line-badge { margin-right: 2px; }
.bus-map-btn { min-height: 48px; }

/* its numbers: a switch of four periods and four figures */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--db-surface-2); max-width: 100%; }
.seg button { min-height: 44px; min-width: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--db-muted); font: 700 14px/1 var(--db-font); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--db-surface); color: var(--db-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.bus-kpis, .st-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
@media (min-width: 640px) { .st-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bus-kpis[hidden] { display: none; }
.bus-kpis div, .st-kpis div { padding: 10px 12px; border-radius: 8px; background: var(--db-surface-2); min-width: 0; }
.bus-kpis dt, .st-kpis dt { font-size: 12.5px; line-height: 1.25; color: var(--db-muted); font-weight: 700; }
.bus-kpis dd, .st-kpis dd { margin: 4px 0 0; font: 800 24px/1.1 var(--db-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.st-kpis .is-live dd { color: var(--db-success); }
.st-kpis dd small { display: block; font: 400 13px/1.3 var(--db-font); color: var(--db-muted); margin-top: 3px; }
.bus-first { font-size: 13.5px; margin: 8px 0 0; }

/* charts: bars in SVG, labels in HTML */
.ch { position: relative; display: grid; gap: 4px; margin: 4px 0 2px; }
.ch-max { font-size: 12px; color: var(--db-muted); font-variant-numeric: tabular-nums; }
.ch-svg { display: block; width: 100%; height: 120px; overflow: visible; }
.ch-bar { fill: var(--db-accent); }
.ch-bar.is-today { fill: var(--db-accent-hover); opacity: .55; }
.ch-bar.is-partial { opacity: .55; }
.st-line-body .ch-bar { fill: var(--line-color, var(--db-accent)); }
.ch-nodata { opacity: .7; }
.ch-hatch { fill: var(--db-border-strong); }
.ch-base { stroke: var(--db-border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--db-muted); }
.ch-labels.is-ticks { display: block; }
.ch-ticks { display: flex; justify-content: space-between; }
.st-swatch { display: inline-block; width: 14px; height: 10px; vertical-align: -1px; border-radius: 2px; background: repeating-linear-gradient(45deg, var(--db-border-strong) 0 2px, transparent 2px 4px); }

/* horizontal bars: lines, models, buses */
.bl { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.bl-row { display: grid; grid-template-columns: minmax(46px, auto) 1fr auto; align-items: center; gap: 10px; min-height: 34px; color: inherit !important; text-decoration: none !important; }
a.bl-row { min-height: 44px; }
a.bl-row:hover .bl-value { text-decoration: underline; }
.bl-label { font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.bl-bar svg { display: block; width: 100%; height: 12px; }
.bl-fill { fill: var(--line-color, var(--db-sea)); }
.bl-value { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--db-muted); white-space: nowrap; }
.st-bus { font: 800 16px/1 var(--db-display); }

/* the history: a card per day */
.bus-history-filter { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; margin-bottom: 12px; }
.bus-history-filter label { display: grid; gap: 4px; font-size: 13px; color: var(--db-muted); font-weight: 700; min-width: 0; }
.bus-history-filter label:first-of-type { grid-column: 1 / -1; }
.bus-history-filter .db-input, .bus-history-filter .db-select { min-width: 0; }
.bus-history-filter .db-btn { grid-column: 1 / -1; min-height: 44px; }
@media (min-width: 720px) {
  .bus-history-filter { grid-template-columns: 1.4fr 1fr 1fr auto; }
  .bus-history-filter label:first-of-type, .bus-history-filter .db-btn { grid-column: auto; }
}
.bus-days { display: grid; gap: 10px; }
.bus-day { border: 1px solid var(--db-border); border-radius: var(--db-radius); padding: 10px 12px; background: var(--db-bg); }
.bus-day h3 { margin: 0 0 6px; font-size: 15px; }
.bus-day h3 span { font-weight: 400; color: var(--db-muted); font-family: var(--db-font); font-size: 13.5px; }
.bus-day ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.bus-day li { display: grid; grid-template-columns: auto auto 1fr; grid-template-areas: "time line to" "time line state"; align-items: center; gap: 0 10px; min-height: 40px; }
.bus-trip-time { grid-area: time; font: 700 14px/1.2 var(--db-mono); font-variant-numeric: tabular-nums; }
.bus-day .line-badge { grid-area: line; min-width: 40px; height: 28px; font-size: 14px; }
.bus-trip-to { grid-area: to; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.bus-trip-km, .bus-trip-state { grid-area: state; font-size: 12.5px; color: var(--db-muted); }
.bus-trip-km { justify-self: start; }
.bus-trip-state { justify-self: end; }
.bus-trip-state.is-complete { color: var(--db-success); font-weight: 700; }
.bus-history-more { margin: 12px 0 0; }
.bus-history-more .db-btn { width: 100%; min-height: 46px; }

/* the statistics */
.st-two { display: grid; gap: 14px; }
@media (min-width: 760px) { .st-two { grid-template-columns: 1fr 1fr; } }
.st-two figure { margin: 0; }
.st-two figcaption { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.st-hint { font-size: 13.5px; margin: 8px 0 0; }
.st-avg { margin-top: 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-avg dd small + small { margin-top: 0; }
.st-table-wrap { overflow-x: auto; margin: 0 -4px; }
.st-lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.st-lines th, .st-lines td { padding: 6px 6px; text-align: right; border-bottom: 1px solid var(--db-border); white-space: nowrap; }
.st-lines th:first-child { text-align: left; }
.st-lines thead th { position: sticky; top: 0; background: var(--db-surface); }
.st-lines thead button { min-height: 44px; min-width: 44px; padding: 0 2px; border: 0; background: none; color: var(--db-muted); font: 700 13px/1.1 var(--db-font); cursor: pointer; }
.st-lines thead button[aria-sort], .st-lines thead button[data-active] { color: var(--db-text); }
.st-lines thead button[data-dir="asc"]::after { content: ' ▲'; font-size: 10px; }
.st-lines thead button[data-dir="desc"]::after { content: ' ▼'; font-size: 10px; }
.st-line-link { display: inline-flex; min-height: 44px; align-items: center; text-decoration: none !important; }
.st-line-detail td { text-align: left; white-space: normal; background: var(--db-bg); padding: 10px; }
.st-line-body h3 { margin-top: 4px; }
.st-buses { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.st-buses a { display: inline-flex; gap: 6px; align-items: baseline; min-height: 44px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--db-border-strong);
  background: var(--db-surface); color: var(--db-text) !important; text-decoration: none !important; box-sizing: border-box; }
.st-buses span { font-size: 12.5px; color: var(--db-muted); }
.st-records { display: grid; gap: 10px; margin: 0; }
@media (min-width: 640px) { .st-records { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.st-records div { padding: 12px; border-radius: 8px; background: var(--db-surface-2); }
.st-records dt { font-size: 13px; color: var(--db-muted); font-weight: 700; }
.st-records dd { margin: 4px 0 0; font-weight: 800; font-size: 16px; }

@media (max-width: 380px) {
  .fleet-grid { gap: 8px; }
  .fleet-num { font-size: 23px; }
  .bus-card { padding: 14px 12px; }
  .seg button { padding: 0 8px; font-size: 13px; }
  .st-lines th, .st-lines td { padding: 6px 4px; font-size: 14px; }
}

/* «Proponer foto de este autobús» (24 Nov 2026, Emt\PhotoSubmissions): the button under a bus's photos, and the page of the proposals */
.bus-propose { margin: .75rem 0 0; }
.photo-submit .lead { color: var(--db-muted); }
.photo-form { display: grid; gap: 1rem; }
.photo-form .db-field { display: grid; gap: .35rem; }
.photo-form .db-field > span { font-weight: 600; }
.photo-form .db-field small { color: var(--db-muted); }
.photo-form .db-input { font-size: 16px; min-height: 44px; }
.photo-preview { display: block; max-width: 100%; height: auto; border-radius: var(--db-radius); }
.photo-ticks { border: 0; padding: 0; margin: 0; display: grid; gap: .6rem; }
.photo-tick { display: flex; gap: .65rem; align-items: flex-start; min-height: 44px; line-height: 1.4; }
.photo-tick input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; }
.photo-mine { margin-top: 1.5rem; }
.photo-mine-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.photo-mine-item { display: grid; grid-template-columns: 96px 1fr; gap: .75rem; align-items: start; padding: .75rem; border: 1px solid var(--db-border-strong);
  border-radius: var(--db-radius); background: var(--db-surface); }
.photo-mine-item:not(:has(img)) { grid-template-columns: 1fr; }
.photo-mine-item img { width: 96px; height: auto; border-radius: 6px; }
.photo-mine-item p { margin: 0 0 .35rem; overflow-wrap: anywhere; }
.photo-pending .photo-mine-item, .photo-mine-item.photo-pending { border-style: dashed; }
