/*
 * Lisibilité et accessibilité, communes à toutes les pages publiques.
 * Chargée après le thème, le thème sombre et les feuilles de page : elle ne pose que des
 * correctifs ciblés (focus, contrastes, bandeau cookies, formulaire, navigation).
 *
 * Les couleurs passent par des variables : un seul jeu pour le clair, un seul pour le sombre.
 * Le thème sombre est un bloc `prefers-color-scheme` ; site-theme.js réécrit sa condition quand
 * le visiteur force « clair » ou « sombre » (panneau Affichage), y compris dans cette feuille.
 */

:root {
    --a11y-ring: #303f9f;
    --a11y-ink: #141414;
    --a11y-muted: #4a5578;
    --a11y-line: rgba(48, 63, 159, 0.28);
    --a11y-panel: #ffffff;
    --a11y-bar: rgba(255, 255, 255, 0.92);
    --a11y-accent-bg: #303f9f;
    --a11y-accent-fg: #ffffff;
    --a11y-danger: #c0182b;
    --a11y-tuile: #e8f0ff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --a11y-ring: #9fc0ff;
        --a11y-ink: #f4f6ff;
        --a11y-muted: #a8b1e0;
        --a11y-line: rgba(150, 168, 255, 0.4);
        --a11y-panel: #161e4a;
        --a11y-bar: rgba(13, 19, 51, 0.92);
        --a11y-accent-bg: #9fc0ff;
        --a11y-accent-fg: #0d1333;
        --a11y-danger: #ff6b7d;
    }
}

/* ---- Focus clavier visible, partout (A4) ---- */

/* Anneau de 3 px, au moins 3:1 sur le fond de chaque thème ; important : les feuilles de page posaient
   des anneaux de 1 à 2 px en bleu de marque, à 2:1 sur fond sombre. Le décalage n'est pas important,
   pour que l'animation `is-focus-glitch` puisse le faire vibrer. */
html body :focus-visible {
    outline: 3px solid var(--a11y-ring) !important;
    outline-offset: 3px;
}

/* La cible du lien d'évitement reçoit le focus par programme : pas d'anneau autour de toute la page. */
html body #main:focus,
html body #main:focus-visible {
    outline: none !important;
}

/* Une tuile entière est cliquable : l'anneau l'entoure, pas seulement son titre. */
html body .pv2-tuile:has(:focus-visible) {
    outline: 3px solid var(--a11y-ring);
    outline-offset: 3px;
}

/* Court effet glitch sur l'élément qui prend le focus au clavier (site-a11y.js, 420 ms). */
@keyframes a11y-focus-glitch {
    0% { outline-offset: 9px; text-shadow: 3px 0 var(--a11y-ring), -3px 0 var(--a11y-ink); }
    30% { outline-offset: 1px; text-shadow: -2px 0 var(--a11y-ring), 2px 0 var(--a11y-ink); }
    60% { outline-offset: 6px; text-shadow: 1px 0 var(--a11y-ring); }
    100% { outline-offset: 3px; text-shadow: none; }
}

html body .is-focus-glitch:focus-visible {
    animation: a11y-focus-glitch 0.42s steps(7, end) 1;
}

@media (prefers-reduced-motion: reduce) {
    html:not([data-glitch='on']) body .is-focus-glitch:focus-visible {
        animation: none;
    }
}

html[data-glitch='off'] body .is-focus-glitch:focus-visible {
    animation: none;
}

/* ---- Lien d'évitement ---- */

a.skip-link {
    position: fixed;
    left: 12px;
    top: 0;
    z-index: 400;
    transform: translateY(-140%);
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--a11y-accent-bg);
    color: var(--a11y-accent-fg);
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
}

a.skip-link:hover {
    color: var(--a11y-accent-fg);
}

a.skip-link:focus {
    transform: translateY(12px);
}

/* ---- Titres et étiquettes des tuiles du Mur : toujours clairs, fond toujours sombre (A1) ---- */

/* Le voile des tuiles reste bleu nuit dans les deux thèmes ; le titre héritait du texte sombre du
   thème clair (glitche-basic.css : h1…h6 en #141414), soit 1,01:1 sur ce fond. */
.pv2-tuile .pv2-nom,
.pv2-tuile .pv2-nom a,
.pv2-tuile .pv2-lien,
.pv2-tuile .pv-cat,
.pv2-tuile .pv2-desc,
.pv2-tuile .pv2-coin,
.pv2-tuile a.pv-tag,
.pv2-tuile .pv-tag {
    color: var(--a11y-tuile);
}

/* Voile plus dense sous le texte : 7:1 au moins, même devant une capture presque blanche. Seuls les
   56 px de marge haute se fondent dans l'image. */
