/* ═══════════════════════════════════════════════════════════════
   slidou.me — mobile.css (v24 : refonte mobile · v26 : consolidation)
   ─────────────────────────────────────────────────────────────
   v26 : les anciens blocs @media de style.css (pré-v24) ont été
   purgés — 100 % de l'adaptation largeur vit désormais ICI.
   • Chargé APRÈS style.css et season.css → il gagne les égalités.
   • Toutes les règles d'adaptation sont dans @media (max-width: 768px)
     → le PC est inchangé au pixel près.
   • La « section 0 » reprend telles quelles les règles historiques
     déplacées de style.css : la cascade reste identique.
   • Hors media query : uniquement les deux composants dédiés
     (barre basse + feuille « plus »), masqués par défaut → invisibles sur PC.

   Au programme :
   1. Barre de navigation basse (pouce) + feuille « plus »
   2. Sidebar transformée en barre supérieure fine et collante
   3. Popups (review, calendrier) → bottom-sheets plein écran
   4. Recherche → palette plein écran
   5. Grilles de covers 2 colonnes propres
   6. Cibles tactiles ≥ 44px partout (chips, tris, flèches, player)
   7. Calendrier liste, bilan, stats, à propos : recalibrés
   8. Calibrage Android Chrome : safe-areas (barre de gestes),
      100dvh, inputs ≥ 16px (pas de zoom automatique)
   ═══════════════════════════════════════════════════════════════ */

/* ── COMPOSANT 1 : barre de navigation basse (masquée sur PC) ── */
.mobile-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 950; /* au-dessus du contenu et du player, sous les popups */
  display: none;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -6px 18px var(--shadow-color);
  padding-bottom: env(safe-area-inset-bottom, 0px); /* barre de gestes Android */
  transition: background 0.3s;
}
.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  text-decoration: none;
  color: var(--secondary-text);
  font-family: 'Space Grotesk', sans-serif;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-btn .mn-ico { font-size: 21px; line-height: 1; }
.mobile-nav-btn .mn-label {
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: lowercase;
}
.mobile-nav-btn.active { color: var(--link-color); }
.mobile-nav-btn:active { color: var(--link-color); }

