/* ============================================================
   chapter.css  –  Lecteur de chapitre (frontend public)
   ============================================================ */

/* ── Variables ── */
:root {
    --clr-bg         : #121212;
    --clr-surface    : #1a1a1a;
    --clr-surface2   : #242424;
    --clr-border     : #2e2e2e;
    --clr-text       : #e0e0e0;
    --clr-muted      : #888;
    --clr-accent     : #ff4c4c;
    --clr-accent2    : #ffa500;
    --clr-gold       : #fae846;
    --radius         : 8px;
    --transition     : 0.25s ease;
    font-family      : 'Tajawal', sans-serif;
}

/* ── Base ── */
body {
    background-color : var(--clr-bg);
    color            : var(--clr-text);
}

/* ══════════════════════════════════════════
   BARRE DE PROGRESSION LECTURE
══════════════════════════════════════════ */
#progress-bar-reader {
    position   : fixed;
    top        : 0;
    left       : 0;
    height     : 3px;
    width      : 0%;
    background : var(--clr-accent);
    z-index    : 9999;
    transition : width 0.15s linear;
    border-radius: 0 2px 2px 0;
}

/* ══════════════════════════════════════════
   EN-TÊTE DU CHAPITRE
══════════════════════════════════════════ */
.chapter-header {
    padding    : 2rem 1rem 1rem;
    background : var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    margin-bottom: 0;
}

.chapter-number {
    font-size   : 1rem;
    font-weight : 700;
    color       : var(--clr-accent2);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.chapter-title {
    font-size   : 1.4rem;
    font-weight : 700;
    color       : var(--clr-text);
    margin-bottom: 0.5rem;
}

.chapter-desc {
    font-size  : 0.9rem;
    color      : var(--clr-muted);
    max-width  : 680px;
    margin     : 0 auto 0.5rem;
}

/* Compteur de page (header) */
.page-counter-wrapper {
    display         : inline-flex;
    align-items     : center;
    gap             : 0.4rem;
    background      : var(--clr-surface2);
    border          : 1px solid var(--clr-border);
    border-radius   : 20px;
    padding         : 4px 14px;
    font-size       : 0.82rem;
    color           : var(--clr-muted);
    margin-top      : 0.5rem;
}

/* ══════════════════════════════════════════
   CONTENEUR DES PAGES
══════════════════════════════════════════ */
#manga-container {
    display        : flex;
    flex-direction : column;
    align-items    : center;
    background     : #0e0e0e;
    padding        : 1rem 0.5rem;
    gap            : 4px;
}

/* ── Page individuelle ── */
.manga-page {
    position   : relative;
    width      : 100%;
    max-width  : 900px;
    overflow   : hidden;
    background : var(--clr-surface2);
}

/* ── Image ── */
.manga-page img.manga-image {
    display    : block;
    width      : 100%;
    height     : auto;
    transition : opacity var(--transition);
}

.manga-page img.manga-image.lazy {
    opacity    : 0;
    min-height : 380px;
}

.manga-page img.manga-image.loaded {
    opacity    : 1;
}

/* ── Skeleton loader ── */
.manga-page .skeleton {
    position   : absolute;
    inset      : 0;
    background : linear-gradient(
        90deg,
        var(--clr-surface2) 25%,
        #2e2e2e 50%,
        var(--clr-surface2) 75%
    );
    background-size : 400% 100%;
    animation       : shimmer 1.4s infinite;
}

.manga-page .skeleton.hidden { display: none; }

@keyframes shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* Page image loading indicator (per image) */
.image-load-indicator {
    --progress: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    background: rgba(10, 10, 10, 0.55);
    backdrop-filter: blur(2px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.image-load-indicator.is-visible {
    opacity: 1;
}

.image-load-indicator.is-finished {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.93);
}

.image-load-ring {
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
}

.image-load-ring .ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.16);
    stroke-width: 3;
}

.image-load-ring .ring-progress {
    fill: none;
    stroke: var(--clr-accent2);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 126;
    stroke-dashoffset: calc(126 - (126 * var(--progress)) / 100);
    transition: stroke-dashoffset 0.15s linear;
}

