/* ==========================================================================
   Waqt Al-Hadhara - gallery.css
   Full-Page Photo Gallery
   ========================================================================== */

/* ── Gallery Header ─────────────────────────────────────────────────── */
.gallery-header {
    background-color: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border-grey);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.gallery-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gallery-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.2s;
}

.gallery-back:hover {
    color: var(--color-gold);
}

.gallery-header-center {
    text-align: center;
}

.gallery-header-center h1 {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    margin-bottom: 4px;
}

.gallery-logo {
    height: 32px;
    margin-bottom: 8px;
}

.gallery-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

/* Vision 2030 as main logo in gallery header */
.gallery-vision-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
    margin-bottom: 12px;
}

.gallery-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    background: none;
    border: 1px solid var(--color-border-grey);
    color: var(--color-text-primary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.25s var(--transition-ease);
}

.btn-icon:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
}

/* ── Masonry Gallery ────────────────────────────────────────────────── */
.gallery-page {
    padding: 40px 0 60px;
}

.gallery-masonry {
    columns: 3;
    column-gap: 16px;
    max-width: 100%; /* 3-column masonry can never overflow */
}

.gallery-item {
    width: 100%;
    max-width: 100%; /* image can never exceed its column */
    display: block;
    margin-bottom: 16px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.4s var(--transition-ease), box-shadow 0.4s var(--transition-ease);
    break-inside: avoid;
    /* aspect-ratio prevents CLS while images load — values are normalized across varied source aspect ratios */
    aspect-ratio: 4 / 3;
}

/* ── Skeleton Loading Placeholders ──────────────────────────────────── */
.gallery-skeleton {
    width: 100%;
    margin-bottom: 16px;
    break-inside: avoid;
    background-color: var(--color-bg-card);
    position: relative;
    overflow: hidden;
    min-height: 200px;
}

.gallery-skeleton:nth-child(odd)  { min-height: 260px; }
.gallery-skeleton:nth-child(even) { min-height: 180px; }
.gallery-skeleton:nth-child(3n)   { min-height: 300px; }

.gallery-skeleton .skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(229, 184, 105, 0.06) 40%,
        rgba(229, 184, 105, 0.12) 50%,
        rgba(229, 184, 105, 0.06) 60%,
        transparent 100%
    );
    animation: skeletonShimmer 1.8s ease-in-out infinite;
}

html.light-mode .gallery-skeleton .skeleton-shimmer {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(184, 134, 11, 0.04) 40%,
        rgba(184, 134, 11, 0.09) 50%,
        rgba(184, 134, 11, 0.04) 60%,
        transparent 100%
    );
}

@keyframes skeletonShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.gallery-skeleton.hidden {
    display: none;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

html.light-mode .gallery-item:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* ── CTA Section ────────────────────────────────────────────────────── */
.gallery-cta {
    padding: 80px 0;
    background-color: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border-grey);
}

.gallery-cta h2 {
    margin-bottom: 12px;
}

.gallery-cta p {
    color: var(--color-text-secondary);
    margin-bottom: 28px;
}

.gallery-cta .btn {
    display: inline-flex;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.gallery-footer {
    padding: 24px 0;
    border-top: 1px solid var(--color-border-grey);
    text-align: center;
}

.gallery-footer p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* ── Lightbox ───────────────────────────────────────────────────────── */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox-overlay:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border: none;
    animation: lightboxZoomIn 0.3s var(--transition-ease);
}

@keyframes lightboxZoomIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.lightbox-counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #F5F5F7;
    font-size: 0.85rem;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #F5F5F7;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: var(--color-gold);
    color: var(--color-text-dark);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #F5F5F7;
    font-size: 2rem;
    cursor: pointer;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-nav:hover {
    background: var(--color-gold);
    color: var(--color-text-dark);
}

.lightbox-prev { right: 20px; }
.lightbox-next { left: 20px; }

/* ── Reading Progress Bar ───────────────────────────────────────────── */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-gold), var(--color-gold-bright));
    z-index: 10001;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ── Language Toggle ────────────────────────────────────────────── */
.lang-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: transform 0.25s ease;
}

.lang-toggle:hover {
    transform: scale(1.08);
}

.lang-flag {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
    outline: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(0.92);
    pointer-events: none;
}

.lang-flag.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .gallery-masonry {
        columns: 2;
    }
}

@media (max-width: 768px) {
    .gallery-header-center h1 {
        font-size: 1.1rem;
    }

    .gallery-subtitle {
        display: none;
    }

    .gallery-back span {
        display: none;
    }

    .gallery-vision-logo {
        height: 56px;
    }
}

@media (max-width: 600px) {
    .gallery-masonry {
        columns: 1;
        column-gap: 0;
    }

    .gallery-item {
        margin-bottom: 12px;
    }

    .lightbox-nav {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .lightbox-prev { right: 8px; }
    .lightbox-next { left: 8px; }
}
