/**
 * EventPrime Categories — feuille de styles unique du rendu des cartes.
 *
 * Source unique : aucune regle n'est generee en PHP. Les valeurs dynamiques
 * arrivent en custom properties posees sur le wrapper par le shortcode :
 *
 *   --ep-cat-col-min  largeur minimale d'une colonne (pilote le responsive)
 *   --ep-cat-gap      gouttiere de la grille
 *   --ep-cat-img-h    hauteur du visuel, si l'attribut image_height est fourni
 *
 * Ces variables voyageant dans le HTML, le rendu est identique en front, dans
 * les resultats AJAX de eventprime-filters et dans l'apercu de l'editeur.
 */

/* ==========================================================================
   WRAPPER
   ========================================================================== */

.emagic.ep-events-by-category {
    --ep-cat-overlay: linear-gradient(20deg, #000000ff 14%, #ff000000 70%);

    margin: 20px 0;
    position: relative;
}

.emagic.ep-events-by-category a {
    display: block;
}

/* ==========================================================================
   GRILLE
   ========================================================================== */

.emagic.ep-events-by-category .ep-events {
    margin: 0;
    padding: 0;
    list-style: none;
}

/*
 * Une seule regle pilote tout le responsive : auto-fill place autant de
 * colonnes que --ep-cat-col-min en autorise, et min(100%, …) empeche une
 * colonne de depasser son conteneur sur petit ecran. Pas de points de rupture
 * a maintenir.
 */
.emagic.ep-events-by-category .ep-events.ep-events-grid {
    display: grid;
    gap: var(--ep-cat-gap, 20px);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--ep-cat-col-min)), 1fr));
}

/*
 * Rangee unique a defilement horizontal. grid-template-columns est remis a
 * none : le cumuler avec grid-auto-flow revenait a decrire deux grilles
 * concurrentes, d'ou les largeurs incoherentes. Ici seules les colonnes
 * implicites comptent.
 */
.emagic.ep-events-by-category.single-row .ep-events.ep-events-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: var(--ep-cat-col-min, 280px);
    overflow-x: auto;
    overflow-y: hidden;

    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;

    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.emagic.ep-events-by-category.single-row .ep-events.ep-events-grid .ep-event-card {
    scroll-snap-align: start;
}

.emagic.ep-events-by-category.single-row .ep-events.ep-events-grid::-webkit-scrollbar {
    height: 8px;
}

.emagic.ep-events-by-category.single-row .ep-events.ep-events-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.emagic.ep-events-by-category.single-row .ep-events.ep-events-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.emagic.ep-events-by-category.single-row .ep-events.ep-events-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   CARTE
   ========================================================================== */