/* ── COMPOSANT 2 : feuille « plus » (masquée sur PC) ─────────── */
.mobile-plus-sheet {
  position: fixed;
  inset: 0;
  z-index: 2500; /* au-dessus des popups (1000), sous la palette (3000) */
  display: none;
  background: rgba(0, 0, 0, 0.45);
  overscroll-behavior: contain;
}
.mobile-plus-sheet.open { display: block; }
.mobile-plus-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 76vh;
  max-height: 76dvh;
  overflow-y: auto;
  background: var(--bg-color);
  border-top: 1px solid var(--border-color);
  border-radius: 16px 16px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3);
  animation: mpsUp 0.22s cubic-bezier(0.3, 0.9, 0.4, 1);
  transition: background 0.3s;
}
@keyframes mpsUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.mobile-plus-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: lowercase;
  color: var(--secondary-text);
  margin-bottom: 8px;
}
.mobile-plus-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 6px 8px;
  color: var(--text-color);
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  border-bottom: 1px solid var(--border-color);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-plus-item:last-of-type { border-bottom: none; }
.mobile-plus-item:active,
.mobile-plus-item:hover { color: var(--link-color); }
.mobile-plus-item .mn-ico { font-size: 20px; line-height: 1; }
.mobile-plus-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  font-size: 26px;
  color: var(--secondary-text);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════
   ADAPTATION MOBILE (< 768px) — le PC ne lit JAMAIS cette section
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── 0. BASE HISTORIQUE (règles déplacées des anciens @media de style.css — v26) ──
     Cascade préservée : ces règles arrivent AVANT les ajustements ci-dessous,
     exactement comme quand elles vivaient dans style.css (chargé avant celui-ci). */
  .wrapper { flex-direction: column; }
  .book-card img { aspect-ratio: 2 / 3; object-fit: cover; }
  #filmsContent .book-card img, #seriesContent .book-card img { height: auto; aspect-ratio: 2 / 3; object-fit: cover; }
  /* v30 (A4) : le sélecteur .anime-card img est retiré — les img des cartes anime sont wrappées
     par le cover-stack (v22, height:100% !important) qui fixe déjà le ratio 2/3 ; le .anime-placeholder
     reste vivant ici pour les top-lists (non wrappées) */
  .anime-placeholder { aspect-ratio: 2 / 3; height: auto; }
  /* v31 (S5) : .manga-placeholder retiré — règle morte (motif A4 v30) : dans les cartes le
     placeholder vit dans le cover-stack (100 %/100 % !important depuis la v22) et dans les
     top-lists l'élément porte aussi .anime-placeholder (règle au-dessus, mêmes valeurs) */
  .recap-music-card img { aspect-ratio: 1 / 1; height: auto; object-fit: cover; }
  .recap-ecrans-card img { height: auto; aspect-ratio: 2 / 3; object-fit: cover; }

  /* Calendrier : mode liste (historique) */
  .home-calendar-grid { display: flex; flex-direction: column; gap: 4px; }
  .calendar-day-header { display: none; }
  .calendar-day.empty { display: none; }
  .calendar-day { display: flex; flex-direction: row; align-items: center; aspect-ratio: unset; height: auto; padding: 8px; gap: 10px; }
  .calendar-day img { width: 45px; height: 65px; object-fit: cover; position: relative; top: auto; left: auto; }
  .calendar-day-num { position: relative; bottom: auto; left: auto; background: none; color: var(--secondary-text); padding: 0; z-index: 1; font-size: 12px; }
  .calendar-badge { position: relative; top: auto; right: auto; margin-left: auto; background: var(--link-color); color: white; }

  /* Lecteur musique : collé en bas (historique — ajusté plus bas avec la barre basse) */
  .player-widget { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; margin: 0; border-radius: 12px 12px 0 0; box-shadow: 0 -4px 15px var(--shadow-color); padding: 15px 20px; }
  #page-musique { padding-bottom: 140px; }

  /* Perruches : cages en colonne (historique) */
  .tamagotchi-cages-wrapper { flex-direction: column; gap: 30px; }
  .tamagotchi-bird-container { max-width: 100%; }

  /* Statistiques : top 3 sous le graphique + panthéon/sévérité compacts (historique) */
  .stats-main-flex { flex-direction: column; }
  .stats-top { flex: unset; border-left: none; border-top: 1px solid var(--border-color); padding-left: 0; padding-top: 16px; margin-top: 16px; }
  .sev-label { flex: 0 0 92px; font-size: 10px; }
  .sev-val { flex: 0 0 36px; font-size: 12px; }
  .sev-sub { margin-left: 104px; }
  .sev-note { margin-left: 0; }
  .pantheon { padding: 15px; }
  /* v36 (S4) : format uniforme repris en mobile (62×92) */
  .pantheon-cover { flex: 0 0 62px; width: 62px; height: 92px; }
  .pantheon-cover img { width: 62px; height: 92px; }

  /* Perruches passives : perchoir ambulant compact (historique — bottom réajusté plus bas) */
  .budgie-ambient { right: var(--br, 6px); bottom: var(--bb, 6px); width: 58px; height: 74px; }
  .ba-bird-holder { height: 58px; }
  .budgie-ambient .ba-mark { font-size: 15px; top: -4px; right: 0; }
  .budgie-ambient .ba-fx span { font-size: 12px; left: 12px; }

  /* ── Socle ── */
  :root { --mn-h: 58px; } /* hauteur de la barre basse (hors safe-area) */
  html { -webkit-text-size-adjust: 100%; }
  body {
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none; /* pas de rebond cascade sur Android */
  }
  button, a, input { touch-action: manipulation; }

  /* ── 1. SIDEBAR → BARRE SUPÉRIEURE FINE ET COLLANTE ── */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 900;
    flex-direction: row;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-header { margin-bottom: 0; }
  .sidebar h1 { font-size: 21px; }
  .sidebar nav { display: none; } /* remplacée par la barre basse + « plus » */
  .sidebar-header-actions { display: flex; gap: 2px; }
  #menu-toggle,
  #search-toggle,
  #theme-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
  }

  /* ── 2. BARRE BASSE VISIBLE + AIR SOUS LE CONTENU ── */
  .mobile-nav { display: flex; }
  .content {
    padding: 18px 12px calc(var(--mn-h) + env(safe-area-inset-bottom, 0px) + 30px);
    overflow-x: hidden;
  }

  /* ── 3. GRILLES DE COVERS : 2 COLONNES PROPRES ── */
  .books { gap: 14px; }
  #filmsContent .books, #seriesContent .books { gap: 14px; }
  .book-card { width: calc(50% - 7px); }
  .recap-music-card, .recap-ecrans-card { width: calc(50% - 7px); }
  /* Zones sans cover-stack (v22) : ratios gérés à la main */
  #jeuxContent .book-card img { height: auto; aspect-ratio: 3 / 4; }
  #musiqueContent .book-card img { height: auto; aspect-ratio: 1 / 1; }
  .anime-grid { gap: 12px; }
  .book-title { font-size: 13px; }
  .book-meta { letter-spacing: 1.5px; }

  /* ── 4. CIBLES TACTILES ≥ 44PX : CHIPS, TRIS, BOUTONS ── */
  .anime-tag-btn { padding: 11px 15px; font-size: 12px; }
  .anime-tag-section-tags { gap: 9px; }
  .anime-sort-btn { padding: 12px 8px; font-size: 12px; }
  /* v30 (S3) : chips et tri mesuraient ~40px — on atteint la cible ≥44px annoncée par la section
     (socle partagé : toutes les pages qui utilisent ces classes — biblio, écrans, jeux, musique, anime, manga) */
  .anime-tag-btn, .anime-sort-btn { min-height: 44px; }
  .anime-sort { gap: 6px; }
  .anime-top-controls { gap: 8px; flex-wrap: wrap; }
  .counter { font-size: 11px; margin-bottom: 6px; }
  .review-btn { padding: 8px 14px; font-size: 11px; margin-top: 8px; }
  .load-more-btn { padding: 14px 24px; font-size: 13px; }
  .toggle-tags-btn { padding: 12px; font-size: 12px; }
  .manga-filters { gap: 12px; margin-bottom: 30px; }
  .anime-tags-wrapper { margin-bottom: 30px; }

  /* Recherche locale : 16px = pas de zoom auto au focus */
  .search-bar {
    font-size: 16px;
    padding: 12px 0;
    margin: 26px auto 18px;
  }

  /* Titres de créateurs / sections */
  .text-content h2 { margin: 44px 0 16px; font-size: 21px; padding-bottom: 12px; }
  #filmsContent h2, #seriesContent h2 { margin: 44px 0 16px; font-size: 21px; padding-bottom: 12px; }
  .empty-state { padding: 30px 0; }

  /* Sous-nav films/séries : pouces confortables */
  .sub-nav { margin-bottom: 30px; }
  .sub-nav-link { display: inline-block; padding: 10px 14px; font-size: 13px; }

  /* Listes top (rank) */
  .top-item { padding: 12px; gap: 14px; }
  .top-rank { font-size: 22px; min-width: 30px; }
  .top-item img, .top-item .anime-placeholder, .top-item .manga-placeholder { width: 54px; height: 78px; }

  /* ── 5. ACCUEIL : DASHBOARD + CALENDRIER LISTE ── */
  #page-home.active { padding: 14px 0 0; }
  .home-dashboard-grid { flex-wrap: wrap; gap: 12px; }
  .home-dash-card { width: 72px; }
  .home-calendar-header { gap: 12px; margin-bottom: 16px; }
  .calendar-nav-btn { width: 44px; height: 44px; font-size: 22px; }
  .home-month-title { font-size: 16px; margin-bottom: 12px; }
  /* Le mode liste (déjà en place) prend des rangées plus digestes */
  .calendar-day { padding: 10px; gap: 12px; }
  .calendar-day img { width: 48px; height: 70px; }

  /* ── 6. POPUPS → BOTTOM-SHEETS PLEIN ÉCRAN ── */
  .calendar-popup,
  .review-popup {
    align-items: flex-end; /* collées au bas de l'écran */
    padding: 0;
    overscroll-behavior: contain;
  }
  .calendar-popup-content,
  .review-popup-content {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    max-height: 85vh;
    max-height: 85dvh;
    padding: 24px 16px calc(22px + env(safe-area-inset-bottom, 0px));
    animation: sheetUp 0.24s cubic-bezier(0.3, 0.9, 0.4, 1);
  }
  @keyframes sheetUp {
    from { transform: translateY(60px); opacity: 0.5; }
    to   { transform: translateY(0); opacity: 1; }
  }
  /* Poignée décorative (feuille qu'on tire vers le bas) */
  .calendar-popup-content::before,
  .review-popup-content::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 44px; height: 4px;
    border-radius: 2px;
    background: var(--border-color);
  }
  .popup-close,
  .review-popup-close {
    top: 8px; right: 8px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
  }
  .popup-date { font-size: 13px; margin-bottom: 16px; }
  .popup-item { width: 92px; }
  .popup-item img { height: 128px; }
  .review-popup-title { font-size: 16px; margin-bottom: 14px; }
  .review-popup-text { font-size: 14px; line-height: 1.7; }

  /* ── 7. RECHERCHE : PALETTE PLEIN ÉCRAN ── */
  .search-palette { padding: 0; }
  .search-palette-panel { position: relative; }
  .search-palette .palette-close {
    display: block;
    top: max(6px, env(safe-area-inset-top)); right: 8px;
    width: 44px; height: 44px; padding: 0;
  }
  .search-palette .search-palette-input { padding-right: 60px; }
  .search-palette-panel {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* suit la barre d'adresse dynamique d'Android */
    max-height: none;
    border-radius: 0;
    border: none;
    animation: none;
  }
  .search-palette-input {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 14px;
    font-size: 16px; /* pas de zoom auto au focus */
  }
  .search-palette-results { padding: 6px 10px 16px; }
  .search-palette-hint { padding: 40px 10px; font-size: 14px; }
  .search-palette-footer { display: none; } /* raccourcis clavier inutiles au doigt */
  .gs-item { padding: 12px 10px; }
  .gs-item img { width: 36px; height: 54px; }
  .gs-creator-avatar { width: 36px; height: 54px; }

  /* ── 8. PLAYER MUSIQUE : AU-DESSUS DE LA BARRE BASSE ── */
  .player-widget {
    bottom: calc(var(--mn-h) + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    padding: 14px 18px 16px;
  }
  .player-btn { width: 44px; height: 44px; font-size: 18px; }
  .player-btn-play { width: 52px; height: 52px; font-size: 20px; }
  .player-bar { position: relative; height: 5px; }
  .player-bar::after { content: ''; position: absolute; inset: -14px 0; } /* zone de tap élargie */
  #page-musique { padding-bottom: calc(var(--mn-h) + env(safe-area-inset-bottom, 0px) + 190px); }

  /* ── 9. BILAN ANNUEL : RECALIBRÉ ── */
  .home-recap { padding: 26px 0; }
  .home-recap-nav { gap: 14px; margin-bottom: 28px; }
  .home-recap-toggle { padding: 10px 16px; font-size: 12px; }
  .wrapped-open-btn { padding: 9px 16px; font-size: 13px; }
  /* v36 (W4) : bouton centré sous l'année — tiré un peu moins haut qu'en PC
     (la marge du rang d'année est plus courte en mobile) */
  .recap-wrapped-row { margin: -18px 0 20px; }
  .recap-headline { gap: 20px; margin-bottom: 34px; }
  .recap-stat-num { font-size: 46px; }
  .recap-stat-detail { max-width: none; }
  .recap-section { margin-top: 36px; }
  /* Heatmap : cellules réduites, défilement horizontal déjà en place */
  .hm-months { grid-auto-columns: 9px; }
  .hm-months span { font-size: 8px; }
  .hm-grid { grid-template-rows: repeat(7, 9px); grid-auto-columns: 9px; }
  .hm-cell { width: 9px; height: 9px; }

  /* ── 10. STATISTIQUES : LE GRAPHIQUE ENTRE DANS 360PX ── */
  .stats-section { padding: 16px 14px 8px 18px; }
  .stats-cards { gap: 10px; }
  .stats-card { min-width: 88px; padding: 12px; }
  .stats-card-count { font-size: 22px; }
  .stats-bars { margin-left: 34px; gap: 8px; height: 140px; padding-left: 8px; }
  .stats-vbar-col { flex: 0 0 30px; }
  .stats-axis-x { margin-left: 34px; }

  /* ── 11. À PROPOS : COMPACT ET TACTILE ── */
  #page-apropos.active { padding-top: 22px; }
  .apropos-layout { padding: 20px 14px; gap: 26px; }
  .apropos-bio-img { margin-bottom: 18px; }
  .apropos-pfp { max-width: 140px; }
  .bio-col { border-left: none; border-right: none; padding: 0; }
  .carrd-links-verticaux a { padding: 14px 16px; font-size: 14px; }
  .tamagotchi-container { padding: 18px 14px; }
  .tamagotchi-cage { height: 140px; }
  .tamagotchi-actions button { padding: 12px 18px; font-size: 13px; }

  /* Pages : on réduit le grand padding supérieur du PC */
  #page-bibliographie.active, #page-ecrans.active, #page-jeux.active,
  #page-musique.active, #page-anime.active, #page-manga.active,
  #page-statistiques.active { padding-top: 22px; }

  /* ── 12. DÉCOR : PERRUCHES ET SAISONS AU-DESSUS DE LA BARRE ── */
  .budgie-ambient { bottom: calc(var(--mn-h) + env(safe-area-inset-bottom, 0px) + 6px); }
  .season-chip { bottom: calc(var(--mn-h) + env(safe-area-inset-bottom, 0px) + 10px); }

}