.pv2-tuile .pv2-voile {
    background: linear-gradient(to top, rgba(10, 16, 48, 0.97) 0%, rgba(10, 16, 48, 0.95) calc(100% - 56px), rgba(10, 16, 48, 0) 100%);
}

/* Étiquettes : fond quasi opaque, pour tenir 7:1 même sur une capture claire. */
.pv2-tuile .pv-tag,
.pv2-etiquettes .pv-tag {
    border-color: rgba(232, 240, 255, 0.55);
    background: rgba(10, 16, 48, 0.94);
}

/* ---- Sélecteur de langue : la langue inactive reste lisible (A5) ---- */

.locale-flag {
    color: var(--a11y-muted);
}

.locale-flag:hover,
.locale-flag.is-active {
    color: var(--a11y-ink);
}

/* ---- Hero : ligne statique, toujours visible (B1) ---- */

.section.started .started-content .h-status {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.02em;
    color: var(--a11y-ink);
    margin: 0 auto 10px;
    max-width: 64ch;
    text-wrap: balance;
}

/* ---- Bandeau cookies compact (A2) ---- */

.cookie-consent {
    padding: 0;
}

.cookie-consent .cookie-consent__inner {
    max-width: none;
    margin: 0;
    padding: 10px 16px;
    gap: 8px 20px;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    border-width: 1px 0 0;
    border-radius: 0;
}

/* Le titre reste pour les lecteurs d'écran (aria-labelledby), mais ne prend plus de place. */
.cookie-consent .cookie-consent__heading {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.cookie-consent .cookie-consent__text {
    flex: 0 1 44rem;
    font-size: 14px;
    line-height: 1.4;
}

.cookie-consent .cookie-consent__actions {
    flex-wrap: nowrap;
}

.cookie-consent .cookie-consent__actions .btn {
    height: 40px;
    min-width: 88px;
    margin: 0;
    padding: 0 16px;
    line-height: 38px;
    font-size: 14px;
}

@media (max-width: 640px) {
    .cookie-consent .cookie-consent__inner {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }

    .cookie-consent .cookie-consent__text {
        flex: 0 0 auto;
    }

    .cookie-consent .cookie-consent__actions {
        justify-content: flex-end;
    }

    .cookie-consent .cookie-consent__actions .btn {
        flex: 1 1 0;
    }
}

/* Lien « Cookies » du pied de page, et réglage des effets : de simples boutons-liens. */
button.site-footer__glitch {
    display: inline-flex;
    align-items: center;
    width: auto;
    height: auto;
    min-height: 40px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ---- Formulaire de contact : erreurs par champ, en rouge de la charte (B2) ---- */

.contact-field.is-invalide > span:first-child {
    color: var(--a11y-danger);
}

.contact-field.is-invalide :is(input, textarea) {
    border-color: var(--a11y-danger);
    box-shadow: 0 0 0 1px var(--a11y-danger);
}

.contact-erreur {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--a11y-danger);
}

.contact-erreur::before {
    content: '> ERR ' / '';
    opacity: 0.8;
}

.contact-feedback--error {
    border: 1px solid var(--a11y-danger);
}

/* ---- Bouton Affichage (A9) ---- */

.display-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.display-menu[hidden] {
    display: none;
}

button.display-menu__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    height: 36px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--a11y-line);
    border-radius: 999px;
    background: var(--a11y-bar);
    color: var(--a11y-ink);
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

button.display-menu__toggle:hover {
    border-color: var(--a11y-ring);
}

.display-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 140;
    width: min(320px, calc(100vw - 24px));
    padding: 14px;
    border: 1px solid var(--a11y-line);
    border-radius: 12px;
    background: var(--a11y-panel);
    box-shadow: 0 12px 32px rgba(10, 16, 48, 0.25);
    text-align: left;
}

.display-menu__panel[hidden] {
    display: none;
}

.display-menu .display-menu__title {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--a11y-ink);
}

.display-menu__row + .display-menu__row {
    margin-top: 12px;
}

.display-menu__choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

button.display-menu__choice {
    width: auto;
    height: 40px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--a11y-line);
    border-radius: 8px;
    background: transparent;
    color: var(--a11y-ink);
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    cursor: pointer;
}

button.display-menu__choice[aria-pressed='true'] {
    border-color: transparent;
    background: var(--a11y-accent-bg);
    color: var(--a11y-accent-fg);
}

/* ---- Barre de navigation commune à toutes les pages publiques (B3) ---- */

.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    background: var(--a11y-bar);
    border-bottom: 1px solid var(--a11y-line);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.site-nav__links {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav__links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--a11y-ink);
    text-decoration: none;
}

.site-nav__links a:hover {
    color: var(--a11y-ring);
    text-decoration: underline;
    text-underline-offset: 6px;
}

.site-nav__end {
    display: flex;
    align-items: center;
    gap: 8px;
}

