/* =========================================
   BASE & SCROLLING
   ========================================= */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --gold: #e9c138;
    --blue: #0072ff;
    --text: #c9d1d9;
    --border: #30363d;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-x: hidden; /* Empêche le scroll horizontal */
    overflow-y: auto;   /* Force le scroll vertical */
}


.container {
    width: 95%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

/* =========================================
   HEADER DU LECTEUR
   ========================================= */
.reader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5%;
    background: var(--surface);
    border-bottom: 2px solid var(--gold);
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (max-width: 768px) {
    .reader-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

.creator-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    color: var(--gold);
}

.mini-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    object-fit: cover;
}

/* =========================================
   INFOS ŒUVRE & MÉDIAS
   ========================================= */
.work-intro { text-align: center; margin-bottom: 40px; }
.synopsis-box{ text-align: left;}
.gold-text { color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }

.genre-list { font-size: 0.9rem; color: #888; margin-bottom: 20px; }

.work-media-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.main-cover {
    width: 200px;
    height: 280px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.trailer-area {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

/* =========================================
   ADAPTATIONS (Box avec nom superposé)
   ========================================= */
.adapt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.adapt-card {
    position: relative;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: 0.3s;
}

.adapt-card img { width: 100%; height: 100%; object-fit: cover; }

.adapt-card .name-overlay {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    color: white;
    padding: 10px 5px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: bold;
}

/* =========================================
   TICKETS DE CHAPITRES
   ========================================= */
.chapter-ticket {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 12px;
    border-radius: 10px;
    overflow: hidden;
    transition: 0.3s;
}

.chapter-ticket:hover { border-color: var(--gold); background: #1c232b; }

.chapter-ticket img {
    width: 100px;
    height: 60px;
    object-fit: cover;
    cursor: pointer;
}

.chapter-ticket .info {
    flex: 1;
    padding: 0 15px;
    cursor: pointer;
}

.btn-clue {
    background: var(--gold);
    border: none;
    padding: 15px;
    cursor: pointer;
    font-weight: bold;
    height: 100%;
    border-radius: 20px;
    margin-right: 10px;
}

/* =========================================
   LECTEUR WEBTOON (Zéro espace entre images)
   ========================================= */
#reader-area { margin-top: 50px; border-top: 2px solid var(--gold); padding-top: 20px; }

#reader-container {
    width: 100%;
    line-height: 0; /* Supprime les espaces blancs sous les images */
}

.webtoon-page-wrapper {
    width: 100%;
    overflow: hidden;
    margin-top: -0.313px;
}

.webtoon-page-wrapper img {
    will-change: transform;
    width: 100%;
    height: auto;
    display: block; /* Supprime l'espace d'alignement de texte */
}

/* =========================================
   PAGINATION
   ========================================= */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
}

.page-btn {
    background: var(--surface);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.page-btn.active { background: var(--gold); color: black; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* =========================================
   CONTRÔLES FIXES (Vitesse & Top)
   ========================================= */
#fixed-action-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: raw;
    gap: 10px;
    z-index: 1000;
}

.action-panel {
    background: var(--surface);
    border: 1px solid var(--gold);
    border-radius: 50px;
    display: flex;
    padding: 5px;
}

.speed-btn {
    background: none;
    border: none;
    color: white;
    padding: 10px;
    cursor: pointer;
    border-radius: 50%;
    font-size: 0.8rem;
}

.speed-btn.active { background: var(--gold); color: black; }

#back-to-top-btn {
    background: var(--gold);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}



.creator-box {
    background: rgba(233, 193, 56, 0.1);
    border: 1px dashed var(--gold);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.comment-item {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.comment-main { display: flex; gap: 15px; align-items: center; }
.comment-avatar { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--gold); }

.comment-body strong { color: var(--gold); font-size: 0.9rem; }
.comment-body p { margin: 5px 0 0 0; font-size: 0.95rem; }

.creator-reply {
    margin-top: 10px;
    margin-left: 50px;
    padding: 10px;
    background: rgba(0, 114, 255, 0.1);
    border-left: 3px solid var(--blue);
    border-radius: 5px;
}

.add-comment { margin-bottom: 30px; }
.add-comment textarea { 
    height: 80px; 
    background: #000; 
    border-color: var(--border); 
    color: white; 
    padding: 10px; 
    border-radius: 8px;
}







/* --- LECTEUR VIDÉO SUR MESURE --- */
.custom-video-container {
    width: 100%;
    margin: 10px 0;
    border: 2px solid var(--gold);
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.8);
}
.custom-video-container video { width: 100%; display: block; }

/* --- LECTEUR AUDIO GROUPÉ (PLAYLIST) --- */
.audio-group-player {
    background: linear-gradient(135deg, var(--surface), #0a0e14);
    border: 1px solid var(--gold);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.audio-header {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--gold);
}

.audio-info { flex: 1; }
.audio-info h5 { margin: 0; font-size: 1rem; }
.audio-info p { margin: 0; font-size: 0.8rem; color: #888; }

.audio-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
}

.audio-btn {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 1.5rem;
    cursor: pointer;
    transition: 0.3s;
}
.audio-btn:hover { transform: scale(1.2); color: white; }

.audio-progress-container {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
}

.audio-progress-bar {
    height: 100%;
    background: var(--grad-gold);
    border-radius: 10px;
    width: 0%;
}

/* --- IFRAME (Musique Spotify/Youtube) --- */
.iframe-wrapper {
    width: 100%;
    height: 80vh;
    margin: 15px 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}


/* =========================================
   LECTEUR VIDÉO "QRLOD TV" (Style YouTube)
   ========================================= */
.qrlod-video-player {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--gold);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    margin: 20px 0;
}

.qrlod-video-player video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Barre de contrôles flottante */
.video-controls {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    display: flex;
    align-items: center;
    padding: 10px 15px;
    gap: 15px;
    opacity: 0; /* Caché par défaut */
    transition: opacity 0.3s;
}

.qrlod-video-player:hover .video-controls { opacity: 1; }

.v-play-btn { background: none; border: none; color: var(--gold); cursor: pointer; font-size: 1.2rem; }

.v-progress-container {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    position: relative;
    cursor: pointer;
}

.v-progress-bar {
    height: 100%;
    background: var(--grad-gold);
    width: 0%;
    border-radius: 5px;
}

/* =========================================
   LECTEUR AUDIO "QRLOD BEATS" (Style Spotify)
   ========================================= */
.qrlod-audio-player {
    background: #181818; /* Noir Spotify */
    border: 1px solid var(--gold);
    border-radius: 15px;
    padding: 15px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 400px;
}

.audio-thumb {
    width: 60px;
    height: 60px;
    background: var(--grad-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.audio-main-content { flex: 1; }

.audio-meta h5 { color: white; margin: 0; font-size: 0.9rem;  margin-top: 20px; }
.audio-meta p { color: var(--gold); margin: 0; font-size: 0.75rem; font-weight: bold; }

.audio-player-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.audio-btns {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.a-btn { background: none; border: none; color: #b3b3b3; cursor: pointer; font-size: 1rem; transition: 0.2s; }
.a-btn:hover { color: white; transform: scale(1.1); }
.a-play-btn { color: white; font-size: 2rem; }
.a-play-btn:hover { color: var(--gold); }

.audio-timeline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.7rem;
    color: #b3b3b3;
}

.audio-progress-bg {
    flex: 1;
    height: 4px;
    background: #4f4f4f;
    border-radius: 2px;
    cursor: pointer;
}

.audio-progress-fill {
    height: 100%;
    background: var(--gold);
    width: 0%;
    border-radius: 2px;
}









/* =========================================
   SWIPE LOADING BAR (New for Horizontal Mode)
   ========================================= */
#swipe-loading-bar-container {
    /* Styles are mostly in JS, but define base here for safety */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px; /* Matches JS */
    background-color: rgba(255, 255, 255, 0.1); /* Subtle background */
    z-index: 100;
    overflow: hidden;
    display: none; /* Hidden by default, JS shows it */
}

#swipe-loading-bar {
    /* Styles are mostly in JS, but define base here for safety */
    width: 30%; /* Matches JS */
    height: 100%;
    background: linear-gradient(90deg, var(--gold, #e9c138), #ffeb3b); /* Gold gradient */
    position: absolute;
    left: -30%; /* Starting position for animation */
    border-radius: 2px;
    /* Animation definition is in JS, so no animation properties here */
}


/* =========================================
   PER-SLIDE LOADING INDICATOR (Horizontal Mode)
   ========================================= */

.media-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex; /* Centers content */
    justify-content: center;
    align-items: center;
    background-color: #000; /* Dark background for loading state */
    overflow: hidden; /* Important to keep children within bounds */
}

.slide-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 0.9rem;
    text-align: center;
}

.loader-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--gold); /* Gold spinner */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-text {
    margin-top: 5px;
    color: var(--text);
}

/* Hide the image completely until it's loaded to prevent broken image icons */
.hidden-image {
    visibility: hidden; /* Hides the element but keeps its space */
    width: 0; /* Collapse width/height to prevent layout shift */
    height: 0;
    max-width: 0; /* Ensure it takes no space */
    max-height: 0;
    pointer-events: none; /* Prevent interaction */
}

/* When .media-wrapper is NOT .loading, the image should become visible and take space */
.media-wrapper:not(.loading) .webtoon-img {
    visibility: visible;
    width: auto; /* Restore auto width */
    height: auto; /* Restore auto height */
    max-width: 100%; /* Restore max constraints */
    max-height: 100%;
    pointer-events: auto; /* Re-enable interaction */
}

/* Ensure the .webtoon-img inside .media-wrapper is styled correctly when loaded */
.media-wrapper .webtoon-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: auto; /* Re-enable interaction for loaded images */
    cursor: zoom-in;
    /* Add transition for a smoother reveal, if desired */
    transition: visibility 0s, width 0s, height 0s, max-width 0s, max-height 0s; /* Adjust as needed */
}



/* --- LECTEUR HORIZONTAL --- */
#slider-wrapper {
    position: relative;
    width: 100%;
    height: 85vh;
    background: #000;
    overflow: hidden;
    margin: 20px 0;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-drag: none;
}
/* Masquer les contrôles de vitesse si on n'est pas en Webtoon */
.hide-controls { display: none !important; }
#slider-container {
    display: flex;
    height: 100%;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* LECTEUR HORIZONTAL specific image styling */
