/* =========================================================================
   2.13 — THÈME NOIR iOS & ANDROID
   Couche de couleurs chargée APRÈS mono-2027.css, sur toutes les pages.
   Elle ne touche ni à la typographie, ni aux grilles, ni aux filets : elle
   retourne seulement les jetons de couleur vers les palettes système d'iOS
   (noir vrai, gris « elevated », bleu #0a84ff) et d'Android (Material, noir,
   bleu #8ab4f8). Le thème clair reste intact ; le bouton soleil / lune de la
   barre bascule entre les deux.

   La plateforme est posée sur <html data-platform="ios|android|desktop">
   par js/theme.js, avant le premier rendu. Les deux palettes partagent le même
   noir absolu : ce qui change, ce sont les surfaces, les séparateurs et les
   accents — exactement comme d'un système à l'autre.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. JETONS COMMUNS — le socle noir
   ------------------------------------------------------------------------- */
html {
  accent-color: var(--sys-blue, #0a84ff);
}

/* Le fond le plus profond est peint sur html : en rebond de défilement,
   aucune bande claire n'apparaît sous une page noire. En thème clair, c'est
   mono-2027 qui garde la main sur ce fond. */
html[data-theme="dark"] {
  background: #000;
}

/* Le thème clair garde ses propres accents système (iOS clair). */
html[data-theme="light"] {
  --sys-blue: #007aff;
  --sys-green: #1b6e30;
  --sys-orange: #b34400;
  --sys-red: #c4001a;
}

/* Le bandeau de consentement reste sombre dans les deux thèmes : son lien
   légal doit donc rester clair, sinon il disparaît sur son propre fond. */
html[data-theme="light"] .cookie-legal {
  color: #f2f1ee;
}

/* Le panneau d'appel à l'action est sombre dans les deux thèmes : ses boutons
   creux suivent le papier, pas l'encre de la page claire. */
html[data-theme="light"] .cta .btn-ghost {
  border-color: rgba(242, 241, 238, .42);
  color: #f2f1ee;
}

html[data-theme="light"] .cta .btn-ghost:hover {
  background: #f2f1ee;
  border-color: #f2f1ee;
  color: #101014;
}

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

  /* Jetons du site, réécrits avec les valeurs système. */
  --paper: #000;
  --paper-2: #0a0a0c;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --ink: #ffffff;
  --ink-2: #d1d1d6;
  --muted: #98989d;
  --brand: #ffffff;
  --brand-ink: #ffffff;
  --brand-soft: #1c1c1e;
  --on-brand: #000000;
  --dark: #000000;
  --dark-2: #151517;
  --dline: #38383a;
  --line: rgba(84, 84, 88, .64);
  --line-soft: rgba(84, 84, 88, .34);
  --line-strong: rgba(84, 84, 88, .92);
  --topbar-bg: rgba(0, 0, 0, .74);
  --hover-bg: rgba(120, 120, 128, .28);
  --hover-fg: #ffffff;
  --sb-thumb: rgba(235, 235, 245, .32);
  --sb-thumb-hover: rgba(235, 235, 245, .62);

  /* Couleurs système iOS (mode sombre). */
  --sys-blue: #0a84ff;
  --sys-green: #30d158;
  --sys-orange: #ff9f0a;
  --sys-red: #ff453a;
  --sys-yellow: #ffd60a;
  --sys-fill: rgba(120, 120, 128, .24);

  --green: var(--sys-green);
  --green-soft: rgba(48, 209, 88, .16);
  --amber: var(--sys-orange);
  --red: var(--sys-red);
  --lime: #ffffff;
  --accent: var(--sys-blue);
}

/* -------------------------------------------------------------------------
   2. PALETTE ANDROID — mêmes noirs, surfaces et accents Material
   ------------------------------------------------------------------------- */
html[data-platform="android"][data-theme="dark"] {
  --paper: #000;
  --paper-2: #0d0d0f;
  --card: #1f1f22;
  --card-2: #2a2a2e;
  --ink: #ffffff;
  --ink-2: #e3e3e3;
  --muted: #9aa0a6;
  --line: rgba(227, 227, 227, .14);
  --line-soft: rgba(227, 227, 227, .08);
  --line-strong: rgba(227, 227, 227, .32);
  --topbar-bg: rgba(0, 0, 0, .82);
  --hover-bg: rgba(227, 227, 227, .12);
  --brand-soft: #1f1f22;

  /* Couleurs système Material 3 (mode sombre). */
  --sys-blue: #8ab4f8;
  --sys-green: #81c995;
  --sys-orange: #fdd663;
  --sys-red: #f28b82;
  --sys-yellow: #fdd663;
  --sys-fill: rgba(227, 227, 227, .10);

  --green: var(--sys-green);
  --green-soft: rgba(129, 201, 149, .16);
  --amber: var(--sys-orange);
  --red: var(--sys-red);
  --accent: var(--sys-blue);
}

/* Sur ordinateur, on garde la teinte iOS : c'est la référence visuelle du
   site. Aucun jeton supplémentaire n'est nécessaire. */

/* -------------------------------------------------------------------------
   3. SURFACES
   ------------------------------------------------------------------------- */
html[data-theme="dark"] body {
  background: var(--paper);
  color: var(--ink);
}

