/* =============================================================================
   Faith'SchooLab - Galerie CSS
   Styles spécifiques à la page Galerie (masonry, lightbox, pagination,
   photo-card, bouton retour haut).
   Chargé uniquement sur /gallery/ via {% block extra_css %}.
============================================================================= */

/* ── Masonry (CSS columns, vrai masonry sans JS) ─────────────────────────── */
.masonry {
    columns: 4;
    column-gap: 10px;
}
@media (max-width: 1280px) { .masonry { columns: 3; } }
@media (max-width:  860px) { .masonry { columns: 2; } }
@media (max-width:  480px) { .masonry { columns: 1; } }

.masonry-item {
    break-inside: avoid;
    margin-bottom: 10px;
    display: block;
}

/* ── Carte photo ──────────────────────────────────────────────────────────── */
/* Les squelettes utilisent animate-pulse + bg-gray-200 de Tailwind           */
.photo-card {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 10px;
    display: block;
}

/* Hauteurs squelettes variées (nth-child, pas de JS) */
.masonry-item:nth-child(4n+1) .photo-card { min-height: 280px; }
.masonry-item:nth-child(4n+2) .photo-card { min-height: 200px; }
.masonry-item:nth-child(4n+3) .photo-card { min-height: 320px; }
.masonry-item:nth-child(4n)   .photo-card { min-height: 210px; }

/* Image toujours visible, jamais cachée (robustesse connexion lente) */
.photo-card img {
    width: 100%;
    display: block;
    transition: transform .5s cubic-bezier(.25,.46,.45,.94);
    will-change: transform;
}
.photo-card:hover img { transform: scale(1.06); }

/* Squelette retiré une fois l'image chargée */
.photo-card.sk-done { min-height: 0 !important; }

/* Erreur : image absente → fond gris clair */
.photo-card.sk-error {
    min-height: 120px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlay hover */
.photo-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(30,64,175,.78) 0%, rgba(30,64,175,.08) 45%, transparent 100%);
    opacity: 0;
    transition: opacity .3s ease;
    display: flex;
    align-items: flex-end;
    padding: 12px 14px;
    pointer-events: none;
}
.photo-card:hover .photo-card-overlay { opacity: 1; }

/* Loupe centrale */
.photo-card-zoom {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%) scale(.45);
    opacity: 0;
    transition: all .3s cubic-bezier(.34,1.56,.64,1);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(6px);
    border: 1.5px solid rgba(255,255,255,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 17px;
    pointer-events: none;
}
.photo-card:hover .photo-card-zoom {
    opacity: 1;
    transform: translate(-50%,-50%) scale(1);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #374151;
    text-decoration: none;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
}
.pag-btn:hover { border-color: #2563EB; color: #2563EB; background: #EFF6FF; }
.pag-btn.active {
    background: #2563EB;
    border-color: #2563EB;
    color: #fff;
    box-shadow: 0 3px 10px rgba(37,99,235,.35);
}
.pag-btn.disabled { opacity: .4; pointer-events: none; cursor: default; }
.pag-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 38px;
    color: #9ca3af;
    font-size: .85rem;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
#lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(3,7,18,.97);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 58px 68px 46px;
}
#lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 100px rgba(0,0,0,.55);
    display: block;
    transition: opacity .18s ease;
    user-select: none;
    -webkit-user-drag: none;
}
#lb-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    background: linear-gradient(to bottom, rgba(0,0,0,.65) 0%, transparent 100%);
}
#lb-bottombar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 80px;
    background: linear-gradient(to top, rgba(0,0,0,.5) 0%, transparent 100%);
}
#lb-counter {
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.9);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .03em;
}
#lb-caption {
    color: rgba(255,255,255,.6);
    font-size: .8rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 500px;
}
#lb-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16,185,129,.85);
    border: 1px solid rgba(16,185,129,.4);
    backdrop-filter: blur(8px);
    color: #fff;
    text-decoration: none;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    transition: background .2s;
}
#lb-download:hover { background: #10B981; }
.lb-ctrl {
    position: absolute;
    background: rgba(255,255,255,.1);
    border: 1.5px solid rgba(255,255,255,.14);
    backdrop-filter: blur(10px);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: background .2s, transform .2s;
}
.lb-ctrl:hover {
    background: rgba(255,255,255,.22);
    transform: scale(1.08);
}
#lb-close { top: 14px; right: 16px; width: 40px; height: 40px; font-size: 15px; }
#lb-close:hover { background: rgba(239,68,68,.6); }
#lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
#lb-prev:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }
#lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
#lb-next:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }
#lb-spinner {
    position: absolute;
    color: rgba(255,255,255,.4);
    font-size: 2rem;
}

/* ── Bouton haut de page ──────────────────────────────────────────────────── */
#back-top {
    position: fixed;
    bottom: 26px;
    right: 26px;
    z-index: 500;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #2563EB;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .3s;
    transform: translateY(10px);
}
#back-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
#back-top:hover { background: #1E40AF; }
