/* =========================================================
   Thème clair / sombre — pages publiques OSME
   Le thème est posé sur <html data-theme="light|dark"> par
   assets/js/theme.js (choix mémorisé ou préférence système).
   ========================================================= */

/* ---------- Bouton de bascule ---------- */
.brand-row > .brand { margin-right: auto; }
.theme-toggle {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-grid;
  place-items: center;
  margin-left: -14px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.theme-toggle:hover,
.theme-toggle:focus-visible { border-color: var(--red); color: var(--red); }
.theme-toggle:focus-visible { outline: 3px solid rgba(191, 24, 52, .27); outline-offset: 2px; }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (max-width: 1060px) {
  .theme-toggle { margin-left: 0; height: 42px; }
}

/* Transition douce lors du changement (désactivée au chargement). */
html.theme-animate,
html.theme-animate *,
html.theme-animate *::before,
html.theme-animate *::after {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease !important;
}

/* ---------- Palette sombre ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #e6edf5;          /* utilisée comme couleur de titre */
  --navy-bg: #0a1828;       /* fond « marine » des bandeaux */
  --red: #f07a8c;
  --red-dark: #f6a1ae;
  --ink: #e4e8ec;
  --muted: #a3adb8;
  --line: #2b3a4b;
  --paper: #0f1720;
  --soft: #151f2b;
  --warm: #1b2531;
  --surface: #1a2634;
  --text-2: #c3ccd5;
  --text-3: #9eaab6;
  --btn: #b9213b;
  --btn-hover: #d12f4b;
}

