/* Agenda Mairie - Carrousel
   Largeurs calculees en CSS (calc) et non en JS : chaque tuile fait
   exactement (100% - gaps) / colonnes, meme s'il y a moins d'items
   que de colonnes visibles. */

/* Conteneur de widget Elementor : dans un conteneur flexbox, .elementor-widget
   est un flex item qui ne recoit qu'un max-width: 100% de la part d'Elementor
   (.e-con.e-con > .e-con-inner > .elementor-widget). Sans largeur minimale il
   se dimensionne sur son contenu et le carrousel demarre sur une base trop
   etroite : tous les calculs en pourcentage des tuiles en decoulent. */
.elementor-widget-ag-widget-carousel {
    min-width: 100%;
    width: 100%;
}

.ag-carousel-wrapper {
    --ag-car-gap: 20px;
    /* --ag-car-cols-desktop / -tablet / -mobile sont posés en inline sur le
       wrapper par le widget. --ag-car-cols est dérivée ici (et dans les media
       queries en bas du fichier) : c'est elle que lisent les tuiles et le JS. */
    --ag-car-cols: var(--ag-car-cols-desktop, 3);
    position: relative;
    box-sizing: border-box;
}

/* Le padding vertical laisse respirer l'ombre des tuiles : overflow decoupe
   au niveau de la boite de padding, pas du contenu. Un padding horizontal ici
   laisserait au contraire apparaitre les tuiles voisines (regle par le
   controle "Espace reserve aux fleches", applique sur le wrapper). */
.ag-carousel-viewport {
    overflow: hidden;
    width: 100%;
    padding: 10px 0;
    box-sizing: border-box;
}

.ag-carousel-track {
    display: flex;
    gap: var(--ag-car-gap);
    transition: transform .35s ease;
    will-change: transform;
    align-items: stretch;
}

/* Moins d'items que de colonnes : on centre au lieu de coller a gauche */
.ag-carousel-track.is-centered {
    justify-content: center;
}

/* Tuile */
.ag-car-tile {
    flex: 0 0 calc((100% - (var(--ag-car-gap) * (var(--ag-car-cols) - 1))) / var(--ag-car-cols));
    max-width: calc((100% - (var(--ag-car-gap) * (var(--ag-car-cols) - 1))) / var(--ag-car-cols));
    background: #fff;
    display: flex;
    border-radius: 8px;
    overflow: hidden;
}

.ag-car-link {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-decoration: none;
    color: inherit;
}

/* Verticale : image au-dessus du contenu. Regle explicite plutot que de
   compter sur le flex-direction par defaut de .ag-car-link, qu'un style
   global de theme ou d'Elementor pourrait ecraser. */
.ag-car-tile--vertical {
    flex-direction: column;
}

.ag-car-tile--vertical .ag-car-link {
    flex-direction: column;
}

/* Horizontale : image a cote du contenu. */
.ag-car-tile--horizontal {
    flex-direction: row;
}

.ag-car-tile--horizontal .ag-car-link {
    flex-direction: row;
    align-items: stretch;
}

.ag-car-tile--horizontal.ag-car-tile--img-right .ag-car-link {
    flex-direction: row-reverse;
}

/* Photo : background-image (et non <img>).
   Approche reprise du plugin Annuaire : evite que Flexbox recalcule la
   hauteur des tuiles d'apres l'image, et permet d'egaliser les tuiles. */
.ag-car-thumb {
    flex: 0 0 auto;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #e9ecef;
}

.ag-car-tile--vertical .ag-car-thumb {
    width: 100%;
    aspect-ratio: 16/9;
}

.ag-car-tile--horizontal .ag-car-thumb {
    width: 40%;
    align-self: stretch;
}

/* Corps */
.ag-car-body {
    flex: 1 1 auto;
    min-width: 0;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ag-car-kicker {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #2271b1;
}

.ag-car-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.ag-car-title a {
    text-decoration: none;
    color: inherit;
    transition: opacity .15s ease;
}

.ag-car-title a:hover { opacity: .75; }

.ag-car-address,
.ag-car-excerpt {
    margin: 0;
    font-size: 13px;
    color: #50575e;
    line-height: 1.45;
}

/* Fleches */
.ag-car-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #1d2327;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    transition: background-color .15s ease, color .15s ease;
}

/* SVG plutot qu'un glyphe texte : centrage parfait, pas de decalage de
   baseline selon la police du theme. */
.ag-car-arrow svg {
    width: 45%;
    height: 45%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ag-car-prev { left: 0; }
.ag-car-next { right: 0; }

.ag-car-arrow[disabled] { opacity: .3; cursor: default; }

/* Points */
.ag-car-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.ag-car-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c3c4c7;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease;
}

.ag-car-dot.is-active {
    background: #2271b1;
    transform: scale(1.3);
}

/* Bouton */
.ag-car-btn-wrap {
    text-align: center;
    margin-top: 26px;
}

.ag-car-btn {
    display: inline-flex;
    align-items: center;
    padding: 12px 28px;
    background: #2271b1;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    border-radius: 30px;
    transition: background-color .2s ease;
    overflow: hidden;
}

.ag-car-btn--arrow::after {
    content: '\2192';
    display: inline-block;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width .3s ease, opacity .25s ease, margin-left .3s ease;
    margin-left: 0;
}

.ag-car-btn--arrow:hover::after {
    max-width: 2em;
    opacity: 1;
    margin-left: 8px;
}

.ag-car-empty {
    text-align: center;
    color: #787c82;
    padding: 20px;
}

/* Responsive : le nombre de colonnes est pilote par --ag-car-cols,
   reecrite ici selon le breakpoint. */
@media (max-width: 1024px) {
    .ag-carousel-wrapper { --ag-car-cols: var(--ag-car-cols-tablet, 2); }
}

@media (max-width: 767px) {
    .ag-carousel-wrapper { --ag-car-cols: var(--ag-car-cols-mobile, 1); }
    .ag-car-tile--horizontal .ag-car-link { flex-direction: column; }
    .ag-car-tile--horizontal .ag-car-thumb { width: 100%; aspect-ratio: 16/9; }
}