.slide .webtoon-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensures the whole image is visible within the slide */
    pointer-events: auto !important; /* On réactive le clic sur l'image */
    cursor: zoom-in;
}

/* Ensure that images in .slide do not have line-height issues */
.slide {
    line-height: 0; /* Good practice for images inside flex containers */
}

/* Mode MANGA : On inverse l'ordre des éléments flex */
.reading-rtl #slider-container { flex-direction: row-reverse; }

.slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: auto !important; /* On réactive le clic sur l'image */
    cursor: zoom-in;
}

/* Flèches de navigation */
.slider-nav {
    position: absolute; top: 0; bottom: 0; width: 50px;
    background: rgba(0, 0, 0, 0); border: none; color: var(--gold);
    font-size: 3rem; cursor: pointer; z-index: 10; transition: 0.3s;
}

.slider-nav:hover { background: rgba(0,0,0,0.6); }
.slider-nav.prev { left: 0; }
.slider-nav.next { right: 0; }

.slide .qrlod-video-player, .slide .iframe-wrapper{
    max-width: 80%;
    max-height: 100%;
}

.modal-background { /* Renommé pour être générique */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}



/* --- MODALE LIGHTBOX (VERSION SCROLL SNAP CSS) --- */

#lightbox-modal {
    /* Le .modal-background est bon, on le garde. On ajoute un curseur pour indiquer la fermeture. */
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
#lightbox-content {
    display: flex;
    width: 100%;
    height: 90vh;
    align-items: center;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
}

