/* Feuille principale. Importée après tokens.css : aucune couleur en dur ici. */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
}

code, .mono { font-family: var(--font-mono); }
/* Le rouge de marque signale l'identité et le danger — jamais « cliquable ».
 *
 * Il servait aux trois à la fois, et la conséquence se voyait sur un avis Microsoft :
 * treize noms de produits en rouge dans une colonne, au-dessus desquels le badge
 * CRITIQUE et le badge KEV — rouges eux aussi — ne ressortaient plus. Le seul signal de
 * la page qui devait attraper l'œil se noyait dans une liste de liens.
 *
 * `tokens.css` posait déjà la règle en toutes lettres : « rouge de marque — interactif et
 * identitaire, jamais une sévérité ». Elle était vraie dans le fichier et fausse à
 * l'écran, les deux rouges étant trop proches pour se distinguer.
 *
 * Un lien se reconnaît donc à son soulignement, et prend la couleur d'accent au survol.
 * C'est aussi ce qu'exige le WCAG 1.4.1 : la couleur seule ne doit pas porter
 * l'information — ce que faisait la version précédente dans le corps du texte. */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--text-faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Ne jamais supprimer l'anneau de focus : le public visé navigue au clavier (§7). */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Lien d'évitement : visible dès qu'il prend le focus, invisible sinon. */