/* Fonds marine (la variable --navy devient claire en mode sombre) */
html[data-theme="dark"] .utility-bar,
html[data-theme="dark"] .events-section,
html[data-theme="dark"] .newsletter,
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .module-identity-panel,
html[data-theme="dark"] .module-action-dark { background: var(--navy-bg); }
html[data-theme="dark"] .events-section,
html[data-theme="dark"] .newsletter { border-top: 1px solid var(--line); }
html[data-theme="dark"] .axis-icon { background: #22344a; }
html[data-theme="dark"] .skip-link { background: var(--surface); }

/* Boutons pleins : garder un rouge soutenu avec texte blanc */
html[data-theme="dark"] .newsletter-field-row button,
html[data-theme="dark"] .event-row time,
html[data-theme="dark"] .axis-card.active .axis-icon,
html[data-theme="dark"] .module-identity-icon,
html[data-theme="dark"] .module-cta-inner > a,
html[data-theme="dark"] .search-dialog-form > button,
html[data-theme="dark"] .search-page-form > button { background: var(--btn); color: #fff; }
html[data-theme="dark"] .newsletter-field-row button:hover,
html[data-theme="dark"] .module-cta-inner > a:hover,
html[data-theme="dark"] .search-dialog-form > button:hover,
html[data-theme="dark"] .search-dialog-form > button:focus-visible,
html[data-theme="dark"] .search-page-form > button:hover,
html[data-theme="dark"] .search-page-form > button:focus-visible { background: var(--btn-hover); }

/* Survols « fond marine + texte blanc » */
html[data-theme="dark"] .search-button:hover,
html[data-theme="dark"] .search-button:focus-visible,
html[data-theme="dark"] .desktop-nav > .search-button:hover,
html[data-theme="dark"] .desktop-nav > .search-button:focus-visible,
html[data-theme="dark"] .search-dialog-close:hover,
html[data-theme="dark"] .search-dialog-close:focus-visible { background: #22344a; border-color: #22344a; color: #fff; }

/* Surfaces blanches → cartes sombres */
html[data-theme="dark"] .section-nav { background: #121b26; }
html[data-theme="dark"] .mobile-menu nav,
html[data-theme="dark"] .publication-featured,
html[data-theme="dark"] .publication-empty,
html[data-theme="dark"] .axis-card,
html[data-theme="dark"] .module-action-card:not(.module-action-dark),
html[data-theme="dark"] .search-dialog,
html[data-theme="dark"] .search-dialog-close,
html[data-theme="dark"] .search-input-wrap,
html[data-theme="dark"] .search-result-card,
html[data-theme="dark"] .search-message,
html[data-theme="dark"] .search-suggestions a { background: var(--surface); }
html[data-theme="dark"] .axis-card-disabled { background: #141d28; }
html[data-theme="dark"] .axis-card-disabled .axis-icon { background: #253244; color: #9eaab6; }
html[data-theme="dark"] .publication-thumb { background: #223042; }
html[data-theme="dark"] .search-input-wrap { border-color: #3a4a5c; }
html[data-theme="dark"] .newsletter-field-row input { background: #0f1720; color: var(--ink); border-color: #3a4a5c; }

/* Textes secondaires codés en dur */
html[data-theme="dark"] .desktop-nav { color: var(--text-2); }
html[data-theme="dark"] .brand-copy small,
html[data-theme="dark"] .intro-copy .lead,
html[data-theme="dark"] .portal-intro-grid .lead,
html[data-theme="dark"] .module-detail-hero .lead { color: var(--text-2); }
html[data-theme="dark"] .intro-copy > p:not(.eyebrow):not(.lead),
html[data-theme="dark"] .contact-panel p:not(.eyebrow),
html[data-theme="dark"] .publication-content > p:not(.publication-meta),
html[data-theme="dark"] .publication-row p:last-child,
html[data-theme="dark"] .data-number span,
html[data-theme="dark"] .approach-section p:not(.eyebrow),
html[data-theme="dark"] .portal-explainer,
html[data-theme="dark"] .current-module-note p:last-child,
html[data-theme="dark"] .axis-card p,
html[data-theme="dark"] .portal-guidance p:not(.eyebrow),
html[data-theme="dark"] .module-detail-grid > div > p:last-child,
html[data-theme="dark"] .module-action-card p,
html[data-theme="dark"] .module-scope-grid p,
html[data-theme="dark"] .module-cta p:not(.eyebrow),
html[data-theme="dark"] .search-hero-copy,
html[data-theme="dark"] .search-result-summary { color: var(--text-3); }
html[data-theme="dark"] .breadcrumb,
html[data-theme="dark"] .data-note > p:last-child,
html[data-theme="dark"] .module-catalog-heading > p,
html[data-theme="dark"] .search-result-meta,
html[data-theme="dark"] .axis-availability,
html[data-theme="dark"] .axis-status-pending { color: #8794a1; }
html[data-theme="dark"] .axis-status:not(.axis-status-pending),
html[data-theme="dark"] .module-live-label { color: #5fd09e; }
html[data-theme="dark"] .contact-separator { background: var(--line); }
html[data-theme="dark"] .publication-row { border-bottom-color: var(--line); }
html[data-theme="dark"] .axis-card { border-top-color: #3a4a5c; }
html[data-theme="dark"] .axis-card.active { border-top-color: var(--btn); }

/* ---------- Page d'accueil (styles intégrés à index.php) ---------- */
html[data-theme="dark"] .content-card { background: var(--surface); border-color: var(--line); box-shadow: 0 .8rem 2.3rem rgba(0, 0, 0, .3); }
html[data-theme="dark"] .content-card-media { background: #223042; }
html[data-theme="dark"] .content-card h3 { color: var(--navy); }
html[data-theme="dark"] .content-card h3 a:hover,
html[data-theme="dark"] .content-card h3 a:focus-visible { color: #b59cf0; }
html[data-theme="dark"] .content-card-summary { color: var(--text-3); }
html[data-theme="dark"] .events-section .content-card { border-color: #2f4157; }

/* ---------- Article (styles intégrés à article.php) ---------- */
html[data-theme="dark"] .article-page,
html[data-theme="dark"] .article-shell,
html[data-theme="dark"] .article-not-found { background: var(--paper); }
html[data-theme="dark"] .article-shell { background: var(--surface); }
html[data-theme="dark"] .article-cover { background: #223042; }
html[data-theme="dark"] .article-breadcrumb,
html[data-theme="dark"] .article-meta { color: #8f9cab; }
html[data-theme="dark"] .article-breadcrumb a,
html[data-theme="dark"] .article-kicker { color: #b59cf0; }
html[data-theme="dark"] .article-header h1,
html[data-theme="dark"] .article-not-found h1 { color: var(--navy); }
html[data-theme="dark"] .article-summary { color: var(--text-2); }
html[data-theme="dark"] .article-copy { color: var(--text-2); column-rule-color: var(--line); }
html[data-theme="dark"] .article-actions { border-top-color: var(--line); }
html[data-theme="dark"] .article-back { background: transparent; color: var(--navy); border-color: #3a4a5c; }

/* ---------- Module mortalité (styles intégrés) ---------- */
html[data-theme="dark"] .module-scope-link { border-color: #7b9be0; color: #a9c0f2; }
html[data-theme="dark"] .module-scope-link-primary { background: #3158a6; border-color: #3158a6; color: #fff; }
html[data-theme="dark"] .module-scope-status { color: var(--text-3); }

/* ---------- Pages légales (legal.css) ---------- */
html[data-theme="dark"] .legal-main { background: var(--paper); }
html[data-theme="dark"] .legal-card { background: var(--surface); border-top-color: #8c63d1; box-shadow: none; }
html[data-theme="dark"] .legal-card h1,
html[data-theme="dark"] .legal-card h2 { color: var(--navy); }
html[data-theme="dark"] .legal-card p,
html[data-theme="dark"] .legal-card li { color: var(--text-2); }
html[data-theme="dark"] .legal-card a { color: #b59cf0; }
html[data-theme="dark"] .legal-meta { color: #8f9cab; }
html[data-theme="dark"] .legal-actions { border-top-color: var(--line); }
