/* Tableau de bord d'un focus, pensé pour un écran de télévision.
   Mise en page : une seule hauteur d'écran, sans défilement — bandeau titre, carte (le plus grand espace),
   puis une bande qui montre une catégorie à la fois (historique, en direct, prévisions), toutes ses
   vues côte à côte. Police, mode sombre ou clair et trois couleurs viennent du focus (Config › Focus) :
   --c1 identité du focus et « en direct », --c2 historique, --c3 prévisions et mises en avant. */
:root {
  --c1: #c2410c;
  --c2: #8fb4ff;
  --c3: #f3c86b;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rotate: 10s;
  /* sombre (par défaut) */
  --bg: #0a1117;
  --panel: #111c24;
  --panel-2: #1a2a35;
  --line: #22333e;
  --ink: #e9f1f1;
  --muted: #8ea3a9;
  --good: #3fd59d;
  --warn: #f0a020;
  --bad: #ef5a4f;
  --veil: #0a1117e0;
  --tiles: invert(1) hue-rotate(180deg) brightness(.72) contrast(.9) saturate(.4);
  color-scheme: dark;
  font-size: clamp(12px, 1.42vh, 24px);
}
:root[data-theme="light"] {
  --bg: #f3f5f2;
  --panel: #ffffff;
  --panel-2: #e3e9e5;
  --line: #d2dbd6;
  --ink: #142026;
  --muted: #5a6c71;
  --good: #11905e;
  --warn: #c07800;
  --bad: #cc3a2f;
  --veil: #ffffffe6;
  --tiles: grayscale(.85) brightness(1.04) contrast(.9);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); }
[hidden] { display: none !important; }

.fd {
  position: fixed; inset: calc(var(--rs-top-h) + env(safe-area-inset-top, 0px)) 0 0 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) minmax(14rem, 36%);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
body.fs .rs-topbar { display: none; }
body.fs .fd { inset: 0; }
body.fs.idle, body.fs.idle * { cursor: none !important; }

