/**
 * Global Harmony Layer
 * ────────────────────────────────────────────────────────────
 * Couche finale chargée APRÈS tout pour :
 *  1. Unifier les fonds de page light/dark (pas de saut visuel au scroll)
 *  2. Harmoniser les surfaces des sections récurrentes vers une seule palette
 *  3. Arrondir toutes les sections "carrées" (border-radius minimum)
 *
 * Tokens utilisés :
 *   --cqh-bg-page       : fond global de la page
 *   --cqh-bg-surface    : carte / panneau standard
 *   --cqh-bg-surface-2  : carte alternée (zebra subtile)
 *   --cqh-border        : bordure neutre
 *   --cqh-radius        : radius minimum pour blocs section
 */

:root {
  --cqh-bg-page: #fafbff;
  --cqh-bg-surface: #ffffff;
  --cqh-bg-surface-2: #f6f8fc;
  --cqh-border: rgba(15, 23, 42, 0.08);
  --cqh-shadow-soft: 0 1px 0 rgba(15,23,42,0.04), 0 18px 48px -28px rgba(99,102,241,0.18);
  --cqh-radius: 20px;
  --cqh-radius-sm: 14px;
}

body.qcm-dark,
[data-theme="dark"] {
  --cqh-bg-page: #0b1226;
  --cqh-bg-surface: #111a31;
  --cqh-bg-surface-2: #0f172e;
  --cqh-border: rgba(148, 163, 184, 0.12);
  --cqh-shadow-soft: 0 1px 0 rgba(255,255,255,0.03), 0 22px 60px -32px rgba(0,0,0,0.6);
}

/* ════════════════════════════════════════════════════════════
   1. PAGE BG — fond global unifié, transition douce
   ════════════════════════════════════════════════════════════ */

body:not(#nope) {
  background: var(--cqh-bg-page) !important;
  background-attachment: fixed;
}

