/* ==========================================================================
   Carrousel agenda — module "Actualités / événements" Websee
   Client : mairie de Cohade (page d'accueil) — NET 15
   --------------------------------------------------------------------------
   100 % CSS, aucun JavaScript.
   - Cartes avec image en tête, pastille date sur l'image, carte cliquable.
   - Défilement horizontal au doigt / trackpad / molette+Maj, aimanté carte par carte.
   - Flèches précédent/suivant en CSS natif (::scroll-button) sur les
     navigateurs qui le gèrent (Chrome, Edge). Ailleurs (Firefox, Safari),
     une fine barre de défilement aux couleurs du site prend le relais.
   - Ciblage : instance du module #calendrier-liste-132. Pour un autre site,
     remplacer #calendrier-liste-132 partout.
   - Rien ne change côté administration.
   ========================================================================== */

#calendrier-liste-132 {
  --ca-navy: #0a3b5c;
  --ca-accent: #70163c;
  --ca-soft: #e8eff4;
  --ca-muted: #4d6475;
  --ca-card: #ffffff;
  --ca-gap: 24px;
  --ca-radius: 16px;
  position: relative;
  font-family: Montserrat, sans-serif;
  color: var(--ca-navy);
}

/* ---------- Titre du bloc ----------
   Le titre du module ("Les événements en cours / à venir") est masqué :
   le titre de la section est saisi directement dans la page.
   Là où les flèches existent, sa place est gardée vide pour les accueillir. */
#calendrier-liste-132 .calendrier-bloc-titre { display: none; }

@supports selector(::scroll-button(*)) {
  #calendrier-liste-132 .calendrier-bloc-titre {
    display: block;
    height: 46px;
    margin: 0 0 4px;
    padding: 0;
    background: none;
    font-size: 0;
    line-height: 0;
    overflow: hidden;
  }
}

/* ---------- Piste du carrousel ---------- */
#calendrier-liste-132 .calendrier-bloc-ligne {
  display: flex !important;
  flex-wrap: nowrap;
  gap: var(--ca-gap);
  width: auto;
  margin: 0 -6px;
  padding: 10px 6px 22px;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  /* barre de défilement fine aux couleurs du site (navigateurs sans flèches) */
  scrollbar-width: thin;
  scrollbar-color: var(--ca-navy) var(--ca-soft);
}
#calendrier-liste-132 .calendrier-bloc-ligne::-webkit-scrollbar { height: 6px; }
#calendrier-liste-132 .calendrier-bloc-ligne::-webkit-scrollbar-track { background: var(--ca-soft); border-radius: 999px; }
#calendrier-liste-132 .calendrier-bloc-ligne::-webkit-scrollbar-thumb { background: var(--ca-navy); border-radius: 999px; }

/* le clearfix Websee deviendrait un élément flex parasite */
#calendrier-liste-132 .calendrier-bloc-ligne::after,
#calendrier-liste-132 .un-calendrier-bloc-ligne::after { display: none; }

#calendrier-liste-132 .calendrier-bloc-ligne > li {
  flex: 0 0 calc((100% - 2 * var(--ca-gap)) / 3);
  width: auto !important;
  margin: 0;
  padding: 0;
  display: flex;
  scroll-snap-align: start;
}

/* ---------- Carte ---------- */
#calendrier-liste-132 .un-calendrier-bloc-ligne {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--ca-card);
  border-radius: var(--ca-radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(10, 59, 92, .12);
  transition: transform .25s ease, box-shadow .25s ease;
}
#calendrier-liste-132 .un-calendrier-bloc-ligne:hover,
#calendrier-liste-132 .un-calendrier-bloc-ligne:focus-within {
  transform: translateY(-6px);
  box-shadow: 0 14px 30px rgba(10, 59, 92, .18);
}

/* Image en tête de carte (le HTML la place en dernier : on la remonte) */
#calendrier-liste-132 .un-calendrier-bloc-ligne-contenu {
  order: -1;
  height: auto !important;
  padding: 0;
}
#calendrier-liste-132 .un-calendrier-bloc-ligne-contenu a { display: block; }
#calendrier-liste-132 .un-calendrier-bloc-ligne-image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--ca-soft);
}
#calendrier-liste-132 .un-calendrier-bloc-ligne-image img {
  display: block;
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  transition: transform .6s ease;
}
#calendrier-liste-132 .un-calendrier-bloc-ligne:hover .un-calendrier-bloc-ligne-image img {
  transform: scale(1.04);
}

