/* ============================================================================
   base.css
   ==========================================================================*/

   *,
   *::after,
   *::before {
     box-sizing: border-box;
   }
   
   :root {
     font-size: 14px;
   
     --color-text: #fff;
     --color-bg: #0f0e0e;
     --color-link: #ffffff;
     --color-link-hover: rgba(255, 255, 255, 0.6);
   
     --page-padding: 0.5rem;
     --aspect: 4 / 5;
     --c-gap: 3rem;
     --r-gap: 3rem;
     --column-count: 3;
     --border-radius: 4px;
   
     /* --- Géométrie du carrousel 3D -------------------------------------------
        UNE seule dimension pilote toute la scène : largeur de carte, rayon de
        l'anneau, boîte du carrousel et distance de la caméra. Comme perspective
        est une longueur, réduire --cell-w réduit l'image projetée de façon
        strictement homothétique : la composition reste identique sur un écran
        de 360px et sur un 1920px. Les valeurs desktop ne changent pas :
        350 / 1.4286 / 900.                                                    */
     --cell-w: clamp(140px, 54vw, 350px);
     --cell-h: calc(var(--cell-w) * 1.2);          /* 420 / 350 */
     --carousel-w: calc(var(--cell-w) * 1.1429);   /* 400 / 350 */
     --carousel-h: calc(var(--cell-h) * 1.1905);   /* 500 / 420 */
     --persp: calc(var(--cell-w) * 2.5714);        /* = 900px quand --cell-w = 350 */
   }
   
   html {
     height: 100%;
     /* hidden masque; clip interdit TOUT défilement horizontal, même le pan
        tactile et le scroll programmatique. clip = verrou fiable sur mobile. */
     overflow-x: hidden;
     overflow-x: clip;
     scrollbar-color: var(--color-text) var(--color-bg);
     scrollbar-width: thin; /* Firefox */
   }
   
   html::-webkit-scrollbar {
     width: 5px;
     height: 5px;
   }
   
   html::-webkit-scrollbar-thumb {
     background: #333;
     border-radius: 4px;
   }
   
   html::-webkit-scrollbar-thumb:hover {
     background: #555;
   }
   
   body {
     height: 100%;
     width: 100%;
     margin: 0;
     font-family: 'forma-djr-mono', sans-serif;
     text-transform: uppercase;
     color: var(--color-text);
     background-color: var(--color-bg);
     /* Second verrou : les projections 3D des carrousels ne doivent jamais
        créer de zone défilable horizontale (cause des barres horizontales
        intermittentes sur mobile après retour de la vidéo). */
     overflow-x: hidden;
     overflow-x: clip;
     overscroll-behavior: none;
     -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
   }
   
   /* --- Verrou de scroll ------------------------------------------------------
      Remplace wheel/touchmove/keydown + preventDefault. touch-action: none bloque
      le pan tactile, overflow: hidden bloque molette et clavier, et le scroll
      courant n'est PAS réinitialisé (contrairement à position: fixed sur body). */
   html.is-locked,
   html.is-locked body {
     overflow: hidden;
     overscroll-behavior: none;
   }
   
   html.is-locked {
     touch-action: none;
   }
   
   /* --- Écran de chargement -------------------------------------------------- */
   @media (scripting: enabled) {
     .loading::before,
     .loading::after {
       content: '';
       position: fixed;
       z-index: 10000;
     }
   
     .loading::before {
       top: 0;
       left: 0;
       width: 100%;
       height: 100%;
       background: var(--color-bg);
     }
   
     .loading::after {
       top: 50%;
       left: 50%;
       width: 100px;
       height: 1px;
       margin: 0 0 0 -50px;
       background: var(--color-link);
       animation: loaderAnim 1.5s ease-in-out infinite alternate forwards;
     }
   }
   
   @keyframes loaderAnim {
     0%   { transform: scaleX(0);   transform-origin: 0% 50%; }
     50%  { transform: scaleX(1);   transform-origin: 0% 50%; }
     50.1%{ transform: scaleX(1);   transform-origin: 100% 50%; }
     100% { transform: scaleX(0);   transform-origin: 100% 50%; }
   }
   
   /* --- Liens ---------------------------------------------------------------- */
   a {
     text-decoration: none;
     color: var(--color-link);
     outline: none;
     cursor: pointer;
     transition: color 0.3s ease, background-color 0.3s ease;
   }
   
   a:hover {
     color: var(--color-link-hover);
   }
   
   a:focus {
     outline: none;
   }
   
   a:focus:not(:focus-visible) {
     background: transparent;
   }
   
   a:focus-visible {
     outline: 2px solid red;
     background: transparent;
   }
   
   .line {
     display: inline-block;
     overflow: hidden;
     position: relative;
     vertical-align: top;
   }
   
   .line::before {
     background: var(--color-link-hover);
     bottom: 0;
     content: '';
     height: 1px;
     left: 0;
     position: absolute;
     transition: transform 0.4s ease;
     width: 100%;
     transform: scaleX(0);
     transform-origin: right center;
   }
   
   .line:hover::before {
     transform: scaleX(1);
     transform-origin: left center;
   }
   
   /* --- Cadre fixe ----------------------------------------------------------- */
   .frame {
     display: grid;
     z-index: 1000;
     width: 100%;
     height: 100svh;
     position: fixed;
     inset: 0;
     grid-column-gap: 1rem;
     grid-row-gap: 0.5rem;
     pointer-events: none;
     justify-items: start;
     padding: max(var(--page-padding), env(safe-area-inset-top))
              max(var(--page-padding), env(safe-area-inset-right))
              max(var(--page-padding), env(safe-area-inset-bottom))
              max(var(--page-padding), env(safe-area-inset-left));
     align-content: space-between;
     justify-content: space-between;
     align-items: end;
     grid-template-areas: 'title links' 'tags sponsor';
   }
   
   .frame a,
   .frame button {
     pointer-events: auto;
     color: var(--color-text);
   }
   
   .frame__title {
     font-size: inherit;
     background-color: var(--color-bg);
     padding: 5px;
     margin: 80px 0 0 -90px;
     font-weight: inherit;
     grid-area: title;
     text-align: right;
     transform: rotate(-90deg);
     transform-origin: center;
     white-space: nowrap;
     display: block;
   }
   
   .frame__tags,
   .frame__links {
     grid-area: tags;
     display: flex;
     gap: 1rem;
     align-items: start;
   }
   
   .frame__links {
     grid-area: links;
     justify-self: end;
   }
   
   .frame.frame--footer {
     display: flex;
     min-height: 300px;
     align-items: end;
     justify-content: space-between;
   }
   
   /* --- Scène / carrousel 3D ------------------------------------------------- */
   .scene {
     position: relative;
     height: 100svh;
     display: flex;
     justify-content: center;
     align-items: center;
     perspective: var(--persp);
     /* La scène fait exactement la taille de l'écran : tout ce que la 3D projette
        au-delà (cellules en translateZ, tilts) est rogné ici au lieu d'étendre la
        zone défilable du document. Visuellement identique (hors écran = invisible)
        mais c'est LA fin des défilements horizontaux parasites. */
     overflow: hidden;
     overflow: clip;
   }
   
   .scene__title {
     position: relative;
     z-index: 10;
     margin: 0;
     padding: 0 4vw;
     text-align: center;
   }
   
   .scene__title h2 {
     margin: 0;
   }
   
   .scene__title a {
     display: block;
   }
   
   .scene__title span {
     display: inline-block;
   }
   
   .scene__title .char {
     display: inline-block;
     transform-style: preserve-3d;
     -webkit-transform-style: preserve-3d;
     transform-origin: 50% 0%;
   }
   
   .scene__sub,
   .preview__sub {
     margin: 8px 0 0;
     font-size: 1.2rem;
     font-weight: normal;
     line-height: 1.2;
   }
   
   .carousel {
     width: var(--carousel-w);
     height: var(--carousel-h);
     position: absolute;
     top: 50%;
     left: 50%;
     margin: calc(var(--carousel-h) / -2) 0 0 calc(var(--carousel-w) / -2);
     transform-style: preserve-3d;
     -webkit-transform-style: preserve-3d;
     will-change: transform;
   }
   
   .carousel__cell {
     position: absolute;
     width: var(--cell-w);
     height: var(--cell-h);
     left: 0;
     top: 0;
     transform-style: preserve-3d;
     -webkit-transform-style: preserve-3d;
   }
   
   .card {
     width: 100%;
     height: 100%;
     position: relative;
     transform-style: preserve-3d;
     -webkit-transform-style: preserve-3d;
   }
   
   .card__face {
     width: 100%;
     height: 100%;
     position: absolute;
     inset: 0;
     background-size: cover;
     background-position: 50% 50%;
     background-repeat: no-repeat;
     border-radius: var(--border-radius);
     backface-visibility: hidden;
     -webkit-backface-visibility: hidden;
   }
   
   /* Seule la face avant porte l'image : la face arrière ne doit plus afficher
      une copie en miroir de la même capture. */
   .card__face--front {
     background-image: var(--img);
   }
   
   .card__face--back {
     transform: rotateY(180deg);
     background-color: #141414;
     background-image: none;
   }
   
   /* Voile animé à la place de filter: brightness() (compositor-only). */
   .card__shade {
     position: absolute;
     inset: 0;
     background: #000;
     opacity: 0;
     border-radius: var(--border-radius);
     pointer-events: none;
   }
   
   /* --- Aperçu --------------------------------------------------------------- */
   .preview {
     position: fixed;
     inset: 0;
     width: 100%;
     height: 100%;
     padding: 0 15vw;
     display: grid;
     align-content: center;
     justify-items: center;
     grid-row-gap: 1rem;
     opacity: 0;
     pointer-events: none;
     z-index: 1100;
     /* Les items volent en 3D (z: -3500, rotationY 100) pendant ouverture et
        fermeture : sans clip, leurs projections dépassent la fenêtre et créent
        un débordement horizontal transitoire. */
     overflow: hidden;
   }
   
   .preview__header {
     display: flex;
     width: 100%;
     align-items: flex-end;
     justify-content: space-between;
     gap: 1rem;
     line-height: 1;
   }
   
   .preview__title {
     margin: 0;
   }
   
   .preview__title h2 {
     margin: 0;
   }
   
   .preview__close {
     display: flex;
     align-items: center;
     justify-content: center;
     flex: 0 0 auto;
     width: 30px;
     height: 30px;
     border-radius: 50%;
     border: 2px solid var(--color-link);
     background: none;
     text-transform: inherit;
     padding: 0;
     margin: 0;
     translate: 0 -30%;
     font: inherit;
     line-height: 1;
     cursor: pointer;
     color: var(--color-link);
     transition: color 0.2s ease, border-color 0.2s ease;
   }
   
   .preview__close:hover {
     color: var(--color-link);
     border-color: var(--color-link-hover);
   }
   
   .preview__close:focus {
     outline: none;
   }
   
   .preview__close:focus-visible {
     outline: 2px solid red;
     outline-offset: 3px;
   }
   
   /* --- Grille de l'aperçu --------------------------------------------------- */
   .grid {
     position: relative;
     padding: 1rem 0;
     display: grid;
     grid-template-columns: repeat(var(--column-count), minmax(0, 1fr));
     grid-column-gap: var(--c-gap);
     grid-row-gap: var(--r-gap);
     width: 100%;
     perspective: 900px;
     cursor: pointer;
   }
   
   .grid__item {
     margin: 0;
     padding: 0;
     display: flex;
     flex-direction: column;
     gap: 0.25rem;
     overflow: hidden;
     border-radius: var(--border-radius);
     position: relative;
   }
   
   /* will-change uniquement pendant la transition : 12 couches plein écran en
      permanence font évincer les textures sur un GPU Android d'entrée de gamme. */
   .grid.is-animating .grid__item {
     will-change: transform, opacity;
   }
   
   .grid__item-image {
     width: 100%;
     aspect-ratio: var(--aspect);
     background-size: cover;
     background-position: 50% 50%;
     transition: opacity 0.15s cubic-bezier(0.2, 0, 0.2, 1);
   }
   
   .grid__item-caption h3 {
     font-size: 1rem;
     font-weight: 400;
     margin: 0;
   }
   
   /* --- Bouton play ---------------------------------------------------------- */
   .grid-play-overlay {
     position: absolute;
     inset: 0;
     z-index: 10;
     display: flex;
     justify-content: center;
     align-items: center;
     background-color: rgba(0, 0, 0, 0.25);
     opacity: 0;
     transition: opacity 0.3s ease;
     pointer-events: none;
   }
   
   .play-icon {
     width: clamp(48px, 12vw, 80px);
     height: auto;
   }
   
   /* Sur appareil tactile il n'y a pas de :hover → le bouton doit être visible. */
   @media (hover: none), (pointer: coarse) {
     .grid-play-overlay {
       opacity: 1;
     }
   }
   
   @media (hover: hover) and (pointer: fine) {
     .grid:hover .grid-play-overlay {
       opacity: 1;
     }
   
     .grid__item:hover .grid__item-image {
       opacity: 0.7;
     }
   }
   
   /* --- Overlay vidéo -------------------------------------------------------- */
   .video-overlay {
     position: fixed;
     inset: 0;
     width: 100%;
     height: 100%;
     background-color: rgba(0, 0, 0, 0.92);
     display: none;
     justify-content: center;
     align-items: center;
     z-index: 1200;
     cursor: pointer;
     overscroll-behavior: none;
   }
   
   .video-overlay.is-open {
     display: flex;
   }
   
   .video-overlay__close {
     position: absolute;
     top: max(1rem, env(safe-area-inset-top));
     right: max(1rem, env(safe-area-inset-right));
     z-index: 2;
     display: flex;
     align-items: center;
     justify-content: center;
     width: 44px;
     height: 44px;
     padding: 0;
     border-radius: 50%;
     border: 2px solid var(--color-link);
     background: none;
     color: var(--color-link);
     font: inherit;
     line-height: 1;
     cursor: pointer;
   }
   
   .video-container {
     width: 80%;
     max-width: 1000px;
     z-index: 1;
     cursor: default;
   }
   
   #overlay-video {
     display: block;
     width: 100%;
     max-height: 80svh;
     object-fit: contain;
     background: #000;
   }
   
   /* --- Responsive ----------------------------------------------------------- */
   @media screen and (min-width: 65em) {
     :root {
       --column-count: 6;
     }
   }
   
   /* --- Petits écrans OU écrans très bas (mobile paysage, fenêtre basse) ------
      LE correctif du bogue paysage : la condition portait uniquement sur la
      largeur (max-width: 48em). Un téléphone en paysage fait ~850 px de large →
      l'aperçu retombait sur les styles desktop (centré, sans overflow) : la
      grille, plus haute que l'écran, envoyait le titre et le bouton × hors de
      portée, sans possibilité de scroller. max-height: 32em couvre le paysage. */
   @media screen and (max-width: 48em), screen and (max-height: 32em) {
     :root {
       --column-count: 2;
       --c-gap: 1rem;
       --r-gap: 1rem;
     }
   
     .frame__title {
       position: fixed;   
       top: 4px;
       left: 4px;
     }
   
     /* L'aperçu redevient un plein écran défilant, centré, avec safe areas. */
     .preview {
       inset: 0;
       width: 100%;
       height: 100svh;
       padding: max(1rem, env(safe-area-inset-top)) 5vw
                max(1rem, env(safe-area-inset-bottom)) 5vw;
       grid-row-gap: 0.75rem;
       align-content: start;
       overflow-y: auto;
       overflow-x: hidden;
       overscroll-behavior: contain;
       -webkit-overflow-scrolling: touch;
       /* Garantit que le pan vertical de l'aperçu fonctionne pendant que
          html.is-locked impose touch-action: none au document. */
       touch-action: pan-y;
       background: var(--color-bg);
     }
   
     .preview__close {
       translate: 0 0;
       width: 36px;
       height: 36px;
     }
   
     .scene__title {
       padding: 0 6vw;
     }
   
     .scene__sub,
     .preview__sub {
       font-size: 1rem;
     }
   }
   
   /* --- Écrans très bas : carte du carrousel dimensionnée à la HAUTEUR -------
      En paysage mobile, 54vw donnerait des cartes de 350×420 px dans un écran
      de ~390 px de haut. On passe en vh : la scène entière tient dans l'écran
      et, --persp étant dérivée de --cell-w, l'homothétie est préservée. */
   @media screen and (max-height: 32em) {
     :root {
       --cell-w: clamp(120px, 36vh, 350px);
     }
   }
   
   /* --- Paysage mobile : assez large pour plus de 2 colonnes ----------------- */
   @media screen and (max-height: 32em) and (min-width: 40em) {
     :root {
       --column-count: 4;
     }
   }