/* =========================================================================
   Veille IA agence359 - feuille de style du site.
   S'appuie sur tokens.css (charte agence 359), qui n'est pas modifié.
   Règle : uniquement des tokens sémantiques (--color-*, --space-*, --radius-*,
   --text-*, --container-*). Aucune couleur écrite en dur.
   ========================================================================= */

/* --- Polices auto-hébergées ---------------------------------------------
   Plus Jakarta Sans, sous-ensemble latin, fichier variable (axe de graisse
   200-800 : couvre 400, 600 et 800 en une seule requête). Aucun appel à
   Google Fonts au chargement : souveraineté et vie privée.
   ----------------------------------------------------------------------- */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/static/fonts/plus-jakarta-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/static/fonts/plus-jakarta-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Thème sombre sans JavaScript ---------------------------------------
   tokens.css ne bascule que sur [data-theme="dark"] : sans JavaScript, il
   faut rejouer le thème pour prefers-color-scheme, sauf si l'internaute a
   forcé le clair. Les valeurs ci-dessous sont la COPIE EXACTE du bloc
   [data-theme="dark"] de tokens.css (qui n'est pas modifié) : sombre
   automatique et sombre forcé rendent strictement la même chose.
   ----------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg:              var(--violet-950);
    --color-surface:         var(--aubergine);
    --color-surface-sunken:  #18102F; /* copie de tokens.css : doit différer de --color-surface */
    --color-surface-inverse: var(--creme);
    --color-surface-accent:  var(--dark-violet);

    --color-border:          rgba(255, 250, 242, 0.12); /* crème translucide */
    --color-border-subtle:   rgba(255, 250, 242, 0.07);
    --color-border-strong:   rgba(255, 250, 242, 0.24);

    --color-text:            var(--creme);
    --color-text-muted:      #C7BEEA; /* copie de tokens.css */
    --color-text-subtle:     #9990C0; /* copie de tokens.css */
    --color-text-inverse:    var(--aubergine);
    --color-text-on-accent:  var(--creme);

    --color-brand:           var(--creme);
    --color-accent:          var(--dark-violet);
    --color-link:            var(--violet-200);
    --color-link-hover:      var(--vert-200);
    --color-focus:           var(--dark-violet);

    --color-action:          var(--dark-violet);
    --color-action-hover:    var(--violet-400);
    --color-action-text:     var(--creme);

    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
  }
}

/* Correctif de contraste, thème sombre : crème sur --dark-violet (#8963FF)
   ne donne que 3.82:1, sous le seuil AA de 4.5:1 pour du texte de 14px
   (jour actif du calendrier, boutons des pages 404 et 503). On assombrit
   le fond d'action : crème sur --violet-700 = 8.11:1, sur --violet-600
   (survol) = 5.88:1. Le token de tokens.css n'est pas touché, seul son
   emploi comme fond de texte est corrigé ici. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-action:       var(--violet-700);
    --color-action-hover: var(--violet-600);
  }
}
[data-theme="dark"] {
  --color-action:       var(--violet-700);
  --color-action-hover: var(--violet-600);
}

:root {
  color-scheme: light dark;

  /* Éclats de catégorie : une teinte par catégorie, toujours doublée d'un
     texte. Alias locaux pour ne pas répandre les tokens bruts dans le code. */
  --eclat-nouveautes: var(--vert-200);
  --eclat-open_weight: var(--bleu-200);
  --eclat-ai_act: var(--rose-200);
  /* Texte posé sur un éclat : toujours l'encre de marque (contraste > 10:1
     dans les deux thèmes, les éclats étant des teintes claires). */
  --eclat-texte: var(--aubergine);

  /* Cible tactile minimale (RGAA) et gabarit du calendrier. */
  --cible: 44px;
  --colonne-largeur: 392px; /* 7 cases de 44px + les marges de la colonne */
}

