/* ============================================================================
   AEGIS — Rendu d'analyse enrichi (preuves vs indices, jauge, heatmap, métriques)
   S'appuie sur les variables du thème : --cyan --gold --green --red --amber
   --ink --muted --panel --border --mono
   ========================================================================== */
.res-hero { display: grid; grid-template-columns: 148px 1fr; gap: 26px; align-items: center; padding: 26px; }
.gauge { position: relative; width: 148px; height: 148px; flex: none; }
.gauge svg { transform: rotate(-90deg); display: block; }
.gauge .g-bg { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 12; }
.gauge .g-fg { fill: none; stroke-width: 12; stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(.16,.84,.24,1); }
.gauge .g-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.gauge .g-score { font: 800 38px/1 var(--mono); letter-spacing: -.02em; }
.gauge .g-max { font-size: 10.5px; color: var(--muted); letter-spacing: .12em; margin-top: 3px; }
.res-verdict { display: flex; flex-direction: column; gap: 11px; min-width: 0; }
.res-vline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conf-chip { font: 600 11.5px/1 var(--mono); color: var(--muted);
  background: var(--panel); border: 1px solid var(--border); padding: 5px 9px; border-radius: 20px; }
.res-explain { color: var(--ink); opacity: .88; font-size: 13.6px; line-height: 1.55; white-space: pre-line; }
.tech-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tech-chip { font: 600 10.5px/1 var(--mono); color: var(--cyan); background: rgba(94,200,255,.09);
  border: 1px solid rgba(94,200,255,.26); padding: 5px 9px; border-radius: 20px; letter-spacing: .02em; }

/* Groupes de signaux : preuves déterministes vs indices forensiques */
.sig-group { margin-top: 20px; }
.sig-group-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 11px; }
.sig-group-h .gh-t { font-weight: 800; font-size: 12.5px; letter-spacing: .07em; text-transform: uppercase; }
.sig-group-h .gh-n { font: 700 11.5px/1 var(--mono); color: var(--muted); }
.sig-group-h .gh-hint { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.sig-group.proofs .gh-t { color: var(--gold); }
.sig-group.indices .gh-t { color: var(--cyan); }
.sig { display: flex; gap: 12px; padding: 13px 14px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--border); margin-bottom: 9px; align-items: flex-start; }
.sig.proof { border-color: rgba(232,177,90,.32); background: rgba(232,177,90,.045); }
.sig .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.sig .s-main { flex: 1; min-width: 0; }
.sig .s-lbl { font-weight: 650; font-size: 13.8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sig .s-det { color: var(--muted); font-size: 12.4px; margin-top: 3px; line-height: 1.45; }
.s-tag { font: 800 9px/1 var(--mono); padding: 3px 6px; border-radius: 5px; letter-spacing: .07em; }
.s-tag.proof { color: var(--gold); background: rgba(232,177,90,.14); border: 1px solid rgba(232,177,90,.42); }
.s-tag.indice { color: var(--muted); background: rgba(138,155,189,.1); border: 1px solid var(--border); }
.s-w { font: 700 12px/1 var(--mono); flex: none; padding-top: 3px; }
.s-w.pos { color: var(--green); } .s-w.neg { color: var(--red); }
.dot.positive { background: var(--green); } .dot.info { background: var(--cyan); }
.dot.warning { background: var(--amber); } .dot.critical { background: var(--red); }

/* Tuiles de métriques */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px; margin-top: 18px; }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; }
.metric .m-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  display: flex; align-items: center; gap: 6px; }
.metric .m-v { font-weight: 650; font-size: 13.6px; margin-top: 4px; word-break: break-word; }
.metric.good { border-color: rgba(110,231,168,.3); } .metric.good .m-v { color: var(--green); }
.metric.bad { border-color: rgba(255,123,123,.32); } .metric.bad .m-v { color: var(--red); }

