/* Evolve — tableau de bord. Bâti sur les tokens de l'app (css/tokens.css). Thème clair uniquement. */
@font-face { font-family: Archivo; font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; src: url(/fonts/archivo.woff2) format('woff2'); }

:root {
  /* Les séries des graphiques : une couleur par chose mesurée, toujours la même d'un graphique à l'autre. */
  --c-visites: #257de0;  --c-actifs: #f47230;  --c-nouveaux: #00b894;
  --c-clics: #f2a600;    --c-vues: #ee7fac;    --c-seances: #6a4ce2;
  /* Les grandeurs (barres, cartes de chaleur) : un seul bleu, du clair au foncé. */
  --barre: var(--blue);  --barre-fond: var(--surface-2);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 132px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--w-regular) var(--t-md)/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue-text); outline-offset: 2px; }
.note { color: var(--ink-2); font-size: var(--t-sm); }

/* ----- la porte : saisie de la clé ----- */
.porte { min-height: 100vh; display: grid; place-items: center; padding: var(--s-4); background: linear-gradient(var(--sky-1), var(--bg) 70%); }
.porte .carte { width: min(420px, 100%); display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-6) var(--s-5); }
.marque { font-weight: var(--w-bold); font-stretch: 125%; letter-spacing: .02em; text-transform: uppercase; font-size: var(--t-sm); color: var(--blue-text); }
.porte h1 { font-size: var(--t-xl); line-height: 1.15; }
.porte label { font-size: var(--t-sm); font-weight: var(--w-medium); margin-top: var(--s-2); }
.porte input { min-height: 48px; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font: inherit; }
.btn { min-height: 48px; padding: 0 var(--s-5); border: 0; border-radius: var(--r-full); background: var(--ink); color: #fff; font-weight: var(--w-medium); }
#etat { min-height: 1.5em; }

/* ----- la barre du haut ----- */
.barre { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--sky-1), var(--sky-2)); border-bottom: 1px solid var(--line); }
.barre-in { max-width: 1240px; margin: 0 auto; padding: var(--s-3) var(--s-4) var(--s-2); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); }
.titre { font-size: var(--t-lg); margin-right: auto; }
.titre b { font-stretch: 125%; text-transform: uppercase; letter-spacing: .02em; }
.titre span { color: var(--ink-2); font-size: var(--t-md); margin-left: var(--s-2); }
.periodes { display: flex; padding: 3px; gap: 2px; background: var(--glass); border-radius: var(--r-full); }
.periodes button { min-height: 38px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-full); background: none; font-size: var(--t-sm); font-weight: var(--w-medium); white-space: nowrap; }
.periodes button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.actions { display: flex; gap: var(--s-1); }
.lien { min-height: 38px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-full); background: var(--glass); font-size: var(--t-sm); font-weight: var(--w-medium); }
.onglets { max-width: 1240px; margin: 0 auto; padding: 0 var(--s-4) var(--s-2); display: flex; gap: var(--s-1); overflow-x: auto; scrollbar-width: none; }
.onglets a { flex: none; padding: var(--s-2) var(--s-3); border-radius: var(--r-full); color: var(--ink); text-decoration: none; font-size: var(--t-sm); font-weight: var(--w-medium); }
.onglets a:hover { background: var(--glass); }

/* ----- la page ----- */
main { max-width: 1240px; margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-7); display: flex; flex-direction: column; gap: var(--s-4); }
main.charge { opacity: .5; transition: opacity var(--d-base); }
.partie { display: flex; flex-direction: column; gap: var(--s-4); padding-top: var(--s-5); }
.partie:first-child { padding-top: 0; }
.partie > header h2 { font-size: var(--t-xl); line-height: 1.15; }
.partie > header p { color: var(--ink-2); font-size: var(--t-sm); margin-top: var(--s-1); max-width: 70ch; }
.grille { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4); }
.carte { background: var(--surface); border-radius: var(--r-md); padding: var(--s-5); min-width: 0; }
.grille > .carte { grid-column: span 6; display: flex; flex-direction: column; gap: var(--s-3); }
.grille > .large { grid-column: 1 / -1; }
.grille > .tiers { grid-column: span 4; }
.carte h3 { font-size: var(--t-md); font-weight: var(--w-medium); }
.carte h3 + .note { margin-top: calc(-1 * var(--s-2)); }
.vide { color: var(--ink-2); font-size: var(--t-sm); padding: var(--s-4) 0; }