[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

/* --- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base); /* 16px minimum */
  line-height: var(--leading-relaxed);
  font-weight: var(--weight-regular);
  overflow-wrap: break-word; /* aucun défilement horizontal sur les URL longues */
}

img, svg { max-width: 100%; height: auto; }

h1, h2, h3 {
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
  font-weight: var(--weight-extra);
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}

p { margin: 0 0 var(--space-4); }

a { color: var(--color-link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--color-link-hover); }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Réservé aux lecteurs d'écran. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.lien-evitement {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-16));
  z-index: var(--z-sticky);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--duration-2) var(--ease-standard);
}
.lien-evitement:focus { top: var(--space-4); }

/* --- En-tête ------------------------------------------------------------- */
.entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-5) var(--container-gutter);
}

.entete-marque {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
  min-height: var(--cible);
}

.logo { display: block; height: 32px; width: auto; }
/* Un logo par fond : jamais de recoloration du fichier SVG. */
.logo-sombre { display: none; }
[data-theme="dark"] .logo-clair { display: none; }
[data-theme="dark"] .logo-sombre { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-clair { display: none; }
  :root:not([data-theme="light"]) .logo-sombre { display: block; }
}

.entete-titre {
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  padding-left: var(--space-3);
  border-left: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
}

.entete-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.entete-nav a,
.bascule-theme {
  display: inline-flex;
  align-items: center;
  min-height: var(--cible);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}
.entete-nav a:hover { background: var(--color-surface-sunken); color: var(--color-text); }

.bascule-theme {
  display: none; /* sans JavaScript, la bascule n'a pas de sens : le thème suit le système */
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  font-family: inherit;
  cursor: pointer;
}
[data-js] .bascule-theme { display: inline-flex; }
.bascule-theme:hover { border-color: var(--color-border-strong); color: var(--color-text); }

/* --- Gabarit de page ----------------------------------------------------- */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--colonne-largeur);
  gap: var(--space-10);
  align-items: start;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-6) var(--container-gutter) var(--space-16);
}

.contenu { min-width: 0; }

/* Longueur de ligne tenue entre 60 et 75 caractères. */
.contenu p,
.contenu li { max-width: var(--container-prose); }

/* --- Titres d'édition ---------------------------------------------------- */
.fil {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  /* Casse de phrase : pas de text-transform, la charte proscrit les capitales
     forcées sur les titres et sur-titres. */
  color: var(--color-text-muted);
}

.edition-titre { font-size: var(--text-3xl); margin-bottom: var(--space-3); }

.edition-sous-titre {
  font-size: var(--text-md);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.edition-sujet { color: var(--color-text-muted); }

.edition-permalien { font-size: var(--text-sm); color: var(--color-text-muted); }

.edition-entete { margin-bottom: var(--space-8); }

/* Mention de transparence : présente sur chaque édition. */
.transparence {
  max-width: var(--container-prose);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-10);
  background: var(--color-surface-sunken);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.transparence .modele { font-family: var(--font-mono); color: var(--color-text); }

/* --- Sections par catégorie ---------------------------------------------- */
.section { margin: 0 0 var(--space-12); }

.section-titre {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-xl);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-6);
}

/* L'éclat de catégorie est un repère, jamais l'information : le nom de la
   catégorie est toujours écrit à côté. */
.section-nom { position: relative; padding-left: var(--space-5); }
.section-nom::before {
  content: "";
  position: absolute;
  left: 0; top: 0.18em;
  width: 6px; height: 1em;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  /* Filet fin : les éclats sont des teintes claires, elles ont besoin d'un
     contour pour rester visibles sur le fond crème. */
  box-shadow: 0 0 0 1px var(--color-border-strong);
}
.section-nouveautes .section-nom::before { background: var(--eclat-nouveautes); }
.section-open_weight .section-nom::before { background: var(--eclat-open_weight); }
.section-ai_act .section-nom::before { background: var(--eclat-ai_act); }

.section-compteur {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
}

.section-vide {
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-4) 0;
}