/* Comparateur Original ↔ Carte de falsification */
.cmp-tabs { display: flex; gap: 6px; margin: 0 0 10px; }
.cmp-tab { font: 600 12px/1 var(--mono); padding: 7px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); cursor: pointer; transition: .15s; }
.cmp-tab.on { color: var(--ink); border-color: var(--cyan); background: rgba(94,200,255,.1); }
.cmp-stage { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.cmp-img { width: 100%; display: block; }
.cmp-legend { font-size: 11.5px; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 22px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(94,200,255,.2), var(--red)); }

@media (max-width: 720px) {
  .res-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .res-vline, .tech-row { justify-content: center; }
}

/* ============================================================================
   ▓▓▓ THÈME CLAIR (LIGHT MODE) + ACCESSIBILITÉ — AJOUTÉ EN FIN DE FICHIER ▓▓▓
   Activé via <html data-theme="light"> (voir /static/js/theme.js).
   Le thème SOMBRE reste le défaut : rien ci-dessous ne s'applique sans
   data-theme="light". On surcharge uniquement les variables de :root, plus
   quelques surfaces codées en rgba-sur-fond-noir qui ne se re-teintent pas
   automatiquement (jauges, panneaux « solides », dégradés, textes forcés).

   Contraste (WCAG AA sur fond clair ~#f6f8fc) — accents assombris :
     --cyan  #5ec8ff → #0d74c4   (le cyan clair d'origine ~1.5:1 sur blanc)
     --green #2fe0a6 → #0f8f66   (le vert d'origine illisible sur blanc)
     --amber #ffb648 → #a86400   (l'ambre d'origine illisible sur blanc)
     --gold  #e8b15a → #9a6b12   (idem, pour texte)
     --red   #ff5d76 → #d81f47   (léger renfort de contraste)
   Les couleurs vives d'origine restent utilisées comme *remplissage* (dots,
   traits de jauge) où le contraste n'est pas requis sur le texte.
   ========================================================================== */
:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-2: #eef2fa;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --border: rgba(14, 21, 36, 0.12);
  --border-strong: rgba(13, 116, 196, 0.34);
  --ink: #0e1524;
  --muted: #4a5a75;
  --faint: #6b7a95;
  --cyan: #0d74c4;
  --cyan-deep: #0a5c9e;
  --green: #0f8f66;
  --amber: #a86400;
  --red: #d81f47;
  --gold: #9a6b12;
  --violet: #9a6b12;
  --shadow: 0 20px 48px -30px rgba(14, 21, 36, 0.32);
}

/* Fond de page clair (le <body> compose plusieurs dégradés sur --bg) */
:root[data-theme="light"] body {
  background:
    linear-gradient(rgba(13, 116, 196, 0.05) 1px, transparent 1px) 0 0 / 100% 32px,
    radial-gradient(1100px 640px at 84% -10%, rgba(13, 116, 196, 0.10), transparent 60%),
    radial-gradient(820px 520px at 2% 4%, rgba(154, 107, 18, 0.08), transparent 55%),
    var(--bg);
}
:root[data-theme="light"] a:hover { color: var(--cyan-deep); }

/* Topbar : le fond était un dégradé bleu-nuit codé en dur */
:root[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.72));
  border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] .nav a:hover,
:root[data-theme="light"] .btn:hover { color: var(--cyan-deep); }
:root[data-theme="light"] .pill { background: rgba(13, 116, 196, 0.08); }

