/*
 * Bandeau supérieur commun aux applications du CdC (voir docs/bandeau-commun.md).
 * Fichier unique dans cdcapps/Commun, chargé par chaque module : ne dépend d'aucune autre feuille de style.
 * Thème sombre : attribut data-theme="dark" sur <html>, ou thème du système si l'attribut est absent
 * (data-theme="light" force le clair). Thèmes daltonien et pride : css/cdc-themes.css.
 */
.cdc-header {
    --cdc-header-bg: #2f2f33;
    --cdc-header-fg: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    padding: 0.5rem 1.2rem;
    background: var(--cdc-header-bg);
    color: var(--cdc-header-fg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
}
:root[data-theme="dark"] .cdc-header { --cdc-header-bg: #0e0e10; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .cdc-header { --cdc-header-bg: #0e0e10; }
}
.cdc-header a { color: inherit; }

.cdc-header-left,
.cdc-header-right,
.cdc-header-links { display: flex; align-items: center; flex-wrap: wrap; }
.cdc-header-left { gap: 0.4rem 1rem; min-width: 0; }
.cdc-header-right { gap: 0.6rem; margin-left: auto; }
.cdc-header-links { gap: 0.2rem 1rem; }

.cdc-header-brand { font-weight: 700; text-decoration: none; white-space: nowrap; }
.cdc-header-logo { height: 1.75rem; width: auto; max-width: 8rem; margin-right: 0.55rem; object-fit: contain; vertical-align: middle; }
.cdc-header-version { margin-left: 0.3rem; font-size: 0.65rem; font-weight: 400; opacity: 0.7; }

/* Instance de test (CdcCommun\Instance) : mention « TEST » rouge et liseré hachuré rouge sous le bandeau. */
.cdc-header[data-instance="test"] {
    border-bottom: 4px solid #dc2626;
    border-image: repeating-linear-gradient(-45deg, #dc2626 0 10px, #fbbf24 10px 20px) 4;
}
.cdc-header-test {
    padding: 0.05rem 0.5rem;
    border-radius: 0.3rem;
    background: #dc2626;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    white-space: nowrap;
    cursor: help;
}

/* Fines barres blanches entre le nom, les liens et le complément. */
.cdc-header-links,
.cdc-header-extra { padding-left: 1rem; border-left: 1px solid rgba(255, 255, 255, 0.6); }
.cdc-header-links a { text-decoration: none; opacity: 0.85; }
.cdc-header-links a:hover { opacity: 1; }
.cdc-header-links a[aria-current="page"] { opacity: 1; text-decoration: underline; }
.cdc-header-extra { font-size: 0.75rem; opacity: 0.7; }

/* Liste déroulante (ex. « Administration ») : liens sous le bandeau, aux couleurs du bandeau. */
.cdc-header-menu { position: relative; }
.cdc-header-menu summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    cursor: pointer;
    opacity: 0.85;
}
.cdc-header-menu summary::-webkit-details-marker { display: none; }
.cdc-header-menu summary:hover,
.cdc-header-menu[open] summary { opacity: 1; }
.cdc-header-menu summary[aria-current="page"] { opacity: 1; text-decoration: underline; }
.cdc-header-menu[open] summary svg { transform: rotate(180deg); }
.cdc-header-menu-list {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: -0.6rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    min-width: 13rem;
    padding: 0.35rem;
    border-radius: 0 0 0.5rem 0.5rem;
    background: var(--cdc-header-bg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.cdc-header-menu-list a {
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    text-decoration: none;
    white-space: nowrap;
    opacity: 0.9;
}
.cdc-header-menu-list a:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.cdc-header-menu-list a[aria-current="page"] { opacity: 1; font-weight: 600; background: rgba(255, 255, 255, 0.08); }

.cdc-header-user { text-decoration: none; opacity: 0.85; white-space: nowrap; }
.cdc-header-user:hover { opacity: 1; text-decoration: underline; }

.cdc-header-form { display: inline-flex; margin: 0; }
.cdc-header .cdc-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: inherit;
    box-shadow: none;
    cursor: pointer;
    opacity: 0.85;
}
.cdc-header .cdc-header-icon:hover,
.cdc-header .cdc-header-icon:focus-visible { opacity: 1; background: rgba(255, 255, 255, 0.15); }
.cdc-header-icon svg { display: block; }

/* Alerte météo (bandeau avec « meteo ») : pluie jaune ou rouge, toujours bien visible. */
.cdc-header .cdc-header-meteo, .cdc-header .cdc-header-chaleur { opacity: 1; }
.cdc-header .cdc-header-meteo[data-niveau="jaune"], .cdc-header .cdc-header-chaleur[data-niveau="jaune"] { color: #facc15; background: rgba(250, 204, 21, 0.18); }
.cdc-header .cdc-header-meteo[data-niveau="rouge"], .cdc-header .cdc-header-chaleur[data-niveau="rouge"] { color: #fff; background: #dc2626; }

/* Icône du thème : celle du thème suivant (data-suivant, voir js/cdc-header.js) — soleil (normal), lune (sombre),
   lunettes rouge / vert (daltonien), drapeau arc-en-ciel (pride), drapeau suisse (1er août). */
.cdc-header .cdc-header-icon[hidden] { display: none; }
.cdc-header-theme svg { display: none; }
.cdc-header-theme[data-suivant="light"] .cdc-i-sun,
.cdc-header-theme[data-suivant="dark"] .cdc-i-moon,
.cdc-header-theme[data-suivant="daltonien"] .cdc-i-daltonien,
.cdc-header-theme[data-suivant="pride"] .cdc-i-pride,
.cdc-header-theme[data-suivant="suisse"] .cdc-i-suisse { display: block; }

/* Textes d'aide (classe cdc-aide) : masqués d'un coup par le bouton « ? » du bandeau (data-aide="masquee"). */
html:has(.cdc-header[data-aide="masquee"]) .cdc-aide { display: none !important; }
/* Icône « ? » barrée quand les textes d'aide sont masqués. */
.cdc-header-aide .cdc-i-barre { display: none; }
.cdc-header-aide[aria-pressed="false"] .cdc-i-barre { display: inline; }

@media print {
    .cdc-header { display: none !important; }
}

/* Pages d'erreur communes (templates/erreur.php) : code HTTP discret au-dessus du titre. */
.cdc-erreur-statut { margin: 0 0 0.25rem; font-size: 0.9em; opacity: 0.7; }