.skip { text-decoration: none;
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--bg-elevated); color: var(--accent);
  border: 1px solid var(--accent-border); border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
}
.skip:focus { left: var(--space-4); top: var(--space-2); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- En-tete ---------- */

.site-header { background: var(--bg-elevated); border-bottom: 1px solid var(--border); }
.head {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 26px 0 20px; gap: var(--space-4); flex-wrap: wrap;
}
.brand-title { margin: 0; font-size: var(--text-3xl); line-height: 1.15; letter-spacing: -.02em; }
.brand-title a { color: var(--text); text-decoration: none; }
.brand-title a:hover { color: var(--text); text-decoration: none; }
.brand-title .dot { color: var(--accent); }
.brand-tagline { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: .95rem; }

/* Bascule de theme : un formulaire, donc operante sans JavaScript (§7). */
.theme-toggle {
  display: flex; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.theme-toggle button {
  background: var(--bg-elevated); border: 0; color: var(--text-muted);
  font: inherit; font-size: .8rem; padding: var(--space-2) var(--space-3);
  min-height: 44px; cursor: pointer;
}
.theme-toggle button:hover { color: var(--accent); background: var(--accent-subtle); }
.theme-toggle button[aria-pressed="true"] {
  background: var(--accent-subtle); color: var(--accent); font-weight: 600;
}

/* ---------- Navigation ---------- */

.site-nav { background: var(--bg-elevated); border-bottom: 1px solid var(--border); position: relative; }
.menu { display: flex; list-style: none; margin: 0; padding: 0; }
.menu > li { position: relative; }

.menu > li > a,
.menu > li > .menu-trigger {
  display: block; padding: 13px 18px; color: var(--text);
  font: inherit; font-size: .93rem; font-weight: 500;
  background: none; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer; min-height: 44px; text-align: left;
}
.menu > li > a[aria-current] { border-bottom-color: var(--accent); color: var(--accent); }
.menu > li:hover > a,
.menu > li:hover > .menu-trigger,
.menu > li:focus-within > .menu-trigger {
  color: var(--accent); background: var(--accent-subtle);
  border-bottom-color: var(--accent); text-decoration: none;
}

.sub, .sub2 {
  display: none; position: absolute; list-style: none; margin: 0; padding: 5px 0;
  background: var(--bg-elevated); border: 1px solid var(--border);
  box-shadow: var(--shadow-menu); z-index: 20;
}
.sub { top: 100%; left: 0; min-width: 230px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.sub2 { top: -6px; left: 100%; min-width: 150px; border-radius: var(--radius-lg); }

/* Survol **et** focus : le focus rend le menu utilisable au clavier et au tap sans
   JavaScript, le script n'ajoutant ensuite que la fermeture par Echap et le second tap. */
.menu > li:hover > .sub,
.menu > li:focus-within > .sub,
.sub li:hover > .sub2,
.sub li:focus-within > .sub2 { display: block; }

.sub a {
  display: flex; justify-content: space-between; gap: var(--space-4);
  padding: 9px 14px; color: var(--text); font-size: .88rem; min-height: 44px;
  text-decoration: none;
  align-items: center;
}
.sub li:hover > a, .sub a:focus-visible {
  background: var(--accent-subtle); color: var(--accent); text-decoration: none;
}
.sub .count { color: var(--text-faint); font-family: var(--font-mono); font-size: .78rem; }
.chev { color: var(--text-faint); }

.menu-trigger[aria-expanded="true"] { color: var(--accent); background: var(--accent-subtle); }
.nav-toggle { display: none; }

/* ---------- Bandeaux et cartes ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin: 22px 0; }
.stat {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-4);
}
.stat .n { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.stat .l {
  color: var(--text-muted); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .06em; margin-top: 3px;
}
.stat.alerte .n { color: var(--accent); }

.searchbar { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: 22px; }
.searchbar input, .searchbar select {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: .88rem; padding: var(--space-2) 11px; min-height: 44px;
}
.searchbar input { flex: 1; min-width: 220px; }
.btn {
  background: var(--accent); color: #FFF; border: 0; border-radius: var(--radius);
  font: inherit; font-size: .88rem; font-weight: 500; padding: var(--space-2) var(--space-4);
  min-height: 44px; cursor: pointer;
}
.btn:hover { background: var(--accent-hover); }

.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap;
}
.sec-head h2 { margin: 0; font-size: var(--text-xl); letter-spacing: -.01em; }
h2.sec { font-size: var(--text-xl); margin: 0 0 var(--space-4); letter-spacing: -.01em; }
.page-title { font-size: var(--text-2xl); margin: var(--space-6) 0 var(--space-2); letter-spacing: -.015em; }
.page-intro { color: var(--text-muted); max-width: var(--measure); margin-top: 0; }

.crumbs { font-size: var(--text-sm); color: var(--text-muted); margin: var(--space-4) 0 0; }
.crumbs a { color: var(--text-muted); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li::after { content: "\203A"; margin-left: 6px; color: var(--text-faint); }
.crumbs li:last-child::after { content: ""; }

/* ---------- Tableau d'alertes ---------- */

.table-wrap { overflow-x: auto; }
table.alerts,
table.affected {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; font-size: var(--text-sm);
}
table.alerts thead th,
table.affected thead th {
  background: var(--bg-subtle); text-align: left; padding: 9px 12px;
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600;
  position: sticky; top: 0; z-index: 1;
}
table.alerts tbody td,
table.affected tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.alerts tbody tr:last-child td,
table.affected tbody tr:last-child td { border-bottom: 0; }
table.alerts tbody tr:nth-child(even),
table.affected tbody tr:nth-child(even) { background: var(--bg-subtle); }
table.alerts tbody tr:hover { background: var(--accent-subtle); }
td.cve { font-family: var(--font-mono); font-size: .82rem; white-space: nowrap; }
td.date { font-family: var(--font-mono); font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.prod { color: var(--text-muted); font-size: .8rem; }

table.alerts a,
table.affected .vendor a { text-decoration: none; }
table.alerts a:hover,
table.affected .vendor a:hover { text-decoration: underline; }

/* ---------- Badges ---------- */

.sev {
  display: inline-block; font-family: var(--font-mono); font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; padding: 2px 7px; border-radius: var(--radius-sm); white-space: nowrap;
}
.sev-crit { background: var(--sev-crit-bg); color: var(--sev-crit-fg); }
.sev-high { background: var(--sev-high-bg); color: var(--sev-high-fg); }
.sev-med { background: var(--sev-med-bg); color: var(--sev-med-fg); }
.sev-low { background: var(--sev-low-bg); color: var(--sev-low-fg); }
.sev-none { background: var(--sev-none-bg); color: var(--sev-none-fg); }

/* Seul element entierement arrondi du site : sa singularite de forme signale
   l'information la plus urgente. */
.kev {
  display: inline-block; border: 1px solid var(--kev); color: var(--kev);
  background: var(--accent-subtle); border-radius: 999px;
  font-size: .7rem; font-weight: 600; padding: 1px 9px; white-space: nowrap; margin-left: 5px;
}
.fix { color: var(--fixed); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.nofix { color: var(--text-faint); font-size: .75rem; white-space: nowrap; }

/* ---------- Page d'alerte ---------- */

.article {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px; margin-bottom: 26px;
}
.article h1 { margin: 0 0 var(--space-1); font-size: 1.5rem; letter-spacing: -.015em; }
.article .meta {
  color: var(--text-muted); font-size: .82rem;
  font-family: var(--font-mono); margin-bottom: var(--space-4);
}
.badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: var(--space-4); }
.article h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin: 22px 0 7px;
}
.article p { margin: 0 0 10px; max-width: var(--measure); font-size: .94rem; }

.generated-note {
  border-left: 3px solid var(--generated); background: var(--bg-subtle);
  padding: 11px 15px; border-radius: 0 var(--radius) var(--radius) 0; margin: 10px 0;
}
.generated-note .tag {
  color: var(--generated); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.generated-note p { margin: 5px 0 0; font-size: .86rem; color: var(--text-muted); }

/* Sections restituées à partir des données vérifiées. Aucun encart ne les précède :
   elles ne sont pas d'une autre nature que le reste de la page, contrairement au
   contenu rédigé qui, lui, porte sa mention. */

.article .lead { font-weight: 600; color: var(--text); margin-bottom: 8px; }

.weakness { margin: 0 0 12px; }
.weakness h3 {
  margin: 0 0 3px; font-size: .92rem; font-weight: 600; line-height: 1.35;
}
.weakness h3 a { font-family: var(--font-mono); font-size: .84rem; }
.weakness p { margin: 0; color: var(--text-muted); }

.conditions { margin: 0 0 12px; padding-left: 1.15em; max-width: var(--measure); }
.conditions li { font-size: .94rem; margin-bottom: 3px; }

.fixes { list-style: none; margin: 0 0 12px; padding: 0; max-width: var(--measure); }
.fixes li {
  display: flex; justify-content: space-between; gap: var(--space-4);
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.fixes li:last-child { border-bottom: 0; }
.fix-version { font-family: var(--font-mono); color: var(--fixed); font-weight: 600; }

.cmd { margin: 0 0 var(--space-4); }
.cmd figcaption {
  font-size: .8rem; color: var(--text-muted); margin-bottom: 4px;
}
.cmd pre { margin: 0; }
/* Une commande ne se coupe pas au milieu d'un argument : elle défile. */
.cmd pre code { white-space: pre; }

.caveat {
  font-size: .84rem !important; color: var(--text-faint);
  border-left: 2px solid var(--border); padding-left: 11px; margin-top: 12px;
}

pre {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 14px; overflow-x: auto; font-family: var(--font-mono);
  font-size: .82rem; margin: var(--space-2) 0;
}

.sources { border-top: 1px solid var(--border); margin-top: 22px; padding-top: var(--space-4); }
.sources ul { margin: 0; padding-left: 1.1em; }
.sources li { font-size: .86rem; margin-bottom: 5px; }
.attribution { color: var(--text-faint); font-size: var(--text-xs); }

/* Bloc « produits et versions affectes ». Le cas dur du corpus (3 396 lignes pour une
   seule CVE) impose de regrouper par produit et de replier : un gabarit qui deroulerait
   tout produirait une page inutilisable et penalisante pour l'indexation. */
table.affected { margin-bottom: var(--space-4); }
table.affected .vendor { font-weight: 600; }
/* Les numéros de version se comparent chiffre à chiffre : chasse fixe obligatoire. */
table.affected .ranges,
table.affected .fixed-in { font-family: var(--font-mono); font-size: .82rem; }
table.affected .ranges { color: var(--text-muted); }
table.affected .ranges ul { margin: 0; padding: 0; list-style: none; }
table.affected .ranges li { padding: 1px 0; }
table.affected .ranges .count { margin: 0 0 4px; font-family: var(--font-sans); }
table.affected .ranges .attribution { margin: 5px 0 0; font-family: var(--font-sans); }
table.affected .fixed-in { color: var(--fixed); font-weight: 600; white-space: nowrap; }
table.affected .nofix { font-family: var(--font-sans); white-space: normal; }

details.more > summary {
  cursor: pointer; color: var(--accent); font-size: .82rem; font-weight: 500;
  margin-top: 6px; min-height: 24px;
}
details.more > summary:hover { color: var(--accent-hover); text-decoration: underline; }
details.more[open] > summary { margin-bottom: 6px; }

.cve-siblings {
  margin: 0; padding-left: 1.1em; font-family: var(--font-mono);
  font-size: .82rem; columns: 3;
}
.cve-siblings li { break-inside: avoid; }

.revisions { margin: 0; padding-left: 1.1em; font-size: .86rem; color: var(--text-muted); }

/* ---------- Etat des sources ---------- */

.source-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3); margin-bottom: 26px;
}
.source-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-4);
}
.source-card h3 { margin: 0 0 var(--space-1); font-size: 1rem; }
.source-card dl { margin: 0; font-size: var(--text-sm); }
.source-card dt {
  color: var(--text-muted); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .06em;
}
.source-card dd { margin: 0 0 6px; font-family: var(--font-mono); }
.badge-ok { color: var(--fixed); font-weight: 600; font-size: .8rem; }
.badge-stale { color: var(--stale); font-weight: 600; font-size: .8rem; }

/* ---------- Contenu editorial ---------- */

.prose { max-width: var(--measure); }
.prose h2 { font-size: var(--text-xl); margin: var(--space-8) 0 var(--space-2); }
.prose h3 { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-2); }
.prose li { margin-bottom: var(--space-1); }