/* Wrappers de pages : transparents pour ne pas créer de "couche" visible */
body:not(#nope) > main,
body:not(#nope) > main.cq-main,
body:not(#nope) .home-page-v2,
body:not(#nope) .dashboard-v2,
body:not(#nope) .dashboard-page,
body:not(#nope) .blog-hub,
body:not(#nope) .blog-single,
body:not(#nope) .equipe-page,
body:not(#nope) .premium-page,
body:not(#nope) .qcm-hub-page,
body:not(#nope) .matiere-hub-page,
body:not(#nope) .notion-hub-page,
body:not(#nope) .leaderboard-page,
body:not(#nope) .cq-lb,
body:not(#nope) .profile-page,
body:not(#nope) .teacher-page,
body:not(#nope) .scores-page,
body:not(#nope) .aide-page,
body:not(#nope) .a-propos-page,
body:not(#nope) .culture-page,
body:not(#nope) .grp-page,
body:not(#nope) .generator-page,
body:not(#nope) .gen-wizard-page,
body:not(#nope) .contact-page,
body:not(#nope) .auth-page,
body:not(#nope) .methodologie-page {
  background: transparent !important;
  background-image: none !important;
}

/* Annule les fonds de gradient lourds / radial sur les pages (créaient des sauts au scroll) */
body:not(#nope) .cq-lb,
body:not(#nope) .blog-hub,
body:not(#nope) .dashboard-v2 {
  background-image: none !important;
}

/* ════════════════════════════════════════════════════════════
   2. RADIUS UNIVERSEL — sections carrées → arrondies
   ════════════════════════════════════════════════════════════ */

/* Sections / blocs / cards / panels génériques sans radius */
body:not(#nope) .cq-section,
body:not(#nope) .cq-block,
body:not(#nope) .cq-panel,
body:not(#nope) .cq-card,
body:not(#nope) .section-box,
body:not(#nope) .content-box,
body:not(#nope) .info-box,
body:not(#nope) .feature-box,
body:not(#nope) .stat-box,
body:not(#nope) [class*="__section"]:not([class*="hero"]):not([class*="nav"]):not([class*="cocon"]),
body:not(#nope) [class*="__panel"],
body:not(#nope) [class*="__block"]:not([class*="hero"]):not([class*="grid"]) {
  border-radius: var(--cqh-radius);
}

/* Cards plus petites */
body:not(#nope) [class*="__card"]:not([class*="hero"]):not([class*="bar"]) {
  border-radius: var(--cqh-radius-sm);
}

/* Garde-fou : aucune section ne doit avoir radius 0 sauf navbar/footer/hero edge-to-edge */
body:not(#nope) section[class]:not(.no-radius):not([class*="hero"]):not([class*="nav"]):not([class*="footer"]):not([class*="header"]) {
  border-radius: var(--cqh-radius);
}

/* ════════════════════════════════════════════════════════════
   3. SURFACES — harmonisation des cards & panneaux fréquents
   On force la palette unifiée sur les blocs qui ont leur propre
   bg blanc/gris pour éviter les écarts visuels entre pages.
   ════════════════════════════════════════════════════════════ */

body.qcm-dark .pour-toi-section,
body.qcm-dark .quick-bar-inner,
body.qcm-dark .dashboard-card,
body.qcm-dark .cq-lb__personal-card,
body.qcm-dark .cq-lb__table,
body.qcm-dark .cq-lb__empty-state-inner,
body.qcm-dark .cq-lb__podium-card:not(.cq-lb__podium-card--gold),
body.qcm-dark .blog-hub__card,
body.qcm-dark .blog-hub__cocon-card,
body.qcm-dark .pricing-card,
body.qcm-dark .feature-card,
body.qcm-dark .stat-card,
body.qcm-dark .testimonial-card {
  background-color: var(--cqh-bg-surface) !important;
  border-color: var(--cqh-border) !important;
}

/* Light mode : les cartes blanches sont OK (déjà #fff) — on aligne juste les bordures
   pour avoir une cohérence visuelle */
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__personal-card,
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__table,
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__empty-state-inner,
body:not(.qcm-dark):not([data-theme="dark"]) .pour-toi-section,
body:not(.qcm-dark):not([data-theme="dark"]) .quick-bar-inner {
  border-color: var(--cqh-border);
}

/* ════════════════════════════════════════════════════════════
   4. TRANSITIONS DOUCES — éviter flash entre sections
   ════════════════════════════════════════════════════════════ */

body, body * {
  /* Évite que les changements bg/border en hover ne créent un flash */
}

body:not(#nope) section,
body:not(#nope) [class*="-section"],
body:not(#nope) [class*="__section"] {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ════════════════════════════════════════════════════════════
   5. EXCEPTIONS — heros / nav / footer gardent leurs styles
   ════════════════════════════════════════════════════════════ */

/* On laisse intentionnellement les heros et le header/footer
   gérer leur propre fond (gérés par hero-unified-v2.css et
   header-footer.css). */

/* ════════════════════════════════════════════════════════════
   6. LIGHT MODE — visibilité des stats / trust bars dans heros
   Beaucoup de heros legacy forçaient color:#fff !important sur
   leurs valeurs/labels (groups, profile, leaderboard, etc.) car
   ils avaient un fond gradient indigo. Maintenant que les heros
   sont en fond clair en light mode, le texte est invisible.
   ════════════════════════════════════════════════════════════ */

body:not(.qcm-dark):not([data-theme="dark"]) .grp-stats-bar {
  background: rgba(99, 102, 241, 0.06) !important;
  border-color: rgba(99, 102, 241, 0.18) !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .grp-stats-bar__value {
  color: #0f172a !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .grp-stats-bar__label {
  color: #475569 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .grp-stats-bar__sep {
  background: rgba(15, 23, 42, 0.10) !important;
}

/* MATIERE HUB — trust bar */
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-hero__trust {
  background: rgba(99, 102, 241, 0.06) !important;
  border-color: rgba(99, 102, 241, 0.18) !important;
  color: #475569 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-trust-item {
  color: #475569 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-trust-item svg {
  stroke: #6366f1 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-trust-item a {
  color: #4f46e5 !important;
  text-decoration-color: rgba(79, 70, 229, 0.4) !important;
}

/* LEADERBOARD HERO — badge / week / privacy */
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__hero-badge,
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__hero-week,
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__hero-privacy {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.20) !important;
  color: #4f46e5 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__hero-privacy svg {
  color: #6366f1 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__hero-title {
  color: #0f172a !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .cq-lb__hero-subtitle {
  color: #475569 !important;
}

/* NOTION HERO — aligné sur le hero unifié clair (leaderboard & co).
   notions-premium.css force un dégradé coloré (!important) ; on neutralise
   ce fond en light mode pour retrouver le fond clair + mesh unifié.
   ATTENTION : hero-unified-v2.css force --cqh2-bg-tint:#111a31 (sombre) sur
   TOUS les .qcm-hub-hero, en light comme en dark. Sans rebasculer ces tokens,
   var(--cqh2-bg-tint) résolvait ici en sombre (le fallback clair #fafbff
   n'était jamais utilisé) → fond sombre + titre #0f172a = illisible. On
   remet donc les tokens en version claire pour ce hero en light mode. */
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-hero--notion {
  --cqh2-bg-tint: #fafbff;
  --cqh2-fg: #0f172a;
  --cqh2-fg-soft: #475569;
  --cqh2-border: rgba(99, 102, 241, 0.12);
  background: var(--cqh2-bg-tint, #fafbff) !important;
  background-image: none !important;
  border: 1px solid var(--cqh2-border, rgba(99, 102, 241, 0.12)) !important;
  box-shadow: var(--cqh2-shadow, 0 18px 48px rgba(99, 102, 241, 0.10)) !important;
  color: var(--cqh2-fg, #0f172a) !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-hero--notion .notion-eeat-badge {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.20) !important;
  color: #4f46e5 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .qcm-hub-hero--notion .notion-eeat-badge svg {
  stroke: #6366f1 !important;
  color: #6366f1 !important;
}
/* Titre / sous-titre / badge du hero notion : le fond est neutralisé en clair
   (ci-dessus), mais global-typography force color:white !important sur le titre
   et le badge est translucide blanc → texte invisible sur fond pâle. On rétablit
   un texte sombre lisible. Le :not(#nope) hausse la spécificité (1 id) pour
   battre le patch générique de hero-unified-v2. Light mode uniquement → le dark
   n'est pas touché. */
body:not(.qcm-dark):not([data-theme="dark"]):not(#nope) .qcm-hub-hero--notion .qcm-hub-hero__title {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  text-shadow: none !important;
}
body:not(.qcm-dark):not([data-theme="dark"]):not(#nope) .qcm-hub-hero--notion .qcm-hub-hero__subtitle {
  color: #475569 !important;
  -webkit-text-fill-color: #475569 !important;
  text-shadow: none !important;
}
body:not(.qcm-dark):not([data-theme="dark"]):not(#nope) .qcm-hub-hero--notion .qcm-hub-hero__badge {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.20) !important;
  color: #4f46e5 !important;
}

/* PROFILE / TEACHER / DASHBOARD / GENERATOR / SCORES — chips, stats, badges */
body:not(.qcm-dark):not([data-theme="dark"]) .profile-hero [class*="badge"],
body:not(.qcm-dark):not([data-theme="dark"]) .profile-hero [class*="chip"],
body:not(.qcm-dark):not([data-theme="dark"]) .profile-hero [class*="tag"],
body:not(.qcm-dark):not([data-theme="dark"]) .generator-hero [class*="pill"],
body:not(.qcm-dark):not([data-theme="dark"]) .generator-hero [class*="chip"],
body:not(.qcm-dark):not([data-theme="dark"]) .generator-hero [class*="badge"],
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero [class*="badge"] {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.20) !important;
  color: #4f46e5 !important;
}

body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero [class*="stat-value"],
body:not(.qcm-dark):not([data-theme="dark"]) .dashboard-hero [class*="stat-value"],
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero [class*="value"] {
  color: #0f172a !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero [class*="stat-label"],
body:not(.qcm-dark):not([data-theme="dark"]) .dashboard-hero [class*="stat-label"],
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero [class*="label"] {
  color: #475569 !important;
}

/* TEACHER HERO — badges (Vue Enseignant / Données d'apprentissage) */
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-badge,
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero__badges .teacher-badge,
body:not(.qcm-dark):not([data-theme="dark"]) .period-badge {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.20) !important;
  color: #4f46e5 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-badge svg,
body:not(.qcm-dark):not([data-theme="dark"]) .period-badge svg {
  stroke: #6366f1 !important;
  color: #6366f1 !important;
}

/* TEACHER / DASHBOARD HERO — title & subtitle */
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero h1,
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero__title,
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero--compact h1,
body:not(.qcm-dark):not([data-theme="dark"]) .dashboard-hero h1 {
  color: #0f172a !important;
  text-shadow: none !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero__subtitle,
body:not(.qcm-dark):not([data-theme="dark"]) .teacher-hero p,
body:not(.qcm-dark):not([data-theme="dark"]) .dashboard-hero p {
  color: #475569 !important;
}

/* SCORES HERO — title + subtitle blanc → slate */
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero h1,
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero .page-h1,
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero-content h1 {
  color: #0f172a !important;
  text-shadow: none !important;
  -webkit-text-fill-color: #0f172a !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero-subtitle,
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero p {
  color: #475569 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .scores-hero-badge {
  background: rgba(99, 102, 241, 0.08) !important;
  border-color: rgba(99, 102, 241, 0.20) !important;
  color: #4f46e5 !important;
}

/* BLOG HUB — breadcrumb (Accueil > Blog) en haut du hero */
body:not(.qcm-dark):not([data-theme="dark"]) .blog-hub__breadcrumb .cq-breadcrumb__link {
  color: #475569 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .blog-hub__breadcrumb .cq-breadcrumb__link:hover {
  color: #4f46e5 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .blog-hub__breadcrumb .cq-breadcrumb__current {
  color: #0f172a !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .blog-hub__breadcrumb .cq-breadcrumb__separator {
  color: #94a3b8 !important;
}

/* BLOG HUB — liens dans l'intro (ex : "outils d'apprentissage") */
body:not(.qcm-dark):not([data-theme="dark"]) .blog-hub__intro a {
  color: #4f46e5 !important;
  text-decoration: underline !important;
  text-decoration-color: rgba(79, 70, 229, 0.4) !important;
  text-underline-offset: 3px !important;
  background: none !important;
  -webkit-text-fill-color: #4f46e5 !important;
}
body:not(.qcm-dark):not([data-theme="dark"]) .blog-hub__intro a:hover {
  color: #4338ca !important;
  text-decoration-color: #4338ca !important;
  -webkit-text-fill-color: #4338ca !important;
}
