/* 
  gallery.css
  Styles for the Gallery Section with a bottom slider
*/

.gallery-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 15vh 2rem 2rem 2rem;
    position: relative;
}

/* Container for all images */
.gallery-grid {
    display: grid;
    grid-template-rows: repeat(2, 30vh);
    /* Fixed 2 rows */
    grid-auto-columns: calc(33.333% - 1rem);
    /* Each column is roughly 1/3, matching the "3 columns at once" requirement */
    grid-auto-flow: column;
    /* Items fill top-to-bottom, then left-to-right */
    gap: 1.5rem;
    width: 90%;
    max-width: 1400px;
    height: calc(60vh + 1.5rem);
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    padding-bottom: 1rem;
    /* Space for shadow */

    overflow-x: auto;
    overflow-y: hidden;
    /* Hide scrollbar for a cleaner look */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* Internet Explorer 10+ */
    scroll-behavior: smooth;

    /* Ensure snap alignment for smooth column-by-column scrolling */
    scroll-snap-type: x mandatory;
}

.gallery-grid::-webkit-scrollbar {
    display: none;
    /* WebKit */
}

/* Fix for mobile scrolling ghost artifacts */
.gallery-grid>* {
    transform: translateZ(0);
    /* force hardware acceleration */
    backface-visibility: hidden;
}

.gallery-grid.visible {
    opacity: 1;
}

/* Individual Image Styles */
.gallery-item {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border: 3px solid #fff;
    /* Small white border */
    border-radius: 8px;
    /* Slight rounding for a premium feel */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    /* Subtle shadow for depth */
    transition: transform 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    /* Snap to each column */
    background: #000;
    /* Prevent transparent bleeding from bg */
}

.gallery-item:hover {
    transform: scale(1.02);
    border-color: #ddd;
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.2);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    will-change: object-position;
    display: block;
    /* transition for manual hover if needed, but animation handles movement */
}

/* Panning Animations */
@keyframes panVertical {
    0% {
        object-position: center top;
    }

    50% {
        object-position: center bottom;
    }

    100% {
        object-position: center top;
    }
}

@keyframes panHorizontal {
    0% {
        object-position: left center;
    }

    50% {
        object-position: right center;
    }

    100% {
        object-position: left center;
    }
}

.pan-vertical {
    animation: panVertical ease-in-out infinite;
}

.pan-horizontal {
    animation: panHorizontal ease-in-out infinite;
}

/* Slider Controls section */
.gallery-controls {
    margin-top: 5vh;
    /* Increased space between grid and slider */
    width: 60%;
    max-width: 800px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    /* Space between arrows and slider */
}

/* Range Slider Styling */
.gallery-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 400px;
    /* Constrain max width of slider itself */
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    border-radius: 2px;
    transition: background 0.3s;
}

/* Hover over range slider */
.gallery-slider:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Slider Thumb (the dragging circle) */
.gallery-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    transition: transform 0.2s;
    border: none;
}

.gallery-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px #fff;
}

.gallery-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px #fff;
}

/* Arrow Buttons */
.gallery-nav-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s ease, text-shadow 0.3s ease, opacity 0.3s ease;
    padding: 0.5rem;
    opacity: 0.7;
}

.gallery-nav-btn:hover {
    opacity: 1;
    transform: scale(1.2);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.gallery-nav-btn:active {
    transform: scale(0.9);
}

/* View All Images Button */
.gallery-view-all-btn {
    position: absolute;
    top: 8vh;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--text-color);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.gallery-view-all-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-50%) scale(1.05);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-rows: repeat(2, 28vh);
        /* Adjust row height */
        grid-auto-columns: calc(50% - 0.75rem);
        /* 2 columns at once */
        height: calc(56vh + 1.5rem);
    }
}

@media (max-width: 600px) {
    .gallery-grid {
        grid-template-rows: repeat(3, 18vh);
        /* Mobile row height - 3 rows */
        grid-auto-columns: 75vw;
        /* Narrower images on mobile */
        height: calc(54vh + 3rem);
    }

    .gallery-container {
        padding-top: 20vh;
        /* Increased top padding to move down on mobile */
    }

    .gallery-view-all-btn {
        top: 13vh !important;
        /* Lowered relative to mobile gallery container */
    }
}



/* All Images Grid Modal Content */
.gallery-all-images-content {
    margin: 5vh auto;
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding: 20px;
    background: transparent;
    border-radius: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.5) transparent;
}

.gallery-all-images-content::-webkit-scrollbar {
    width: 8px;
}

.gallery-all-images-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
}

.gallery-all-images-item {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}

.gallery-all-images-item:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

/* ========================================= */
/* Gallery Fullscreen Modal                  */
/* ========================================= */
.gallery-modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    /* Stay in place */
    z-index: 50000;
    /* Sit on top of everything including navs */
    padding-top: 5vh;
    /* Location of the box */
    left: 0;
    top: 0;
    width: 100%;
    /* Full width */
    height: 100%;
    /* Full height */
    overflow: hidden;
    /* Disable scrolling behind it */
    background-color: rgba(0, 0, 0, 0.95);
    /* Black w/ high opacity */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    /* Smooth fade in/out */
}

.gallery-modal.active {
    opacity: 1;
}

#gallery-all-images-modal {
    z-index: 45000;
}

.gallery-modal-wrapper {
    margin: auto;
    display: flex;
    justify-content: center;
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.gallery-modal-content {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease-in-out;
}

.gallery-modal.active .gallery-modal-content {
    transform: scale(1);
    opacity: 1;
}

/* Modal Arrows */
.gallery-modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    z-index: 5002;
    padding-bottom: 4px;
    /* visually center arrow */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    opacity: 0.7;
}

.gallery-modal-arrow:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

#gallery-modal-prev-btn {
    left: 20px;
}

#gallery-modal-next-btn {
    right: 20px;
}

.gallery-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 50001;
}

.gallery-modal-close:hover,
.gallery-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}