/**
 * MOBILE BLACK SCREEN FIX CSS
 * Styles pour forcer l'affichage des vidéos sur mobile et corriger l'écran noir
 */

/* ================================
   CORRECTION ÉCRAN NOIR MOBILE
=============================== */

@media (max-width: 768px) {
  
  /* ================================
     FORCER L'AFFICHAGE DES VIDÉOS
  ================================ */
  
  /* Toutes les vidéos des sections book, application et hero */
  #book video,
  #book .book-video,
  #application video,
  #application .application-video-element,
  #hero video,
  #hero .hero-showcase-video {
    /* Forcer l'affichage */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    
    /* Dimensions et positionnement */
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
    
    /* Background de fallback */
    background: linear-gradient(45deg, #1a1a2e, #16213e) !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    
    /* Optimisations mobiles */
    transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    contain: layout style paint !important;
    
    /* Forcer le rendu sur WebKit */
    -webkit-transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    -webkit-perspective: 1000px !important;
    
    /* Améliorer la qualité d'image */
    image-rendering: -webkit-optimize-contrast !important;
    image-rendering: optimizeQuality !important;
  }
  
  /* ================================
     MASQUER LES CONTRÔLES NATIFS
  ================================ */
  
  /* Masquer tous les contrôles natifs sur mobile */
  #book video::-webkit-media-controls,
  #application video::-webkit-media-controls,
  #hero video::-webkit-media-controls {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-panel,
  #application video::-webkit-media-controls-panel,
  #hero video::-webkit-media-controls-panel {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-play-button,
  #application video::-webkit-media-controls-play-button,
  #hero video::-webkit-media-controls-play-button {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-timeline,
  #application video::-webkit-media-controls-timeline,
  #hero video::-webkit-media-controls-timeline {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-current-time-display,
  #application video::-webkit-media-controls-current-time-display,
  #hero video::-webkit-media-controls-current-time-display {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-time-remaining-display,
  #application video::-webkit-media-controls-time-remaining-display,
  #hero video::-webkit-media-controls-time-remaining-display {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-mute-button,
  #application video::-webkit-media-controls-mute-button,
  #hero video::-webkit-media-controls-mute-button {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-volume-slider,
  #application video::-webkit-media-controls-volume-slider,
  #hero video::-webkit-media-controls-volume-slider {
    display: none !important;
  }
  
  #book video::-webkit-media-controls-fullscreen-button,
  #application video::-webkit-media-controls-fullscreen-button,
  #hero video::-webkit-media-controls-fullscreen-button {
    display: none !important;
  }
  
  /* ================================
     CONTENEURS VIDÉO
  ================================ */
  
  /* Conteneurs des vidéos */
  #book .book-media,
  #application .video-frame,
  #application .video-container,
  #hero .video-showcase-frame,
  #hero .video-showcase-container {
    position: relative !important;
    overflow: hidden !important;
    background: linear-gradient(45deg, #1a1a2e, #16213e) !important;
    border-radius: 12px !important;
  }
  
  /* ================================
     BOUTONS DE LECTURE AMÉLIORÉS
  ================================ */
  
  #book .play-pause-btn,
  #application .play-pause-btn,
  #hero .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;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 10 !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;
    
    /* Optimiser pour le tactile */
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    cursor: pointer !important;
  }
  
  /* États hover et active */
  #book .play-pause-btn:hover,
  #application .play-pause-btn:hover,
  #hero .play-pause-btn:hover,
  #book .play-pause-btn:active,
  #application .play-pause-btn:active,
  #hero .play-pause-btn:active {
    background: rgba(138, 76, 255, 1) !important;
    transform: translate(-50%, -50%) scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(138, 76, 255, 0.6) !important;
  }
  
  /* Focus pour l'accessibilité */
  #book .play-pause-btn:focus,
  #application .play-pause-btn:focus,
  #hero .play-pause-btn:focus {
    outline: 3px solid rgba(138, 76, 255, 0.6) !important;
    outline-offset: 2px !important;
  }
  
  /* Ajustement visuel pour l'icône play */
  #book .play-pause-btn i,
  #application .play-pause-btn i,
  #hero .play-pause-btn i {
    margin-left: 2px !important;
  }
  
  /* ================================
     INDICATEURS DE CORRECTION
  ================================ */
  
  /* Indicateur que la correction est terminée */
  .mobile-video-fixed #book video,
  .mobile-video-fixed #application video,
  .mobile-video-fixed #hero video {
    transition: opacity 0.3s ease !important;
  }
  
  /* Animation de chargement */
  #book video:not([poster]):not([src]),
  #application video:not([poster]):not([src]),
  #hero video:not([poster]):not([src]) {
    position: relative !important;
  }
  
  #book video:not([poster]):not([src])::before,
  #application video:not([poster]):not([src])::before,
  #hero video:not([poster]):not([src])::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(45deg, #1a1a2e, #16213e, #0f3460) !important;
    z-index: -1 !important;
    animation: videoLoading 2s ease-in-out infinite !important;
  }
  
  @keyframes videoLoading {
    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,
    #hero 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,
    #hero .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,
    #hero video {
      transition: none !important;
    }
    
    #book .play-pause-btn,
    #application .play-pause-btn,
    #hero .play-pause-btn {
      transition: none !important;
    }
    
    #book video:not([poster])::before,
    #application video:not([poster])::before,
    #hero video:not([poster])::before {
      animation: none !important;
    }
  }
  
  /* ================================
     OPTIMISATIONS SPÉCIFIQUES iOS
  ================================ */
  
  @supports (-webkit-touch-callout: none) {
    #book video,
    #application video,
    #hero 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,
    #hero .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,
    #hero video {
      /* Optimisations spécifiques Android */
      -webkit-transform: translate3d(0, 0, 0) !important;
      -webkit-backface-visibility: hidden !important;
    }
  }
  
  /* ================================
     AMÉLIORATIONS ACCESSIBILITÉ
  ================================ */
  
  /* Contraste amélioré pour les textes */
  #book .book-content,
  #application .application-content,
  #hero .hero-content {
    color: rgba(255, 255, 255, 0.9) !important;
  }
  
  /* Améliorer la visibilité des éléments interactifs */
  #book .video-fullscreen-btn,
  #application .video-fullscreen-btn,
  #hero .video-fullscreen-btn {
    background: rgba(138, 76, 255, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
}

/* ================================
   STYLES GLOBAUX (TOUS ÉCRANS)
=============================== */

/* Améliorer la qualité des vidéos sur tous les écrans */
#book video[poster],
#application video[poster],
#hero 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),
#hero 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-mobile-videos #book video,
  .debug-mobile-videos #application video,
  .debug-mobile-videos #hero video {
    border: 2px solid rgba(138, 76, 255, 0.5) !important;
  }
  
  .debug-mobile-videos #book video::after,
  .debug-mobile-videos #application video::after,
  .debug-mobile-videos #hero video::after {
    content: 'Mobile Video Fix Active' !important;
    position: absolute !important;
    bottom: 5px !important;
    left: 5px !important;
    background: rgba(138, 76, 255, 0.8) !important;
    color: white !important;
    font-size: 10px !important;
    padding: 2px 5px !important;
    border-radius: 3px !important;
    z-index: 1000 !important;
  }
}
