/* ============================================================================
   MOBILE V2 — design mobile reconstruit de zéro (2026-08-03)
   Coquille app + composants + transitions fluides « type React Native ».
   Opt-in PAR PAGE : une page migrée charge CE fichier À LA PLACE de
   gate-mobile-app.css / bottom-nav.css / responsive.css. Les pages non migrées
   gardent l'ancien CSS → migration progressive sans rien casser.
   S'appuie sur les tokens de marque (tokens.css, déjà importé par gate2026.css).
   ============================================================================ */

/* Le header mobile n'apparaît que sur téléphone (masqué par défaut = desktop) */
.mobile-app-header { display: none; }

:root {
  --m2-safe-top: env(safe-area-inset-top, 0px);
  --m2-safe-bot: env(safe-area-inset-bottom, 0px);
  --m2-header-h: 60px;
  --m2-tabbar-h: 62px;
  --m2-gap: 14px;
  --m2-radius: 18px;
  --m2-radius-lg: 24px;
  --m2-chrome: rgba(12, 12, 15, 0.96);
  --m2-chrome-solid: #0c0c0f;
  --m2-hairline: rgba(255, 255, 255, 0.08);
  --m2-press: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ====== FLUIDITÉ : transitions de page (View Transitions API) ================
   DÉSACTIVÉ 2026-08 — la personnalisation « coquille persistante » ci-dessous
   posait `view-transition-name: m2-header/m2-tabbar` sur .mobile-app-header /
   .bottom-nav. Dès qu'un de ces éléments existait en double dans le DOM (nav
   codée en dur + injectée par app.js renderBottomNav), deux éléments partageaient
   le même view-transition-name → la view-transition avortait avec
   « InvalidStateError: Transition was aborted because of invalid state » (vu
   dans logs/js-errors.log sur /search), laissant l'overlay ::view-transition
   plein écran FIGÉ par-dessus la page → SCROLL BLOQUÉ sur event/search.
   MISE À JOUR : la view-transition inter-documents avortait AUSSI sur desktop
   (« InvalidStateError: Transition was aborted » vu sur /search, Windows) — un
   overlay ::view-transition figé restait par-dessus la page → SCROLL BLOQUÉ au
   trackpad. On désactive donc la view-transition sur les pages qui chargent ce
   fichier (mobile-v2 se charge APRÈS gate2026.css → `navigation:none` gagne).
   Le cross-fade de page est du pur cosmétique ; un scroll qui marche prime. */
@view-transition { navigation: none; }

/* =========================== SCAFFOLD MOBILE =============================== */
@media (max-width: 768px) {
  /* La navbar bureau n'existe pas en mobile */
  .navbar, .hide-mobile { display: none !important; }
  .hide-desktop { display: revert; }

  body {
    padding-bottom: calc(var(--m2-tabbar-h) + var(--m2-safe-bot) + 8px);
    background: var(--bg-primary);
  }
  /* padding-top UNIQUEMENT si le header mobile est réellement présent.
     event.html utilise .event-mobile-header (pas .mobile-app-header) → sans
     cette garde, les 60px réservés au header devenaient un espace vide en
     haut qui décalait toute la page. */
  body:has(.mobile-app-header) {
    padding-top: calc(var(--m2-header-h) + var(--m2-safe-top));
  }

  .container { width: 100%; padding-inline: 16px; margin-inline: 0; max-width: 100%; }

  /* ============================= HEADER ================================== */
  .mobile-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 200;
    height: calc(var(--m2-header-h) + var(--m2-safe-top));
    padding: var(--m2-safe-top) 16px 0;
    background: var(--m2-chrome);
    border-bottom: 1px solid transparent;
    transition: background 0.25s ease, border-color 0.25s ease;
  }
  .mobile-app-header.scrolled {
    background: var(--m2-chrome-solid);
    border-bottom-color: var(--m2-hairline);
  }
  .mobile-page-title {
    font-family: var(--font-sans);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.1;
  }

  /* =========================== TAB BAR (bas) ============================== */
  .bottom-nav {
    display: flex !important; /* gate2026.css force display:none !important */
    position: fixed;
    inset: auto 0 0 0;
    z-index: 200;
    height: calc(var(--m2-tabbar-h) + var(--m2-safe-bot));
    padding-bottom: var(--m2-safe-bot);
    background: var(--m2-chrome);
    border-top: 1px solid var(--m2-hairline);
  }
  .bottom-nav > a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-tertiary);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.18s ease, transform 0.12s var(--m2-press);
  }
  .bottom-nav > a svg { width: 24px; height: 24px; stroke-width: 2; }
  .bottom-nav > a.active { color: var(--text-primary); }
  .bottom-nav > a.active svg { stroke: var(--gate-violet); }
  .bottom-nav > a:active { transform: scale(0.9); }
  /* pastille de notification */
  .bottom-nav .nav-badge {
    position: absolute; top: 6px; left: 56%;
    min-width: 16px; height: 16px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; font-weight: 800; color: #fff;
    background: var(--gate-rose, #ec4899); border-radius: 999px;
  }

  /* ======================= COMPOSANTS DE BASE ============================ */
  /* Titres de section façon iOS */
  .section-header, .home-section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 26px 0 12px;
  }
  .section-title, .home-section-title {
    font-size: 1.28rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary);
  }
  .section-link, .see-all { font-size: 0.85rem; font-weight: 600; color: var(--gate-violet); }

  /* Rails horizontaux à défilement fluide (scroll-snap, momentum) */
  .h-rail, .cards-scroll, .events-row {
    display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding-inline: 16px; margin-inline: -16px;
  }
  .h-rail::-webkit-scrollbar, .cards-scroll::-webkit-scrollbar, .events-row::-webkit-scrollbar { display: none; }
  .h-rail > *, .cards-scroll > *, .events-row > * { scroll-snap-align: start; flex: 0 0 auto; }

  /* Chips / filtres */
  .chip, .filter-tag, .genre-tag, .category-chip {
    flex: 0 0 auto; white-space: nowrap;
    padding: 9px 16px; border-radius: 999px;
    font-size: 0.85rem; font-weight: 600;
    background: var(--surface); color: var(--text-secondary);
    border: 1px solid var(--m2-hairline);
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s var(--m2-press);
  }
  .chip:active, .filter-tag:active { transform: scale(0.94); }
  .chip.active, .filter-tag.active, .genre-tag.active {
    background: var(--gate-violet); color: #fff; border-color: transparent;
  }

  /* Champ de recherche */
  .search-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 16px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--m2-hairline);
  }
  .search-bar input {
    flex: 1; min-width: 0; border: 0; background: none; outline: none;
    color: var(--text-primary); font-size: 16px; /* 16px = pas de zoom iOS */
  }

  /* Boutons */
  .btn, .btn-primary, .hero-v5-actions a, .hero-v5-actions button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 20px; border-radius: 14px;
    font-size: 0.95rem; font-weight: 700;
    transition: transform 0.12s var(--m2-press), filter 0.18s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:active, .btn-primary:active { transform: scale(0.96); }
  .btn-primary, .btn.primary { background: var(--gradient-brand); color: #fff; border: 0; }

  /* Carte générique */
  .card, .stat-card, .event-card {
    background: var(--bg-card); border: 1px solid var(--border-card);
    border-radius: var(--m2-radius);
  }
}