/* Neutralise la grille en flex d'EventPrime : c'est le conteneur qui repartit. */
.emagic.ep-events-by-category .ep-events.ep-events-grid .ep-event-card {
    width: 100%;
    max-width: 100%;
    flex: none;
    flex-basis: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.emagic.ep-events-by-category .ep-event-card {
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.emagic.ep-events-by-category .ep-event-card:is(:hover, :focus-within) {
    transform: translateY(-1px);
}

.emagic.ep-events-by-category .ep-box-card-item {
    border-radius: 18px;
}

/* ==========================================================================
   CARTE CLIQUABLE

   Le titre est le seul lien de la carte ; son ::after se resout contre
   .ep-box-card-item (porteur de ep-position-relative cote markup EventPrime,
   donc plus proche ancetre positionne) et couvre toute la carte visible. Tout
   devient cliquable sans imbriquer de liens ni ajouter d'arret de tabulation.
   Ce qui doit rester cliquable par soi-meme — bouton de reservation, icones
   EventPrime — repasse au-dessus en z-index.

   Aucun de ces conteneurs ne cree de contexte d'empilement (position sans
   z-index), les valeurs 1 et 2 se comparent donc bien entre elles.
   ========================================================================== */

/* Le titre est un h3 pour la structure ; il ne doit pas ramener ses marges. */
.emagic.ep-events-by-category .ep-box-card-title h3,
.emagic.ep-events-by-category .ep-box-list-title h3 {
    margin: 0;
    line-height: inherit;
}

.emagic.ep-events-by-category .ep-cat-title-link {
    color: inherit;
    text-decoration: none;
    pointer-events: auto;
}

/*
 * display:block est indispensable et non redondant : quelque chose sur ces
 * pages ramene les ::after des liens a display:none, et un pseudo-element non
 * genere ne capte aucun clic — la zone etendue existe alors sans fonctionner.
 * Constate en recette sur le staging le 11/08/2026.
 */
.emagic.ep-events-by-category .ep-cat-title-link::after {
    content: "";
    display: block;
    position: absolute;
    inset: 0;
    z-index: 1;
}

/*
 * Le calque et le contenu n'interceptent plus rien : sans cela le texte passe
 * a opacity:0 au survol continuait d'avaler les clics destines a la carte.
 */
.emagic.ep-events-by-category .ep-infos,
.emagic.ep-events-by-category .ep-box-card-content {
    pointer-events: none;
}

.emagic.ep-events-by-category .ep-card-footer,
.emagic.ep-events-by-category .ep-box-card-icon-group,
.emagic.ep-events-by-category .ep-list-icon-group {
    z-index: 2;
    pointer-events: auto;
}

/* L'anneau de focus entoure la carte entiere, pas seulement le mot clique. */
.emagic.ep-events-by-category .ep-cat-title-link:focus-visible {
    outline: none;
}

.emagic.ep-events-by-category .ep-cat-title-link:focus-visible::after {
    outline: 3px solid currentColor;
    outline-offset: -3px;
    border-radius: 18px;
}

.emagic.ep-events-by-category .ep-events.ep-events-grid .ep-event-card .ep-card-wrapper,
.emagic.ep-events-by-category .ep-events.ep-events-grid .ep-event-card .ep-card-container {
    width: 100%;
    max-width: 100%;
    flex: 1;
}

.emagic.ep-events-by-category .ep-event-card .ep-card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

.emagic.ep-events-by-category .ep-event-card .ep-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.emagic.ep-events-by-category .ep-event-card .ep-card-footer {
    margin-top: auto;
}

.emagic.ep-events-by-category .ep-box-card-content {
    justify-content: flex-end;
    gap: 5px;
}

/* ==========================================================================
   VISUEL
   ========================================================================== */

.emagic.ep-events-by-category .ep-box-card-thumb {
    height: var(--ep-imageCardHeight, var(--ep-cat-img-h));
    max-height: var(--ep-imageCardHeight, var(--ep-cat-img-h));
    overflow: hidden;
    position: relative;
    background-color: rgba(0, 0, 0, 0.03);
}

/* Leger zoom de l'affiche au survol. Personne d'autre ne fournit cette regle :
   elle vivait dans le CSS de repli, qui n'est pas charge partout. */
.emagic.ep-events-by-category .ep-box-card-thumb img.ep-event-cover {
    transform: scale(1, 1);
    transition: transform 2s;
}

.emagic.ep-events-by-category .ep-box-card-item:hover .ep-box-card-thumb img.ep-event-cover {
    transform: scale(1.02, 1.02);
}

.emagic.ep-events-by-category .ep-box-card-thumb img.ep-event-cover,
.emagic.ep-events-by-category .ep-box-card-thumb .ep-event-cover {
    width: 100%;
    height: auto;
    max-height: var(--ep-imageCardHeight, var(--ep-cat-img-h));
    object-fit: cover;
    display: block;
}

/* Aplat affiche quand l'evenement n'a ni affiche ni image de remplacement. */
.emagic.ep-events-by-category .ep-image-default {
    min-height: 200px;
}

.emagic.ep-events-by-category .ep-image-default .material-icons-outlined {
    font-size: 48px;
}

.emagic.ep-events-by-category.ep-view-list .ep-image-default {
    min-height: 150px;
}

.emagic.ep-events-by-category.ep-view-list .ep-image-default .material-icons-outlined {
    font-size: 36px;
}

/* ==========================================================================
   CALQUE DEGRADE (vue grid)
   ========================================================================== */

.emagic.ep-events-by-category .ep-infos {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    bottom: 0;
    opacity: 1;
    background-image: var(--ep-cat-overlay);
    background-size: 100% 100%;
    background-position: 0 0;
    transition: opacity 0.3s ease-in-out;
}

/*
 * Au survol le texte s'efface pour degager l'affiche. :focus-within applique le
 * meme etat au clavier, sans quoi la navigation au clavier ne revelerait rien.
 */
.emagic.ep-events-by-category .ep-event-card:is(:hover, :focus-within) .ep-infos {
    background-image: none;
}

.emagic.ep-events-by-category .ep-event-card:is(:hover, :focus-within) .ep-box-card-content {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.emagic.ep-events-by-category .ep-event-list-price {
    color: white !important;
}

/* ==========================================================================
   VUE GRID-ALT — meme carte, contenu sous le visuel
   ========================================================================== */

/*
 * static, surtout pas relative : le calque doit revenir dans le flux, mais il
 * ne doit PAS devenir l'ancetre positionne du ::after du titre. En relative il
 * le devenait, et comme il se place sous l'image, la zone de clic s'arretait au
 * bloc de texte — l'affiche redevenait morte. En static, le ::after se resout
 * contre .ep-box-card-item et couvre la carte entiere, comme en vue grid.
 */
.emagic.ep-events-by-category.ep-view-grid-alt .ep-infos {
    position: static;
    background: none;
}

.emagic.ep-events-by-category.ep-view-grid-alt .ep-event-card:is(:hover, :focus-within) .ep-box-card-content {
    opacity: 1;
    transition: none;
}

.emagic.ep-events-by-category.ep-view-grid-alt .ep-event-list-price {
    color: initial !important;
}

/* ==========================================================================
   VUE LISTE
   ========================================================================== */

.emagic.ep-events-by-category .ep-event-list-item {
    position: relative;
}

/* ==========================================================================
   PIED DE CARTE

   Calage du pied et de son conteneur. Comme le zoom du visuel, ces regles ne
   sont fournies par personne d'autre — ni EventPrime ni le theme — et vivaient
   a tort dans le CSS de repli, qui n'est pas charge sur toutes les pages.
   ========================================================================== */

.emagic.ep-events-by-category .ep-card-footer-wrap {
    position: relative;
}

.emagic.ep-events-by-category .ep-card-footer {
    padding: 0.5rem 1rem;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
}

.emagic.ep-events-by-category .ep-card-footer a {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   RESPONSIVE

   Le nombre de colonnes decoule de --ep-cat-col-min via auto-fill : plus de
   cascade de points de rupture qui forcait 3 / 2 / 1 colonnes. Il ne reste que
   le resserrement des gouttieres sur petit ecran.
   ========================================================================== */

@media (max-width: 768px) {
    .emagic.ep-events-by-category .ep-events.ep-events-grid {
        gap: calc(var(--ep-cat-gap, 20px) * 0.75);
    }
}

@media (max-width: 480px) {
    .emagic.ep-events-by-category .ep-events.ep-events-grid {
        gap: calc(var(--ep-cat-gap, 20px) * 0.5);
    }

    .emagic.ep-events-by-category .ep-event-card {
        border-radius: 8px;
    }

    /* Une carte par ecran en rangee unique, plutot qu'une colonne tronquee. */
    .emagic.ep-events-by-category.single-row .ep-events.ep-events-grid {
        grid-auto-columns: min(var(--ep-cat-col-min, 280px), 85%);
    }
}

/* ==========================================================================
   MOUVEMENT REDUIT

   L'effet est conserve pour tout le monde par defaut, mais qui demande moins
   d'animation garde le texte lisible et la carte immobile.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .emagic.ep-events-by-category .ep-event-card,
    .emagic.ep-events-by-category .ep-infos,
    .emagic.ep-events-by-category .ep-box-card-content {
        transition: none;
    }

    .emagic.ep-events-by-category .ep-event-card:is(:hover, :focus-within) {
        transform: none;
    }

    .emagic.ep-events-by-category .ep-event-card:is(:hover, :focus-within) .ep-infos {
        background-image: var(--ep-cat-overlay);
    }

    .emagic.ep-events-by-category .ep-event-card:is(:hover, :focus-within) .ep-box-card-content {
        opacity: 1;
    }
}

/* ==========================================================================
   IMPRESSION
   ========================================================================== */

@media print {
    .emagic.ep-events-by-category .ep-events.ep-events-grid {
        display: block;
        gap: 0;
    }

    .emagic.ep-events-by-category .ep-event-card {
        break-inside: avoid;
        margin-bottom: 20px;
        height: auto;
    }
}