.image-load-percent {
    position: absolute;
    color: #fff;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* ── Badge numéro de page ── */
.page-badge {
    position       : absolute;
    bottom         : 8px;
    right          : 10px;
    background     : rgba(0,0,0,0.65);
    color          : #fff;
    font-size      : 0.72rem;
    padding        : 2px 8px;
    border-radius  : 20px;
    pointer-events : none;
    letter-spacing : 0.5px;
    user-select    : none;
}

/* ── Erreur image ── */
.img-error {
    display         : flex;
    flex-direction  : column;
    align-items     : center;
    justify-content : center;
    min-height      : 280px;
    gap             : 0.5rem;
    color           : var(--clr-muted);
    font-size       : 0.9rem;
}
.img-error i { font-size: 2rem; }

/* ── Fin du chapitre ── */
.end-of-chapter {
    padding    : 2rem;
    font-size  : 1.1rem;
    color      : var(--clr-muted);
    font-weight: 600;
}

.no-images {
    color: var(--clr-muted);
}

/* ══════════════════════════════════════════
   NAVIGATION ENTRE CHAPITRES
══════════════════════════════════════════ */
.chapter-navigation {
    display         : flex;
    justify-content : space-between;
    align-items     : center;
    gap             : 0.75rem;
    padding         : 1.25rem 0;
    flex-wrap       : wrap;
}

.chapter-navigation .btn {
    min-width : 140px;
    font-size : 0.95rem;
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 600px) {
    #manga-container {
        padding: 0.25rem 0;
        gap    : 2px;
    }
    .manga-page { max-width: 100%; }
    .chapter-navigation { gap: 0.4rem; }
    .chapter-navigation .btn { min-width: 110px; font-size: 0.85rem; }
}

@media (min-width: 601px) and (max-width: 1024px) {
    .manga-page { max-width: 86%; }
}

@media (min-width: 1025px) {
    .manga-page { max-width: 720px; }
}
/* ══════════════════════════════════════════
   COMMENTS — Clean Fire Theme
   Animations simples et élégantes
══════════════════════════════════════════ */

@keyframes fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer-line {
    from { background-position: 200% center; }
    to   { background-position: -200% center; }
}

@keyframes like-pop {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.35); }
}

/* ── Wrapper ── */
.comments-section {
    max-width    : 820px;
    margin-inline: auto;
    padding      : 0 1rem 3.5rem;
}

/* ══════════════════════════════════════════
   TITRES DE SECTION
══════════════════════════════════════════ */
.section-title {
    display      : flex;
    align-items  : center;
    gap          : 0.7rem;
    margin-bottom: 1.4rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(255,140,0,0.2);
}

