/* -----------------------------------------------------------------------------
  Auteur : Simon-Pierre Boucher — contact@spboucher.ai
  Fichier : ka-stats/public/styles.css
  Desc.  : Ka·Stats — styles applicatifs par-dessus le design system ka-ui
           (tokens.css). Accent Ka·Stats = bleu Québec #095797.
----------------------------------------------------------------------------- */

@font-face { font-family: "Space Grotesk"; src: url("/fonts/SpaceGrotesk-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("/fonts/SpaceGrotesk-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("/fonts/SpaceGrotesk-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono-Regular.ttf") format("truetype"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

/* Accent Ka·Stats (bleu Québec) — seule surcharge de marque, comme les satellites */
:root {
  --accent: #095797;
  --accent-soft: #e2edf6;
  --accent-deep: #063a63;
  --on-accent: #ffffff;
}

/* ---------- header ---------- */
#site-header {
  position: sticky; top: 0; z-index: var(--z-header);
  background: var(--paper); border-bottom: 1.5px solid var(--ink);
}
.header-inner { display: flex; align-items: center; gap: var(--sp-4); min-height: 62px; }
.brand { display: inline-flex; align-items: baseline; font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: -0.04em; text-decoration: none; }
.brand-qc { color: var(--ink); }
.brand-dot { color: var(--ink-3); margin: 0 1px; }
.brand-stats { background: var(--accent); color: var(--on-accent); border-radius: 7px; padding: 0 8px 2px; transform: rotate(-2deg); }
.brand:hover .brand-stats { transform: rotate(0); }
.main-nav { display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex: 1; }
.main-nav::-webkit-scrollbar { display: none; }
.nav-link {
  display: inline-flex; align-items: center; min-height: var(--touch); padding: 6px 13px;
  font-family: var(--font-display); font-weight: 700; font-size: 14px; white-space: nowrap;
  text-decoration: none; border-radius: var(--r-ctl); color: var(--ink-2);
}
.nav-link:hover { color: var(--ink); background: var(--surface); }
.nav-link.active { color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }

/* ---------- sélecteur de période (une rangée au-dessus de tout) ---------- */
.period-bar { background: var(--surface); border-bottom: 1.5px solid var(--line); }
.period-inner { display: flex; align-items: center; gap: var(--sp-3); padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.period-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill {
  min-height: 34px; padding: 4px 13px; cursor: pointer;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em;
  border: 1.5px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2);
}
.pill:hover { border-color: var(--ink); color: var(--ink); }
.pill.active { background: var(--ink); border-color: var(--ink); color: var(--accent-soft); }
.pill:disabled { opacity: 0.4; cursor: not-allowed; }
.period-custom { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.date-in { width: 132px; min-height: 34px; padding: 3px 8px; font-size: 12.5px; border-color: var(--line); }

/* ---------- héros ---------- */
.hero { padding: var(--sp-7) 0 var(--sp-6); border-bottom: 1.5px solid var(--ink); background:
  linear-gradient(180deg, var(--accent-soft) 0%, var(--paper) 78%); }
.lead { max-width: 720px; color: var(--ink-2); font-size: 16.5px; }
.hero-figure { margin-top: var(--sp-5); }
.hero-num { font-family: var(--font-display); font-weight: 700; font-size: clamp(52px, 8vw, 108px); line-height: 1; letter-spacing: -0.045em; color: var(--ink); }
.hero-sub { margin-top: 6px; font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--accent); }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--sp-5); }

.page-head { padding: var(--sp-6) 0 var(--sp-4); border-bottom: 1.5px solid var(--ink); background: linear-gradient(180deg, var(--accent-soft) 0%, var(--paper) 85%); }
.site-head { padding: var(--sp-5) 0 var(--sp-4); border-bottom: 1.5px solid var(--ink); background: linear-gradient(180deg, var(--accent-soft) 0%, var(--paper) 85%); }
.site-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); }
.site-h1 { margin-bottom: 4px; }
.site-actions { display: flex; gap: 10px; align-items: center; position: relative; }
.crumb { margin-bottom: var(--sp-3); }
.crumb-link { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; color: var(--ink-2); }
.crumb-link:hover { color: var(--ink); }
.fresh-row { display: flex; flex-wrap: wrap; gap: 8px; margin: var(--sp-4) 0 0; }
.fresh.stale { color: var(--danger); }

