/* ═══════════════════════════════════════════════════════════
   InterFilm — Responsive mobile & tablette (source unique)
   Chargé en dernier pour écraser les conflits legacy
   ═══════════════════════════════════════════════════════════ */

:root {
  --mobile-nav-h: 56px;
  --mobile-tab-h: 62px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-content-pad: calc(var(--mobile-tab-h) + var(--mobile-safe-bottom) + 12px);
}

/* Chips filtres recherche & franchises — masqués mobile + desktop */
.search-filters,
.search-popular-chips,
#trendChips,
#studioGenreChips {
  display: none !important;
}

/* ─── BARRE BAS FIXE ─── */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99990;
  height: calc(var(--mobile-tab-h) + var(--mobile-safe-bottom));
  padding-bottom: var(--mobile-safe-bottom);
  background: #000;
  border-top: 1px solid rgba(247, 127, 0, 0.35);
  justify-content: space-around;
  align-items: stretch;
  box-shadow: 0 -4px 28px rgba(247, 127, 0, 0.1), 0 -8px 32px rgba(0, 0, 0, 0.55);
}

.mobile-tab-btn {
  flex: 1;
  min-width: 0;
  max-width: 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.38);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 6px 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
}

.mobile-tab-btn svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  flex-shrink: 0;
}

.mobile-tab-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.mobile-tab-btn.active {
  color: #f77f00;
}

.mobile-tab-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  background: linear-gradient(90deg, #f77f00, #ff9500);
  border-radius: 0 0 2px 2px;
}

.mobile-tab-btn.active svg {
  filter: drop-shadow(0 0 8px rgba(247, 127, 0, 0.45));
}

