/* ================================================== */
/* COMMON-MOBILE.CSS — Responsive Mobile & Tablet     */
/* Iktisar — Approche Mobile-First                     */
/* ================================================== */
/* Ce fichier gère TOUTES les adaptations responsive   */
/* du layout commun (sidebar, topbar, wrap, search,    */
/* auth, slogan) ainsi que les utilitaires mobiles.     */
/* Les media queries spécifiques à chaque page restent */
/* dans leurs fichiers CSS respectifs.                 */
/* ================================================== */

/* ===========================
   UTILITAIRES TOUCH
   =========================== */

/* Améliorer les zones tactiles pour le mobile */
@media (hover: none) and (pointer: coarse) {
  /* Taille minimale recommandée pour les cibles tactiles (48dp Google, 44pt Apple) */
  /*button,
  a,
  .icon,
  .filter-btn,
  .arrow,
  input[type="text"],
  input[type="search"],
  select {
    min-height: 44px;
    min-width: 44px;
  }*/

  /* Exceptions : petits éléments décoratifs qui ne doivent pas être agrandis */
  .home-banner-dot,
  .carousel-indicator,
  .home-banner-arrow,
  .zoom-btn,
  .graph-zoom-btn,
  .search-btn,
  .reset-btn,
  .graph-ctrl-btn,
  .control-btn,
  .fullscreen-btn {
    min-height: unset;
    min-width: unset;
  }

  /* Exceptions : éléments de popups lecture qui ne doivent pas être déformés */
  .selection-action-btn,
  #note-popup button,
  .sidebar-column button,
  .sidebar-column input,
  .sidebar-column a,
  .note-item button,
  .note-item a,
  .notes-navigation button,
  .remove-tag,
  .color-option,
  .edit-color-btn,
  .change-color-btn,
  .note-detail-change-color-btn,
  .note-detail-edit-btn,
  .note-detail-delete-btn,
  .note-detail-close-btn,
  [data-modal-type="note-modal"] button,
  [data-modal-type="note-modal"] input,
  [data-modal-type="change-color-modal"] button,
  [data-modal-type="change-color-modal"] input,
  [data-modal-type="create-color-modal"] button,
  [data-modal-type="create-color-modal"] input {
    min-height: unset;
    min-width: unset;
  }

  /* Désactiver les hover effects sur mobile */
  .icon:not(.active):hover {
    transform: none;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
  }

  .book:hover img {
    transform: none;
    box-shadow: var(--shadow-md);
  }

  /* Smooth scrolling natif */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ===========================
   MOBILE — max 768px
   =========================== */

/* Mobile header : masqué par défaut (desktop), affiché en flex sur mobile */
.mobile-header {
  display: none;
}

/* Label de page statique (ex: "Lecture", "Auteur") : caché dans <main>,
   visible uniquement une fois déplacé dans .mobile-header par le JS */
.mobile-page-label {
  display: none;
}

/* Couvre à la fois le portrait mobile (≤768px) ET le paysage mobile
   (appareils tactiles PURS — phones/tablettes sans souris ni trackpad) */
@media (max-width: 500px) and (pointer: coarse),
       (pointer: coarse) and (max-height: 600px) and (orientation: landscape) {

  /* --- BODY & HTML --- */
  html, body {
    overflow-x: hidden;
    width: 100%;
    min-height: 100dvh;
  }

  body {
    /* Supprimer le padding desktop (20px 0) qui crée un espace vide scrollable sous le wrap */
    padding: 0 !important;
    /* Supprimer l'image de fond lourde sur mobile */
    background-image: none !important;
    background-color: var(--bg, #FBF8F1);
  }

  /* Masquer la barre dorée sous le titre serif sur mobile */
  .page-title-serif::after {
    display: none;
  }

  /* Supprimer le gap de wrap-body (wrap-left est à 0 largeur) */
  .wrap-body {
    gap: 0;
  }

  /* Desktop header : toujours masqué sur mobile (doublon avec mobile-header).
     CSS renforce le display:none appliqué par JS pour éviter tout flash au retour
     d'un OAuth externe (bfcache, transition navigateur, etc.). */
  .wrap-top-row {
    display: none !important;
  }

  /* Colonne gauche : réduite à 0 sur mobile — la sidebar est position:fixed donc toujours visible */
  .wrap-left {
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    overflow: visible; /* Ne pas clipper la sidebar fixée */
  }

  /* Widgets desktop uniquement : cachés sur mobile */
  /* Spécificité ID requise pour battre body.page-accueil #community-stats-widget { block !important } */
  body.page-accueil #community-stats-widget,
  .community-stats-widget,
  .mentions-legales-sidebar {
    display: none !important;
  }

  /* --- MOBILE HEADER (logo | titre | auth) --- */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    box-sizing: border-box;
    /* Force une couche GPU indépendante (même raison que .sidebar) */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    gap: 8px;
    position: relative;
    z-index: 100;
  }

  .mobile-header .wrap-top-logo {
    position: static;
    width: auto;
    padding: 0;
    margin-left: 5px;
    justify-content: flex-start;
    flex-shrink: 0;
  }

  .mobile-header-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    font-family: var(--font-serif);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
  }

  /* Titre déplacé depuis le DOM page — réduire la taille desktop, supprimer les marges */
  .mobile-header [data-mobile-title] {
    flex: 1;
    text-align: center;
    font-size: 17px !important;
    font-weight: 600 !important;
    font-family: var(--font-serif) !important;
    margin: 0 !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary) !important;
  }

  /* Label statique (ex: "Lecture", "Auteur") : visible une fois dans le header */
  .mobile-header .mobile-page-label {
    display: block;
  }

  /* Bouton retour dans le mobile header (pages Lecture, PDF…) */
  .back-btn-mobile-header {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 6px;
    background: transparent !important;
    border-color: transparent !important;
    border-radius: 6px;
  }

  .back-btn-mobile-header svg {
    width: 18px;
    height: 18px;
  }

  .mobile-header-auth {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .mobile-header-auth .auth {
    gap: 6px;
    justify-content: flex-end;
  }

  /* Le .auth est déplacé dans .mobile-header via JS, il n'est plus dans .top sur mobile */

  /* --- WRAP (container principal) --- */
  .wrap {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    flex-direction: column;
    min-height: 100dvh;
    gap: 0;
    background-image: none;
    background-color: var(--bg, #FBF8F1);
  }

  /* --- SIDEBAR → Bottom Navigation Bar (flottante arrondie) --- */
  .sidebar {
    position: fixed;
    bottom: 12px;
    left: 50%;
    right: auto;
    top: auto;
    width: calc(100vw - 24px);
    max-width: 430px;
    height: auto;
    flex-direction: column;
    align-items: center;
    padding: 8px 10px 8px;
    margin: 0;
    z-index: 10010;
    border-radius: 14px;
    border: none;
    /* transform combine centrage et couche GPU */
    -webkit-transform: translateX(-50%) translateZ(0);
    transform: translateX(-50%) translateZ(0);
    box-shadow:
      0 8px 28px rgba(0, 0, 0, 0.14),
      0 2px 8px  rgba(0, 0, 0, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.7);
    background: rgba(250, 248, 243, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  /* Masquer la bottom-nav, le header mobile et le back button pendant le plein écran */
  body.mindmap-fullscreen .sidebar,
  body.mindmap-fullscreen .mobile-header,
  body.mindmap-fullscreen #backBtn {
    display: none !important;
  }

  /* === Fix iOS Safari ≥18.7 : position:fixed clippé au backing layer GPU ===
     Quand html.scrollHeight = window.innerHeight (page non-scrollable), iOS composite
     les éléments position:fixed dans un backing layer clippé à la hauteur de l'ancêtre
     stacking context (ici main#app : 72-218px), masquant le bas du conteneur fullscreen.
     Bibliothèque n'est pas affectée car main#app y dépasse le viewport (scrollable).
     Fix : +1px sur html rend le document "virtuellement scrollable", forçant iOS à créer
     un backing layer plein-viewport pour tous les éléments position:fixed.
     overflow:hidden sur html et body empêche tout scroll visible réel. */
  html:has(body.mindmap-fullscreen) {
    min-height: calc(100dvh + 1px) !important;
    /* Équivalent horizontal — cf. commentaire jumeau dans common-styles.css
       (html:has(body.site-fullscreen)) pour le détail du mécanisme. */
    min-width: calc(100vw + 1px) !important;
    /* Pas d'overflow:hidden — iOS vérifie que le nœud PEUT scroller (overflow != hidden)
       pour choisir son compositing path. overflow:hidden annule l'effet du +1px. */
    overscroll-behavior: none;
  }
  body.mindmap-fullscreen {
    overflow-y: hidden;
    overflow-x: hidden;
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
  }

  /* === Fix iOS Safari 18.7 : position:fixed clippé par overflow:auto des ancêtres ===
     Régression iOS 18.7 : un élément position:fixed à l'intérieur d'un scroll container
     (overflow:auto) est visuellement clippé à la hauteur visible de ce conteneur.
     hero-left (ov-y:auto, 126px) et main#app (ov-y:auto, 218px) coupent le conteneur
     fullscreen même si position:fixed devrait le soustraire à ce clipping.
     overflow:visible supprime le scroll context.
     min-height:100dvh garantit que même si iOS clippe, la hauteur clip = viewport. */
  body.mindmap-fullscreen .hero-left,
  body.mindmap-fullscreen main#app {
    overflow: visible !important;
    min-height: 100dvh !important;
  }

  .sidebar-inner {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 0;
    width: 100%;
    padding: 0;
  }

  /* Icônes de nav dans la bottom bar */
  .nav-item-wrap {
    width: auto;
    height: auto;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    flex-direction: column;
    gap: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  .icon svg {
    width: 34px;
    height: 34px;
  }

  .sidebar .icon img.ikt-nav-icon {
    width: 40px;
    height: 40px;
  }

  .icon.active {
    background: var(--accent);
    transform: none;
    box-shadow: 0 2px 8px rgba(26, 82, 56, 0.3);
  }

  /* Labels : masqués sur mobile — icônes seules */
  .sidebar-inner .label {
    display: none;
  }

  .icon:hover .label {
    transform: none;
  }

  /* --- LOGO EN HAUT DU WRAP --- */
  .wrap-top-logo {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    justify-content: center;
    padding: 12px 16px 4px;
    z-index: 1;
  }

  .wrap-top-logo img {
    width: 105px;
  }

  /* --- SLOGAN --- */
  .slogan {
    display: none; /* Masquer sur mobile pour gagner de la place */
  }

  /* --- MAIN (contenu principal) --- */
  main {
    padding: 0 12px;
    padding-bottom: 94px; /* Espace pour la bottom bar */
    flex: 1;
    width: 100%;
    overflow-x: hidden;
  }

  /* --- HERO --- */
  .hero {
    flex-direction: column;
    padding: 0;
    width: 100%;
  }

  .hero-left {
    padding: 0;
    width: 100%;
  }

  /* --- TOP BAR (recherche + auth) --- */
  /* Masquer le top sur mobile sauf Accueil (gagne de la place) */
  .top {
    display: none !important;
  }

  /* Sur Accueil, afficher la recherche globale */
  .page-accueil .top {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 8px;
    width: 100%;
    position: relative;
    z-index: 100; /* Assure que le dropdown de résultats couvre le contenu en dessous */
  }

  /* --- RECHERCHE GLOBALE : masquée sur mobile sauf Accueil --- */
  /* Chaque page a sa propre recherche locale, pas besoin du doublon global */
  body:not(.page-accueil) .search-filters {
    display: none !important;
  }

  /* Sur Accueil, la barre globale reste visible et adaptée */
  .search-filters {
    max-width: 100%;
    width: 100%;
  }

  /* Masquer la recherche avancée (filtres) sur mobile */
  .filter-toggle-btn {
    display: none !important;
  }
  .filter-drawer {
    display: none !important;
  }

  /* --- BARRES DE RECHERCHE : design unifié (style Bibliothèque) --- */
  .search,
  .library-search-box,
  .authors-search-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-left: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }

  .search input,
  .library-search-box input,
  .authors-search-container input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border, #ddd);
    border-radius: 8px;
    background: var(--panel-light);
    color: var(--text, #333);
    font-family: 'Inter', sans-serif;
    font-size: 16px; /* Empêcher le zoom auto iOS */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .search input:focus,
  .library-search-box input:focus,
  .authors-search-container input:focus {
    outline: none;
    border-color: var(--accent, #3c8c6c);
    box-shadow: 0 2px 8px rgba(60, 140, 108, 0.18);
  }

  .search .search-icon,
  .search > svg,
  .library-search-box > svg,
  .library-search-box input ~ svg,
  .authors-search-container .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted, #888);
    z-index: 1;
  }

  /* Résultats de recherche — dropdown sous la barre de recherche */
  .search-results-container {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    max-height: calc(100dvh - 200px); /* Espace pour search bar + bottom bar */
    max-height: calc(100dvh - 200px);
    height: auto;
    border-radius: 12px;
    z-index: 10005;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  }

  /* Panneau filtres */
  .filter-drawer {
    position: fixed;
    top: auto;
    bottom: 64px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
  }

  .filter-field-options {
    gap: 6px;
  }

  .filter-field-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .filter-input-row {
    flex-wrap: wrap;
  }

  .filter-operator-wrap {
    flex: 0 0 100%;
  }

  /* --- AUTH (connexion) --- */
  .auth {
    gap: 6px;
    justify-content: flex-end;
  }

  /* Masquer l'email long sur mobile */
  .auth-dropdown-trigger span#userEmail {
    display: none;
  }

  .auth-user-info {
    display: none;
  }

  /* Agrandir l'avatar pour compenser */
  .auth-dropdown-trigger svg#userAvatar {
    width: 26px;
    height: 26px;
  }

  .auth-dropdown-trigger {
    padding: 4px;
  }

  /* Menu déroulant auth */
  .auth-dropdown-menu {
    right: 0;
    min-width: 180px;
  }

  .auth-dropdown-menu-guest {
    right: 0;
  }

  .auth-dropdown-trigger-guest svg {
    width: 24px;
    height: 24px;
  }

  .community-stats-widget {
    display: none !important;
  }

  /* --- BOUTON RETOUR --- */
  .back-button {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 10008;
    padding: 8px 12px;
    font-size: 13px;
  }

  .back-button-xmind {
    left: 8px;
    top: 8px;
  }

  /* --- BADGES --- */
  .badges-container {
    gap: 4px;
  }

  .category-badge,
  .level-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  /* --- RÉSULTATS DE RECHERCHE (items) --- */
  .results-section {
    padding: 8px;
    margin-bottom: 2px;
  }

  .results-section:first-child {
    border-radius: 12px 12px 0 0;
  }

  .results-section:last-child {
    border-radius: 0 0 12px 12px;
    margin-bottom: 0;
  }

  .results-section:only-child {
    border-radius: 12px;
  }

  .section-header {
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .section-title {
    font-size: 0.8rem;
  }

  .results-list {
    gap: 4px;
  }

  .result-item {
    padding: 8px;
    gap: 8px;
    margin-bottom: 2px;
    flex-wrap: wrap;
  }

  .result-item:active {
    background: #e9ecef;
  }

  /* Désactiver hover transform sur mobile */
  .result-item:hover {
    transform: none;
  }

  .result-cover {
    width: 38px;
    min-height: 48px;
  }

  .result-icon-placeholder {
    width: 38px;
    min-height: 48px;
  }

  .result-content {
    min-width: 0;
  }

  .result-title {
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .result-author {
    font-size: 0.7rem;
  }

  .result-excerpt {
    font-size: 0.75rem;
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  .badges-container {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .no-results {
    padding: 16px 12px;
  }

  .no-results-icon svg {
    width: 28px;
    height: 28px;
  }

  .no-results-text {
    font-size: 0.82rem;
  }

  .show-more-link {
    font-size: 0.78rem;
    padding: 6px 8px;
  }

  /* --- POPUP RÉSULTATS --- */
  .results-popup-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .results-popup {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
  }

  .results-popup-header {
    padding: 16px;
  }

  .results-popup-content {
    padding: 12px 16px;
  }

  /* --- TOAST --- */
  #ikt-toast-container {
    bottom: 80px; /* Au-dessus de la bottom bar */
  }

  /* --- INLINE CONFIRM --- */
  .inline-confirm {
    max-width: 100%;
  }

  .inline-confirm.popover {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    top: auto;
    width: auto;
    z-index: 10009;
  }
}

/* ===========================
   PETIT MOBILE — max 480px
   =========================== */
@media (max-width: 480px) {

  main {
    padding: 0 8px;
    padding-bottom: 88px;
    padding-top: 4px;
  }

  /* Sidebar plus compacte */
  .sidebar {
    max-height: 68px;
    padding: 4px 4px;
  }

  .icon {
    width: 54px;
    height: 54px;
  }

  .icon svg {
    width: 30px;
    height: 30px;
  }

  .label {
    font-size: 8px;
  }

  /* Bouton retour plus compact */
  .back-button {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ===========================
   TRÈS PETIT MOBILE — max 360px
   =========================== */
@media (max-width: 360px) {

  .sidebar {
    padding: 2px 2px;
    max-height: 62px;
  }

  .icon {
    width: 48px;
    height: 48px;
  }

  .icon svg {
    width: 26px;
    height: 26px;
  }

  .label {
    font-size: 7px;
  }

  main {
    padding: 0 6px;
    padding-bottom: 78px;
  }

  .search input {
    font-size: 14px;
  }
}

/* ===========================
   TABLETTE — 769px à 1024px
   =========================== */
@media (min-width: 769px) and (max-width: 1024px) {

  .wrap {
    width: calc(100% - 20px);
    margin: 0 auto;
    padding: 12px;
    gap: 12px;
  }

  /* Sidebar compacte sur tablette */
  .sidebar {
    width: 60px;
    padding: 16px 0;
  }

  .sidebar .nav-item-wrap {
    width: 42px;
    height: 42px;
  }

  /* Scopé à .sidebar : évite d'écraser l'icône du bouton politique
     (.mentions-legales-sidebar), dont le conteneur reste à 28px sur tablette. */
  .sidebar .icon svg {
    width: 20px;
    height: 20px;
  }

  /* Labels en tooltip classique sur tablette */
  .label {
    font-size: 11px;
  }

  /* Slogan compact */
  .slogan {
    bottom: 12px;
    left: 12px;
    padding: 6px 14px;
    height: 38px;
  }

  .slogan-text {
    font-size: 0.9rem;
  }

  .slogan .slogan-logo {
    width: 32px;
    height: 32px;
    margin-right: 8px;
  }

  main {
    padding-left: 4px;
    padding-bottom: 50px;
  }

  /* Recherche */
  .search-filters {
    max-width: 500px;
  }
}

/* ===========================
   LANDSCAPE MOBILE
   =========================== */
/* Ajustements spécifiques paysage — phones en landscape (coarse + hover: none + hauteur ≤ 600px) */
@media (pointer: coarse) and (max-height: 600px) and (orientation: landscape) {

  /* Bottom bar paysage */
  .sidebar {
    width: 100% !important;
    flex-direction: row;
    padding: 4px 12px;
  }

  /* Dots inutiles en paysage (espace horizontal suffisant pour voir toutes les icônes) */
  .tab-indicators {
    display: none !important;
  }

  /* Masquer les éléments de la sidebar gauche — inexistante en paysage mobile */
  .mentions-legales-sidebar,
  .community-stats-widget {
    display: none !important;
  }

  .icon {
    width: 46px;
    height: 44px;
  }

  .label {
    font-size: 8px;
  }

  main {
    padding-bottom: 64px;
  }

  /* Résultats de recherche */
  .search-results-container {
    bottom: auto;
  }
}

/* ===========================
   SAFE AREAS (notch, etc.)
   =========================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 500px) and (pointer: coarse),
         (pointer: coarse) and (max-height: 600px) and (orientation: landscape) {
    .sidebar {
      padding-bottom: calc(6px + env(safe-area-inset-bottom));
    }

    main {
      /* 78px = hauteur de la bottom nav, + safe area + 4px marge */
      padding-bottom: calc(78px + env(safe-area-inset-bottom) + 4px);
    }

    #ikt-toast-container {
      bottom: calc(78px + env(safe-area-inset-bottom) + 4px);
    }
  }
}

/* ===========================
   THÈMES — Adaptations mobile
   =========================== */
@media (max-width: 500px) and (pointer: coarse),
       (pointer: coarse) and (max-height: 600px) and (orientation: landscape) {

  /* Bottom bar en thème beige */
  body.theme-beige .sidebar {
    background: rgba(235, 216, 180, 0.97);
    box-shadow:
      0 8px 28px rgba(0, 0, 0, 0.16),
      0 2px 8px  rgba(0, 0, 0, 0.10),
      inset 0 1px 0 rgba(255, 255, 255, 0.45);
  }

  body.theme-beige .label {
    color: var(--text-secondary);
  }

  /* Bottom bar en thème noir */
  body.theme-noir .sidebar {
    background: rgba(34, 50, 53, 0.97);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  }

  body.theme-noir .tab-dot { background: rgba(255, 255, 255, 0.2); }
  body.theme-noir .tab-dot.active { background: var(--accent-gold, #b89e14); }

  body.theme-noir .label {
    color: rgba(255, 255, 255, 0.5);
  }

  body.theme-noir .icon.active .label {
    color: white;
  }

  body.theme-noir .wrap {
    background-color: var(--bg);
  }

  /* Recherche en thème noir */
  body.theme-noir .search {
    background: rgba(255, 255, 255, 0.08);
  }

  body.theme-noir .search input {
    color: #e8e8e8;
  }
}

/* ===========================
   SWIPE NAVIGATION
   =========================== */

.tab-indicators { display: none; }

@media (max-width: 768px) and (pointer: coarse) {
  /* ── Indicateurs de position (dots) ── */
  .tab-indicators {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: center;
    padding: 5px 0 2px;
    width: 100%;
  }

  .tab-dot {
    width: 12px;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
  }

  .tab-dot.active {
    width: 20px;
    background: var(--accent, #1A5238);
  }

  @keyframes swipe-hint-pulse {
    0%   { transform: translateX(0);    opacity: 1; }
    20%  { transform: translateX(-9px); opacity: 0.7; }
    60%  { transform: translateX(9px);  opacity: 0.7; }
    85%  { transform: translateX(-3px); opacity: 0.9; }
    100% { transform: translateX(0);    opacity: 1; }
  }

  .tab-indicators.swipe-hint {
    animation: swipe-hint-pulse 0.85s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  /* ── Transitions de page ── */
  @keyframes tab-slide-in-from-right {
    from { opacity: 0.55; transform: translateX(32px); }
    to   { opacity: 1;    transform: translateX(0); }
  }

  @keyframes tab-slide-in-from-left {
    from { opacity: 0.55; transform: translateX(-32px); }
    to   { opacity: 1;    transform: translateX(0); }
  }

  #app[data-tab-slide="next"] {
    animation: tab-slide-in-from-right 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  }

  #app[data-tab-slide="prev"] {
    animation: tab-slide-in-from-left 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  }
}

/* ===========================
   ANIMATIONS RÉDUITES (a11y)
   =========================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================
   PRINT — Masquer la navigation
   =========================== */
@media print {
  .sidebar,
  .slogan,
  .top,
  .mentions-legales-sidebar,
  .back-button,
  .back-button-xmind {
    display: none !important;
  }

  .wrap {
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
  }

  main {
    padding: 0;
  }
}

/* ===========================
   RESPONSIVE NARROW — max 500px
   Couvre le resize desktop (pointer: fine) que (pointer: coarse) ne capte pas
   =========================== */
@media (max-width: 768px) {
  body.page-accueil #community-stats-widget,
  .community-stats-widget {
    display: none !important;
  }

  .mobile-header-title {
    text-transform: capitalize;
  }
}

/* Badges "filtrer par ce livre" des popups mobiles glossaire/références
   (voir common-layout.js renderLegacyBookFilterBadges) — empile les badges
   verticalement comme dans la sidebar native desktop. */
.ikt-legacy-book-badges {
  display: flex;
  flex-direction: column;
}