/* ---------- sections ---------- */
.block { margin: var(--sp-7) 0; }
.sect-note { max-width: 720px; color: var(--ink-2); margin-top: -4px; }
.sect-note.warn { color: var(--danger); }
.sect-more { margin-top: var(--sp-4); }

/* ---------- cartes de graphique ---------- */
.viz-card { margin: var(--sp-4) 0 var(--sp-5); padding: var(--sp-4) var(--sp-4) var(--sp-3); background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--r-card); box-shadow: var(--shadow-off-soft); }
figure.viz-card { margin-left: 0; margin-right: 0; }
.viz-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.viz-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.viz-plot { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; }
.viz-tick { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.viz-endlbl { font-family: var(--font-mono); font-size: 11px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.viz-bar { cursor: default; }
.viz-cell { cursor: default; }
.viz-arc { cursor: default; }
.viz-donut-total { font-family: var(--font-display); font-weight: 700; font-size: 26px; fill: var(--ink); }
.viz-legend-txt { font-size: 12.5px; fill: var(--ink-2); }
.viz-legend-num { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.viz-empty { padding: var(--sp-6); text-align: center; color: var(--ink-3); background: var(--surface-2); border-radius: var(--r-ctl); font-size: 14px; }
.viz-empty.big { margin: var(--sp-6) 0; padding: var(--sp-7); }

/* légende */
.viz-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 var(--sp-2); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.viz-key-line { width: 20px; height: 3px; border-radius: 2px; }
.viz-key-rect { width: 12px; height: 12px; border-radius: 3px; }

/* infobulle */
.viz-tt {
  display: none; position: absolute; z-index: var(--z-dropdown); pointer-events: none;
  min-width: 130px; max-width: 260px; padding: 8px 11px;
  background: var(--ink); color: var(--paper); border-radius: 8px;
  font-size: 12px; line-height: 1.45; box-shadow: var(--shadow-off-mid);
}
.viz-tt-title { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(245,243,238,0.65); margin-bottom: 4px; }
.viz-tt-row { display: flex; align-items: center; gap: 7px; }
.viz-tt-key { flex: 0 0 14px; height: 3px; border-radius: 2px; }
.viz-tt-val { font-variant-numeric: tabular-nums; }
.viz-tt-lbl { color: rgba(245,243,238,0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* vue tableau jumelle */
.viz-data { margin-top: var(--sp-2); border-top: 1px solid var(--line); }
.viz-data > summary { cursor: pointer; padding: 8px 0 4px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); list-style: none; }
.viz-data > summary::before { content: "⊞ "; }
.viz-data[open] > summary { color: var(--ink); }
.viz-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.viz-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); padding: 6px 10px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.viz-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); }
.viz-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-table tbody tr:nth-child(even) { background: var(--surface-2); }
.viz-data .tbl-wrap { max-height: 320px; overflow: auto; }

/* résumé statistique */
.viz-summary { display: flex; flex-wrap: wrap; gap: 7px; margin-top: var(--sp-2); }
.viz-stat { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); font-size: 12.5px; }
.viz-stat b { font-variant-numeric: tabular-nums; }

/* deltas ▲▼ */
.viz-delta { font-family: var(--font-mono); font-size: 11px; font-weight: 700; white-space: nowrap; }
.viz-delta.up { color: var(--green); }
.viz-delta.down { color: var(--danger); }

/* barres horizontales */
.viz-hbars { display: grid; gap: 12px; }
.viz-hbar-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); margin-bottom: 3px; }
.viz-hbar-label { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-hbar-val { display: inline-flex; gap: 8px; align-items: baseline; }
.viz-hbar-val b { font-variant-numeric: tabular-nums; font-size: 13px; }
.viz-hbar-track { height: 12px; background: var(--surface-2); border-radius: 0 6px 6px 0; }
.viz-hbar-fill { height: 100%; border-radius: 0 6px 6px 0; min-width: 3px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--sp-4); margin: var(--sp-5) 0; }
.kpi { padding: var(--sp-4); box-shadow: var(--shadow-off-mid); }
.kpi-label { display: block; margin-bottom: 6px; }
.kpi-value { font-family: var(--font-display); font-weight: 700; font-size: clamp(24px, 2.4vw, 34px); letter-spacing: -0.03em; line-height: 1.05; }
.kpi-foot { margin-top: 5px; min-height: 16px; }
.kpi-spark { margin-top: 8px; }
.spark { display: block; }