/* Pastille date posée sur l'image */
#calendrier-liste-132 .un-calendrier-bloc-ligne-date {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 2;
  width: max-content;
  max-width: calc(100% - 28px);
  height: auto !important;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #70163c;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(10, 59, 92, .25);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  pointer-events: none;
}
#calendrier-liste-132 .un-calendrier-bloc-ligne-date::before {
  content: "";
  flex: 0 0 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Titre + "Voir l'événement" — toute la carte devient cliquable */
#calendrier-liste-132 .un-calendrier-bloc-ligne > a {
  order: 1;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 14px;
  padding: 18px 22px 22px;
  color: var(--ca-navy);
  text-decoration: none;
}
#calendrier-liste-132 .un-calendrier-bloc-ligne > a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--ca-radius);
}
#calendrier-liste-132 .un-calendrier-bloc-ligne > a:focus { outline: none; }
#calendrier-liste-132 .un-calendrier-bloc-ligne > a:focus-visible::before {
  outline: 3px solid var(--ca-navy);
  outline-offset: -3px;
}
#calendrier-liste-132 .un-calendrier-bloc-ligne > a::after {
  content: "Voir l'événement \2192";
  margin-top: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--ca-accent);
}
#calendrier-liste-132 .un-calendrier-bloc-ligne-titre {
  height: auto !important;
  font-family: 'Rozha One', serif;
  font-size: 17px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Flèches CSS natives (Chrome / Edge) ---------- */
@supports selector(::scroll-button(*)) {
  #calendrier-liste-132 .calendrier-bloc-ligne { scrollbar-width: none; }
  #calendrier-liste-132 .calendrier-bloc-ligne::-webkit-scrollbar { display: none; }

  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(*) {
    position: absolute;
    top: 0;
    width: 46px;
    height: 46px;
    border: 2px solid var(--ca-navy);
    border-radius: 50%;
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a3b5c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 18l-6-6 6-6'/%3E%3C/svg%3E") center / 20px no-repeat;
    cursor: pointer;
    transition: background-color .2s ease, opacity .2s ease;
  }
  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(left) {
    content: "" / "Événements précédents";
    right: 58px;
  }
  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(right) {
    content: "" / "Événements suivants";
    right: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a3b5c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E");
  }
  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(left):enabled:hover {
    background-color: var(--ca-navy);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 18l-6-6 6-6'/%3E%3C/svg%3E");
  }
  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(right):enabled:hover {
    background-color: var(--ca-navy);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E");
  }
  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(*):focus-visible {
    outline: 3px solid var(--ca-accent);
    outline-offset: 2px;
  }
  #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(*):disabled {
    opacity: .3;
    cursor: default;
  }
}

/* ---------- Responsive ---------- */
@media screen and (max-width: 980px) {
  #calendrier-liste-132 .calendrier-bloc-ligne > li {
    flex-basis: calc((100% - var(--ca-gap)) / 2);
  }
}
@media screen and (max-width: 600px) {
  #calendrier-liste-132 { --ca-gap: 16px; padding: 0 12px; }
  #calendrier-liste-132 .calendrier-bloc-ligne {
    margin: 0 -12px;
    padding: 10px 12px 22px;
    scroll-padding-left: 12px;
  }
  #calendrier-liste-132 .calendrier-bloc-ligne > li { flex-basis: 85%; }
  /* sur mobile : on fait glisser au doigt, flèches inutiles */
  @supports selector(::scroll-button(*)) {
    #calendrier-liste-132 .calendrier-bloc-ligne::scroll-button(*) { display: none; }
    #calendrier-liste-132 .calendrier-bloc-titre { display: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  #calendrier-liste-132 .calendrier-bloc-ligne { scroll-behavior: auto; }
  #calendrier-liste-132 *,
  #calendrier-liste-132 *::before { transition: none !important; }
  #calendrier-liste-132 .un-calendrier-bloc-ligne:hover,
  #calendrier-liste-132 .un-calendrier-bloc-ligne:focus-within { transform: none; }
}
