/* --- Premium Horizontal Gallery Slider --- */
.gallery-slider {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 24px;
    padding: 24px 10px 40px 10px;
    scrollbar-width: none; /* Hide scrollbar for cleaner look */
    -webkit-overflow-scrolling: touch;
}
.gallery-slider::-webkit-scrollbar {
    display: none;
}

/* Individual Thumbnail Items */
.gallery-item {
    position: relative;
    flex: 0 0 auto;
    width: 320px; 
    height: 220px;
    scroll-snap-align: center;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    background-color: #f8f9fa;
    transform: translateZ(0); /* Hardware acceleration */
}

/* Elegant dark gradient overlay that appears on hover */
.gallery-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.gallery-item:hover::after {
    opacity: 1;
}

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

.gallery-item:hover .gallery-thumbnail {
    transform: scale(1.08);
}

/* --- Fullscreen Modal Overlay --- */
@keyframes modalFadeIn {
    from { opacity: 0; backdrop-filter: blur(0px); }
    to { opacity: 1; backdrop-filter: blur(15px); }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(10, 10, 15, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(15px);
    animation: modalFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Modal Content & Image */
@keyframes imageScaleUp {
    from { opacity: 0; transform: scale(0.92) translateY(15px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: imageScaleUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-image {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Caption */
.modal-caption {
    color: rgba(255, 255, 255, 0.9);
    margin-top: 20px;
    font-size: 1.15rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 24px;
    border-radius: 30px;
}

/* Modal Navigation (Glassmorphism style) */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.modal-nav-prev {
    left: 15px;
}

.modal-nav-next {
    right: 15px;
}

/* Close Button (Matching Glassmorphism) */
.modal-close {
    position: absolute;
    top: -20px;
    right: -20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    z-index: 20;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    padding-bottom: 3px; /* visual center fix */
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
    .modal-close {
        top: -60px;
        right: 0px;
    }
    .modal-image {
        max-width: 95vw;
    }
}

/* Modal Counter Context */
.modal-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    z-index: 20;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    font-family: inherit;
    font-weight: 500;
}

/* Loading Spinner */
.modal-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: modalSpin 1s linear infinite;
    z-index: 5;
    display: none; /* Shown only when HTMX adds .htmx-request */
}

.modal-loader.htmx-request {
    display: block;
}

@keyframes modalSpin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* HTMX Swapping Crossfade Animations */
.modal-image {
    transition: opacity 0.2s ease, filter 0.2s ease;
}

#gallery-modal.htmx-swapping .modal-overlay {
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.modal-overlay {
    animation: modalFadeIn 200ms ease-out forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