/* ============================================================================
   BOTTOM SHEETS — panneaux glissants type app (navigation, filtres, actions)
   Ouverts par [data-sheet="#id"], fermés par swipe-down / backdrop / [data-sheet-close].
   Contrôleur : assets/js/mobile-v2-sheets.js
   ============================================================================ */
.m2-sheet-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0; visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.m2-sheet-backdrop.open { opacity: 1; visibility: visible; }

.m2-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 901;
  max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--bg-modal, #111116);
  border-top-left-radius: var(--m2-radius-lg);
  border-top-right-radius: var(--m2-radius-lg);
  border-top: 1px solid var(--m2-hairline);
  box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.5);
  padding-bottom: var(--m2-safe-bot);
  transform: translateY(101%);
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1); /* ressort iOS */
  will-change: transform;
  touch-action: none;
  /* FERMÉ : ne JAMAIS capter le pointeur. `will-change: transform` +
     translateY(101%) peut laisser la zone de hit-test de la feuille SUR le
     contenu alors qu'elle est visuellement hors écran (bug de compositing
     Chrome) → elle avalait la molette et bloquait tout le scroll de la page.
     pointer-events:none règle ça définitivement. */
  pointer-events: none;
}
.m2-sheet.open { transform: translateY(0); pointer-events: auto; }
.m2-sheet.dragging { transition: none; } /* suivi du doigt sans latence */

.m2-sheet-handle {
  flex: 0 0 auto; width: 100%; padding: 10px 0 6px;
  display: flex; justify-content: center; cursor: grab;
}
.m2-sheet-handle::before {
  content: ""; width: 40px; height: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}
.m2-sheet-title {
  padding: 2px 20px 12px; font-size: 1.15rem; font-weight: 800;
  letter-spacing: -0.02em; color: var(--text-primary);
}
.m2-sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 16px 16px;
}

/* Liste d'actions/liens de navigation dans un sheet */
.m2-sheet-list { display: flex; flex-direction: column; gap: 4px; }
.m2-sheet-link {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 14px; border-radius: 14px;
  color: var(--text-primary); text-decoration: none;
  font-size: 1rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.12s var(--m2-press);
}
.m2-sheet-link:active { background: var(--surface-hover); transform: scale(0.98); }
.m2-sheet-link svg { width: 22px; height: 22px; stroke-width: 2; color: var(--gate-violet); flex: 0 0 auto; }
.m2-sheet-link .m2-chevron { margin-left: auto; color: var(--text-tertiary); }
.m2-sheet-link .nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 800; color: #fff;
  background: var(--gate-rose, #ec4899); border-radius: 999px;
}
@media (prefers-reduced-motion: reduce) {
  .m2-sheet { transition: transform 0.01ms; }
}

/* ============================================================================
   FILET DE SÉCURITÉ GLOBAL — scroll (2026-08)
   Cause d'une semaine de galère : plusieurs panneaux plein écran (m2-sheet,
   checkout-drawer, *-overlay, *-sheet…) sont cachés par transform/opacity MAIS
   gardent pointer-events:auto. Sur écran tactile (device.js → is-mobile), leur
   zone de hit-test reste sur le contenu → ils AVALENT la molette (surtout ceux
   en overflow-y:auto + overscroll-behavior:contain) → page impossible à scroller.
   Règle : TOUT panneau/drawer/overlay/modale qui n'est PAS ouvert (.open/.active)
   ne capte JAMAIS le pointeur. Réactif : dès qu'il reçoit .open, il redevient
   cliquable. Couvre les cas connus ET futurs (sélecteurs [class*=…]).
   ============================================================================ */
.m2-sheet:not(.open),
.m2-sheet-backdrop:not(.open),
.checkout-drawer:not(.open),
.checkout-overlay:not(.open),
.map-overlay:not(.open),
.resale-modal-overlay:not(.active),
[class*="-drawer"]:not(.open):not(.active),
[class*="-overlay"]:not(.open):not(.active),
[class*="-sheet"]:not(.open):not(.active):not([class*="-sheet-"]) {
  pointer-events: none !important;
}
