/**
 * Accès Rapide - Styles CSS
 * Architecture responsive MOBILE-FIRST avec variables CSS
 * Compatible RGAA 4.1 et accessibilité
 *
 * @package Astra Child RGAA
 * @since 1.0.0
 */

/* ================================================
   VARIABLES CSS
   ================================================ */

:root {
    /* Couleurs (définies dynamiquement par PHP, valeurs par défaut ici) */
    --acces-rapide-bg: #3b82f6;
    --acces-rapide-hover: #2563eb;
    --acces-rapide-text: #ffffff;

    /* Espacements */
    --acces-rapide-spacing: 0.75rem;

    /* Transitions */
    --acces-rapide-transition: 0.3s ease;

    /* Z-index */
    --acces-rapide-z-index: 98;
}

/* ================================================
   SKIP LINK (Accessibilité)
   ================================================ */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--acces-rapide-bg);
    color: var(--acces-rapide-text);
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: 600;
    transition: top var(--acces-rapide-transition);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--acces-rapide-hover);
    outline-offset: 2px;
}

/* ================================================
   BASE MOBILE - STYLES PAR DÉFAUT
   ================================================ */

/* Masquer la version desktop sur mobile */
.acces-rapide--desktop {
    display: none;
}

/* Navigation mobile : barre fixe en bas du viewport */
.acces-rapide__nav,
.acces-rapide--desktop .acces-rapide__nav,
.acces-rapide--horizontal .acces-rapide__panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-start;
    gap: 4px;
    padding: 8px;
    background-color: var(--acces-rapide-menu-bg);
    z-index: var(--acces-rapide-z-index);
}

/* État ouvert sur mobile (toujours visible) */
.acces-rapide--horizontal .acces-rapide__panel {
    opacity: 1;
    transform: none;
    pointer-events: all;
}

/* Masquer le trigger horizontal sur mobile */
.acces-rapide--horizontal .acces-rapide__trigger {
    display: none;
}

/* Items : colonne avec icône + label */
.acces-rapide__item,
.acces-rapide--desktop .acces-rapide__item,
.acces-rapide--horizontal .acces-rapide__item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    min-width: 48px;
    min-height: 48px;
    background-color: var(--acces-rapide-bg);
    color: var(--acces-rapide-text);
    text-decoration: none;
    border-radius: 0;
    cursor: pointer;
    transition: all var(--acces-rapide-transition);
}

.acces-rapide__item:hover,
.acces-rapide__item:focus-visible {
    background-color: var(--acces-rapide-hover);
}

.acces-rapide__item:focus-visible {
    outline: 3px solid var(--acces-rapide-text);
    outline-offset: 2px;
}

.acces-rapide__item:active {
    transform: scale(0.98);
}

/* Icônes mobile : 100% avec max 48px */
.acces-rapide__icon,
.acces-rapide--desktop .acces-rapide__icon,
.acces-rapide--horizontal .acces-rapide__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    max-width: 48px;
    aspect-ratio: 1;
    flex-shrink: 0;
}

.acces-rapide__icon svg,
.acces-rapide__icon img {
    width: 100%;
    height: 100%;
    fill: currentColor;
    object-fit: contain;
}

.acces-rapide__icon img {
    filter: brightness(0) invert(1);
}

.acces-rapide__icon--placeholder {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Labels mobile */
.acces-rapide__label,
.acces-rapide--desktop .acces-rapide__label,
.acces-rapide--horizontal .acces-rapide__label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    margin-top: 4px;
    flex-shrink: 0;
}

/* Masquer l'ancien système mobile */
.acces-rapide--mobile .acces-rapide__label {
    display: none;
}

/* ================================================
   ANIMATIONS
   ================================================ */

@keyframes slideInRight {
    from {
        transform: translateX(100%) translateY(-50%);
        opacity: 0;
    }
    to {
        transform: translateX(0) translateY(-50%);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%) translateY(-50%);
        opacity: 0;
    }
    to {
        transform: translateX(0) translateY(-50%);
        opacity: 1;
    }
}

@keyframes slideInBottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ================================================
   TABLET & DESKTOP (min-width: 769px)
   ================================================ */