/* ----- les tuiles : un chiffre, son évolution, sa courbe ----- */
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-3); }
.tuile { background: var(--surface); border-radius: var(--r-md); padding: var(--s-4); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tuile p { color: var(--ink-2); font-size: var(--t-sm); }
.tuile b { font-size: var(--t-xl); line-height: 1.15; font-variant-numeric: tabular-nums; }
.tuile small { font-size: var(--t-xs); color: var(--ink-2); min-height: 1.4em; }
.tuile .hausse { color: var(--success); font-weight: var(--w-medium); }
.tuile .baisse { color: var(--danger); font-weight: var(--w-medium); }
.tuile svg { width: 100%; height: 30px; margin-top: var(--s-1); overflow: visible; }

/* ----- les courbes ----- */
.legende { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--t-sm); color: var(--ink-2); }
.legende span { display: inline-flex; align-items: center; gap: var(--s-2); }
.legende i, .bulle i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.courbes { position: relative; }
.courbes svg { display: block; width: 100%; touch-action: pan-y; }
.courbes text { font: var(--t-xs) var(--font); fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.courbes .grille-l { stroke: var(--line); stroke-width: 1; }
.courbes .trait { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.courbes .repere { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.courbes .point { stroke: var(--surface); stroke-width: 2; }
.courbes .survol[hidden] { display: none; }   /* un groupe SVG ne suit pas tout seul l'attribut hidden */
details.chiffres { font-size: var(--t-sm); }
details.chiffres summary { cursor: pointer; color: var(--blue-text); font-weight: var(--w-medium); width: max-content; padding: var(--s-1) 0; }
.defile { overflow: auto; max-height: 320px; margin-top: var(--s-2); }
table { border-collapse: collapse; width: 100%; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--ink-2); font-weight: var(--w-medium); padding: var(--s-2) var(--s-3) var(--s-2) 0; white-space: nowrap; }
td { padding: var(--s-2) var(--s-3) var(--s-2) 0; border-top: 1px solid var(--line); white-space: nowrap; }
th.n, td.n { text-align: right; padding-right: 0; padding-left: var(--s-3); }

/* ----- les listes à barres ----- */
.barres { display: flex; flex-direction: column; gap: var(--s-2); }
.ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s-3); align-items: baseline; font-size: var(--t-sm); }
.ligne > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne > b { font-weight: var(--w-medium); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ligne > b small { color: var(--ink-2); font-weight: var(--w-regular); font-size: var(--t-xs); margin-left: var(--s-2); }
.ligne > .piste { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--barre-fond); overflow: hidden; }
.ligne > .piste i { display: block; height: 100%; min-width: 2px; border-radius: 4px; background: var(--barre); }

/* ----- les entonnoirs ----- */
.entonnoir { display: flex; flex-direction: column; gap: var(--s-3); }
.etape { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-3); align-items: baseline; }
.etape > span { font-size: var(--t-sm); }
.etape > b { font-variant-numeric: tabular-nums; }
.etape > b small { color: var(--ink-2); font-weight: var(--w-regular); font-size: var(--t-xs); margin-left: var(--s-2); }
.etape > .piste { grid-column: 1 / -1; height: 22px; border-radius: 6px; background: var(--barre-fond); overflow: hidden; }
.etape > .piste i { display: block; height: 100%; min-width: 3px; border-radius: 6px; background: var(--barre); }

/* ----- les colonnes (durées, séries, semaines) ----- */
.colonnes { display: flex; align-items: flex-end; gap: 2px; height: 150px; }
.colonnes > div { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: var(--s-1); height: 100%; }
.colonnes i { display: block; width: 100%; max-width: 44px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--barre); }
.colonnes b { font-size: var(--t-xs); font-weight: var(--w-medium); font-variant-numeric: tabular-nums; }
.axe { display: flex; gap: 2px; font-size: var(--t-xs); color: var(--ink-2); text-align: center; border-top: 1px solid var(--line); padding-top: var(--s-1); }
.axe span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }

/* ----- les cartes de chaleur : jour × heure, et fidélité ----- */
.chaleur { display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 2px; font-size: var(--t-xs); color: var(--ink-2); align-items: center; }
.chaleur > i { aspect-ratio: 1; border-radius: 3px; min-height: 9px; }
.chaleur > span { padding-right: var(--s-2); }
.chaleur > em { font-style: normal; text-align: center; }
.rampe { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-xs); color: var(--ink-2); }
.rampe i { width: 96px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #eaf3fc, #8ec3f2, #257de0, #0f3d75); }
.bascule { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: var(--r-full); width: max-content; max-width: 100%; }
.bascule button { min-height: 34px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-full); background: none; font-size: var(--t-sm); font-weight: var(--w-medium); }
.bascule button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 2px rgba(50, 100, 160, .2); }
.fidelite { border-collapse: separate; border-spacing: 2px; }
.fidelite th, .fidelite td { border: 0; padding: var(--s-2); text-align: center; font-size: var(--t-xs); }
.fidelite th:first-child, .fidelite td:first-child { text-align: left; padding-left: 0; white-space: nowrap; }
.fidelite td.c { border-radius: 4px; min-width: 46px; font-weight: var(--w-medium); }
.fidelite td.partiel { outline: 1px dashed var(--ink-2); outline-offset: -1px; }

/* ----- la bulle au survol ----- */
.bulle { position: fixed; z-index: 20; pointer-events: none; max-width: 280px; padding: var(--s-2) var(--s-3); border-radius: 10px; background: var(--ink); color: #fff; font-size: var(--t-xs); line-height: 1.5; box-shadow: var(--shadow); }
.bulle b { font-variant-numeric: tabular-nums; }
.bulle p { display: flex; align-items: center; gap: var(--s-2); }
.bulle p b { margin-left: auto; padding-left: var(--s-3); }
.pied { max-width: 1240px; margin: 0 auto; padding: 0 var(--s-4) var(--s-7); color: var(--ink-2); font-size: var(--t-xs); }

@media (max-width: 900px) {
  .grille > .carte, .grille > .tiers { grid-column: 1 / -1; }
  .carte { padding: var(--s-4); }
  .titre span { display: none; }
  /* Sur petit écran, la barre ne suit pas le défilement : elle prendrait un quart de l'écran. */
  .barre { position: static; }
  html { scroll-padding-top: 12px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } main.charge { transition: none; } }
