/* LPE 2.59.1 — couche canonique de scroll, toujours chargée en dernier
 * Règle absolue : le document scrolle par défaut.
 * Seul html.lpe-v258-scroll-locked peut réellement bloquer le document,
 * et cette classe est calculée par v258-scroll.js à partir d'un overlay visible.
 */

html{
  min-height:100%;
  overflow-x:clip;
  -webkit-text-size-adjust:100%;
  scroll-padding-top:clamp(76px,8vw,112px);
}
body{
  min-height:100%;
  overflow-x:clip;
}

/* État normal : on écrase les anciens verrous CSS, même s'une classe orpheline
   reste une fraction de seconde sur body/html. */
html:not(.lpe-v258-scroll-locked){
  overflow-y:auto!important;
  overscroll-behavior-y:auto!important;
  touch-action:auto!important;
}
html:not(.lpe-v258-scroll-locked) body{
  overflow-y:visible!important;
  overscroll-behavior-y:auto!important;
  touch-action:auto!important;
  max-height:none!important;
}
html:not(.lpe-v258-scroll-locked) :where(.lpe-site-main,.lpe-page-content,.lpe-ministry-page,.lpe-portal-main,.lpe-mayor-v256){
  overflow-y:visible!important;
  max-height:none!important;
}

/* L'ancien portail V8 ne doit plus retransformer l'accueil en écran fermé. */
html:not(.lpe-v258-scroll-locked) body.lpe-is-front-page .lpe-portal-main{
  height:auto!important;
  min-height:100%!important;
  overflow:visible!important;
}

/* Le verrou canonique, uniquement lorsqu'un vrai overlay est visible. */
html.lpe-v258-scroll-locked,
html.lpe-v258-scroll-locked body{
  overflow:hidden!important;
  overscroll-behavior:none!important;
}

/* Les surfaces qui justifient un verrou de page doivent, elles, pouvoir scroller. */
:where(
  dialog[open],
  .lpe-primary-nav.is-open,
  .lpe-measure-modal.is-open,
  [data-measure-modal].is-open,
  .lpe-v6-modal.is-open,
  [data-v6-modal].is-open,
  [data-v233-gate].is-visible:not([hidden]),
  [data-q218-gate]:not([hidden]),
  .lpe-v236-filters.is-open,
  .lpe-v236-inspector.is-open,
  .lpe-v237-filters.is-open,
  .lpe-v237-inspector.is-open,
  .lpe-v238-filters.is-open,
  .lpe-v238-inspector.is-open,
  .lpe-v8-menu.is-open,
  [data-lpe-v8-menu-panel].is-open:not([hidden]),
  .lpe-q219-details:not([hidden])
){
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

@media (max-width:1120px){
  :where(
    .lpe-v236-filters.is-open,.lpe-v236-inspector.is-open,
    .lpe-v237-filters.is-open,.lpe-v237-inspector.is-open,
    .lpe-v238-filters.is-open,.lpe-v238-inspector.is-open
  ){
    overflow-y:auto!important;
    overflow-x:hidden!important;
    max-height:100dvh!important;
  }
}

/* Le quiz plein écran conserve son verrou, mais son contenu ne doit jamais être
   tronqué sur un téléphone bas ou en paysage. */
body.q219-playing .lpe-q219-arena__body{
  overflow-y:auto!important;
  overscroll-behavior:contain!important;
  -webkit-overflow-scrolling:touch;
}
body.q219-playing .lpe-q219-questionstage,
body.q219-playing .lpe-q218-answers{
  overflow:visible!important;
}

/* Tous les rails tactiles connus autorisent toujours le geste vertical.
   Le scroll horizontal reste possible, mais n'emprisonne pas la page. */
:where(
  .lpe-v244-hero__ctas,
  .lpe-v244-facts__rail,
  .lpe-v242-reading,
  .lpe-v242-transformations__grid,
  .lpe-ministry-rail__track,
  .lpe-v8-carousel,
  .lpe-v84-carousel,
  .lpe-page-scale,
  .lpe-demo-filters,
  .lpe-assistant__suggestions,
  .lpe-mayor-v256__cta-row,
  .lpe-mayor-v225__quicknav .lpe-wrap,
  .lpe-v255-materials,
  .lpe-v255-domains,
  .lpe-v238-mobile-results,
  [class*="__rail"],
  [class*="-rail__"],
  [class*="carousel"]
){
  touch-action:pan-x pan-y pinch-zoom!important;
  overscroll-behavior-x:contain;
  overscroll-behavior-y:auto!important;
  -webkit-overflow-scrolling:touch;
}

/* Les ancres restent visibles sous le header sticky. */
:where(section[id],[id].lpe-anchor-offset,[id^="mesure-"]){
  scroll-margin-top:clamp(82px,9vw,126px);
}

/* Safari/iOS : une ancienne règle de hauteur ne doit pas créer un faux viewport
   indépendant hors des expériences réellement plein écran. */
body:not(.q219-playing) :where(.lpe-site-main,.lpe-page-content,.lpe-ministry-page,.lpe-editorial-shell,.lpe-mayor-v256){
  max-height:none!important;
}

/* Page Maires : aucune couche historique ne doit convertir le shell en viewport
   indépendant. Les vraies modales restent protégées par le verrou canonique. */
html:not(.lpe-v258-scroll-locked) body.lpe-v249-mayors,
html:not(.lpe-v258-scroll-locked) body.lpe-v257-mayors{
  height:auto!important;
  max-height:none!important;
  overflow-y:visible!important;
}
html:not(.lpe-v258-scroll-locked) body.lpe-v249-mayors .lpe-mayor-v256,
html:not(.lpe-v258-scroll-locked) body.lpe-v257-mayors .lpe-mayor-v256{
  height:auto!important;
  max-height:none!important;
  overflow-y:visible!important;
  overscroll-behavior-y:auto!important;
}

@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto!important}
}

/* 2.59.2 — Maires / Safari : le rail sticky ne devient jamais un scroller vertical. */
.lpe-mayor-v225__quicknav .lpe-wrap{
  overflow-y:hidden!important;
  overscroll-behavior-y:auto!important;
}
