/**
 * MOBILE VIDEO THUMBNAILS STYLES
 * Styles optimisés pour l'affichage des thumbnails vidéo en mode mobile
 */

/* ================================
   CONFIGURATION MOBILE
=============================== */

@media (max-width: 768px) {
  
  /* ================================
     OPTIMISATIONS VIDÉOS BOOK
  ================================ */
  
  #book video,
  #book .book-video {
    /* Optimiser l'affichage des thumbnails */
    background-color: #1a1a2e !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    
    /* Améliorer la transition thumbnail -> vidéo */
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    
    /* Masquer les contrôles natifs sur mobile */
    -webkit-media-controls: none !important;
    -webkit-media-controls-panel: none !important;
    -webkit-media-controls-play-button: none !important;
    -webkit-media-controls-timeline: none !important;
    -webkit-media-controls-current-time-display: none !important;
    -webkit-media-controls-time-remaining-display: none !important;
    -webkit-media-controls-mute-button: none !important;
    -webkit-media-controls-volume-slider: none !important;
    -webkit-media-controls-fullscreen-button: none !important;
    
    /* Optimiser les performances de rendu */
    transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    contain: layout style paint !important;
    
    /* Améliorer la qualité d'image */
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: optimizeQuality !important;
  }
  
  /* ================================
     OPTIMISATIONS VIDÉOS APPLICATION
  ================================ */
  
  #application video,
  #application .application-video-element {
    /* Optimiser l'affichage des thumbnails */
    background-color: #1a1a2e !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    
    /* Améliorer la transition thumbnail -> vidéo */
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    
    /* Masquer les contrôles natifs sur mobile */
    -webkit-media-controls: none !important;
    -webkit-media-controls-panel: none !important;
    -webkit-media-controls-play-button: none !important;
    -webkit-media-controls-timeline: none !important;
    -webkit-media-controls-current-time-display: none !important;
    -webkit-media-controls-time-remaining-display: none !important;
    -webkit-media-controls-mute-button: none !important;
    -webkit-media-controls-volume-slider: none !important;
    -webkit-media-controls-fullscreen-button: none !important;
    
    /* Optimiser les performances de rendu */
    transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    contain: layout style paint !important;
    
    /* Améliorer la qualité d'image */
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: optimizeQuality !important;
  }
  
  /* ================================
     BOUTONS DE LECTURE OPTIMISÉS
  ================================ */
  
  #book .play-pause-btn,
  #application .play-pause-btn {
    /* Style moderne et visible */
    background: rgba(138, 76, 255, 0.9) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 50% !important;
    width: 60px !important;
    height: 60px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    font-size: 24px !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 15px rgba(138, 76, 255, 0.4) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    z-index: 10 !important;
    
    /* Optimiser pour le tactile */
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none !important;
    -webkit-user-select: none !important;
  }
  
  #book .play-pause-btn:hover,
  #application .play-pause-btn:hover,
  #book .play-pause-btn:active,
  #application .play-pause-btn:active {
    background: rgba(138, 76, 255, 1) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(138, 76, 255, 0.6) !important;
  }
  
  /* Ajustement visuel pour l'icône play */
  #book .play-pause-btn i,
  #application .play-pause-btn i {
    margin-left: 2px !important;
  }
  
  /* ================================
     INDICATEURS DE CHARGEMENT
  ================================ */
  
  /* Indicateur que les thumbnails sont chargés */
  .mobile-thumbnails-loaded #book video,
  .mobile-thumbnails-loaded #application video {
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Animation de chargement des thumbnails */
  #book video:not([poster]),
  #application video:not([poster]) {
    position: relative !important;
  }
  
  #book video:not([poster])::before,
  #application video:not([poster])::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(45deg, #1a1a2e, #16213e) !important;
    z-index: -1 !important;
    animation: thumbnailLoading 2s ease-in-out infinite !important;
  }
  
  @keyframes thumbnailLoading {
    0%, 100% {
      opacity: 0.8;
    }
    50% {
      opacity: 1;
    }
  }
  
  /* ================================
     OPTIMISATIONS PERFORMANCES
  ================================ */
  
  /* Réduire la charge GPU sur les appareils moins puissants */
  @media (max-width: 480px) {
    #book video,
    #application video {
      /* Optimisations agressives pour petits écrans */
      image-rendering: optimizeSpeed !important;
      -webkit-image-rendering: optimizeSpeed !important;
      
      /* Réduire les effets visuels */
      filter: none !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
    }
    
    #book .play-pause-btn,
    #application .play-pause-btn {
      /* Boutons plus petits sur très petits écrans */
      width: 50px !important;
      height: 50px !important;
      font-size: 20px !important;
    }
  }
  
  /* Mode économie d'énergie */
  @media (prefers-reduced-motion: reduce) {
    #book video,
    #application video {
      transition: none !important;
    }
    
    #book .play-pause-btn,
    #application .play-pause-btn {
      transition: none !important;
    }
    
    #book video:not([poster])::before,
    #application video:not([poster])::before {
      animation: none !important;
    }
  }
  
  /* ================================
     AMÉLIORATIONS ACCESSIBILITÉ
  ================================ */
  
  /* Focus visible pour les boutons */
  #book .play-pause-btn:focus,
  #application .play-pause-btn:focus {
    outline: 3px solid rgba(138, 76, 255, 0.6) !important;
    outline-offset: 2px !important;
  }
  
  /* Contraste amélioré pour les textes */
  #book .book-content,
  #application .application-content {
    color: rgba(255, 255, 255, 0.9) !important;
  }
  
  /* ================================
     OPTIMISATIONS SPÉCIFIQUES iOS
  ================================ */
  
  @supports (-webkit-touch-callout: none) {
    #book video,
    #application video {
      /* Optimisations spécifiques iOS */
      -webkit-transform: translateZ(0) !important;
      -webkit-backface-visibility: hidden !important;
      -webkit-perspective: 1000px !important;
    }
    
    #book .play-pause-btn,
    #application .play-pause-btn {
      /* Améliorer le rendu tactile sur iOS */
      -webkit-touch-callout: none !important;
      -webkit-user-select: none !important;
    }
  }
  
  /* ================================
     OPTIMISATIONS SPÉCIFIQUES ANDROID
  ================================ */
  
  @media screen and (-webkit-min-device-pixel-ratio: 0) {
    #book video,
    #application video {
      /* Optimisations spécifiques Android */
      -webkit-transform: translate3d(0, 0, 0) !important;
      -webkit-backface-visibility: hidden !important;
    }
  }
}

/* ================================
   STYLES GLOBAUX (TOUS ÉCRANS)
=============================== */

/* Améliorer la qualité des thumbnails sur tous les écrans */
#book video[poster],
#application video[poster] {
  /* Transition fluide lors du chargement */
  transition: opacity 0.3s ease !important;
}

/* Optimiser le rendu des vidéos avec poster */
#book video[poster]:not(:hover),
#application video[poster]:not(:hover) {
  /* Réduire la charge GPU quand pas en interaction */
  transform: translateZ(0) !important;
  will-change: auto !important;
}

/* ================================
   DEBUG ET DÉVELOPPEMENT
=============================== */

/* Afficher les informations de debug en mode développement */
@media (max-width: 768px) {
  .debug-thumbnails #book video,
  .debug-thumbnails #application video {
    border: 2px solid rgba(138, 76, 255, 0.5) !important;
  }
  
  .debug-thumbnails #book video::after,
  .debug-thumbnails #application video::after {
    content: 'Thumbnail: ' attr(poster) !important;
    position: absolute !important;
    bottom: 5px !important;
    left: 5px !important;
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    font-size: 10px !important;
    padding: 2px 5px !important;
    border-radius: 3px !important;
    z-index: 1000 !important;
  }
}
