/* Gallery Styles */
#gallery {
    background: #050505;
    color: #fff;
    padding: 120px 40px;
    position: relative;
    width: 100%;
    z-index: 10;
    overflow: hidden; /* Hide horizontal scrollbar if possible or manage bleed */
}

/* Adjust project section flow specifically for gallery */
#gallery.project-section {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 60px;
    max-width: 100%;
}

/* Header container sizing stays roughly same */
#gallery .project-header {
    flex: 0 0 320px;
    width: auto;
    min-width: 260px;
    padding-left: 0;
}

#gallery .project-header h3 {
    color: #fff;
}

#gallery .project-header .desc {
    color: #999;
}

/* The Horizontal Ribbon */
#gallery .horizontal-ribbon {
    display: flex;
    flex-direction: row;
    gap: 40px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 40px;
    scroll-behavior: smooth;
    
    /* Hide scrollbar visually but keep functionality */
    -ms-overflow-style: none;
    scrollbar-width: none;
    
    /* Make it snap and feel like a slider */
    scroll-snap-type: x mandatory;
    cursor: grab;
}

#gallery .horizontal-ribbon::-webkit-scrollbar {
    display: none;
}

#gallery .horizontal-ribbon:active {
    cursor: grabbing;
}

/* Individual slide */
#gallery .horizontal-ribbon .img-wrapper {
    flex: 0 0 auto;
    height: 70vh; /* Consistent height */
    min-height: 400px;
    max-height: 800px;
    width: auto;
    aspect-ratio: 3/4; /* Default to portrait */
    scroll-snap-align: start;
    
    /* Reset margins from original CSS grid styles */
    margin: 0 !important;
    grid-column: auto !important;
}

/* Variation: landscape images */
#gallery .horizontal-ribbon .img-wrapper.landscape {
    aspect-ratio: 3/2;
}

/* Ensure images fill wrapper */
#gallery .horizontal-ribbon .img-wrapper picture,
#gallery .horizontal-ribbon .img-wrapper img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    transition: none;
}

#gallery .horizontal-ribbon .img-wrapper:hover img {
    transform: none;
}

.gallery-slider-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    pointer-events: none;
    transform: translateY(-50%);
    z-index: 20;
}

.gallery-nav-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.gallery-nav-btn svg {
    display: block;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.gallery-nav-btn[data-gallery-nav="prev"] svg {
    transform: scaleX(-1);
}

.gallery-nav-btn:hover:not(:disabled),
.gallery-nav-btn:focus-visible:not(:disabled) {
    background: #fff;
    color: #050505;
    border-color: #fff;
    transform: scale(1.05);
}

.gallery-nav-btn[data-gallery-nav="next"]:hover:not(:disabled) svg {
    transform: translateX(4px);
}

.gallery-nav-btn[data-gallery-nav="prev"]:hover:not(:disabled) svg {
    transform: scaleX(-1) translateX(4px);
}

.gallery-nav-btn:disabled {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.9);
}

#gallery .horizontal-ribbon.nav-controlled {
    overflow-x: hidden;
    touch-action: pan-y;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    #gallery {
        padding: 60px 20px;
    }
    
    #gallery.project-section {
        display: block;
        padding-right: 0;
        padding-left: 0;
    }
    
    #gallery .project-header {
        width: 100%;
        margin-bottom: 30px;
    }
    
    #gallery .horizontal-ribbon {
        width: 100%;
        padding-left: 10px;
        gap: 20px;
    }
    
    #gallery .horizontal-ribbon .img-wrapper {
        height: 50vh;
        width: 80vw; /* Peek effect on mobile */
        aspect-ratio: unset;
    }

    .gallery-nav {
        padding: 0 16px;
    }

    .gallery-nav-btn {
        width: 48px;
        height: 48px;
        background: rgba(20, 20, 20, 0.4); /* clearer visibility on mobile */
    }
}