#lightbox-content.double-page img {
    /* 50% de la largeur du conteneur (qui est 100% du viewport) */
    width: 50vw; 
    height: 100vh; /* Prend toute la hauteur de la fenêtre */
    margin: 0; /* Pas de marge entre les images */
    object-fit: cover; /* On couvre l'espace si l'image n'est pas parfaitement adaptée */
}


/* Manga : Inversion des deux pages */
#lightbox-content.rtl {
    flex-direction: row-reverse;
}
#lightbox-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}
/* FIN DE LA MAGIE CSS SCROLL SNAP */

/* On retire le curseur par défaut sur le contenu pour garder le curseur zoom-out */
#lightbox-content > * {
    cursor: default;
}

.lightbox-slide {
    scroll-snap-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

#lightbox-content img {
    max-height: 95vh;
    object-fit: contain;
    transition: width 0.1s ease-out;
}

/* Barre de zoom flottante */
#lightbox-zoom-controls {
    position: fixed;
    bottom: 20px;
    background: rgba(22, 27, 34, 0.9);
    border: 1px solid var(--gold);
    border-radius: 50px;
    padding: 10px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
    z-index: 3001;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

#lightbox-zoom-slider {
    width: 150px;
    accent-color: var(--gold);
    cursor: pointer;
}