@media (min-width: 769px) {
    /* Masquer le système mobile, afficher le desktop */
    .acces-rapide--mobile {
        display: none;
    }

    .acces-rapide--desktop,
    .acces-rapide--horizontal {
        display: block;
    }
    body.search .acces-rapide__trigger,
    body.category .acces-rapide__trigger {
        display: none;
    }

    /* VERSION VERTICALE : Menu latéral en position absolute */
    .acces-rapide--desktop .acces-rapide__nav {
        position: absolute;
        top: 50%;
        bottom: auto;
        left: auto;
        right: auto;
        transform: translateY(-50%);
        flex-direction: column;
        align-items: center;
        gap: var(--acces-rapide-spacing);
        padding: 0;
        max-width: 100px;
        box-shadow: none;
    }

    .acces-rapide--desktop.acces-rapide--left .acces-rapide__nav {
        left: 0;
        animation: slideInLeft 0.5s ease-out;
    }

    .acces-rapide--desktop.acces-rapide--right .acces-rapide__nav {
        right: 0;
        animation: slideInRight 0.5s ease-out;
    }

    .acces-rapide--desktop .acces-rapide__item {
        flex: none;
        flex-direction: column;
        min-width: 100px;
        padding: 1rem;
        gap: 0.5rem;
        text-align: center;
    }

    .acces-rapide--desktop .acces-rapide__icon {
        width: 24px;
        height: 24px;
        max-width: none;
    }

    .acces-rapide--desktop .acces-rapide__label {
        font-size: 0.875rem;
        margin-top: 0;
    }

    /* VERSION HORIZONTALE : Conteneur positionné pour référence */
    .acces-rapide--horizontal {
        position: absolute;
        top: 24vh;
        left: 0;
        transform: translateY(-50%);
        z-index: var(--acces-rapide-z-index);
    }

    /* Bouton trigger en relative dans son conteneur */
    .acces-rapide--horizontal .acces-rapide__trigger {
        display: flex;
        position: relative;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100px;
        height: 100px;
        padding: 12px;
        gap: 4px;
        background: var(--acces-rapide-bg);
        border: none;
        border-radius: 0;
        cursor: pointer;
        transition: all var(--acces-rapide-transition);
        z-index: 2;
    }

    .acces-rapide__trigger:focus {
        background: var(--acces-rapide-bg) !important;
    }

    .acces-rapide__trigger:focus-visible {
        background: var(--acces-rapide-hover);
        outline: 3px solid var(--acces-rapide-text);
        outline-offset: 2px;
    }

    /* Image du bouton trigger */
    .acces-rapide__trigger-image {
        display: block;
        width: 100%;
        height: 100%;
    }

    .acces-rapide__trigger-image svg,
    .acces-rapide__trigger-image img {
        width: 100%;
        height: 100%;
        object-fit: contain !important;
        display: block;
    }

    /* Panel horizontal : masqué par défaut, s'ouvre à droite du trigger */
    .acces-rapide--horizontal .acces-rapide__panel {
        position: absolute;
        top: 0;
        left: 100%;
        transform: translateX(-20px);
        width: auto;
        height: 100px;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 0;
        opacity: 0;
        pointer-events: none;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1;
    }

    /* État ouvert */
    .acces-rapide--horizontal[aria-expanded="true"] .acces-rapide__panel,
    .acces-rapide--horizontal.is-open .acces-rapide__panel {
        opacity: 1;
        transform: translateX(0);
        pointer-events: all;
    }

    .acces-rapide--horizontal .acces-rapide__item {
        flex-direction: column;
        min-width: 90px;
        padding: 0.75em 0.75em 0.65em;
        gap: 8px;
    }

    .acces-rapide--horizontal .acces-rapide__item:hover {
        background: #003b48;
        color: #fff;
    }

    .acces-rapide--horizontal .acces-rapide__item:focus {
        color: #fff;
        outline: none;
    }

    .acces-rapide--horizontal .acces-rapide__item:focus-visible {
        outline: 3px solid var(--acces-rapide-bg);
        color: #fff;
        outline-offset: 2px;
    }

    .acces-rapide--horizontal .acces-rapide__icon {
        width: var(--icon-size, 32px);
        height: var(--icon-size, 32px);
        max-width: none;
        aspect-ratio: auto;
    }

    .acces-rapide--horizontal .acces-rapide__label {
        font-size: 12px;
        font-weight: 600;
        max-width: 80px;
        margin-top: 0;
    }
}

/* ================================================
   DESKTOP  (min-width: 1024px)
   ================================================ */

@media (min-width: 1024px) {
    .acces-rapide--horizontal {
        top: 50vh;
    }
}

/* ================================================
   DESKTOP LARGE (min-width: 1440px)
   ================================================ */

@media (min-width: 1440px) {
    .acces-rapide--desktop .acces-rapide__icon {
        width: 28px;
        height: 28px;
    }

    .acces-rapide--desktop .acces-rapide__label {
        font-size: 0.9375rem;
    }
}

/* ================================================
   MODE ANCRÉ (injection dans un sélecteur CSS)
   ================================================ */

@media (min-width: 769px) {
    .acces-rapide--horizontal.acces-rapide--anchored {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        /* left/right défini via JS selon le côté choisi */
    }
}

/* ================================================
   ACCESSIBILITÉ RGAA 4.1
   ================================================ */

/* Taille minimum des zones cliquables tactiles */
@media (pointer: coarse) {
    .acces-rapide__item {
        min-width: 48px;
        min-height: 48px;
    }
}

/* Préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    .acces-rapide__item,
    .skip-link {
        transition: none;
    }

    .acces-rapide__item:hover,
    .acces-rapide__item:focus {
        transform: none;
    }

    .acces-rapide--desktop,
    .acces-rapide--mobile {
        animation: none;
    }
}

/* Contraste élevé */
@media (prefers-contrast: high) {
    .acces-rapide__item {
        border: 2px solid var(--acces-rapide-text);
    }

    .acces-rapide__item:focus {
        outline-width: 4px;
    }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .acces-rapide--mobile {
        background: rgba(0, 0, 0, 0.3);
    }
}