/* --- Article ------------------------------------------------------------- */
.article {
  padding: var(--space-5) 0;
  border-bottom: var(--border-width) solid var(--color-border-subtle);
}
.article:last-child { border-bottom: 0; }

.article-titre {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
}
.article-titre a { color: var(--color-text); text-decoration: underline; }
.article-titre a:hover { color: var(--color-link-hover); }

.article-attributs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: none;
}

.attribut-source { font-weight: var(--weight-semibold); color: var(--color-text); }

.etiquette-angle {
  padding: 2px var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.pertinence { display: inline-flex; align-items: center; gap: var(--space-2); }
.pertinence-jauge { display: inline-flex; gap: 3px; }
.pertinence-jauge .cran {
  width: 8px; height: 8px;
  border-radius: var(--radius-full);
  border: var(--border-width) solid var(--color-border-strong);
}
.pertinence-jauge .cran.est-plein { background: var(--color-accent); border-color: var(--color-accent); }
.pertinence-texte { font-size: var(--text-xs); color: var(--color-text-muted); }

.article-resume { color: var(--color-text); margin-bottom: var(--space-3); }

.article-mots-cles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: 0;
  max-width: none;
}
.mot-cle {
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* --- Navigation entre éditions ------------------------------------------- */
.navigation-editions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: space-between;
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: var(--border-width) solid var(--color-border);
}

.nav-edition {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--cible);
  padding: var(--space-3) var(--space-5);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  background: var(--color-surface);
}
.nav-edition:hover { border-color: var(--color-accent); }
.nav-suivante { margin-left: auto; text-align: right; }
.nav-role { font-size: var(--text-xs); color: var(--color-text-muted); }
.nav-date { font-weight: var(--weight-semibold); color: var(--color-link); }

/* --- Colonne latérale ---------------------------------------------------- */
.colonne {
  position: sticky;
  top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  /* Bornée : sans cela, sur un écran large mais peu haut, le bas de la
     colonne collante devient inatteignable au défilement. */
  max-height: calc(100vh - var(--space-12));
  overflow-y: auto;
  padding: var(--space-5);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
}

.colonne-titre {
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-3);
}

.colonne-vide { color: var(--color-text-muted); font-size: var(--text-sm); }
.colonne-lien { margin: var(--space-4) 0 0; font-size: var(--text-sm); }

/* --- Calendrier ---------------------------------------------------------- */
.cal-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.cal-titre {
  margin: 0;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  text-align: center;
  flex: 1;
}

.cal-fleche {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--cible);
  height: var(--cible);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  text-decoration: none;
  font-size: var(--text-lg);
  line-height: 1;
  color: var(--color-link);
}
.cal-fleche:hover { background: var(--color-surface-sunken); }
.cal-fleche.est-inactive {
  /* Pas d'opacité : elle composite la couleur et fait tomber le contraste
     sous le seuil AA. L'état est déjà porté par aria-disabled et le libellé. */
  color: var(--color-text-muted);
  border-color: var(--color-border-subtle);
  cursor: default;
}

/* padding-block : overflow-x force overflow-y en auto, sans cette marge le
   liseré de focus de la première rangée serait rogné par le conteneur. */
.cal-defilement { overflow-x: auto; padding-block: 3px; }

.cal-grille {
  width: 100%;
  /* 7 cibles de 44px : la grille ne descend jamais sous cette largeur ; sur
     un très petit écran c'est .cal-defilement qui défile, pas la page. */
  min-width: calc(7 * var(--cible));
  border-collapse: collapse;
  table-layout: fixed;
}

.cal-grille th {
  padding-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}
.cal-grille th abbr { text-decoration: none; }

.cal-case { padding: 1px; text-align: center; }

.cal-jour {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--cible);
  min-width: var(--cible);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* Jour sans édition : texte inerte, atténué, non cliquable. */
.cal-jour-inerte { color: var(--color-text-muted); }