.section-title-text {
    font-size    : 1rem;
    font-weight  : 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    /* dégradé feu statique — pas d'animation */
    background   : linear-gradient(90deg, #FFD700, #FF8C00, #FF4C4C);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation    : shimmer-line 4s linear infinite;
}

.section-title-icon { font-size: 1.1rem; }

.comments-count-badge {
    margin-right : auto;
    font-size    : 0.73rem;
    font-weight  : 700;
    color        : rgba(255,140,0,0.7);
    background   : rgba(139,0,0,0.2);
    border       : 1px solid rgba(255,76,76,0.2);
    padding      : 2px 10px;
    border-radius: 2px;
}

/* ══════════════════════════════════════════
   CTA ENCOURAGEMENT
══════════════════════════════════════════ */
.comments-cta {
    display      : flex;
    align-items  : center;
    gap          : 1rem;
    background   : rgba(26,26,46,0.8);
    border       : 1px solid rgba(255,140,0,0.15);
    border-right : 3px solid #FF8C00;
    border-radius: 4px;
    padding      : 0.85rem 1.1rem;
    margin-bottom: 1.5rem;
}

.comments-cta-levels {
    display  : flex;
    gap      : 4px;
    flex-shrink: 0;
}

.comments-cta-levels img {
    width     : 26px;
    height    : 26px;
    object-fit: contain;
    opacity   : 0.85;
    transition: opacity 0.2s, transform 0.2s;
}
.comments-cta-levels img:hover {
    opacity  : 1;
    transform: translateY(-2px);
}

.comments-cta-text strong {
    display    : block;
    font-size  : 0.85rem;
    font-weight: 700;
    color      : #FFD700;
    margin-bottom: 0.2rem;
}
.comments-cta-text span {
    font-size: 0.78rem;
    color    : rgba(245,245,245,0.5);
}

/* ══════════════════════════════════════════
   FORMULAIRE
══════════════════════════════════════════ */
.comment-form {
    background   : #1a1a2e;
    border       : 1px solid rgba(255,76,76,0.15);
    border-top   : 2px solid #FF4C4C;
    border-radius: 0 0 6px 6px;
    padding      : 1.3rem;
    margin-bottom: 2rem;
}

.comment-form textarea {
    width       : 100%;
    background  : rgba(18,18,18,0.7);
    color       : #f5f5f5;
    border      : 1px solid rgba(255,255,255,0.08);
    border-radius: 4px;
    padding     : 0.9rem 1rem;
    font-family : 'Tajawal', sans-serif;
    font-size   : 0.93rem;
    resize      : vertical;
    min-height  : 100px;
    outline     : none;
    transition  : border-color 0.2s, box-shadow 0.2s;
}

.comment-form textarea::placeholder { color: rgba(245,245,245,0.25); }

.comment-form textarea:focus {
    border-color: rgba(255,140,0,0.5);
    box-shadow  : 0 0 0 3px rgba(255,140,0,0.08);
}

.btn-submit-comment {
    display     : inline-flex;
    align-items : center;
    gap         : 0.5rem;
    background  : linear-gradient(135deg, #8B0000, #FF4C4C);
    color       : #fff;
    border      : none;
    border-radius: 4px;
    padding     : 0.6rem 1.4rem;
    font-family : 'Tajawal', sans-serif;
    font-size   : 0.93rem;
    font-weight : 700;
    cursor      : pointer;
    margin-top  : 0.85rem;
    transition  : opacity 0.2s, transform 0.2s;
}

.btn-submit-comment:hover  { opacity: 0.88; transform: translateY(-1px); }
.btn-submit-comment:active { transform: translateY(0); opacity: 1; }

#commentError {
    background  : rgba(139,0,0,0.18);
    border      : 1px solid rgba(255,76,76,0.3);
    border-right: 3px solid #FF4C4C;
    color       : #ff7f7f;
    padding     : 0.6rem 1rem;
    border-radius: 3px;
    font-size   : 0.87rem;
    margin-bottom: 0.9rem;
}

/* ══════════════════════════════════════════
   LISTE DES COMMENTAIRES
══════════════════════════════════════════ */
#commentsContainer {
    display       : flex;
    flex-direction: column;
    gap           : 0.75rem;
}

/* ── Carte ── */
.comment-card {
    background   : #1a1a2e;
    border       : 1px solid rgba(255,76,76,0.12);
    border-right : 3px solid transparent;
    border-radius: 5px;
    padding      : 1rem 1.15rem 0.85rem;
    animation    : fade-up 0.35s ease both;
    transition   : border-right-color 0.25s, transform 0.25s;
}

.comment-card:nth-child(1) { animation-delay: 0s; }
.comment-card:nth-child(2) { animation-delay: 0.06s; }
.comment-card:nth-child(3) { animation-delay: 0.12s; }
.comment-card:nth-child(4) { animation-delay: 0.18s; }
.comment-card:nth-child(n+5) { animation-delay: 0.22s; }

.comment-card:hover {
    border-right-color: #FF8C00;
    transform         : translateX(-3px);
}

/* ── En-tête ── */
.comment-header {
    display      : flex;
    align-items  : center;
    gap          : 0.75rem;
    margin-bottom: 0.7rem;
    flex-wrap    : wrap;
}

/* Avatar */
.comment-avatar-wrap {
    position   : relative;
    flex-shrink: 0;
}

.comment-avatar-wrap img.user-avatar {
    width        : 44px;
    height       : 44px;
    border-radius: 50%;
    object-fit   : cover;
    border       : 2px solid rgba(255,76,76,0.25);
    display      : block;
    transition   : border-color 0.25s;
}

.comment-card:hover .comment-avatar-wrap img.user-avatar {
    border-color: #FF8C00;
}