/* Boutons : le fond translucide « verre sur noir » devient sombre sur clair */
:root[data-theme="light"] .btn { background: rgba(13, 116, 196, 0.06); }
:root[data-theme="light"] .btn.primary,
:root[data-theme="light"] .btn-mini,
:root[data-theme="light"] .user-chip .avatar { color: #ffffff !important; }

/* Puce utilisateur / jetons */
:root[data-theme="light"] .user-chip,
:root[data-theme="light"] .token-chip { background: rgba(13, 116, 196, 0.06); }

/* Cartes, panneaux « solides » et surfaces rgba-sur-noir */
:root[data-theme="light"] .step,
:root[data-theme="light"] .signal,
:root[data-theme="light"] .check,
:root[data-theme="light"] .flow-step,
:root[data-theme="light"] .doc-pill,
:root[data-theme="light"] .bar { background: var(--panel-solid); }
:root[data-theme="light"] table.recent tr:hover td { background: rgba(13, 116, 196, 0.05); }

/* Encart d'explication (dégradé + texte codés en clair-sur-noir) */
:root[data-theme="light"] .explain {
  background: linear-gradient(120deg, rgba(13, 116, 196, 0.08), rgba(154, 107, 18, 0.06));
  color: var(--ink);
}

/* --- Rendu d'analyse (analysis.css) en clair --- */
:root[data-theme="light"] .gauge .g-bg { stroke: rgba(14, 21, 36, 0.10); }
:root[data-theme="light"] .sig,
:root[data-theme="light"] .metric,
:root[data-theme="light"] .conf-chip,
:root[data-theme="light"] .cmp-tab { background: var(--panel-solid); }
:root[data-theme="light"] .sig.proof { background: rgba(154, 107, 18, 0.06); }
:root[data-theme="light"] .tech-chip {
  color: var(--cyan); background: rgba(13, 116, 196, 0.08);
  border-color: rgba(13, 116, 196, 0.28);
}
:root[data-theme="light"] .cmp-tab.on { background: rgba(13, 116, 196, 0.1); }
:root[data-theme="light"] .s-tag.indice { background: rgba(74, 90, 117, 0.1); }

/* Badges de verdict : re-teinter les fonds/bordures rgba pour le fond clair */
:root[data-theme="light"] .v-AUTHENTIC,
:root[data-theme="light"] .s-VERIFIED,
:root[data-theme="light"] .tag.AUTHENTIC {
  background: rgba(15, 143, 102, 0.12); border-color: rgba(15, 143, 102, 0.45);
}
:root[data-theme="light"] .v-SUSPICIOUS,
:root[data-theme="light"] .s-CAUTION,
:root[data-theme="light"] .tag.SUSPICIOUS {
  background: rgba(168, 100, 0, 0.12); border-color: rgba(168, 100, 0, 0.45);
}
:root[data-theme="light"] .v-MANIPULATED,
:root[data-theme="light"] .s-FLAGGED,
:root[data-theme="light"] .tag.MANIPULATED {
  background: rgba(216, 31, 71, 0.1); border-color: rgba(216, 31, 71, 0.42);
}

/* Bouton bascule de thème (topbar) — icône soleil/lune */
.theme-toggle {
  display: inline-grid; place-items: center; position: relative;
  width: 34px; height: 34px; padding: 0; cursor: pointer;
  color: var(--muted); border: 1px solid var(--border); border-radius: 10px;
  background: rgba(120, 224, 255, 0.05); transition: 0.18s; font: inherit;
}
.theme-toggle:hover { color: var(--cyan); border-color: var(--border-strong); }
.theme-toggle .ic { grid-area: 1 / 1; }
/* Sombre par défaut : on propose de passer en clair → on montre le soleil */
.theme-toggle .theme-ic-sun { display: block; }
.theme-toggle .theme-ic-moon { display: none; }
/* En clair : on propose de repasser en sombre → on montre la lune */
:root[data-theme="light"] .theme-toggle .theme-ic-sun { display: none; }
:root[data-theme="light"] .theme-toggle .theme-ic-moon { display: block; }
:root[data-theme="light"] .theme-toggle { background: rgba(13, 116, 196, 0.06); }

/* ============================================================================
   ACCESSIBILITÉ — s'applique aux DEUX thèmes
   ========================================================================== */
/* Focus clavier bien visible (le clic souris n'en déclenche pas grâce à
   :focus-visible). 2px cyan + décalage pour ne pas coller au contenu. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.theme-toggle:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Respect de « réduire les animations » : coupe la transition de jauge et
   les animations lourdes, tout en gardant l'interface utilisable. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gauge .g-fg { transition: none !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .spin { animation: none !important; }
}
