/*
 * Gallery Page styles
 * Page: resources/views/gallery.blade.php
 * NEVER hardcode colors - use var(--site-*) variables
 */

/* ========== HERO ========== */
.gallery-hero {
    background-color: var(--site-hero-bg);
    padding: 80px 5% 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.gallery-hero::before,
.gallery-hero::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.gallery-hero::before {
    top: -45%;
    right: -10%;
    width: 460px; height: 460px;
    background: var(--site-secondary);
    opacity: 0.07;
}

.gallery-hero::after {
    bottom: -45%;
    left: -10%;
    width: 380px; height: 380px;
    background: var(--site-primary);
    opacity: 0.06;
}

.gallery-hero-content {
    max-width: 760px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.gallery-hero-content h1 {
    font-size: 2.8rem;
    color: var(--site-primary);
    margin-bottom: 12px;
}

.gallery-hero-content p {
    font-size: 1.15rem;
    opacity: 0.85;
}

/* ========== SECTION ========== */
.gallery-section { padding: 70px 0; }
.gallery-section .section-inner { max-width: 1280px; margin: 0 auto; padding: 0 5%; }

/* ========== CATEGORY ========== */
.gallery-category {
    margin-top: 48px;
}
.gallery-category:first-of-type { margin-top: 24px; }

.gallery-category-title {
    font-size: 1.5rem;
    color: var(--site-primary);
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--site-card-border);
    letter-spacing: -0.01em;
}

/* ========== GRID ==========
 * 4:3 cards on desktop, narrower on small screens.
 * The figure is now a <button> so it's keyboard-focusable + clickable. */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 22px;
}

.gallery-figure {
    position: relative;
    margin: 0;
    padding: 0;
    border: none;
    background: var(--site-card-bg);
    border-radius: var(--site-radius-md, 16px);
    overflow: hidden;
    box-shadow: var(--site-shadow-sm);
    cursor: pointer;
    aspect-ratio: 4 / 3;
    display: block;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.35s ease;
}

.gallery-figure:hover,
.gallery-figure:focus-visible {
    transform: translateY(-4px);
    box-shadow: var(--site-shadow-lg);
}

.gallery-figure img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: block;
}

.gallery-figure:hover img,
.gallery-figure:focus-visible img {
    transform: scale(1.06);
}

/* ========== CAPTION (hover-reveal, slides up from bottom) ========== */
.gallery-caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #ffffff;
    font-family: "Poppins", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: start;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(0, 0, 0, 0.05) 30%,
        rgba(0, 0, 0, 0.72) 100%);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-figure:hover .gallery-caption,
.gallery-figure:focus-visible .gallery-caption {
    transform: translateY(0);
}

.gallery-caption-text {
    flex: 1;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.gallery-caption-icon {
    display: inline-flex;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gallery-caption-icon .icon-svg {
    width: 16px;
    height: 16px;
    color: #ffffff;
}

/* ========== EMPTY STATE ========== */
.gallery-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--site-card-bg);
    border: 1px dashed var(--site-card-border);
    border-radius: var(--site-radius-md, 16px);
    margin-top: 30px;
}

.gallery-empty-icon {
    color: var(--site-primary);
    display: inline-flex;
    margin-bottom: 12px;
}

.gallery-empty-icon .icon-svg { width: 48px; height: 48px; }

.gallery-empty h3 {
    color: var(--site-primary);
    margin-bottom: 8px;
}

.gallery-empty p {
    margin-bottom: 20px;
    opacity: 0.85;
}

/* ============================================================
 * LIGHTBOX — full-screen image viewer
 * Vanilla JS controlled (gallery.blade.php @section('scripts')).
 * Backdrop click / ESC / arrow-keys / X-button all close or navigate.
 * ============================================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: color-mix(in srgb, var(--site-text) 92%, #000);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(20px, 4vw, 60px);
    animation: lb-fade-in 0.25s ease-out;
}
.lightbox[hidden] { display: none; }

@keyframes lb-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lightbox-figure {
    position: relative;
    max-width: min(1100px, 92vw);
    max-height: min(85vh, 800px);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: lb-zoom-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lb-zoom-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.lightbox-figure img {
    max-width: 100%;
    max-height: calc(85vh - 80px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    background: #ffffff;
}

.lightbox-figure figcaption {
    color: #ffffff;
    font-family: "Poppins", system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lightbox-counter {
    font-size: 0.82rem;
    opacity: 0.65;
    letter-spacing: 0.05em;
}

/* Close button (top-right) */
.lightbox-close {
    position: absolute;
    top: clamp(14px, 2.5vw, 28px);
    inset-inline-end: clamp(14px, 2.5vw, 28px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.2s ease;
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.06);
}

/* Prev / Next nav arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.2s ease;
}
.lightbox-prev { inset-inline-start: clamp(10px, 2vw, 28px); }
.lightbox-next { inset-inline-end:   clamp(10px, 2vw, 28px); }

/* Mirror arrow direction in RTL so "prev" still feels like "back" */
[dir="rtl"] .lightbox-prev svg { transform: scaleX(-1); }
[dir="rtl"] .lightbox-next svg { transform: scaleX(-1); }

.lightbox-nav:hover,
.lightbox-nav:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.06);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
    .gallery-hero-content h1 { font-size: 2.1rem; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .gallery-figure { aspect-ratio: 1 / 1; }
    .gallery-caption { padding: 10px 12px; font-size: 0.85rem; }
    .gallery-caption-icon { width: 26px; height: 26px; }
    .gallery-caption-icon .icon-svg { width: 14px; height: 14px; }

    /* Always show caption on touch screens (no hover) */
    @media (hover: none) {
        .gallery-caption { transform: translateY(0); }
    }

    .lightbox-nav { width: 44px; height: 44px; }
}