#lightbox-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--main-gradient);
    cursor: pointer;
    border-radius: 50%;
}



/* --- BARRE DE CONTRÔLE DU ZOOM --- */
#zoom-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background-color: var(--color-surface);
    border-radius: 8px;
    max-width: 400px;
    margin: 10px auto;
    border: 1px solid var(--color-border);
}

#zoom-controls label {
    font-weight: bold;
}

/* Style du curseur de zoom */
#zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--color-border);
    outline: none;
    border-radius: 5px;
    transition: opacity 0.2s;
}

/* Style de la "poignée" du curseur */
#zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--main-gradient);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid var(--color-surface);
}

#zoom-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--main-gradient);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid var(--color-surface);
}


.webtoon-img, .lightbox-slide img {
    user-select: none;
    -webkit-user-drag: none;
    /* Empêche le curseur de texte d'apparaître et de bloquer le double-clic */
    cursor: zoom-in; 
}

/* ANTI-SELECT */
.no-select { user-select: none; -webkit-user-drag: none; }

/* Désactive le menu "Enregistrer l'image" au clic long sur mobile */
img, a {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Empêche le zoom automatique du navigateur sur mobile lors du double-tap */
#slider-wrapper, .slide img, .webtoon-page-wrapper img {
    touch-action: manipulation; 
}

/* Curseur forcé pour indiquer que c'est cliquable */
.webtoon-img, .slide img {
    cursor: zoom-in;
}

/* Le conteneur de la Lightbox */
#lightbox-content {
    touch-action: manipulation; /* Désactive le double-tap-to-zoom natif */
    cursor: zoom-out; /* Indique visuellement qu'on va sortir */
}

/* Les images dans la Lightbox */
.lightbox-slide img {
    touch-action: manipulation;
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: auto; /* Doit être sur AUTO pour détecter le double clic */
}


.lock-box {
    background: rgba(22, 27, 34, 0.95);
    border: 2px solid var(--gold);
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    margin: 0px auto;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
}

.lock-box h2 { color: var(--gold); margin-bottom: 20px; }
.lock-box p { margin-bottom: 30px; font-size: 1.1rem; }

.lock-btns { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.btn-lock { 
    padding: 12px 25px; border-radius: 8px; font-weight: bold; 
    text-decoration: none; transition: 0.3s;
}
.btn-lock.primary { background: var(--grad-gold); color: black; }
.btn-lock.secondary { background: var(--grad-blue); color: white; }


.slide .qrlod-video-player,
.slide .iframe-wrapper {
    max-width: 80%; /* You had this, keep it */
    max-height: 100%; /* Ensure it fits the slide height */
    width: 100%; /* Allow it to scale up to max-width */
    height: 100%; /* Allow it to scale up to max-height */
    display: flex; /* Use flex to center content if needed */
    justify-content: center;
    align-items: center;
}