/* Jour publié : lien, souligné pour ne pas dépendre de la couleur seule. */
.cal-jour-lien {
  color: var(--color-link);
  font-weight: var(--weight-bold);
  text-decoration: underline;
}
.cal-jour-lien:hover { background: var(--color-surface-sunken); }

/* Jour consulté : fond accentué + aria-current="page" côté gabarit. */
.cal-jour-lien.est-actif {
  background: var(--color-action);
  color: var(--color-action-text);
  text-decoration: none;
}

.dernieres-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.dernieres-liste li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: var(--border-width) solid var(--color-border-subtle);
  font-size: var(--text-sm);
}
.dernieres-liste li:last-child { border-bottom: 0; }
.dernieres-nombre { color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }

/* --- Archives ------------------------------------------------------------ */
.archives-mois { margin-bottom: var(--space-10); }

.archives-mois-titre {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-lg);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-4);
}
/* Casse de phrase : seule l'initiale du mois est capitalisée. */
.archives-mois-titre .section-nom::first-letter { text-transform: uppercase; }
.archives-mois-titre .section-nom { padding-left: 0; }
.archives-mois-titre .section-nom::before { content: none; }

.archives-liste { list-style: none; margin: 0; padding: 0; }

.archives-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--color-border-subtle);
  max-width: none;
}

.archives-lien { font-weight: var(--weight-semibold); min-height: var(--cible); display: inline-flex; align-items: center; }
.archives-total { color: var(--color-text-muted); font-size: var(--text-sm); }

.archives-repartition { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }

/* Chaque pastille porte son chiffre ET le nom de la catégorie en toutes
   lettres : la couleur n'est qu'un rappel. */
.puce {
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--eclat-texte);
  white-space: nowrap;
}
.puce-nouveautes { background: var(--eclat-nouveautes); }
.puce-open_weight { background: var(--eclat-open_weight); }
.puce-ai_act { background: var(--eclat-ai_act); }

/* --- Messages 404 / 503 -------------------------------------------------- */
.message { padding: var(--space-8) 0; }
.message-texte { color: var(--color-text-muted); font-size: var(--text-md); }
.message-liens { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.bouton {
  display: inline-flex;
  align-items: center;
  min-height: var(--cible);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-pill);
  background: var(--color-action);
  color: var(--color-action-text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}
.bouton:hover { background: var(--color-action-hover); color: var(--color-action-text); }

.bouton-secondaire {
  background: transparent;
  color: var(--color-link);
  border: var(--border-width) solid var(--color-border-strong);
}
.bouton-secondaire:hover { background: var(--color-surface-sunken); color: var(--color-text); }

/* --- Pied de page -------------------------------------------------------- */
.pied {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-8) var(--container-gutter) var(--space-12);
  border-top: var(--border-width) solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
/* Flux normal (pas de flex) : les phrases du pied doivent pouvoir se couper
   au fil du texte sans qu'un tiret se retrouve seul en début de ligne. */
.pied-ligne { margin: 0 0 var(--space-2); max-width: var(--container-prose); }
.pied-ligne a { margin-inline: 2px; }
.pied-note { color: var(--color-text-muted); font-size: var(--text-xs); }

/* --- Petits écrans -------------------------------------------------------
   Sous 900px : une seule colonne, le calendrier passe SOUS le contenu
   (il est déjà après <main> dans le flux du document).
   ----------------------------------------------------------------------- */
@media (max-width: 900px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-8);
  }
  .colonne { position: static; max-height: none; overflow-y: visible; }
  .entete { padding-block: var(--space-4); }
  .edition-titre { font-size: var(--text-2xl); }
  .archives-repartition { margin-left: 0; }
}

@media (max-width: 480px) {
  /* Colonne moins rembourrée : les 7 cases de 44px du calendrier tiennent
     alors sans défilement interne sur les largeurs de téléphone courantes. */
  .colonne { padding: var(--space-3); }
  .entete-titre { border-left: 0; padding-left: 0; }
  .navigation-editions { flex-direction: column; }
  .nav-suivante { margin-left: 0; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