/* ---------- Bandeau titre ---------- */
.fd-top { display: flex; align-items: center; gap: 1.6rem; padding: .7rem 1.4rem; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, color-mix(in srgb, var(--c1) 16%, var(--bg)), var(--bg) 45%); }
.fd-title { display: flex; align-items: center; gap: .9rem; min-width: 0; flex: 1; }
.fd-swatch { flex: 0 0 auto; width: .9rem; height: 2.4rem; border-radius: 3px; background: linear-gradient(var(--c1) 34%, var(--c2) 34% 67%, var(--c3) 67%); }
.fd-select { display: flex; flex-direction: column; }
.fd-k { color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.fd-select select { padding: 0 1.4rem 0 0; border: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238ea3a9' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right center / .7rem; color: var(--ink); font: 700 2rem/1.05 var(--font); appearance: none; cursor: pointer; }
.fd-select select:focus-visible { outline: 2px solid var(--c1); outline-offset: 3px; border-radius: 4px; }
.fd-select option { background: var(--panel); color: var(--ink); font-size: 1rem; }
.fd-desc { margin: 0; min-width: 0; color: var(--muted); font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-clock { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
#fd-time { font-size: 2.1rem; font-weight: 700; line-height: 1; }
#fd-date { color: var(--muted); font-size: .8rem; }
.fd-live { display: flex; align-items: center; gap: .5rem; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.fd-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--good); box-shadow: 0 0 .6rem var(--good); animation: pulse 2s infinite; }
.fd-live.stale .fd-dot { background: var(--warn); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: .35; } }
.fd-fs { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; padding: 0; border: 1px solid var(--line); border-radius: .6rem; background: var(--panel); color: var(--ink); cursor: pointer; }
.fd-fs:hover, .fd-fs:focus-visible { border-color: var(--c1); outline: none; }
.fd-fs svg { width: 1.3rem; height: 1.3rem; }
.fd-fs .fs-off, body.fs .fd-fs .fs-on { display: none; }
body.fs .fd-fs .fs-off { display: inline; }

/* ---------- Carte ---------- */
.fd-map { position: relative; min-height: 0; }
#fd-map { position: absolute; inset: 0; background: var(--bg); }
#fd-map .leaflet-tile-pane { filter: var(--tiles); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { background: var(--veil) !important; color: var(--muted) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.fd-overlay { position: absolute; z-index: 500; top: 1rem; left: 1rem; display: flex; gap: .7rem; pointer-events: none; }
.fd-big { display: flex; flex-direction: column; padding: .6rem 1rem .5rem; border: 1px solid var(--line); border-top: 3px solid var(--c1); border-radius: .5rem; background: var(--veil); }
.fd-big b { font-size: 2.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.fd-big > span { color: var(--muted); font-size: .78rem; }
.fd-legend { position: absolute; z-index: 500; right: 1rem; bottom: 1.4rem; display: flex; flex-direction: column; gap: .25rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--veil); font-size: .78rem; color: var(--muted); }
.fd-legend i { display: inline-block; width: .7rem; height: .7rem; margin-right: .45rem; border-radius: 50%; vertical-align: -.05rem; background: var(--c); }
.train-tag { padding: 1px 5px !important; border: 0 !important; border-radius: 4px !important; background: var(--veil) !important; color: var(--ink) !important; box-shadow: none !important; font: 600 .78rem/1.3 var(--font) !important; }
.train-tag::before, .gate-tag::before { display: none !important; }
.train-tag em { font-style: normal; color: var(--c); }
.gate-tag { padding: 2px 7px !important; border: 1px solid var(--c1) !important; border-radius: 4px !important; background: var(--veil) !important; color: var(--ink) !important; box-shadow: none !important; font: 700 .8rem/1.2 var(--font) !important; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Bande : une catégorie à la fois ---------- */
.fd-band { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); background: var(--bg); }
.fd-band-head { position: relative; display: flex; align-items: center; padding: .55rem 1.4rem .5rem; border-bottom: 1px solid var(--line); }
.fd-cats { display: flex; gap: 2.2rem; }
.fd-cat { display: inline-flex; align-items: baseline; gap: .55rem; color: var(--muted); opacity: .55; font-size: 1.1rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; transition: opacity .3s, color .3s; }
.fd-cat::before { content: ""; align-self: center; width: .65rem; height: .65rem; border-radius: 2px; background: var(--k); }
.fd-cat small { font-size: .72rem; font-weight: 500; letter-spacing: .04em; text-transform: none; }
.fd-cat.history { --k: var(--c2); } .fd-cat.live { --k: var(--c1); } .fd-cat.forecast { --k: var(--c3); }
.fd-cat.on { color: var(--k); opacity: 1; }
.fd-cat[hidden] { display: none; }
.fd-cat.on small { color: var(--muted); }
.fd-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; }
.fd-progress i { display: block; height: 100%; background: var(--k, var(--c1)); transform-origin: left; transform: scaleX(0); }
.fd-progress i.run { animation: fill var(--rotate) linear forwards; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.fd-cards { flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px; background: var(--line); }
.fd-cards:empty { background: var(--bg); }
.slide { display: flex; flex-direction: column; gap: .5rem; min-width: 0; min-height: 0; padding: .8rem 1.1rem 1rem; background: var(--bg); overflow: hidden; }
.fd-cards.enter .slide { animation: enter .5s ease-out both; }
.fd-cards.enter .slide:nth-child(2) { animation-delay: .06s; } .fd-cards.enter .slide:nth-child(3) { animation-delay: .12s; }
.fd-cards.enter .slide:nth-child(4) { animation-delay: .18s; } .fd-cards.enter .slide:nth-child(5) { animation-delay: .24s; }
.fd-cards.enter .slide:nth-child(6) { animation-delay: .3s; }
@keyframes enter { from { opacity: 0; transform: translateY(.7rem); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fd-cards.enter .slide, .fd-progress i.run, .fd-dot { animation: none; } .fd-progress i.run { transform: none; } }
.s-title { color: var(--muted); font-size: .88rem; font-weight: 600; line-height: 1.25; }
.s-title b { color: var(--ink); }
.s-row { display: flex; align-items: center; gap: 1rem; min-height: 0; flex: 1; }
.s-num { font-size: 3.6rem; font-weight: 700; line-height: .95; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.s-num small { font-size: .42em; font-weight: 600; color: var(--muted); margin-left: .15em; }
.s-sub { color: var(--muted); font-size: .85rem; }
.s-empty { display: flex; flex: 1; align-items: center; color: var(--muted); font-size: .95rem; line-height: 1.45; }
.t-good { color: var(--good); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); } .t-muted { color: var(--muted); }
.chart { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--muted); font: 500 11px var(--font); }
.chart .val { fill: var(--ink); font: 700 12px var(--font); }
.chart .hl { fill: var(--ink); font-weight: 700; }
.chart .hl-bar { stroke: var(--ink); stroke-width: 1.5; }
.chart .dot { stroke: var(--bg); stroke-width: 2; }
.chart .base { fill: var(--line); }
.donut { flex: 0 0 auto; height: 100%; max-height: 8rem; aspect-ratio: 1; max-width: 45%; }
.donut svg { width: 100%; height: 100%; }
.donut .track { stroke: var(--panel-2); }
.donut text { fill: var(--ink); font: 700 22px var(--font); }
.stack { display: flex; height: 1.5rem; border-radius: .35rem; overflow: hidden; background: var(--panel-2); }
.stack i { display: block; height: 100%; background: var(--c); }
.stack-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .8rem; color: var(--muted); }
.stack-legend span::before { content: ""; display: inline-block; width: .65rem; height: .65rem; margin-right: .35rem; border-radius: 2px; background: var(--c); vertical-align: -.05rem; }
.stack-legend b { color: var(--ink); font-size: 1rem; margin-right: .2rem; }
.hbars { display: flex; flex-direction: column; gap: .4rem; flex: 1; justify-content: center; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 2.6rem; align-items: center; gap: .6rem; font-size: .82rem; }
.hbar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: .7rem; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--c, var(--c2)); }
.hbar b { font-size: 1rem; text-align: right; font-variant-numeric: tabular-nums; }
.tbl { display: flex; flex-direction: column; gap: .3rem; flex: 1; justify-content: center; }
.tr { display: grid; grid-template-columns: 3.4rem 3.6rem minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .3rem .5rem; border-radius: .35rem; background: var(--panel); font-size: .88rem; }
.tr .time { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tr .num { font-weight: 600; color: var(--muted); }
.tr .route { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { padding: .1rem .5rem; border-radius: 99px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.pill.good { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.pill.muted { background: var(--panel-2); color: var(--muted); }
.hero-train { display: flex; flex-direction: column; gap: .3rem; flex: 1; justify-content: center; min-width: 0; }
.hero-train .name { font-size: 1.35rem; font-weight: 600; }
.hero-train .route { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; }
.alerts { display: flex; flex-direction: column; gap: .4rem; flex: 1; min-height: 0; overflow: hidden; justify-content: center; }
.alert { padding: .4rem .6rem; border-left: 3px solid var(--warn); border-radius: .3rem; background: var(--panel); font-size: .85rem; line-height: 1.3; }
.alert b { margin-right: .4rem; }
.ok-msg { display: flex; align-items: center; gap: .7rem; flex: 1; color: var(--good); font-size: 1.3rem; font-weight: 600; }
.ok-msg svg { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; flex: 1; align-items: center; }
.duo > div { display: flex; flex-direction: column; min-width: 0; }

/* Accès réservé */
.fd-locked { grid-row: 1 / -1; align-self: center; justify-self: center; display: flex; flex-direction: column; gap: 1rem; max-width: 40rem; padding: 2rem; text-align: center; }
.fd-locked h1 { margin: 0; font-size: 2.6rem; }
.fd-locked p { margin: 0; color: var(--muted); font-size: 1.1rem; line-height: 1.5; }
.fd-locked div { display: flex; justify-content: center; gap: .8rem; flex-wrap: wrap; }
.fd-btn { padding: .6rem 1.2rem; border-radius: .5rem; background: var(--c1); color: #fff; font-weight: 600; text-decoration: none; }
.fd-btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }

@media (max-width: 900px) {
  :root { font-size: 12px; }
  .fd { grid-template-rows: auto minmax(0, 1fr) minmax(18rem, 46%); }
  .fd-cards { grid-auto-flow: row; grid-auto-rows: minmax(12rem, auto); overflow-y: auto; }
  .fd-cats { gap: 1rem; } .fd-cat small { display: none; }
  .fd-desc, .fd-live { display: none; }
  .fd-overlay { flex-wrap: wrap; right: 1rem; }
  .fd-big b { font-size: 1.8rem; }
}
