/* Navigation / Topbar -- floating rounded bar (same style mobile and desktop) */
/* ---------- Header — source unique ----------
   Desktop: floating centered tab pill (dark glass, rounded corners),
   logout ONLY top right. Mobile (@768px): zero top bar,
   pill becomes fixed bottom-nav, floating logout top right.
   /#topbar = phantom container (no background): NO backdrop-filter here,
   sinon il devient containing block du #logout en position:fixed. */
#topbar {
  position: sticky;
  top: max(0.4rem, env(safe-area-inset-top));
  z-index: var(--z-nav);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1.5rem;
  margin: 0.4rem 0 0;
}

/* the pill suffices; brand lives on the login screen */
.brand { display: none; }

.tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  padding: 0.3rem;
  width: auto;
  height: auto;
  min-height: 0;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  padding: 0.7rem 1.3rem;
  min-height: 44px; /* ponytail: WCAG 2.5.8 touch target */
  min-width: 44px; /* idem en largeur (l'icone seule tombait a 42px) */
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  transition: var(--transition);
}

.tabs button:hover {
  color: var(--text-bright);
}

.tabs button:focus-visible {
  outline: 2px solid #e50914;
  outline-offset: 2px;
}

.tabs button.active {
  color: #000;
  background: var(--accent);
  box-shadow: var(--shadow-glow);
}

/* icon buttons in pill (search / favorites / admin): 44px touch target */
#tab-fav, #tab-admin, #search-btn {
  padding: 0.9rem;
  min-width: 44px;
}

#search-btn {
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-full);
  transition: var(--transition);
}
#search-btn:hover { color: var(--text-bright); }
#search-btn:focus-visible { outline: 2px solid #e50914; outline-offset: 2px; }
#search-btn.active {
  color: #000;
  background: var(--accent);
  box-shadow: var(--shadow-glow);
}

/* Search: floats centered below pill when open */

/* Cacher boutons quand un overlay est ouvert */
body:has(.overlay:not([hidden])) #logout { display: none; }
body:has(.overlay:not([hidden])) .tabs { display: none; }
/* Hide detail and category close when player is on top (overlap) */
body:has(#player:not([hidden])) #detail .close,
body:has(#player:not([hidden])) #category .close { display: none !important; }

/* Logout: power button ONLY, floating top right, opaque background */
#logout {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: 1.4rem;
  z-index: 41;
  color: #f87171;
  background: var(--surface);
  border: 1px solid var(--glass-border);
}
#logout:hover { background: #262626; color: #fff; }
#logout:focus-visible { outline: 2px solid #f87171; outline-offset: 2px; }

a:focus-visible {
  outline: 2px solid #e50914;
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
#search-wrap {
  width: 100%;
  max-width: 560px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  z-index: var(--z-search);
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, transform 0.3s ease, margin 0.3s ease;
}

#topbar.search-open #search-wrap {
  max-height: 64px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 0.6rem;
}

#search {
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.search {
  width: 100%;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-bright);
  font-size: 0.95rem;
  transition: var(--transition);
}

.search:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

/* Page Layout */
#content {
  padding: 1.8rem 3rem 6rem;
  max-width: 1580px;
  margin: 0 auto;
}

.row {
  margin-bottom: 3rem;
  /* Off-screen rows not rendered -> much faster first paint
     (38 categories x 40 cards otherwise rendered all at once) */
  content-visibility: auto;
  contain-intrinsic-size: auto 200px; /* reduced from 400px to fix gap measurement */
}
/* Row spacing varies (Netflix-style — Issue #2) */
.row:first-of-type { margin-bottom: 3rem; } /* more space after hero/banner */
#content:has(.card.resume) .row:first-of-type { margin-bottom: 3.5rem; } /* Resume row needs more space */

.row h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.3px;
  color: var(--text-bright);
}

.row-scroll {
  display: flex;
  gap: var(--sp-4);
  overflow-x: auto;
  padding: 0.5rem 0.2rem 1.1rem;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity; /* rail effect: posters snap, never cut at rest */
  scroll-padding-left: 0.2rem;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
  mask-image: linear-gradient(to right, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
}
.row-scroll::-webkit-scrollbar { height: 6px; }
.row-scroll::-webkit-scrollbar-track { background: transparent; }
.row-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}
/* Uniformise les largeurs de cartes dans les rows horizontales (fix bug #3) */
.row-scroll > .card {
  flex: 0 0 170px; /* width fixe pour éviter les tailles inégales */
}

.row-scroll > .card {
  scroll-snap-align: start;
}
/* tactile: scroll natif — smooth se bat avec le doigt */
@media (hover: none) {
  .row-scroll { scroll-behavior: auto; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.4rem;
  padding: 0.5rem 0.2rem;
}


/* Navbar scroll blur (Issue #8) -- transparent → blur + fond sombre au scroll */
.tabs.scrolled {
  background: rgba(26, 26, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

/* ---------- #185: Navigation Rail (desktop >= 1024px) ---------- */
/* La pill horizontale devient une barre verticale d'icônes à gauche ;
   tablette/mobile (<1024px) garde la pill topbar actuelle. */
@media (min-width: 1024px) {
  body { padding-left: 68px; }
  .tabs {
    position: fixed;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem 0.4rem;
    z-index: 60;
  }
  .tabs button {
    position: relative;
    flex-direction: column;
    gap: 3px;
    padding: 0.6rem 0.75rem;
  }
  .tabs button .label { display: none; }
  /* Tooltip (nom de la section) au survol */
  .tabs button[data-tip]:hover::after,
  .tabs button[data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    font-size: 0.78rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 70;
  }
}