/* ─── MENU MOBILE (sheet) ─── */
.mobile-nav-sheet {
  position: fixed;
  inset: 0;
  z-index: 99995;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.mobile-nav-sheet.open {
  pointer-events: auto;
  opacity: 1;
}

.mobile-nav-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.mobile-nav-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(88vh, 720px);
  background: #0a0a0f;
  border-radius: 20px 20px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
  padding: 12px 16px calc(var(--mobile-tab-h) + var(--mobile-safe-bottom) + 16px);
  transform: translateY(105%);
  transition: transform 0.32s cubic-bezier(0.32, 1.1, 0.42, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav-sheet.open .mobile-nav-sheet-panel {
  transform: translateY(0);
}

.mobile-nav-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mobile-nav-sheet-head h3 {
  margin: 0;
  font-family: var(--ff-head);
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
}

.mobile-nav-sheet-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.mobile-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mobile-nav-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 88px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.mobile-nav-tile:active {
  transform: scale(0.97);
}

.mobile-nav-tile svg {
  width: 22px;
  height: 22px;
  stroke: #f77f00;
  fill: none;
  stroke-width: 1.8;
}

.mobile-nav-tile--accent {
  border-color: rgba(247, 127, 0, 0.35);
  background: rgba(247, 127, 0, 0.08);
}

.mobile-nav-tile--staff {
  border-color: rgba(245, 166, 35, 0.35);
  color: var(--gold2);
}

/* ─── MOBILE ≤768px ─── */
@media (max-width: 768px) {
  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden !important;
    padding-bottom: var(--mobile-content-pad) !important;
    min-height: 100vh;
  }

  .mobile-bottom-bar,
  #mobileBottomBar {
    display: flex !important;
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 !important;
    height: calc(var(--mobile-tab-h) + var(--mobile-safe-bottom)) !important;
    padding-bottom: var(--mobile-safe-bottom) !important;
    background: #000 !important;
    border-top: 1px solid rgba(247, 127, 0, 0.35) !important;
    border-bottom: none !important;
    z-index: 99990 !important;
  }

  .mobile-tab-btn.active {
    color: #f77f00 !important;
  }

  .mobile-nav-bar {
    display: none !important;
  }

  /* Navbar haut */
  nav#mainNav {
    height: var(--mobile-nav-h) !important;
    padding: 0 12px !important;
  }

  .nav-links,
  .search-pill,
  .nav-link-staff {
    display: none !important;
  }

  .logo {
    font-size: 1.25rem !important;
  }

  .user-pill span,
  .user-pill svg:last-child {
    display: none !important;
  }

  .hamburger-btn {
    display: flex !important;
  }

  /* Pages — dégagement nav + tab bar */
  #heroSection,
  #homeView,
  #catalogueView,
  #gridView,
  #studioView,
  #dashboardView,
  #faqView,
  #reviewsView,
  #releasesView,
  #tvView,
  #top10View,
  .chart10 {
    padding-top: calc(var(--mobile-nav-h) + 8px) !important;
    padding-bottom: calc(var(--mobile-content-pad) + 8px) !important;
    min-height: auto !important;
  }

  .community-page {
    padding-left: 14px !important;
    padding-right: 14px !important;
    padding-bottom: calc(var(--mobile-content-pad) + 16px) !important;
  }

  /* Franchises — filtres genre scrollables */
  #studioView {
    padding-top: calc(var(--mobile-nav-h) + 8px) !important;
  }

  #studioView .grid-header {
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px 4px !important;
    margin-top: 0 !important;
  }

  #studioView .grid-header h2 {
    font-size: 20px !important;
    flex: 1;
    min-width: 0;
  }

  /* Recherche — au-dessus de la barre bas */
  .search-bg {
    z-index: 99995 !important;
    padding-bottom: var(--mobile-content-pad) !important;
  }

  .search-body {
    padding-bottom: calc(var(--mobile-content-pad) + 12px) !important;
  }

  /* Accueil — affiches plus grandes, contenu plus proche du hero */
  #homeView {
    padding-top: 0 !important;
    margin-top: -6px;
  }

  #homeView .hero-separator {
    margin-bottom: 0;
    opacity: 0.35;
  }

  #homeView .studio-carousel-wrap {
    padding: 2px 4px 6px !important;
    margin-top: 0 !important;
  }

  #homeView .studio-bar {
    padding: 6px 8px !important;
    gap: 6px !important;
  }

  #homeView .studio-bar-actions {
    padding: 0 10px 4px !important;
    margin-top: -2px;
  }

  #homeView .section {
    padding: 0.15rem 0.5rem 0.6rem !important;
  }

  #homeView .section-header {
    margin-bottom: 2px !important;
    padding: 0 6px !important;
  }

  #homeView .scroll-row {
    padding: 2px 0 6px !important;
  }

  #homeView .row-inner {
    padding: 2px 0 8px !important;
    gap: 9px !important;
  }

  #homeView .row-inner > .card {
    flex: 0 0 172px !important;
    width: 172px !important;
    scroll-snap-align: start !important;
  }

  #homeView .row-inner > .card .card-img {
    height: 258px !important;
  }

  #homeView .row-inner > .card-trending {
    flex: 0 0 188px !important;
    width: 188px !important;
  }

  #homeView .row-inner > .card-trending .card-img {
    height: 282px !important;
  }

  /* Recherche mobile — affiches plus grandes, layout compact */
  .search-top {
    padding: 0.85rem 10px 0.5rem !important;
    gap: 0.5rem !important;
  }

  #searchInput {
    font-size: clamp(18px, 5vw, 24px) !important;
  }

  .search-body {
    padding: 0.5rem 8px calc(var(--mobile-content-pad) + 8px) !important;
  }

  .search-label {
    margin-bottom: 0.45rem !important;
    font-size: 11px !important;
  }

  .search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 11px 9px !important;
    padding: 0 6px 10px !important;
  }

  .search-grid .card--poster,
  .search-grid .card {
    width: 100% !important;
    max-width: none !important;
  }

  .search-grid .card-img {
    height: auto !important;
    aspect-ratio: 2 / 3 !important;
    width: 100% !important;
  }

  /* Roue aléatoire — voir wheel-modal.css */
  .wheel-bg {
    z-index: 99996 !important;
  }

  /* Grilles affiches (hors recherche — voir bloc dédié plus haut) */
  .movies-grid,
  #catalogueGrid,
  #moviesGrid,
  #studioGrid,
  #dashGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px 7px !important;
    padding: 0 12px 16px !important;
  }

  .saga-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px 7px !important;
  }

  #catalogueGrid .card--poster,
  #moviesGrid .card--poster,
  #studioGrid .card--poster,
  #dashGrid .card--poster {
    max-width: none !important;
    justify-self: stretch !important;
  }

  /* Chart Top 10 */
  .chart10-topbar {
    padding: 0 12px !important;
  }

  .chart10-display {
    font-size: clamp(1.5rem, 7vw, 2rem) !important;
  }

  .chart10-lede {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  /* Modals plein écran fluides */
  .modal-bg.open {
    padding: 0 !important;
  }

  .modal-floating-back {
    top: max(10px, env(safe-area-inset-top)) !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    padding: 7px 12px !important;
    font-size: 13px !important;
  }

  .film-detail-layout {
    margin-top: -40px !important;
    padding: 0 12px !important;
  }

  .cm-like-bar {
    justify-content: center;
  }

  .cm-like-bar .like-login-hint {
    text-align: center;
  }

  /* Profil éditeur */
  #editMainProfileModal.profile-editor-modal {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  #editMainProfileModal.profile-editor-modal > .pe-shell {
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0 !important;
    width: 100% !important;
  }

  /* Dropdowns */
  .main-dropdown,
  .premium-dropdown,
  .notif-inbox {
    top: calc(var(--mobile-nav-h) + 4px) !important;
    max-width: calc(100vw - 24px) !important;
  }

  .notif-inbox {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
  }

  /* Staff panel */
  .staff-panel {
    width: 100% !important;
    max-width: 100vw !important;
  }

  .staff-sidebar {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Player */
  .player-premium-bar {
    padding-bottom: calc(8px + var(--mobile-safe-bottom)) !important;
  }

  /* Footer */
  .site-footer {
    padding-bottom: var(--mobile-content-pad) !important;
  }

  /* Hero */
  .hero {
    min-height: 58vh !important;
    padding-top: var(--mobile-nav-h) !important;
  }

  .hero-content {
    bottom: 72px !important;
    left: 14px !important;
    right: 14px !important;
  }

  /* Carrousels home */
  .row-inner > .card,
  .row-inner > .card-trending {
    flex: 0 0 132px !important;
    width: 132px !important;
  }

  .card-img {
    height: auto !important;
    aspect-ratio: 2/3 !important;
  }
}

@media (max-width: 420px) {
  .movies-grid,
  #catalogueGrid,
  #moviesGrid,
  #studioGrid,
  #dashGrid,
  .search-grid,
  .saga-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px 8px !important;
  }

  .mobile-nav-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-tab-btn {
    font-size: 8px;
  }
}

/* ─── TABLETTE 769–1024px ─── */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    padding-bottom: 0 !important;
  }

  .mobile-bottom-bar,
  .mobile-nav-sheet {
    display: none !important;
  }

  nav#mainNav {
    padding: 0 16px !important;
  }

  .nav-links {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    gap: 2px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    padding: 8px 14px !important;
    font-size: 13px !important;
  }

  .search-pill {
    display: none !important;
  }

  #catalogueView,
  #gridView,
  #studioView,
  #dashboardView,
  #faqView,
  #reviewsView,
  #releasesView,
  #top10View,
  .chart10 {
    padding-top: calc(var(--nav-h, 64px) + 12px) !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .movies-grid,
  #catalogueGrid,
  #moviesGrid,
  #studioGrid,
  #dashGrid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 14px 10px !important;
  }

  .saga-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .main-dropdown {
    width: 280px !important;
  }
}
