/* Parc solaire de l'UdeS : page publique. Couleurs reprises du Centre de Contrôle Grafana (verts UdeS pour l'énergie,
   orange pour la puissance, or pour le soleil). Thème clair par défaut, thème sombre selon le système. */
:root {
  --ground: #f4f7f3;
  --surface: #ffffff;
  --surface-2: #eaf1ea;
  --ink: #12261b;
  --muted: #56685c;
  --line: #d5e0d6;
  --energy: #00a759;
  --energy-deep: #007a4d;
  --energy-soft: #cdebd9;
  --power: #d9661f;
  --power-soft: rgba(242, 140, 40, 0.18);
  --sun: #d98e00;
  --alert: #b3261e;
  --head-ground: #0f2a1c;
  --head-ink: #f2f7f3;
  --head-muted: #a9c3b2;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-figure: "Bahnschrift", "DIN Alternate", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0b1510;
    --surface: #122019;
    --surface-2: #182a20;
    --ink: #e7f0ea;
    --muted: #9db3a5;
    --line: #23382c;
    --energy: #2fc47a;
    --energy-deep: #78be20;
    --energy-soft: #1d3a2a;
    --power: #f28c28;
    --power-soft: rgba(242, 140, 40, 0.22);
    --sun: #f2a900;
    --alert: #ff8a80;
    --head-ground: #07110b;
    --head-ink: #e7f0ea;
    --head-muted: #8fae9a;
  }
}

:root[data-theme="dark"] {
  --ground: #0b1510;
  --surface: #122019;
  --surface-2: #182a20;
  --ink: #e7f0ea;
  --muted: #9db3a5;
  --line: #23382c;
  --energy: #2fc47a;
  --energy-deep: #78be20;
  --energy-soft: #1d3a2a;
  --power: #f28c28;
  --power-soft: rgba(242, 140, 40, 0.22);
  --sun: #f2a900;
  --alert: #ff8a80;
  --head-ground: #07110b;
  --head-ink: #e7f0ea;
  --head-muted: #8fae9a;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-inline: 16px;
}

@media (min-width: 720px) { .wrap { padding-inline: 28px; } }

h1, h2, h3 { margin: 0; text-wrap: balance; }

.num { font-family: var(--font-figure); font-variant-numeric: tabular-nums; }

.unit { margin-left: 0.3em; color: var(--muted); font-size: 0.45em; font-weight: 600; letter-spacing: 0.02em; }

.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* En-tête */
.masthead { background: var(--head-ground); color: var(--head-ink); }

.masthead__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding-block: 18px;
}

/* Logos UdeS et 3IT sur fond blanc (le « ! » du logo 3IT est noir et disparaîtrait sur l'en-tête foncé) */
.logos { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: #fff; border-radius: 6px; }

.logos img { display: block; height: 40px; width: auto; }

.logos__sep { width: 1px; height: 30px; background: #d5e0d6; }

.masthead__text { flex: 1 1 280px; }

.eyebrow { margin: 0; color: var(--head-muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }

.masthead h1 { font-size: clamp(1.25rem, 2.6vw, 1.75rem); font-weight: 600; line-height: 1.2; }

.status { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--head-muted); font-size: 0.85rem; }

.status__dot { width: 9px; height: 9px; border-radius: 50%; background: #78be20; box-shadow: 0 0 0 3px rgba(120, 190, 32, 0.25); }

.status[data-state="stale"] .status__dot { background: #f2a900; box-shadow: 0 0 0 3px rgba(242, 169, 0, 0.25); }

.status[data-state="error"] .status__dot { background: #ff6b5e; box-shadow: 0 0 0 3px rgba(255, 107, 94, 0.25); }

@media (prefers-reduced-motion: no-preference) {
  .status[data-state="live"] .status__dot { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(120, 190, 32, 0.08); } }
}

main { display: grid; gap: 20px; padding-block: 24px 8px; }

/* Puissance en ce moment */
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (min-width: 860px) { .hero { grid-template-columns: minmax(260px, 1fr) 2fr; align-items: center; } }

.hero__value { margin: 6px 0 4px; color: var(--power); font-size: clamp(3.2rem, 9vw, 5.4rem); font-weight: 700; line-height: 1; }

.hero__value .unit { font-size: 0.32em; }

.hero__sub { margin: 0; color: var(--muted); }

.hero__chart { margin: 0; display: grid; gap: 8px; min-width: 0; }

/* Énergie */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.kpi { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.kpi__value { margin: 6px 0 0; color: var(--energy-deep); font-size: clamp(1.8rem, 4.4vw, 2.6rem); font-weight: 700; line-height: 1.05; }

.kpi__value .unit { font-size: 0.42em; }

.kpi--accent { background: var(--energy-soft); border-color: transparent; }

.kpi__note { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }

/* Panneaux */
.panel { padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }

.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }

.panel h2 { font-size: 1.1rem; font-weight: 600; }

.panel__note { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }

.split { display: grid; grid-template-columns: 1fr; gap: 20px; }

@media (min-width: 860px) { .split { grid-template-columns: 3fr 2fr; } }

/* Onglets */
.tabs { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 8px; gap: 2px; }

.tabs button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.tabs button:focus-visible { outline: 2px solid var(--energy); outline-offset: 2px; }

/* Graphiques (SVG dessinés par app.js) */
.chart { width: 100%; }

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.chart text { fill: var(--muted); font-family: var(--font); font-size: 11px; font-variant-numeric: tabular-nums; }

.chart .grid { stroke: var(--line); stroke-width: 1; }

.chart .area { fill: var(--power-soft); }

.chart .line { fill: none; stroke: var(--power); stroke-width: 2; stroke-linejoin: round; }

.chart .bar { fill: var(--energy); }

.chart .bar--current { fill: var(--energy-deep); }

.chart .dot { fill: var(--power); stroke: var(--surface); stroke-width: 2; }

.chart__empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); font-size: 0.95rem; }

/* Sites */
.sites { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.site { display: grid; grid-template-columns: minmax(150px, 1.4fr) 3fr auto; align-items: center; gap: 10px; }

@media (max-width: 520px) {
  .kpi--accent { grid-column: 1 / -1; }
  .panel { padding: 16px; }
  .site { grid-template-columns: 1fr auto; } .site__track { grid-column: 1 / -1; grid-row: 2; }
}

.site__name { font-weight: 600; }

.site__name small { display: block; color: var(--muted); font-weight: 400; font-size: 0.82rem; }

.site__track { display: block; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }

.site__bar { display: block; height: 100%; background: var(--energy); border-radius: 6px; }

.site__value { font-family: var(--font-figure); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* Météo */
.weather { display: grid; gap: 14px; margin: 0; }

.weather > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.weather > div:last-child { border-bottom: 0; padding-bottom: 0; }

.weather dt { color: var(--muted); }

.weather dd { margin: 0; color: var(--ink); font-size: 1.7rem; font-weight: 700; line-height: 1; }

.weather dd .unit { font-size: 0.5em; }

#irradiance { color: var(--sun); }

/* Pied de page */
.footer { padding-block: 16px 32px; color: var(--muted); font-size: 0.85rem; }

.footer p { margin: 4px 0; max-width: 90ch; }