.note {
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  border-radius: var(--radius); padding: 11px 15px; font-size: .85rem; margin: 18px 0;
}

.pager { display: flex; gap: var(--space-3); align-items: center; margin: var(--space-6) 0; flex-wrap: wrap; }
.pager a, .pager span {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-2) var(--space-3); font-size: var(--text-sm); background: var(--bg-elevated);
}
.pager span { color: var(--text-faint); }

.empty {
  color: var(--text-muted); background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-6); text-align: center;
}

.site-footer {
  border-top: 1px solid var(--border); margin-top: 36px; padding: 22px 0 40px;
  color: var(--text-faint); font-size: .82rem;
}
.site-footer a { color: var(--text-muted); }
.site-footer ul {
  list-style: none; display: flex; flex-wrap: wrap;
  gap: var(--space-4); margin: 0 0 var(--space-2); padding: 0;
}
/* Les liens de pied de page sont les plus petits du site : sans hauteur minimale ils
   tombent sous la cible tactile de 44 px de la charte (§7). */
.site-footer ul a {
  display: inline-flex; align-items: center; min-height: 44px;
}

/* ---------- Adaptation mobile ---------- */

@media (max-width: 768px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand-title { font-size: 1.8rem; }

  /* Bascule en accordeon plein ecran : un menu horizontal a trois niveaux n'est pas
     utilisable au doigt. Le repli s'obtient par `:focus-within`, donc sans JavaScript. */
  .nav-toggle {
    display: block; width: 100%; text-align: left;
    background: var(--bg-elevated); border: 0; border-bottom: 1px solid var(--border);
    color: var(--text); font: inherit; font-weight: 500; padding: 13px 20px; min-height: 44px;
    cursor: pointer;
  }
  .site-nav .menu { display: none; flex-direction: column; }
  .site-nav:focus-within .menu,
  .site-nav .menu[data-open="true"] { display: flex; }

  .menu > li { border-bottom: 1px solid var(--border); }
  .sub, .sub2 {
    position: static; display: none; box-shadow: none; border: 0;
    border-top: 1px solid var(--border); border-radius: 0;
    background: var(--bg-subtle); min-width: 0; padding: 0;
  }
  .sub2 { background: var(--bg); }
  .sub a { padding-left: 34px; }
  .sub2 a { padding-left: 50px; }

  table.alerts thead th,
  table.affected thead th { position: static; }
}

