/* =============================================================================
   ÉTÉ DANS LA ZONE — Styles sur mesure (calendrier, pastilles, badges, modal)
   Le reste de la mise en page utilise Tailwind (voir index.html).
   Les couleurs de marque sont centralisées dans les variables ci-dessous.
   ============================================================================= */

:root {
  --paper:      #FBF4E9;  /* fond crème (papier) */
  --paper-2:    #F5E7D2;  /* crème plus soutenu */
  --ink:        #241826;  /* texte principal (aubergine sombre) */
  --ink-soft:   #6B5560;  /* texte secondaire */
  --brand:      #E0552B;  /* terracotta — couleur EMF / marque */
  --brand-deep: #A8371A;  /* terracotta foncé (boutons, contraste AA) */
  --sun:        #F2A93B;  /* ambre soleil */
  --green:      #127C67;  /* vert palmier (accent + partenaire) */
  --line:       #E6D3B6;  /* traits / bordures sur papier */

  /* Couleurs par type d'événement (fond clair + texte foncé = contraste sûr) */
  --emf-bg:   #FBE1D6;  --emf-tx:   #8E2E17;  --emf-dot:   #C1432A;
  --part-bg:  #D5EBE1;  --part-tx:  #0B5C43;  --part-dot:  #127C67;
  --indep-bg: #FBEAC6;  --indep-tx: #6B4900;  --indep-dot: #9A6A0C;
}

/* =============================================================================
   PALETTE PAR ACTIVITÉ
   Chaque activité porte une couleur (champ « couleur » dans events.js) : toutes
   ses séances sont de la même teinte dans le calendrier. Chaque classe définit
   trois variables reprises ensuite par les pastilles, points et cartes.
   Tous les contrastes texte/fond sont conformes WCAG AA.
   ============================================================================= */