.site-nav .btn.site-nav__cta {
    height: 34px;
    margin: 0;
    padding: 0 16px;
    line-height: 32px;
    font-size: 14px;
    white-space: nowrap;
}

/* Les sections se posent sous la barre, au défilement natif comme au défilement guidé. */
html:has(.site-nav) {
    scroll-padding-top: 52px;
}

@media (max-width: 640px) {
    .site-nav {
        padding: 0 8px;
        gap: 4px;
    }

    .site-nav__links a {
        padding: 0 7px;
        letter-spacing: 0;
    }

    /* Le bouton « Me contacter » tient lieu de lien Contact. */
    .site-nav__contact-link {
        display: none;
    }

    .site-nav__end {
        gap: 4px;
    }

    .site-nav .btn.site-nav__cta {
        padding: 0 10px;
    }

    .site-nav .display-menu__label {
        display: none;
    }

    .site-nav .display-menu__toggle {
        width: 36px;
        padding: 0;
        justify-content: center;
    }
}

@media (max-width: 400px) {
    .site-nav__links a {
        padding: 0 5px;
    }

    .site-nav .btn.site-nav__cta {
        padding: 0 8px;
    }
}

/* ---- Pages d'erreur dans le thème du site (A8) ---- */

.error-page__code {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--a11y-ring);
}

.section.started .started-content .error-page__text {
    max-width: 56ch;
    margin: 0 auto 24px;
    color: var(--a11y-muted);
}

.section.started .started-content .error-page__more {
    margin: 18px 0 0;
}

/* ---- Filtres de projets : quatre puces, elles passent à la ligne plutôt que de défiler (B5) ---- */

html body .project-filters {
    flex-wrap: wrap;
    overflow: visible;
}

/* ---- Impression : rien de tout cela sur papier ---- */

@media print {
    .skip-link,
    .site-nav,
    .display-menu,
    .cookie-consent {
        display: none !important;
    }
}

/* ---- Bandeau « Pour profiter de toute l'expérience » ---- */

.experience-banner {
    position: fixed;
    top: 56px;
    left: 50%;
    z-index: 9000;
    width: min(720px, calc(100vw - 24px));
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid rgba(110, 150, 255, .55);
    border-radius: 10px;
    background: rgba(10, 16, 48, .96);
    color: #e8f0ff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
}

.experience-banner[hidden] { display: none; }
.experience-banner__text { flex: 1 1 320px; min-width: 0; }
.experience-banner__title { margin: 0 0 4px; font-weight: 700; color: #9fc0ff; }
.experience-banner__body { margin: 0; font-size: .875rem; line-height: 1.55; }
.experience-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media print { .experience-banner { display: none !important; } }

/* Pagination : la flèche inactive reste lisible (bleu clair atténué), sans halo ni ombre. */
html body .project-pager__arrow:disabled {
    opacity: .55;
    color: #9fb0e8;
    text-shadow: none;
    filter: none;
    cursor: default;
}

/* Pagination : survol lisible (le texte restait indigo sur fond marine) et pastille voyageuse. */
html body .project-pager__arrow:hover:not(:disabled),
html body .project-pager__arrow:focus-visible:not(:disabled) {
    background: rgba(61, 123, 255, .22);
    border-color: rgba(190, 215, 255, .8);
    color: #ffffff;
}

html body .project-pager__page:hover:not(.is-active) {
    background: rgba(61, 123, 255, .22);
    color: #ffffff;
}

/*
 * Changement de page : la pastille de la page active quitte l'ancien numéro et rejoint le nouveau
 * en glitchant (project-pager.js). Le vrai numéro actif reste masqué pendant le voyage.
 */
html body .project-pager__page.is-arrivee { visibility: hidden; }

.project-pager__ghost {
    position: fixed;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #4c5fd7;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    pointer-events: none;
    will-change: transform, filter;
}

html body .project-pager__bar.is-transfert .project-pager__arrow,
html body .project-pager__bar.is-transfert [data-project-count] {
    animation: pager-glitch .36s steps(1, end) both;
}

@keyframes pager-glitch {
    0%   { transform: translateX(0); filter: none; }
    20%  { transform: translateX(-3px); filter: drop-shadow(3px 0 0 rgba(61, 123, 255, .9)); }
    40%  { transform: translateX(4px); filter: drop-shadow(-3px 0 0 rgba(255, 255, 255, .7)); }
    60%  { transform: translateX(-2px); filter: drop-shadow(2px 0 0 rgba(61, 123, 255, .8)); }
    80%  { transform: translateX(1px); filter: none; }
    100% { transform: none; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
    html body .project-pager__bar.is-transfert .project-pager__arrow,
    html body .project-pager__bar.is-transfert [data-project-count] { animation: none; }
}