/* jauges */
.gauge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-4); margin: var(--sp-4) 0 var(--sp-5); }
.viz-gauge { padding: var(--sp-4); text-align: center; box-shadow: var(--shadow-off-mid); }
.viz-gauge svg { width: 100%; max-width: 200px; margin: 0 auto; }
.viz-gauge-val { font-family: var(--font-display); font-weight: 700; font-size: 24px; fill: var(--ink); }
.viz-gauge-lbl { margin-top: 4px; }

/* ---------- grille des plateformes ---------- */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-5); margin-top: var(--sp-4); }
.site-card { display: flex; flex-direction: column; }
.site-band { background: var(--accent); color: var(--on-accent); padding: 12px 16px; display: flex; flex-direction: column; gap: 1px; }
.site-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.03em; }
.site-tagline { font-size: 12px; opacity: 0.9; }
.site-body { padding: 14px 16px 6px; flex: 1; }
.site-primary-val { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.03em; line-height: 1.05; margin: 2px 0; }
.site-spark { margin: 8px 0 4px; }
.site-minis { display: grid; gap: 6px; margin-top: 8px; }
.site-mini { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
.site-mini b { font-variant-numeric: tabular-nums; font-size: 13.5px; white-space: nowrap; }
.site-mini .klabel { text-align: right; }
.site-foot { display: flex; gap: 8px; padding: 12px 16px 16px; }
.site-btn { flex: 1; font-size: 13px; padding: 8px 10px; }

/* pastille + chip de site */
.site-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.site-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(20,24,20,0.25); }

/* indicateurs */
.ind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }
.ind-card { padding: var(--sp-4); display: flex; flex-direction: column; gap: 5px; align-items: flex-start; box-shadow: var(--shadow-off-mid); }
.ind-val { font-family: var(--font-display); font-weight: 700; font-size: 27px; letter-spacing: -0.03em; line-height: 1.05; }

/* records */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }
.rec-card { padding: var(--sp-4); display: flex; flex-direction: column; gap: 5px; align-items: flex-start; box-shadow: var(--shadow-off-mid); border-left: 5px solid var(--accent); }
.rec-val { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -0.02em; }
.rec-label { font-size: 13px; color: var(--ink-2); }

/* deux colonnes de graphiques */
.two-col { display: grid; gap: var(--sp-4); }
@media (min-width: 1024px) { .two-col { grid-template-columns: 1fr 1fr; } .two-col .viz-card { margin: 0; } }

/* tableaux interactifs */
.viz-tablecard .viz-head { flex-wrap: wrap; }
.viz-search { max-width: 230px; min-height: 36px; padding: 6px 12px; font-size: 13px; border-color: var(--line); }
.viz-th { background: none; border: 0; padding: 0; font: inherit; font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); cursor: pointer; }
.viz-th:hover { color: var(--ink); }
.viz-pager { display: flex; justify-content: space-between; align-items: center; margin-top: var(--sp-2); }
.viz-pager-nav { display: inline-flex; align-items: center; gap: 4px; }
.viz-pgbtn { min-height: 32px; padding: 2px 12px; font-size: 13px; }
.viz-table-lg { font-size: 13px; }

/* menu PDF */
.pdf-menu { position: relative; }
.pdf-menu > summary { list-style: none; }
.pdf-menu > summary::-webkit-details-marker { display: none; }
.pdf-box { top: calc(100% + 6px); right: 0; }
.pdf-box a { color: var(--ink); font-size: 13.5px; }
.pdf-box a:hover { background: var(--accent-soft); }

/* comparateur */
.cmp-controls { margin: var(--sp-5) 0 var(--sp-4); display: grid; gap: var(--sp-3); }
.cmp-chips, .cmp-mode { display: flex; flex-wrap: wrap; gap: 7px; }
.site-pill.active { font-weight: 700; }

/* chargement : on garde le rendu précédent en opacité réduite (pas de squelette) */
#app.is-loading { opacity: 0.55; pointer-events: none; transition: opacity 0.2s; }
#app { transition: opacity 0.2s; }

/* mobile */
@media (max-width: 767px) {
  .header-inner { flex-wrap: wrap; padding-top: 8px; padding-bottom: 4px; }
  .brand { font-size: 21px; }
  .main-nav { order: 3; flex-basis: 100%; }
  .site-head-row { align-items: flex-start; }
  .hero { padding-top: var(--sp-6); }
  .viz-data .tbl-wrap { max-height: 260px; }
}
