/*
 * Hero en carrousel de la home (templates/partials/home/hero.html + static/js/hero-carousel.js).
 * Couleurs : tokens (static/css/tokens.css). Mouvement : transform + opacity uniquement.
 *
 * Les diapos sont empilées dans la même cellule de grille : la hauteur du hero est celle de la
 * diapo la plus haute, rien ne saute pendant le défilement. Le fond (visuel flouté) se fond
 * d'une diapo à l'autre ; le contenu glisse de 48 px dans le sens de la navigation.
 */
.lm-hero {
  --hero-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --hero-duration: 500ms;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ---------------------------------------------------------------- Diapos */
.lm-hero__viewport {
  display: grid;
  touch-action: pan-y; /* le défilement vertical reste natif, le balayage horizontal est pour nous */
}
.lm-hero__slide {
  grid-area: 1 / 1;
  position: relative;
  isolation: isolate; /* fond et dégradé restent derrière le contenu de leur diapo */
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hero-duration) var(--hero-ease);
}
.lm-hero__slide.is-active {
  opacity: 1;
  pointer-events: auto;
}
.lm-hero__inner {
  transform: translateX(48px);
  transition: transform var(--hero-duration) var(--hero-ease);
}
.lm-hero__slide[data-pos="before"] .lm-hero__inner { transform: translateX(-48px); }
.lm-hero__slide[data-pos="after"] .lm-hero__inner { transform: translateX(48px); }
.lm-hero__slide.is-active .lm-hero__inner { transform: none; }
/* Placement instantané avant une entrée, ou suivi du doigt pendant un balayage */
.lm-hero__slide.is-instant,
.lm-hero__slide.is-instant .lm-hero__inner,
.lm-hero.is-dragging .lm-hero__inner { transition: none; }

/* Fond : le visuel de la diapo, très flouté, fondu vers la couleur de page côté texte */
.lm-hero__backdrop {
  position: absolute;
  inset: -12%;
  z-index: -2;
  background-image: var(--hero-img);
  background-size: cover;
  background-position: center;
  filter: blur(48px) saturate(140%);
  opacity: 0.45;
}
.lm-hero__slide::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, transparent 55%, var(--bg)),
    linear-gradient(90deg, var(--bg) 18%, color-mix(in srgb, var(--bg) 55%, transparent) 70%, color-mix(in srgb, var(--bg) 30%, transparent));
}

.lm-hero__inner {
  display: grid;
  gap: 2rem;
  align-items: center;
  max-width: 80rem;
  margin: 0 auto;
  padding: 2.75rem 1rem 1.5rem;
}
@media (min-width: 640px) { .lm-hero__inner { padding-inline: 1.5rem; } }
@media (min-width: 1024px) {
  .lm-hero__inner {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 3.5rem;
    padding: 4.5rem 2rem 2rem;
  }
}

/* ---------------------------------------------------------------- Texte */
.lm-hero__copy { min-width: 0; }
.lm-hero__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.lm-hero__title {
  margin-top: 0.75rem;
  max-width: 20ch;
  font-size: clamp(2rem, 1.25rem + 3.2vw, 3.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--text-strong);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.lm-hero__lead {
  margin-top: 1rem;
  max-width: 34rem;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--text2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lm-hero__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  list-style: none;
  padding: 0;
}
.lm-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 0.875rem;
  color: var(--text);
}
.lm-pill svg,
.lm-btn svg {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lm-btn--primary svg { fill: currentColor; stroke: none; }

.lm-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

/* ---------------------------------------------------------------- Boutons */
.lm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 120ms ease-out;
}
.lm-btn:active { transform: scale(0.97); }
/* Boutons magnétiques (frontend/motion/hover.js) : décalage par `translate`, le `transform`
   reste à l'état :active. Variables nulles par défaut (tactile, mouvement réduit). */
.lm-hero__actions .lm-btn { translate: calc(var(--mx, 0) * 1px) calc(var(--my, 0) * 1px); }
.lm-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.lm-btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.lm-btn--primary:hover { background: var(--accent-hover); }
.lm-btn--ghost {
  border-color: var(--border2);
  background: var(--glass);
  color: var(--text);
}
.lm-btn--ghost:hover { border-color: var(--muted); color: var(--text-strong); }

