/* ============================================================
   RMC Cube · v2 · Jetons du système de design et thèmes
   ------------------------------------------------------------
   Thème clair unique (décision du 12 août 2026). Chargé APRÈS
   style.css : cette feuille définit les jetons du système de
   design et les composants communs.
   ============================================================ */

:root {
    /* Fonds et surfaces */
    --papier: #F6F6F3;          /* fond de page */
    --surface: #FFFFFF;         /* cartes, tableaux, formulaires */
    --surface-2: #FAFAF8;       /* fonds doux, en-têtes de tableau */
    --bandeau: #17191E;         /* barre de navigation, toujours sombre */

    /* Textes : deux niveaux, contrastes conformes RGAA */
    --encre: #1B1D22;
    --texte: #1B1D22;
    --texte-2: #5C5B55;

    /* Traits */
    --ligne: #E4E3DD;
    --ligne-forte: #C9C8C0;

    /* Marque */
    --antenne: #C8102E;
    --acier: #2E4A62;
    --degrade-rmc: linear-gradient(100deg, #00C389 0%, #2E7CF6 30%, #9C4DF4 55%, #F5478C 80%, #FF9E4D 100%);
    --focus: #2E7CF6;
    --blanc: #FFFFFF;

    /* États : un sens, une couleur */
    --ok: #1E7A3B;         --ok-fond: #E7F4EC;
    --attention: #9A5B08;  --attention-fond: #FBEFCF;  --attention-bord: #E6A23C;
    --erreur: #A61B1B;     --erreur-fond: #FBE7E5;     --erreur-bord: #F0BCBC;

    /* Chaînes : valeurs officielles des logos */
    --decouverte: #0068F8;
    --story: #F0500F;
    --story-degrade: linear-gradient(100deg, #F86800, #F81068);
    --life: #C00880;
    --succes: var(--ok); /* alias : la variable était invoquée sans exister */

    /* Échelles */
    --r-s: 4px; --r-m: 8px; --r-l: 12px; --r-pilule: 999px;
    --ombre: 0 2px 8px rgba(23, 25, 30, 0.06);
    --ombre-forte: 0 12px 40px rgba(23, 25, 30, 0.2);

    /* Fond des pages standard (couche « Refresh ») : rosé en clair. */
    --fond-standard: #FDF3F4;

    color-scheme: light;
}


/* ------------------------------------------------------------
   Ajustements communs aux deux thèmes
   ------------------------------------------------------------ */

/* Focus clavier visible partout : c'était le grand absent. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible,
[contenteditable]:focus-visible {
    outline: 2px solid var(--focus) !important;
    outline-offset: 2px;
}

/* Le groupe des logos de chaînes garde son fond blanc dans les
   deux thèmes : les logos officiels sont dessinés pour lui. */
.groupe-grilles { background: #FFFFFF; }

/* Bandeau : liseré dégradé RMC+, discret repère de marque. */
.bandeau { border-bottom: 2px solid transparent; border-image: var(--degrade-rmc) 1; }

/* Boutons : états complets, enfin définis. */
button.principal:focus-visible, .bouton.principal:focus-visible { outline-offset: 3px; }
button:disabled, .bouton[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
button.secondaire, .bouton.secondaire {
    background: var(--surface); color: var(--texte); border: 1px solid var(--ligne-forte);
}
button.secondaire:hover, .bouton.secondaire:hover { border-color: var(--texte-2); }

/* Classes employées par le code mais jamais définies jusqu'ici. */
.aucun { color: var(--texte-2); font-style: italic; }
.btn-action, .btn-reactiver, .btn-desactiver {
    font: inherit; font-size: 13px; font-weight: 600;
    padding: 5px 12px; border-radius: var(--r-s); cursor: pointer;
    background: var(--surface); color: var(--texte); border: 1px solid var(--ligne-forte);
}
.btn-reactiver { color: var(--ok); border-color: var(--ok); }
.btn-desactiver { color: var(--erreur); border-color: var(--erreur); }

/* Chiffres alignés dans les tableaux et compteurs. */
table.liste td, .compteur .valeur, .mono { font-variant-numeric: tabular-nums; }




/* Le libellé du groupe des grilles vit sur le fond blanc du
   groupe : sa couleur ne doit dépendre d'aucun thème. */
.groupe-grilles .libelle-grilles { color: #4A4D53; }

/* ============================================================
   v2.2 · Accueil : mise au niveau des maquettes validées
   Aucun changement de gabarit HTML : uniquement la présentation.
   ============================================================ */

/* ---- Bandeau d'échéance : carte claire, liseré dégradé RMC+ ---- */
.ac-echeance {
    position: relative;
    background: var(--surface);
    color: var(--texte);
    border: 1px solid var(--ligne);
    border-radius: var(--r-l);
    box-shadow: var(--ombre);
    padding: 14px 18px 14px 24px;
    overflow: hidden;
}
.ac-echeance::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
    background: var(--degrade-rmc);
}
.ac-echeance.ac-urgent { background: var(--surface); }
.ac-echeance.ac-urgent::before { background: var(--erreur); }
.ac-echeance-mot { background: var(--encre); color: var(--papier); }
.ac-echeance-reste {
    font-weight: 600; opacity: 1;
    background: var(--attention-fond); color: var(--attention);
    border-radius: var(--r-pilule); padding: 4px 13px;
}
.ac-echeance.ac-urgent .ac-echeance-reste { background: var(--erreur-fond); color: var(--erreur); }
.ac-echeance-lien {
    background: var(--encre); color: var(--papier);
    border: none; border-radius: var(--r-m);
}
.ac-echeance-lien:hover { background: var(--encre); filter: brightness(1.35); }
.ac-echeance-puis { color: var(--texte-2); border-left-color: var(--ligne-forte); }
.ac-echeance-puis b { color: var(--texte); }
.ac-echeance-j2 { opacity: 1; color: var(--texte-2); }

/* ---- Têtes de section : petites capitales, sous-titre intégré ---- */
/* Gamme du 6 septembre : les têtes de widget sont des titres de bloc
   comme partout (Unbounded 17, règle h2 de style.css), plus des petites
   capitales grises. */
main .ac-tete h2, main .widget h2 {
    font-size: var(--t-titre-bloc, 17px);
    font-weight: 800;
    font-stretch: 100%;
    text-transform: none;
    letter-spacing: -.005em;
    color: var(--texte);
}
main .widget-sous { margin-top: 3px; }

/* ---- Cartes : une seule famille ---- */
main .ac-bloc, main .widget { box-shadow: var(--ombre); border-radius: var(--r-l); }

/* ---- Prime du soir : barre de chaîne en tête, carte claire ---- */
.ac-soiree {
    background: var(--surface);
    border: 1px solid var(--ligne);
    border-top: 4px solid var(--texte-2);
    border-radius: var(--r-l);
}
.ac-soiree.decouverte { border-top-color: var(--decouverte); }
.ac-soiree.story { border-top-color: var(--story); }
.ac-soiree.life { border-top-color: var(--life); }
.ac-soiree .ac-soiree-tete {
    background: transparent;
    color: var(--texte-2);
    padding: 11px 13px 0;
    font-size: 11px;
    letter-spacing: .07em;
}
.ac-soiree.decouverte .ac-soiree-tete { background: transparent; color: var(--decouverte); }
.ac-soiree.story .ac-soiree-tete { background: transparent; color: var(--story); }
.ac-soiree.life .ac-soiree-tete { background: transparent; color: var(--life); }
.ac-soiree .ac-soiree-tete img {
    background: var(--surface-2);
    border: 1px solid var(--ligne);
}
.ac-soiree-corps { padding-top: 9px; }
.ac-prog-titre { font-size: 16px; }
.ac-inedit { background: var(--antenne); }

/* ---- Audiences : chiffres en chasse fixe, couleurs officielles ---- */
.aud-carte { background: var(--surface); }
.aud-carte .aud-pda {
    font-family: 'IBM Plex Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-stretch: normal;
    font-size: 26px;
}
.aud-carte.decouverte, .aud-carte.story, .aud-carte.life { border-color: var(--ligne); }
.aud-carte.decouverte .aud-chaine, .aud-carte.decouverte .aud-pda { color: var(--decouverte); }
.aud-carte.story .aud-chaine, .aud-carte.story .aud-pda { color: var(--story); }
.aud-carte.life .aud-chaine, .aud-carte.life .aud-pda { color: var(--life); }
.aud-carte.decouverte .aud-logo, .aud-carte.story .aud-logo, .aud-carte.life .aud-logo {
    background: var(--surface-2); border: none;
}
.aud-carte .aud-record {
    background: var(--degrade-rmc); color: #FFFFFF; border: none;
}
.aud-jauge { background: var(--surface-2); border: 1px solid var(--ligne); }
.aud-jauge-repere { background: var(--texte); opacity: .5; }
.aud-jauge-barre.bas { background: var(--erreur); }
.aud-mouv-pda, .aud-pt {
    font-family: 'IBM Plex Mono', monospace;
    font-variant-numeric: tabular-nums;
}
.aud-pt.haut { color: var(--ok); }
.aud-pt.bas { color: var(--erreur); }

/* ---- Tableau des prime times ---- */
.aud-tableau th {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--texte-2);
    background: var(--surface-2);
}

/* Finitions accueil */
.ac-lien { color: var(--focus); }
.aud-mouv-chiffres { display: inline-flex; gap: 8px; align-items: baseline; }
body .bandeau .groupe-grilles .libelle-grilles { color: #4A4D53; }


/* ------------------------------------------------------------
   v2.5 · Notifications communes (remplacent les alert() natifs)
   ------------------------------------------------------------ */
#ui-toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 36px));
}
.ui-toast {
    background: var(--encre);
    color: var(--papier);
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 13px;
    line-height: 1.45;
    font-weight: 600;
    box-shadow: var(--ombre-forte);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .22s cubic-bezier(.16, 1, .3, 1), transform .22s cubic-bezier(.16, 1, .3, 1);
    cursor: pointer;
}
.ui-toast.visible { opacity: 1; transform: none; }
.ui-toast.ok { background: var(--ok); color: #FFFFFF; }
.ui-toast.erreur { background: var(--erreur); color: #FFFFFF; }
@media (prefers-reduced-motion: reduce) { .ui-toast { transition: opacity .15s; transform: none; } }
@media print { #ui-toasts { display: none; } }


/* Retour visuel d'enregistrement, case par case (bulletin, veille). */
.case-enregistree { box-shadow: inset 0 0 0 2px var(--ok) !important; }
.case-echec { box-shadow: inset 0 0 0 2px var(--erreur) !important; }


/* ------------------------------------------------------------
   v2.6 · Palette « Aller à » (Ctrl K)
   ------------------------------------------------------------ */
.bouton-palette {
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--r-pilule);
    padding: 6px 14px;
    cursor: pointer;
    white-space: nowrap;
}
.bouton-palette:hover { background: rgba(255, 255, 255, 0.2); color: #FFFFFF; }
.bouton-palette kbd {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10.5px;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 4px;
    padding: 1px 5px;
}
/* Le « display: flex » ci-dessous l'emportait sur l'attribut hidden :
   une fois la palette fermée, son voile restait étendu sur toute la
   page et interceptait les clics. Toutes les autres fenêtres du site
   déclarent cette règle (grilles_fiche.css, grille2.css, …) ; la
   palette l'avait oubliée. Trouvé le 24 août par le contrôle au
   navigateur, avant livraison. */
.palette-voile[hidden] { display: none; }
.palette-voile {
    position: fixed;
    inset: 0;
    z-index: 11000;
    background: rgba(20, 21, 25, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 20px 20px;
}
.palette-boite {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border: 1px solid var(--ligne);
    border-radius: var(--r-l);
    box-shadow: var(--ombre-forte);
    overflow: hidden;
}
.palette-champ {
    width: 100%;
    font: inherit;
    font-size: 14px;
    padding: 14px 18px;
    border: none;
    border-bottom: 1px solid var(--ligne);
    background: var(--surface);
    color: var(--texte);
}
.palette-champ:focus { outline: none; }
.palette-liste { list-style: none; margin: 0; padding: 6px; max-height: 46vh; overflow: auto; }
.palette-liste li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.palette-liste li:hover, .palette-liste li.actif {
    background: color-mix(in srgb, var(--focus) 9%, var(--surface));
}
.palette-libelle { font-weight: 600; }
.palette-detail { margin-left: auto; font-size: 11px; color: var(--texte-2); }
@media print { .palette-voile, .bouton-palette { display: none; } }
