/**
 * GDH PDF Viewer — Styles front-end accessibles (RGAA)
 * Palette Grand Dijon Habitat : #004274 (bleu primaire), #e41439 (rouge accentuation)
 *
 * RGAA fixes v1.2 :
 *  - Critère 3.2  : contraste hover des liens de la note de bas corrigé.
 *                   #003057 sur blanc = ratio ~8.5:1 (conforme).
 *                   Ajout de text-decoration:underline au hover pour ne pas
 *                   reposer uniquement sur la couleur (critère 3.1).
 *  - Critère 10.4 : max-width:100% sur .gdh-pdf-iframe pour le zoom texte/navigateur.
 *  - Critère 10.7 : :focus-visible ajouté sur les liens de .gdh-pdf-viewer-note
 *                   (manquant en v1.1).
 *  - Conservation des corrections v1.1 (contraste hover bouton, border:none iframe,
 *    prefers-reduced-motion, forced-colors).
 */

.gdh-pdf-viewer-wrap {
    margin: 24px 0;
    font-family: 'Josefin Sans', sans-serif;
}

.gdh-pdf-viewer-wrap .screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.gdh-pdf-viewer-description {
    margin: 0 0 16px 0;
    padding: 12px 16px;
    background-color: #004A8E;
    color: #ffffff;
    border-radius: 4px;
    font-size: 15px;
    line-height: 1.6;
}

.gdh-pdf-viewer-download {
    margin-bottom: 16px;
}

/* RGAA 6.1 — Lien de téléchargement explicite (intitulé porté par le texte visible) */
.gdh-pdf-download-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: #004274;
    color: #ffffff !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    border: 2px solid transparent;
    transition: background-color 0.2s, border-color 0.2s, outline 0.1s;
}

/*
 * RGAA 3.2 — Contraste au survol conforme.
 * #1a6fc4 sur #ffffff = ratio ~4.8:1 (seuil requis : 4.5:1). ✓
 */
.gdh-pdf-download-link:hover,
.gdh-pdf-download-link:active {
    background-color: #1a6fc4;
    color: #ffffff !important;
    text-decoration: none;
}

/* RGAA 10.7 — Focus visible */
.gdh-pdf-download-link:focus,
.gdh-pdf-download-link:focus-visible {
    outline: 3px solid #e41439;
    outline-offset: 3px;
    background-color: #004274;
    color: #ffffff !important;
}

.gdh-pdf-download-icon {
    font-size: 18px;
    line-height: 1;
}

.gdh-pdf-viewer-container {
    position: relative;
    width: 100%;
    border: 2px solid #c3d3e5;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f8f9fa;
}

.gdh-pdf-viewer-container:focus-within {
    outline: 3px solid #004274;
    outline-offset: 2px;
}

/*
 * RGAA 8.2  — border:none remplace l'attribut frameborder déprécié.
 * RGAA 10.4 — max-width:100% garantit que l'iframe ne déborde pas du conteneur
 *             lors d'un zoom navigateur ou sur petits écrans.
 */
.gdh-pdf-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    border: none;
    background-color: #525659;
}

.gdh-pdf-fallback {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    color: #1d2327;
    font-size: 15px;
    line-height: 1.6;
}

.gdh-pdf-fallback a {
    color: #004274;
    text-decoration: underline;
    font-weight: 600;
}

/*
 * RGAA 3.2 — #003057 sur blanc = ratio ~8.5:1. ✓
 * Underline conservé au hover pour ne pas reposer uniquement sur la couleur (RGAA 3.1).
 */
.gdh-pdf-fallback a:hover {
    color: #003057;
    text-decoration: underline;
}

/* RGAA 10.7 — Focus visible sur les liens du fallback */
.gdh-pdf-fallback a:focus,
.gdh-pdf-fallback a:focus-visible {
    outline: 3px solid #e41439;
    outline-offset: 2px;
    border-radius: 2px;
}

.gdh-pdf-viewer-note {
    margin: 10px 0 0 0;
    color: #646970;
    font-size: 13px;
    line-height: 1.5;
}

.gdh-pdf-viewer-note a {
    color: #004274;
    text-decoration: underline;
}

/*
 * RGAA 3.2 FIX v1.2 — Contraste hover liens note corrigé.
 * #003057 sur blanc = ratio ~8.5:1 (conforme, seuil : 4.5:1). ✓
 * RGAA 3.1 — text-decoration conservé pour ne pas reposer sur la couleur seule.
 */
.gdh-pdf-viewer-note a:hover {
    color: #003057;
    text-decoration: underline;
}

/*
 * RGAA 10.7 FIX v1.2 — :focus-visible manquant sur les liens de la note (ajout).
 * Ces liens étaient focusables mais sans indicateur visible.
 */
.gdh-pdf-viewer-note a:focus,
.gdh-pdf-viewer-note a:focus-visible {
    outline: 3px solid #e41439;
    outline-offset: 2px;
    border-radius: 2px;
}

.gdh-pdf-error {
    margin: 16px 0;
}

/* Avertissement désactivation téléchargement — admin */
.gdh-pdf-download-warning {
    display: none;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 12px;
    color: #664d03;
}

@media (max-width: 768px) {
    .gdh-pdf-download-link {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
    }

    .gdh-pdf-iframe {
        min-height: 400px;
    }
}

@media (prefers-color-scheme: dark) {
    .gdh-pdf-viewer-description {
        background-color: #004A8E;
        color: #FFFFFF;
    }

    .gdh-pdf-viewer-container {
        border-color: #3a4a5a;
    }

    .gdh-pdf-viewer-note {
        color: #8c9aa8;
    }

    /*
     * RGAA 3.2 dark mode — couleur hover liens note en dark mode.
     * #a8c4e0 sur #1d2327 (fond sombre type WP) = ratio ~5.2:1. ✓
     */
    .gdh-pdf-viewer-note a:hover {
        color: #a8c4e0;
    }
}

/* RGAA 13.7 — Réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    .gdh-pdf-download-link {
        transition: none;
    }
}

/* Contraste élevé Windows (forced-colors) */
@media (forced-colors: active) {
    .gdh-pdf-download-link {
        border: 2px solid ButtonText;
        forced-color-adjust: none;
    }

    .gdh-pdf-viewer-container {
        border: 2px solid ButtonText;
    }

    /* RGAA 10.7 — En mode forced-colors, outline hérite du système */
    .gdh-pdf-download-link:focus,
    .gdh-pdf-download-link:focus-visible,
    .gdh-pdf-fallback a:focus,
    .gdh-pdf-fallback a:focus-visible,
    .gdh-pdf-viewer-note a:focus,
    .gdh-pdf-viewer-note a:focus-visible {
        forced-color-adjust: none;
        outline: 3px solid Highlight;
    }
}