/* ---------------------------------------------------------------- Visuels */
.lm-hero__media {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border2);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: 0 24px 60px -24px color-mix(in srgb, var(--bg) 85%, transparent);
}
.lm-hero__still {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* Affiche d'événement : entière, sur fond flouté tiré d'elle-même */
.lm-hero__poster {
  aspect-ratio: 4 / 3;
  isolation: isolate;
}
.lm-hero__poster::before {
  content: "";
  position: absolute;
  inset: -12%;
  z-index: -1;
  background-image: var(--hero-img);
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(140%) brightness(0.6);
}
.lm-hero__poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.lm-hero__datetile {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.25rem;
  padding: 0.55rem 0.7rem 0.6rem;
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  line-height: 1;
  text-align: center;
}
.lm-hero__datetile-month {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-text);
}
@media (max-width: 639px) {
  .lm-hero__datetile { top: 0.75rem; left: 0.75rem; min-width: 3.25rem; padding: 0.4rem 0.5rem 0.45rem; }
  .lm-hero__datetile-day { font-size: 1.6rem !important; }
}
.lm-hero__datetile-day {
  margin-top: 0.3rem;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Contrôles */
.lm-hero__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
  pointer-events: none; /* seule la barre capte les clics */
}
.lm-hero__controls > * { pointer-events: auto; }
@media (min-width: 640px) { .lm-hero__controls { padding-inline: 1.5rem; } }
@media (min-width: 1024px) { .lm-hero__controls { padding: 0 2rem 2.25rem; } }
/* Place réservée sous le contenu de chaque diapo pour la barre */
.lm-hero[data-hero-carousel] .lm-hero__inner { padding-bottom: 6rem; }
@media (min-width: 1024px) { .lm-hero[data-hero-carousel] .lm-hero__inner { padding-bottom: 7rem; } }

.lm-hero__bar {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 0.15rem;
  padding: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--border2) 70%, transparent);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}
.lm-hero__tabs {
  display: flex;
  min-width: 0;
  gap: 0.15rem;
}
.lm-hero__ctl,
.lm-hero__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: transform 120ms ease-out;
}
.lm-hero__ctl { flex-shrink: 0; width: 44px; color: var(--text); }
.lm-hero__ctl svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lm-hero__icon-play { fill: currentColor !important; stroke: none !important; width: 1.05rem !important; }
.lm-hero__ctl .lm-hero__icon-play { display: none; }
.lm-hero.is-paused .lm-hero__icon-pause { display: none; }
.lm-hero.is-paused .lm-hero__icon-play { display: block; }

.lm-hero__tab {
  min-width: 0;
  padding: 0 0.95rem 0.2rem;
  font-size: 0.8125rem;
  font-weight: 600;
}
.lm-hero__tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lm-hero__tab[aria-selected="true"] { color: var(--text-strong); }
.lm-hero__progress {
  position: absolute;
  left: 0.95rem;
  right: 0.95rem;
  bottom: 9px;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 16%, transparent);
}
.lm-hero__progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}
.lm-hero__tab[aria-selected="true"] .lm-hero__progress > span { transform: scaleX(var(--progress, 0)); }

.lm-hero__ctl:hover,
.lm-hero__tab:hover { color: var(--text-strong); }
.lm-hero__ctl:active,
.lm-hero__tab:active { transform: scale(0.97); }
.lm-hero__ctl:focus-visible,
.lm-hero__tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Petits écrans : les onglets et le balayage suffisent, on garde la place pour les libellés */
@media (max-width: 419px) {
  .lm-hero__ctl--step { display: none; }
}
/* Sur mobile les onglets deviennent des segments de progression (le nom complet reste dans aria-label) */
@media (max-width: 639px) {
  .lm-hero__tab { width: 3.25rem; padding: 0; }
  .lm-hero__tab-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .lm-hero__progress { left: 0.6rem; right: 0.6rem; bottom: auto; top: calc(50% - 2px); height: 4px; }
}

/* ---------------------------------------------------------------- Préférences */
/* ---------------------------------------------------------------- Le fleuve (docs/PLAN_ANIMATIONS.md, étape 1)
   Fond commun du hero : image fixe (SVG) remplacée en fondu par la scène 3D si l'appareil le
   permet (frontend/motion/river). Le voile garde le texte lisible, côté texte et en bas. */
