/* Le climat à Ferooz — page publique (SPEC §5).
 *
 * Identité visuelle reprise de OpenHABFeroozLight/html/temperature-dashboard.html :
 * mêmes variables de thème, mêmes cartes, mêmes chips, même infobulle. La page
 * publique ressemble donc aux pages internes du domaine, ce qui est le
 * résultat souhaité (SPEC §5.1).
 *
 * Fichier séparé — et non style en ligne comme les pages internes — pour une
 * raison unique : la CSP stricte de §7 interdit 'unsafe-inline'. Un fichier
 * autorise style-src 'self', qui est robuste ; des hachages SHA-256 seraient
 * à recalculer à chaque modification et cassés au premier oubli (SPEC §5.2).
 */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --text: #1c2530;
  --muted: #5b6a7d;          /* AA sur --panel et --panel-2 */
  --line: #d8dee7;
  --grid: #e6eaf0;
  --accent: #cc0000;         /* chaud */
  --accent-2: #2a78d6;       /* froid */
  --ok: #1b7f4e;
  --warn: #a35a00;
  --shadow: 0 1px 3px rgba(16, 24, 40, .12);

  --t-line: #cc0000;
  --hum: #0e7490;
  --pres: #6c4bb6;
  --gas-1: #1baf7a;
  --gas-2: #eda100;
  --gas-3: #2a78d6;
  --gas-4: #b5476b;
  --band: rgba(204, 0, 0, .14);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --panel: #1a2029;
    --panel-2: #222a35;
    --text: #e6ebf2;
    --muted: #9db0c6;
    --line: #2d3743;
    --grid: #263141;
    --accent: #ff6b6b;
    --accent-2: #58a6ff;
    --ok: #3ecf8e;
    --warn: #e0a33a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);

    --t-line: #ff6b6b;
    --hum: #2ba3bd;
    --pres: #a78bfa;
    --gas-1: #34d399;
    --gas-2: #fbbf24;
    --gas-3: #60a5fa;
    --gas-4: #f472b6;
    --band: rgba(255, 107, 107, .18);
  }
}

:root[data-theme="dark"] {
  --bg: #12161c;
  --panel: #1a2029;
  --panel-2: #222a35;
  --text: #e6ebf2;
  --muted: #9db0c6;
  --line: #2d3743;
  --grid: #263141;
  --accent: #ff6b6b;
  --accent-2: #58a6ff;
  --ok: #3ecf8e;
  --warn: #e0a33a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);

  --t-line: #ff6b6b;
  --hum: #2ba3bd;
  --pres: #a78bfa;
  --gas-1: #34d399;
  --gas-2: #fbbf24;
  --gas-3: #60a5fa;
  --gas-4: #f472b6;
  --band: rgba(255, 107, 107, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 28px;
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}
header .titles { flex: 1 1 260px; min-width: 0; }
h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
h1 .sub { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 14px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  min-height: 30px;
}
.chip:hover { border-color: var(--accent-2); }
.chip:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.chip[aria-pressed="true"], .chip.on {
  background: var(--accent-2); border-color: var(--accent-2); color: #fff; font-weight: 600;
}

main { padding: 16px; display: flex; flex-direction: column; gap: 16px; max-width: 1180px; margin: 0 auto; }
main.loading { opacity: .55; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
}
.card > h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 0 0 2px; font-weight: 600;
}
.card > p.sub { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.card[hidden] { display: none; }

/* --- En-tête direct ------------------------------------------------- */

.live { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-start; }
.live .main-figure { flex: 0 0 auto; }
.live .main-figure .v { font-size: 56px; line-height: 1; font-weight: 600; letter-spacing: -1.5px; }
.live .main-figure .l { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.live .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 20px; flex: 1 1 320px; }
.live .side .v { font-size: 21px; font-weight: 600; white-space: nowrap; }
.live .side .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.live .side .x { font-size: 12px; color: var(--muted); margin-top: 3px; }

.age { font-size: 12.5px; color: var(--muted); margin-top: 12px; }

/* Bandeau « station injoignable » : remplace les valeurs, il ne les
   accompagne pas. Ne jamais présenter une valeur périmée comme actuelle. */
.banner {
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
}
.banner b { display: block; margin-bottom: 3px; }
.banner .why { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 8px; padding: 9px 11px; }
.stat .v { font-size: 19px; font-weight: 600; white-space: nowrap; }
.stat .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.stat .x { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* --- Sélecteur de période ------------------------------------------- */

.periodbar {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; box-shadow: var(--shadow);
}
.periodbar .label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }

/* --- Graphiques ------------------------------------------------------ */

.plot { position: relative; width: 100%; }
.plot svg { display: block; width: 100%; }
.plot text { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.plot .axisline { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.plot .crosshair { stroke: var(--muted); stroke-width: 1; opacity: .6; pointer-events: none; }
.plot .hit { fill: transparent; }
.plot .hit:focus-visible { outline: 2px solid var(--accent-2); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend span::before {
  content: ''; width: 12px; height: 3px; border-radius: 2px;
  background: var(--sw, var(--muted)); flex: none;
}
.legend span.area::before { height: 10px; border-radius: 2px; }

.empty { color: var(--muted); font-size: 12.5px; padding: 22px 0; text-align: center; }

/* --- Gaz -------------------------------------------------------------- */

.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.gauge { background: var(--panel-2); border-radius: 10px; padding: 12px 13px 13px; }
.gauge .name { font-size: 12.5px; font-weight: 600; }
.gauge .sensor { font-size: 11px; color: var(--muted); margin-top: 1px; }
.gauge .row { display: flex; align-items: baseline; gap: 8px; margin-top: 9px; }
.gauge .val { font-size: 27px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge .word { font-size: 12px; color: var(--muted); }
.gauge .track { margin-top: 8px; }
.gauge .scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.gauge .spark { margin-top: 9px; }
.gauge .na { font-size: 12px; color: var(--muted); padding: 12px 0; }

/* La notice fait partie de l'indicateur, pas des mentions légales : elle est
   lisible sans clic et ne doit pas être raccourcie (SPEC §5.5, §9). */
.notice {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 13px 15px;
}
.notice h3 { font-size: 13px; margin: 0 0 7px; }
.notice p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.notice p:last-child { margin-bottom: 0; }
.notice strong { font-weight: 600; }

/* --- Infobulle -------------------------------------------------------- */

.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, .18);
  padding: 8px 10px; font-size: 12px; max-width: 250px;
  opacity: 0; transition: opacity .1s;
}
.tip.on { opacity: 1; }
.tip .t { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.tip .r { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.tip .r + .r { margin-top: 2px; }
.tip .r i { width: 12px; height: 3px; border-radius: 2px; background: var(--sw, var(--muted)); flex: none; align-self: center; }
.tip .r b { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 58px; text-align: right; }
.tip .r span { color: var(--muted); }

/* --- Pied de page ----------------------------------------------------- */

footer {
  max-width: 1180px; margin: 0 auto; padding: 4px 16px;
  font-size: 12px; color: var(--muted); line-height: 1.55;
}
footer p { margin: 0 0 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 620px) {
  main { padding: 12px; gap: 12px; }
  .card { padding: 12px 12px 14px; }
  .live .main-figure .v { font-size: 46px; }
  .live { gap: 16px 20px; }
  header { padding: 10px 12px; }
  h1 { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tip { transition: none; }
}
