/* Photo Gallery Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f5f5f5;
    line-height: 1.6;
}

.gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.gallery-header {
    text-align: center;
    margin-bottom: 30px;
}

.gallery-header h1 {
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.gallery-info {
    color: #666;
    font-size: 1.1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

/* Square container styling */
.gallery-grid .gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
}

.gallery-grid .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.gallery-item-info {
    text-align: center;
    color: white;
}

.gallery-item-info h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.lightbox.active {
    display: block;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
}

.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 95vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    margin: 5vh auto 5vh auto;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    gap: 15px;
}

.lightbox-image-container {
    flex: 7;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    position: relative;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}

.lightbox-content img.loading {
    opacity: 0.7;
}

.lightbox-caption {
    flex: 3;
    color: white;
    font-size: 1.1rem;
    line-height: 1.4;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 10px;
    box-sizing: border-box;
    min-height: 60px;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.4) rgba(0, 0, 0, 0.3);
    scroll-behavior: smooth;
    display: block;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.lightbox-caption::-webkit-scrollbar {
    width: 10px;
}

.lightbox-caption::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    margin: 2px;
}

.lightbox-caption::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.lightbox-caption::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}

.lightbox-caption::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.7);
}

.lightbox-caption::-webkit-scrollbar-corner {
    background: rgba(0, 0, 0, 0.3);
}

/* Ensure caption scrolling works on touch devices */
.lightbox-caption {
    -webkit-overflow-scrolling: touch;
}

/* Fallback for browsers without custom scrollbar support */
@supports not (scrollbar-width: thin) {
    .lightbox-caption::-webkit-scrollbar {
        width: 12px;
    }
}

/* Improve readability of long captions */
.lightbox-caption p {
    margin-bottom: 0.8em;
}

.lightbox-caption p:last-child {
    margin-bottom: 0;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(0,0,0,0.9);
}

.lightbox-close {
    top: -50px;
    right: 0;
}

.lightbox-prev {
    position: fixed;
    top: 50vh;
    left: 20px;
    transform: translateY(-50%);
    z-index: 1001;
}

.lightbox-next {
    position: fixed;
    top: 50vh;
    right: 20px;
    transform: translateY(-50%);
    z-index: 1001;
}


/* Responsive Design */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .gallery-header h1 {
        font-size: 2rem;
    }

    /* Lightbox responsive */
    .lightbox-content {
        max-width: 90vw;
        max-height: 80vh;
        margin: 10vh auto 2vh auto;
        padding: 15px;
        gap: 12px;
    }

    .lightbox-image-container {
        flex: 7;
    }

    .lightbox-caption {
        flex: 3;
        font-size: 1rem;
        margin-top: 8px;
        max-height: calc(90vh - 250px);
        min-height: 50px;
        scroll-behavior: smooth;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-caption {
        font-size: 1rem;
        margin-top: 8px;
        max-height: calc(90vh - 250px);
        min-height: 50px;
        scroll-behavior: smooth;
    }

    /* Tablet carousel */
    .gallery-carousel {
        height: calc(100vh - 120px);
    }

    .carousel-slide {
        height: 100%;
    }

    .carousel-slide img {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .carousel-prev,
    .carousel-next {
        padding: 12px 16px;
        font-size: 1.5rem;
    }

    .carousel-caption {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .gallery-container {
        padding: 10px;
    }

    .gallery-header h1 {
        font-size: 1.8rem;
    }

    /* Mobile lightbox */
    .lightbox-content {
        max-width: 95vw;
        max-height: 85vh;
        margin: 7.5vh auto 7.5vh auto;
        padding: 12px;
        gap: 10px;
    }

    .lightbox-image-container {
        flex: 7;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .lightbox-caption {
        flex: 3;
        font-size: 0.9rem;
        line-height: 1.3;
        margin-top: 12px;
        padding: 8px;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-height: calc(85vh - 200px);
        min-height: 45px;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.4) rgba(0, 0, 0, 0.3);
        scroll-behavior: smooth;
    }

    .lightbox-prev {
        left: 5px;
        font-size: 1.5rem;
        padding: 8px 12px;
    }

    .lightbox-next {
        right: 5px;
        font-size: 1.5rem;
        padding: 8px 12px;
    }

    .lightbox-caption {
        font-size: 0.9rem;
        line-height: 1.3;
        margin-top: 12px;
        padding: 8px;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-height: calc(85vh - 200px);
        min-height: 45px;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.4) rgba(0, 0, 0, 0.3);
        scroll-behavior: smooth;
    }

    .lightbox-caption::-webkit-scrollbar {
        width: 8px;
    }

    .lightbox-caption::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 4px;
        margin: 1px;
    }

    .lightbox-caption::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.4);
        border-radius: 4px;
        border: 1px solid rgba(0, 0, 0, 0.1);
    }

    .lightbox-caption::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.6);
    }

    .lightbox-caption::-webkit-scrollbar-thumb:active {
        background: rgba(255, 255, 255, 0.7);
    }

    /* Ensure caption scrolling works on touch devices (mobile) */
    .lightbox-caption {
        -webkit-overflow-scrolling: touch;
    }

    /* Improve readability of long captions (mobile) */
    .lightbox-caption p {
        margin-bottom: 0.7em;
    }

    .lightbox-caption p:last-child {
        margin-bottom: 0;
    }

    /* Mobile carousel */
    .gallery-carousel {
        height: calc(100vh - 110px);
    }

    .carousel-slide {
        height: 100%;
        padding: 15px;
    }

    .carousel-slide img {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .carousel-prev,
    .carousel-next {
        padding: 10px 14px;
        font-size: 1.2rem;
    }

    .carousel-bottom-bar {
        padding: 15px;
        gap: 10px;
    }

    .carousel-caption {
        font-size: 1rem;
        max-width: 95%;
    }

    .carousel-dot {
        width: 12px;
        height: 12px;
    }
}

/* Portrait orientation - center landscape images vertically */
@media (orientation: portrait) {
    .gallery-carousel {
        display: flex;
        align-items: center;
        justify-content: center;
        height: calc(100vh - 200px);
        margin-top: 20px;
        margin-bottom: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .carousel-container {
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .carousel-slide {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        width: 100%;
    }

    .carousel-slide .gallery-item {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }

    .carousel-slide img {
        max-width: 90vw;
        max-height: calc(100vh - 220px);
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .carousel-prev,
    .carousel-next {
        top: calc(50vh - 100px);
    }
}

/* Landscape orientation - optimize space usage */
@media (orientation: landscape) {
    .gallery-carousel {
        display: flex;
        align-items: center;
        justify-content: center;
        height: calc(100vh - 200px);
        margin-top: 20px;
        margin-bottom: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .carousel-container {
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .carousel-slide {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        width: 100%;
    }

    .carousel-slide .gallery-item {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }

    .carousel-slide img {
        max-width: 90vw;
        max-height: calc(100vh - 220px);
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .carousel-prev,
    .carousel-next {
        top: calc(50vh - 100px);
    }
}

/* Loading animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.gallery-item {
    animation: fadeIn 0.5s ease-out;
}