.lm-river {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.lm-river ~ .lm-hero__viewport .lm-hero__backdrop,
.lm-river ~ .lm-hero__viewport .lm-hero__slide::before { display: none; }
.lm-river__still,
.lm-river__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 900ms var(--hero-ease);
}
.lm-river__still { color: var(--accent); }
.lm-river__a { stroke: var(--accent); }
.lm-river__b { stroke: var(--lien); }
[data-theme="light"] .lm-river__b { stroke: var(--texte); }
[data-theme="light"] .lm-river__still { opacity: 0.6; }
.lm-river__canvas { opacity: 0; }
.lm-river__canvas.is-ready { opacity: 1; }
.lm-hero.has-river .lm-river__still { opacity: 0; }
.lm-river::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 62%, transparent) 0%, transparent 58%, transparent 84%, var(--bg) 100%);
}
@media (min-width: 1024px) {
  .lm-river::after {
    background:
      linear-gradient(180deg, transparent 80%, var(--bg) 100%),
      linear-gradient(90deg, color-mix(in srgb, var(--bg) 78%, transparent) 0%, color-mix(in srgb, var(--bg) 40%, transparent) 42%, transparent 70%);
  }
}

/* Intro (frontend/motion/titles.js) : la classe .motion-intro (posée dans <head>) cache le texte
   jusqu'au départ de l'animation. L'image n'est que décalée, jamais cachée (LCP).
   Repli : si le module ne démarre pas, tout s'affiche après 2,5 s. */
.motion-intro .lm-hero__slide.is-active .lm-hero__copy > *,
.motion-intro .lm-hero__controls {
  opacity: 0;
  animation: lm-intro-failsafe 0s 2.5s forwards;
}
.motion-intro .lm-hero__slide.is-active .lm-hero__media {
  transform: translateY(28px) scale(0.97);
  animation: lm-intro-failsafe 0s 2.5s forwards;
}
@keyframes lm-intro-failsafe { to { opacity: 1; transform: none; } }

/* Bouton pause de l'animation, quand le hero n'a pas de carrousel (WCAG 2.2.2) */
.lm-river__toggle {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: 1rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  color: var(--text2);
  transition: transform 120ms ease-out, color 160ms ease-out;
}
.lm-river__toggle:hover { color: var(--text); }
.lm-river__toggle:active { transform: scale(0.94); }
.lm-river__toggle svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.lm-river__toggle .lm-river__icon-play { fill: currentColor; stroke: none; display: none; }
.lm-river__toggle[aria-pressed="true"] .lm-river__icon-play { display: block; }
.lm-river__toggle[aria-pressed="true"] .lm-river__icon-pause { display: none; }

@media (prefers-reduced-motion: reduce) {
  .lm-river__still,
  .lm-river__canvas { transition: none; }
  .lm-hero { --hero-duration: 200ms; }
  .lm-hero__inner,
  .lm-hero__slide[data-pos] .lm-hero__inner { transform: none !important; transition: none; }
  .lm-btn,
  .lm-hero__ctl,
  .lm-hero__tab { transition: none; }
  .lm-btn:active,
  .lm-hero__ctl:active,
  .lm-hero__tab:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .lm-pill,
  .lm-hero__bar,
  .lm-hero__datetile,
  .lm-river__toggle,
  .lm-btn--ghost {
    background: var(--surface2);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ---------------------------------------------------------------- Mobile (docs/PLAN_ANIMATIONS.md, étape 7)
   Les diapositives d'événement ramenées vers la hauteur de celle de l'épisode : le hero tient dans
   l'écran avec ses contrôles, et rien ne saute quand la diapositive change. Le résumé reste
   lisible sur la page de l'événement. */
@media (max-width: 639px) {
  .lm-hero__inner { gap: 1.5rem; padding-top: 2rem; }
  .lm-hero__lead { display: none; }
  .lm-hero__facts { gap: 0.375rem; margin-top: 1rem; }
  .lm-pill { min-height: 2rem; padding: 0.25rem 0.7rem; font-size: 0.8125rem; }
  .lm-hero__poster { aspect-ratio: 16 / 9; }
}