/* Sous 640 px un tableau a six colonnes est illisible : il bascule en cartes empilees.
   Les en-tetes sont reinjectes par `data-label`, le tableau restant un tableau pour les
   lecteurs d'ecran comme pour les navigateurs sans CSS. */
@media (max-width: 640px) {
  table.alerts, table.alerts tbody, table.alerts tr, table.alerts td,
  table.affected, table.affected tbody, table.affected tr, table.affected td {
    display: block; width: 100%;
  }
  table.alerts thead,
  table.affected thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  }
  table.alerts tbody tr,
  table.affected tbody tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: var(--space-2); background: var(--bg-elevated);
  }
  table.alerts tbody tr:nth-child(even),
  table.affected tbody tr:nth-child(even) { background: var(--bg-subtle); }
  table.alerts tbody td,
  table.affected tbody td { border-bottom: 0; padding: 4px 12px; }
  table.alerts tbody td:first-child,
  table.affected tbody td:first-child { padding-top: 11px; }
  table.alerts tbody td:last-child,
  table.affected tbody td:last-child { padding-bottom: 11px; }
  table.alerts tbody td[data-label]::before,
  table.affected tbody td[data-label]::before {
    content: attr(data-label) " ";
    display: inline-block; min-width: 92px;
    color: var(--text-muted); font-size: var(--text-xs);
    text-transform: uppercase; letter-spacing: .06em;
  }
  .cve-siblings { columns: 1; }
}

/* ---------- Recherche et filtres (lot 7) ---------- */

.filters { margin-bottom: 22px; }
.filters-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-end; }
.filters-row + .filters-row { margin-top: var(--space-3); }
.filters input[type="search"] { flex: 1; min-width: 240px; }
.filters input, .filters select {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: .88rem; padding: var(--space-2) 11px;
  min-height: 44px;
}
.filters-secondary { font-size: var(--text-sm); }
.filter-field { display: flex; flex-direction: column; gap: 2px; }
.filter-field > label {
  color: var(--text-muted); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .06em;
}
.filter-check { flex-direction: row; align-items: center; gap: 6px; min-height: 44px; }
.filter-check > label { text-transform: none; letter-spacing: 0; font-size: var(--text-sm); }
.filter-check input { min-height: 0; width: 18px; height: 18px; }

/* La correspondance exacte se distingue du reste des résultats : elle n'est pas classée
   parmi eux, elle les précède. */
.exact-match {
  background: var(--accent-subtle); border: 1px solid var(--accent-border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: var(--space-4);
}
.exact-match p { margin: 0; }
.exact-match .exact-label {
  color: var(--text-muted); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px;
}

@media (max-width: 640px) {
  .filter-field, .filters-row > .btn { width: 100%; }
  .filter-field input, .filter-field select { width: 100%; }
}