/* Barre de navigation : le voile translucide d'iOS, sans bordure lumineuse. */
html[data-theme="dark"] .topbar {
  background: var(--topbar-bg);
  border-bottom-color: var(--line);
}

/* Les panneaux et cartes prennent la surface « élevée » du système. */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .module,
html[data-theme="dark"] .featured a,
html[data-theme="dark"] .app-grid a,
html[data-theme="dark"] .team-card,
html[data-theme="dark"] .seo-card,
html[data-theme="dark"] .ref-card,
html[data-theme="dark"] .news-row {
  background: var(--card);
}

html[data-theme="dark"] .module-details,
html[data-theme="dark"] .app-grid a:hover,
html[data-theme="dark"] .featured a:hover {
  background: var(--card-2);
}

/* Le pied de page reste sur le noir le plus profond : il ferme la page. */
html[data-theme="dark"] .footer {
  background: var(--paper);
  border-top-color: var(--line);
}

/* -------------------------------------------------------------------------
   4. ÉTATS ET ACCENTS SYSTÈME
   La couleur ne sert qu'à l'état : sélection, focus, indicateurs. Le reste de
   la page demeure encre et papier, comme le demande la direction artistique.
   ------------------------------------------------------------------------- */
html[data-theme="dark"] ::selection {
  background: var(--sys-blue);
  color: #ffffff;
}

/* Anneau de focus système : lisible sur le noir, jamais décoratif. */
html[data-theme="dark"] :where(a, button, summary, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--sys-blue);
  outline-offset: 2px;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  caret-color: var(--sys-blue);
}

/* Indicateurs « vivants » : vert système pour l'activité, rouge pour l'alerte,
   orange pour l'avertissement. Aucun changement de forme. */
html[data-theme="dark"] .kpi-trend .dot,
html[data-theme="dark"] .live-dot,
html[data-theme="dark"] .ref-live {
  background: var(--sys-green);
}

html[data-theme="dark"] .kpi-trend.up .txt {
  color: var(--sys-green);
}

html[data-theme="dark"] .kpi-trend .dot {
  box-shadow: 0 0 0 3px var(--green-soft);
}

html[data-theme="dark"] .iat-chk.is-bad .iat-chk-ico,
html[data-theme="dark"] .audit-bad .tick {
  color: var(--sys-red);
  border-color: var(--sys-red);
}

html[data-theme="dark"] .iat-chk.is-warn .iat-chk-ico,
html[data-theme="dark"] .audit-warn .tick {
  color: var(--sys-orange);
}

html[data-theme="dark"] .iat-chk.is-done .iat-chk-ico,
html[data-theme="dark"] .audit-good .tick {
  color: var(--sys-green);
  border-color: var(--sys-green);
}

/* L'étape active du formulaire est une plaque claire : son sous-titre doit
   passer en encre sombre, sinon le gris système disparaît sur le blanc. */
html[data-theme="dark"] .step-dot.active small {
  color: rgba(16, 16, 20, .64);
}

/* En thème clair, la plaque active est sombre : c'est le papier qui éclaire
   le sous-titre. */
html[data-theme="light"] .step-dot.active small {
  color: rgba(242, 241, 238, .74);
}

/* -------------------------------------------------------------------------
   5. BASCULE DE THÈME — la cible tactile système
   ------------------------------------------------------------------------- */
.theme-toggle {
  -webkit-tap-highlight-color: transparent;
}

@media (hover: none) {
  .theme-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

/* -------------------------------------------------------------------------
   6. MARGES DE SÉCURITÉ MOBILES (encoche, barre gestuelle)
   Le noir se prolonge sous les zones système : aucune couture visible quand
   le site est ouvert en application installée.
   ------------------------------------------------------------------------- */
@supports (padding: max(0px)) {
  html[data-theme="dark"] .topbar {
    padding-top: env(safe-area-inset-top, 0px);
  }

  html[data-theme="dark"] .mobile-nav.open {
    padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  }

  html[data-theme="dark"] .float-stack {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* La timeline est la page « nuit » du site : elle garde sa palette propre.
   On lui rend donc ses jetons, puis on lui applique seulement les accents. */
html[data-theme="light"] .tl-body {
  --ink-2: #c9c9cf;
  --muted: #a7a7ad;
  --line: rgba(242, 241, 238, .16);
  --line-soft: rgba(242, 241, 238, .08);
  --line-strong: rgba(242, 241, 238, .40);
}

html[data-theme="dark"] .tl-body {
  --paper: #f2f1ee;
  --ink: #101014;
  --ink-2: #c9c9cf;
  --muted: #a7a7ad;
  --line: rgba(242, 241, 238, .16);
  --line-soft: rgba(242, 241, 238, .08);
  --line-strong: rgba(242, 241, 238, .40);
  --card: #16161b;
  --card-2: #1b1b21;
  --brand: #f2f1ee;
  --on-brand: #101014;
  background: #000;
  color: #f2f1ee;
}

html[data-theme="dark"] .tl-body ::selection {
  background: var(--sys-blue);
  color: #ffffff;
}

/* -------------------------------------------------------------------------
   8. IMPRESSION
   Une page imprimée n'a pas de thème : encre noire sur papier blanc.
   ------------------------------------------------------------------------- */
@media print {
  html,
  html[data-theme="dark"] body {
    background: #ffffff !important;
    color: #000000 !important;
  }
}