/* Badge icône de rang */
.comment-rank-badge {
    position: absolute;
    bottom: -14px;
    right: 20px;
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5));
    transition: transform 0.25s;
}

.comment-card:hover .comment-rank-badge { transform: scale(1.2); }

/* Méta */
.comment-meta {
    flex           : 1;
    min-width      : 0;
    display        : flex;
    flex-direction : column;
    gap            : 0.18rem;
}

.comment-username {
    font-size    : 0.92rem;
    font-weight  : 700;
    color        : #f5f5f5;
    white-space  : nowrap;
    overflow     : hidden;
    text-overflow: ellipsis;
    transition   : color 0.2s;
}

.comment-card:hover .comment-username { color: #FFD700; }

.comment-date {
    font-size  : 0.71rem;
    color      : rgba(245,245,245,0.3);
    display    : flex;
    align-items: center;
    gap        : 0.3rem;
}

/* Tag rang */
.comment-rank-tag {
    font-size    : 0.69rem;
    font-weight  : 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color        : rgba(255,140,0,0.8);
    background   : rgba(139,0,0,0.2);
    border       : 1px solid rgba(255,140,0,0.2);
    padding      : 2px 8px;
    border-radius: 2px;
    white-space  : nowrap;
    margin-right : auto;
    transition   : color 0.2s, border-color 0.2s;
}

.comment-card:hover .comment-rank-tag {
    color       : #FFD700;
    border-color: rgba(255,215,0,0.35);
}

/* Corps */
.comment-body {
    font-size  : 0.92rem;
    color      : rgba(245,245,245,0.78);
    line-height: 1.72;
    margin-bottom: 0.8rem;
    word-break : break-word;
}

/* ── Actions ── */
.comment-actions {
    display    : flex;
    align-items: center;
    gap        : 0.55rem;
    flex-wrap  : wrap;
}

.like-btn {
    display     : inline-flex;
    align-items : center;
    gap         : 0.4rem;
    background  : transparent;
    color       : rgba(245,245,245,0.35);
    border      : 1px solid rgba(255,255,255,0.08);
    border-radius: 3px;
    padding     : 0.3rem 0.85rem;
    font-family : 'Tajawal', sans-serif;
    font-size   : 0.82rem;
    cursor      : pointer;
    transition  : color 0.2s, border-color 0.2s, background 0.2s;
}

.like-btn:hover {
    color       : #FFD700;
    border-color: rgba(255,140,0,0.4);
    background  : rgba(139,0,0,0.2);
}

.like-btn.active {
    color       : #FFD700;
    border-color: rgba(255,140,0,0.5);
    background  : rgba(139,0,0,0.25);
}

/* Pop au clic (déclenché par JS) */
.like-count.pop { animation: like-pop 0.3s ease; }

.like-count { font-weight: 700; min-width: 14px; text-align: center; }

.like-btn i { transition: transform 0.2s; }
.like-btn.active i { transform: scale(1.15); color: #FF8C00; }

.delete-comment-btn {
    display     : inline-flex;
    align-items : center;
    gap         : 0.35rem;
    background  : transparent;
    color       : rgba(245,245,245,0.2);
    border      : 1px solid rgba(255,255,255,0.06);
    border-radius: 3px;
    padding     : 0.3rem 0.85rem;
    font-family : 'Tajawal', sans-serif;
    font-size   : 0.82rem;
    cursor      : pointer;
    transition  : color 0.2s, border-color 0.2s, background 0.2s;
}

.delete-comment-btn:hover {
    color       : #ff7f7f;
    border-color: rgba(255,76,76,0.35);
    background  : rgba(139,0,0,0.15);
}

/* Vide */
#commentsContainer > p {
    text-align : center;
    color      : rgba(245,245,245,0.28);
    padding    : 2.5rem 1rem;
    border     : 1px dashed rgba(255,76,76,0.15);
    border-radius: 5px;
    font-size  : 0.92rem;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .comment-form  { padding: 1rem; }
    .comment-card  { padding: 0.85rem; }
    .comment-avatar-wrap img.user-avatar { width: 38px; height: 38px; }
    .comment-rank-tag   { display: none; }
    .comments-cta-levels{ display: none; }
}