/* --ev-rgb reprend --ev-dot en composantes, pour doser l'opacité des halos. */
.c-terracotta { --ev-bg: #FBE1D6; --ev-tx: #8E2E17; --ev-dot: #C1432A; --ev-rgb: 193 67 42; }
.c-prune      { --ev-bg: #F7DEE9; --ev-tx: #6E2B4C; --ev-dot: #9B3D68; --ev-rgb: 155 61 104; }
.c-pin        { --ev-bg: #D5EBE1; --ev-tx: #0B5C43; --ev-dot: #127C67; --ev-rgb: 18 124 103; }
/* Olive volontairement adouci (moins vif que le vert d'origine) : c'est le
   fond des encadrés d'étapes, qui occupent une grande surface. */
.c-olive      { --ev-bg: #EDF1E3; --ev-tx: #404F22; --ev-dot: #5B6B38; --ev-rgb: 91 107 56; }
/* Point volontairement plus clair et plus jaune que le terracotta : à 11 px
   sur un fond crème, deux bruns chauds voisins sont indiscernables. */
.c-ocre       { --ev-bg: #FBEAC6; --ev-tx: #6B4900; --ev-dot: #D19000; --ev-rgb: 209 144 0; }
.c-nuit       { --ev-bg: #E4DFF0; --ev-tx: #3B2A5C; --ev-dot: #54407E; --ev-rgb: 84 64 126; }

/* --- Texture grain, très subtile, par-dessus tout ------------------------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

/* =============================================================================
   BADGES (légende + cartes + modal)
   ============================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.4;
}
.badge__point { width: 0.55rem; height: 0.55rem; border-radius: 999px; }
.badge--emf         { background: var(--emf-bg);   color: var(--emf-tx); }
.badge--emf .badge__point { background: var(--emf-dot); }
.badge--partenaire  { background: var(--part-bg);  color: var(--part-tx); }
.badge--partenaire .badge__point { background: var(--part-dot); }
.badge--independant { background: var(--indep-bg); color: var(--indep-tx); }
.badge--independant .badge__point { background: var(--indep-dot); }

/* --- Mention d'alerte « pas organisé par EMF » ---------------------------- */
.mention-alerte {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 0.7rem;
  background: var(--indep-bg);
  border: 1px solid var(--indep-dot);
  color: var(--indep-tx);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* =============================================================================
   BOUTONS
   ============================================================================= */
.btn-inscription {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  background: var(--brand-deep);
  color: #fff;
  font-weight: 700;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.18s ease;
  box-shadow: 0 10px 24px -12px rgba(168, 55, 26, 0.9);
}
.btn-inscription:hover { transform: translateY(-2px) scale(1.02); }
.btn-inscription:active { transform: translateY(0) scale(0.97); }

.btn-detail {
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease;
}
.btn-detail:hover { background: var(--ink); color: var(--paper); }

.btn-fermer {
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  color: var(--ink-soft);
  font-weight: 700;
  background: transparent;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.btn-fermer:hover { border-color: var(--ink); color: var(--ink); }

/* Boutons de navigation du calendrier (rond) */
.cal-nav-btn {
  /* flex: none — sinon un titre long (« Semaine du 3 août au 9 août 2026 »)
     écrase ces boutons et les rend ovales sur mobile. */
  flex: none;
  width: 2.5rem; height: 2.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
  transition: transform 0.15s ease, background 0.15s ease;
}
.cal-nav-btn:hover { background: var(--paper-2); transform: translateY(-1px); }

.cal-auj-btn {
  flex: none;
  white-space: nowrap;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}
.cal-auj-btn:hover { background: var(--paper-2); }

/* Segmented control Mois / Semaine */
.seg { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 0.25rem; gap: 0.2rem; }
.seg__btn {
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}
.seg__btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* =============================================================================
   CALENDRIER — vue MOIS (tableau)
   ============================================================================= */
.cal-table { width: 100%; border-collapse: separate; border-spacing: 6px; table-layout: fixed; }
.cal-table th {
  padding: 0.5rem 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.cal-table th abbr { text-decoration: none; }

.cal-cell {
  vertical-align: top;
  height: 7.5rem;
  padding: 0.5rem;
  border-radius: 0.9rem;
  background: #fff;
  border: 1px solid var(--line);
}
.cal-cell--hors { background: transparent; border-color: transparent; }
.cal-cell--hors .cal-num { color: #6F5D4B; font-weight: 500; }
.cal-cell--auj { border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }

.cal-num { display: inline-block; font-size: 1rem; font-weight: 700; color: var(--ink); margin-bottom: 0.35rem; }
.cal-cell--auj .cal-num {
  background: var(--brand-deep); color: #fff;
  width: 1.7rem; height: 1.7rem; line-height: 1.7rem; text-align: center;
  border-radius: 999px;
}
.cal-cell__events { display: flex; flex-direction: column; gap: 0.28rem; }

/* Mobile : vue mois compacte — chaque jour est un bouton (≥ 44 px), les
   événements apparaissent en points colorés (encre = EMF, vert = partenaire,
   ambre = indépendant), et le détail du jour touché s'affiche dans
   l'agenda sous la grille. */
@media (max-width: 640px) {
  .cal-table { border-spacing: 3px; }
  .cal-cell { height: auto; padding: 0; border-radius: 0.65rem; }
  .cal-cell--has { background: #FAE7D3; border-color: #EFC9A4; }
  /* Aujourd'hui = numéro dans un cercle plein (pas d'anneau) ;
     l'anneau est réservé au jour sélectionné. */
  .cal-cell--auj { border-color: var(--line); box-shadow: none; }
  .cal-cell--auj.cal-cell--has { border-color: #EFC9A4; }
  .cal-cell--sel, .cal-cell--auj.cal-cell--sel { background: #fff; border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }

  .cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
    min-height: 3.4rem;
    padding: 6px 2px;
    border-radius: 0.65rem;
  }
  .cal-day .cal-num { font-size: 0.85rem; margin: 0; }
  .cal-day__marks {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 10px;
  }
  .cal-day__dot { width: 11px; height: 11px; border-radius: 999px; background: var(--ev-dot, var(--ink)); }
  .cal-day__plus { font-size: 0.62rem; font-weight: 800; color: var(--ink-soft); }
}

/* Pastille (événement dans le calendrier) */
.pastille {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 0.28rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  transition: transform 0.12s ease, filter 0.12s ease;
}
/* =============================================================================
   AGENDA DU JOUR (mobile, sous le calendrier)
   ============================================================================= */
.cal-agenda { margin-top: 1rem; display: grid; gap: 0.55rem; scroll-margin: 5rem; }
.cal-agenda[hidden] { display: none; }
@media (min-width: 641px) { .cal-agenda { display: none; } }

.cal-agenda__titre {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 0.1rem 0.15rem;
}
.agenda-vide {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed var(--line);
  border-radius: 0.9rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  text-align: center;
}
.agenda-card {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.85rem 0.9rem;
  box-shadow: 0 14px 30px -24px rgba(36, 24, 38, 0.55);
  transition: transform 0.15s ease;
}
.agenda-card:active { transform: scale(0.985); }
/* Horaire : pastille de couleur + texte, comme les cartes de la liste.
   Surtout pas de bloc de couleur collé à gauche — ça retombe dans le
   « liseré d'accent » qu'on a justement supprimé. */
.agenda-card__time {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 4.1rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.agenda-card__debut {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--ink);
}
.agenda-card__puce {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--ev-dot, var(--ink-soft));
}
/* Décalée pour s'aligner sous l'heure de début, après la pastille */
.agenda-card__fin { padding-left: 0.85rem; font-weight: 600; font-size: 0.72rem; color: var(--ink-soft); }
.agenda-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.agenda-card__titre { font-weight: 700; font-size: 0.98rem; line-height: 1.3; color: var(--ink); }
.agenda-card__lieu { font-size: 0.8rem; color: var(--ink-soft); }
.agenda-card__avec { font-size: 0.8rem; font-weight: 700; color: var(--ev-tx, var(--ink)); }
.agenda-card__chev { align-self: center; color: var(--ink-soft); font-size: 1.25rem; line-height: 1; }

@media (prefers-reduced-motion: reduce) { .agenda-card { transition: none; } }
.pastille:hover { transform: translateX(1px); filter: brightness(0.97); }
.pastille__point { flex: none; width: 0.45rem; height: 0.45rem; border-radius: 999px; }
.pastille__warn  { flex: none; font-size: 0.72rem; line-height: 1; }
.pastille__heure { flex: none; font-variant-numeric: tabular-nums; }
.pastille__titre { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* La couleur vient de la classe c-* de l'activité (voir palette plus haut). */
.pastille { background: var(--ev-bg, var(--paper-2)); color: var(--ev-tx, var(--ink)); }
.pastille__point { background: var(--ev-dot, var(--ink-soft)); }

/* =============================================================================
   CALENDRIER — vue SEMAINE
   ============================================================================= */
.semaine { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
/* minmax(0, 1fr) et non 1fr : sinon un titre long élargit sa colonne et la
   grille déborde (samedi/dimanche sortaient du cadre). */
@media (min-width: 768px) { .semaine { grid-template-columns: repeat(7, minmax(0, 1fr)); } }

.semaine__jour {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  min-height: 6rem;
}
.semaine__jour--auj { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.semaine__entete { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; border-bottom: 1px solid var(--line); padding-bottom: 0.35rem; }
.semaine__nom { font-weight: 800; font-size: 0.82rem; text-transform: capitalize; color: var(--ink); }
.semaine__date { font-size: 0.72rem; color: var(--ink-soft); }
.semaine__vide { color: #C9B8A6; text-align: center; margin: auto 0; }
/* Colonnes étroites : l'heure reste en tête, le titre passe à la ligne
   dessous (2 lignes max) au lieu d'être coupé net. */
.semaine .pastille { font-size: 0.78rem; padding: 0.4rem 0.5rem; flex-wrap: wrap; }
.semaine .pastille__titre {
  flex-basis: 100%;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =============================================================================
   CARTES DE LA LISTE « Prochains événements »
   ============================================================================= */
.ev-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  box-shadow: 0 18px 40px -30px rgba(42, 30, 44, 0.55);
  /* Pas d'overflow:hidden ici : le halo des événements phares doit pouvoir
     déborder. La photo est arrondie directement (voir .ev-card__img). */
}
.ev-card__corps { padding: 1.3rem; }

/* Photo du jour (film des projections) */
.ev-card__img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--paper-2);
  border-radius: calc(1.1rem - 1px) calc(1.1rem - 1px) 0 0;
}

/* Ligne d'accroche : pastille de couleur de l'activité + date */
.ev-card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ev-tx, var(--ink-soft));
}
.ev-card__puce { flex: none; width: 0.6rem; height: 0.6rem; border-radius: 999px; background: var(--ev-dot, var(--ink-soft)); }

.ev-card__titre { font-family: 'Fraunces', Georgia, serif; font-size: 1.5rem; font-weight: 700; line-height: 1.15; color: var(--ink); margin-top: 0.5rem; letter-spacing: -0.01em; }
.ev-card__soustitre { color: var(--ink-soft); margin-top: 0.25rem; font-size: 0.88rem; font-weight: 600; }
.ev-card__lieu { color: var(--ink-soft); margin-top: 0.45rem; font-size: 0.92rem; }
.ev-card__rythme { color: var(--ink-soft); margin-top: 0.2rem; font-size: 0.92rem; font-weight: 600; }
.ev-card__avec { color: var(--ev-tx, var(--ink)); font-weight: 700; margin-top: 0.45rem; font-size: 0.9rem; }
.ev-card__desc { color: var(--ink); line-height: 1.7; margin-top: 0.75rem; }
.ev-card__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }

.liste-vide { color: var(--ink-soft); text-align: center; padding: 2rem; }

/* =============================================================================
   ÉVÉNEMENT PHARE — halo lumineux (champ « phare: true » dans events.js)
   Le halo statique est une ombre en couches teintée de la couleur de
   l'activité ; l'anneau qui « respire » n'anime que son opacité.
   ============================================================================= */
/* Couleur DÉDIÉE au halo, volontairement indépendante de celle de l'activité :
   une teinte olive ou prune se noie dans le fond crème. L'ambre solaire, lui,
   se lit comme une vraie source de lumière. Changez ces deux valeurs pour
   changer la couleur de tous les halos du site. */
.ev-card--phare,
.agenda-card--phare,
.pastille--phare,
.cal-day__dot--phare {
  --phare-rgb: 245 158 40;    /* ambre solaire — cœur du halo */
  --phare-rgb-2: 224 85 43;   /* terracotta — couche externe, plus chaude */
}

/* Bordure à peine teintée : surtout PAS d'anneau net, sinon la carte paraît
   entourée d'un trait au lieu d'émettre de la lumière. */
.ev-card--phare { border-color: rgb(var(--phare-rgb) / 0.55); }

/* La lueur : quatre couches de flou de plus en plus large et diffuse.
   Portée par un pseudo-élément transparent pour n'animer que son opacité
   (jamais l'ombre elle-même, qui ferait ramer les téléphones). */
.ev-card--phare::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    0 0 18px 3px rgb(var(--phare-rgb) / 0.8),
    0 0 44px 10px rgb(var(--phare-rgb) / 0.5),
    0 0 95px 24px rgb(var(--phare-rgb-2) / 0.34),
    0 0 170px 50px rgb(var(--phare-rgb-2) / 0.2);
  /* Deux animations combinées : l'intensité pulse vite, et la source de
     lumière tourne franchement autour de la carte en respirant. */
  animation: lueur 2.6s ease-in-out infinite, derive 2.4s ease-in-out infinite;
}
@keyframes lueur {
  0%, 100% { opacity: 0.42; }
  50%      { opacity: 1; }
}
@keyframes derive {
  0%   { transform: translate(0, 0) scale(1); }
  20%  { transform: translate(14px, -10px) scale(1.03); }
  40%  { transform: translate(6px, 11px) scale(0.98); }
  60%  { transform: translate(-13px, 7px) scale(1.04); }
  80%  { transform: translate(-7px, -12px) scale(1); }
  100% { transform: translate(0, 0) scale(1); }
}

/* Le reflet : une bande lumineuse qui balaie la carte. Placée sous le texte
   (z-index négatif dans le contexte du corps) pour ne rien assombrir. */
.ev-card--phare .ev-card__corps {
  position: relative;
  z-index: 0;
  overflow: hidden;
  border-radius: calc(1.1rem - 1px);
}
.ev-card--phare .ev-card__corps::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -60%;
  left: 0;
  width: 42%;
  height: 220%;
  pointer-events: none;
  /* Teinté : un cœur blanc serait invisible sur le fond blanc de la carte. */
  background: linear-gradient(90deg,
    rgb(var(--phare-rgb) / 0) 0%,
    rgb(var(--phare-rgb) / 0.1) 32%,
    rgb(var(--phare-rgb) / 0.34) 50%,
    rgb(var(--phare-rgb) / 0.1) 68%,
    rgb(var(--phare-rgb) / 0) 100%);
  transform: rotate(16deg) translateX(-170%);
  animation: reflet 2s ease-in-out infinite;
}
@keyframes reflet {
  0%        { transform: rotate(16deg) translateX(-170%); }
  75%, 100% { transform: rotate(16deg) translateX(380%); }
}

/* Pastille du calendrier (desktop et vue semaine) : lueur ambrée qui pulse */
.pastille--phare {
  animation: lueur-pastille 2.6s ease-in-out infinite;
}
@keyframes lueur-pastille {
  0%, 100% { box-shadow: 0 0 8px 0 rgb(var(--phare-rgb) / 0.45),
                         0 0 16px 3px rgb(var(--phare-rgb-2) / 0.2); }
  50%      { box-shadow: 0 0 14px 2px rgb(var(--phare-rgb) / 0.9),
                         0 0 28px 7px rgb(var(--phare-rgb-2) / 0.45); }
}

/* Point du calendrier mobile : le point rayonne et pulse */
.cal-day__dot--phare {
  position: relative;
  box-shadow: 0 0 5px 0 rgb(var(--phare-rgb) / 0.7);
}
.cal-day__dot--phare::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  box-shadow:
    0 0 8px 2px rgb(var(--phare-rgb) / 0.95),
    0 0 18px 6px rgb(var(--phare-rgb-2) / 0.5);
  animation: lueur 2.6s ease-in-out infinite;
}

/* Carte de l'agenda mobile */
.agenda-card--phare {
  border-color: rgb(var(--phare-rgb) / 0.55);
  box-shadow:
    0 0 16px 2px rgb(var(--phare-rgb) / 0.55),
    0 0 40px 10px rgb(var(--phare-rgb-2) / 0.3),
    0 14px 30px -24px rgba(36, 24, 38, 0.55);
}

@media (prefers-reduced-motion: reduce) {
  .ev-card--phare::before,
  .cal-day__dot--phare::after { animation: none; opacity: 0.9; }
  .ev-card--phare .ev-card__corps::before { animation: none; opacity: 0; }
  .pastille--phare {
    animation: none;
    box-shadow: 0 0 12px 1px rgb(var(--phare-rgb) / 0.7),
                0 0 24px 6px rgb(var(--phare-rgb-2) / 0.35);
  }
}

/* =============================================================================
   MODALES (détail d'un événement + formulaire d'inscription)
   =============================================================================
   ⚠️ RÈGLE VITALE — NE JAMAIS SUPPRIMER
   Safari n'a supporté <dialog> qu'à partir de la version 15.4. Sur les versions
   antérieures, la feuille de style du navigateur ne fournit pas
   « dialog:not([open]) { display: none } » : les deux fenêtres restaient donc
   affichées en permanence par-dessus la page d'accueil. Des visiteurs ont
   rempli le formulaire d'inscription sans passer par une activité, et les
   inscriptions sont parties avec un champ « projet » vide.
   On déclare donc la règle nous-mêmes, pour tous les navigateurs.
   ============================================================================= */
dialog:not([open]) { display: none !important; }
#modal[open], #modal-inscription[open] { display: block; }

/* Sans support natif : pas de ::backdrop. On recrée l'assombrissement avec une
   ombre portée très étalée, et on bloque le défilement de la page derrière.
   Les sélecteurs reprennent les identifiants, sinon la règle #modal plus bas
   (spécificité supérieure) écraserait cette ombre. */
html.sans-dialog.fenetre-ouverte { overflow: hidden; }
html.sans-dialog #modal[open],
html.sans-dialog #modal-inscription[open] {
  /* Sans couche supérieure native, il faut passer devant l'en-tête collant. */
  z-index: 100;
  box-shadow:
    0 0 0 100vmax rgba(42, 30, 44, 0.55),
    0 40px 80px -30px rgba(42, 30, 44, 0.6);
}

#modal, #modal-inscription {
  width: min(560px, 92vw);
  /* Centré au milieu de l'écran et fixe : la fenêtre ne bouge pas si la
     page défile derrière. */
  position: fixed;
  inset: 0;
  margin: auto;
  /* Le contenu peut être long : on borne la hauteur et on rend le modal
     défilable, avec les boutons d'action toujours visibles en bas. */
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: none;
  border-radius: 1.4rem;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 40px 80px -30px rgba(42, 30, 44, 0.6);
}
#modal::backdrop, #modal-inscription::backdrop {
  background: rgba(42, 30, 44, 0.55);
  /* non prefixe seulement a partir de Safari 18 */
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
#modal[open], #modal-inscription[open] { animation: modal-in 0.25s cubic-bezier(.34,1.56,.64,1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal__inner { padding: 1.8rem 1.8rem 0; }
/* Photo en tête du détail — déborde du padding pour aller bord à bord.
   max-width: none neutralise le « max-width: 100% » de Tailwind, sinon
   l'image s'arrête avant le bord droit. */
.modal__img {
  display: block;
  width: calc(100% + 3.6rem);
  max-width: none;
  margin: -1.8rem -1.8rem 1.2rem;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--paper-2);
}
.modal__titre { font-family: 'Fraunces', Georgia, serif; font-size: 1.9rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; margin: 0.7rem 0 0.5rem; color: var(--ink); }
.modal__soustitre { color: var(--ink-soft); font-size: 0.9rem; font-weight: 600; margin-bottom: 0.6rem; }
.modal__accroche { font-family: 'Fraunces', Georgia, serif; font-size: 1.1rem; font-style: italic; color: var(--ink); line-height: 1.5; margin-bottom: 1rem; }
.modal__ligne { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--ink); margin-top: 0.4rem; line-height: 1.6; }
.modal__ico { flex: none; }
.modal__desc { color: var(--ink); line-height: 1.75; margin-top: 1rem; }

/* Étapes numérotées : bien aérées, chacune détachée, plutôt qu'un pavé. */
.etapes {
  list-style: none;
  counter-reset: etape;
  margin: 1.3rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}
.etape {
  counter-increment: etape;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.85rem 0.95rem;
  background: var(--ev-bg, var(--paper-2));
  border-radius: 0.85rem;
}
.etape__num {
  flex: none;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  background: var(--ev-dot, var(--ink));
  color: #fff;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 900;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.etape__num::before { content: counter(etape); }
.etape__corps { display: flex; flex-direction: column; gap: 2px; }
.etape__titre { font-weight: 800; color: var(--ev-tx, var(--ink)); }
.etape__texte { color: var(--ink); line-height: 1.6; font-size: 0.95rem; }
/* Barre d'action collée en bas du modal : le bouton d'inscription reste
   accessible même quand la description est longue. */
.modal__actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.6rem;
  padding: 1rem 0 1.8rem;
  background: var(--paper);
  box-shadow: 0 -14px 18px -14px rgba(36, 24, 38, 0.35);
}

/* =============================================================================
   FORMULAIRE D'INSCRIPTION
   ============================================================================= */
.champ { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 1rem; }
.champ label { font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.champ label span { color: var(--brand-deep); }
.champ input {
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 0.7rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* ≥16px : évite le zoom automatique sur iOS */
  transition: border-color 0.15s ease;
}
.champ input:hover { border-color: #D9BF98; }
/* :focus et non :focus-visible — un champ de saisie doit toujours montrer
   ou l'on ecrit, et Safari < 15.4 ignore :focus-visible. */
.champ input:focus { outline: 3px solid var(--ink); outline-offset: 2px; border-color: var(--ink); }

/* Piège à robots : invisible pour les humains, rempli par les scripts. */
.pot-de-miel {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.insc-message { margin-top: 0.9rem; font-weight: 700; line-height: 1.5; }
.insc-message:empty { margin-top: 0; }
.insc-message--erreur { color: #A8371A; }
.insc-message--succes { color: var(--part-tx); }

#modal-inscription .modal__titre { margin-top: 0; }
.btn-inscription[disabled] { opacity: 0.65; cursor: default; transform: none; }

/* Mobile : le modal devient une feuille qui remonte du bas de l'écran. */
@media (max-width: 640px) {
  #modal, #modal-inscription {
    width: 100%;
    max-width: 100%;
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 1.4rem 1.4rem 0 0;
  }
  #modal[open], #modal-inscription[open] { animation: sheet-in 0.28s cubic-bezier(.34,1.4,.64,1); }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
  .modal__inner { padding: 1.1rem 1.25rem 0; position: relative; }
  .modal__img { width: calc(100% + 2.5rem); max-width: none; margin: -1.1rem -1.25rem 1rem; }
  /* Petite poignée, comme sur les feuilles natives */
  .modal__inner::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    margin: 0 auto 1.1rem;
  }

  /* Détail AVEC photo : elle doit toucher le bord haut et en épouser
     l'arrondi. La poignée passe alors PAR-DESSUS l'image (sinon elle la
     repoussait vers le bas et laissait apparaître le coin arrondi au-dessus). */
  #modal.modal--image .modal__inner { padding-top: 0; }
  #modal.modal--image .modal__img { margin-top: 0; }
  #modal.modal--image .modal__inner::before {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.85);
  }
  .modal__titre { font-size: 1.55rem; }
  .modal__actions { padding-bottom: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-inscription, .pastille, .cal-nav-btn, #modal[open] { transition: none; animation: none; }
}
