/* Gallery Modal Styles - Modular version */
:root { --border-radius: 0.6vw; }

.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4vh 3vw;
}

/* Lock page scroll when modal is open */
html.modal-open,
body.modal-open {
    overflow: hidden !important;
    overscroll-behavior: contain;
    touch-action: none;
    height: 100%;
    width: 100%;
    position: fixed;
}

.gallery-modal.active {
    display: flex;
}

.gallery-modal-content {
    background: #DEE5DB;
    border-radius: var(--border-radius, 0.6vw);
    width: 100%;
    max-width: min(1200px, 95vw);
    max-height: 80vh;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 32px rgba(120, 150, 102, 0.18), 0 2px 8px rgba(0,0,0,0.08);
    border: 1.5px solid #b7cdb0;
    padding: 0;
}

.gallery-modal-main-row { 
    min-height: 0; 
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    padding: 1.25rem;
    gap: 1.5rem;
    align-items: stretch;
    justify-content: center;
    margin-bottom: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.gallery-modal-left { 
    min-height: 0;
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    flex: 1 1 0 !important;
    max-width: none;
    padding: 0 !important;
    box-sizing: border-box;
    gap: 1rem;
    background: transparent !important;
}

.gallery-modal-text { 
    min-height: 0;
    flex: 0 0 32%;
    max-width: 32%;
    position: relative;
    z-index: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1vh;
    padding: 1.2rem 1.25rem 1.5rem;
    background: rgba(255,255,255,0.8);
    border-left: 1px solid #00000012;
    border-radius: var(--border-radius, 0.6vw);
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.35) transparent;
}

.gallery-modal-text::-webkit-scrollbar {
    width: 10px;
}
.gallery-modal-text::-webkit-scrollbar-track {
    background: transparent;
}
.gallery-modal-text::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
}
.gallery-modal-text::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

.gallery-modal-thumbnails {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100%;
    height: 100%;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    background: transparent !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
    align-self: stretch;
    width: 140px;
}
    .gallery-modal-dots,
    .gallery-modal .img-wrapper .gallery-modal-dots {
        display: none;
        justify-content: center;
        gap: 8px;
        position: absolute;
        left: 50%;
        bottom: 12px;
        transform: translateX(-50%);
        z-index: 3;
    }

    .gallery-modal-dot,
    .gallery-modal .img-wrapper .gallery-modal-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.25);
        transition: all 0.2s ease;
    }

    .gallery-modal-dot.active,
    .gallery-modal .img-wrapper .gallery-modal-dot.active {
        background: #91AE7E;
        transform: scale(1.15);
    }
.gallery-modal-thumbnails::-webkit-scrollbar { display: none; }

.gallery-modal-description {
    display: block;
    font-size: 1rem;
    line-height: 1.5;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.35) transparent;
}

@media (min-width: 769px) {
    .gallery-modal-dots,
    .gallery-modal .img-wrapper .gallery-modal-dots {
        display: none !important;
    }
}

.gallery-modal-description::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.gallery-modal-description::-webkit-scrollbar-track {
    background: transparent;
}
.gallery-modal-description::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.35);
    border-radius: 999px;
}
.gallery-modal-description::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

.gallery-modal-description-scrollbar {
    position: absolute;
    top: 1.2rem;
    bottom: 1.5rem;
    right: 0.6rem;
    width: 8px;
    background: transparent;
    border-radius: 50px;
    z-index: 20;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    scrollbar-width: none;
}
.gallery-modal-description-scrollbar::-webkit-scrollbar { width: 0; height: 0; }
.gallery-modal-description-scrollbar .scrollbar-track {
    position: absolute;
    inset: 0;
    background: transparent;
    border-radius: 6px;
}
.gallery-modal-description-scrollbar .scrollbar-thumb {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(0,0,0,0.35);
    border-radius: 999px;
    min-height: 24px;
    touch-action: none;
    will-change: transform, height;
    transition: background 0.15s;
}
.gallery-modal-description-scrollbar .scrollbar-thumb:hover,
.gallery-modal-description-scrollbar .scrollbar-thumb:active {
    background: rgba(0,0,0,0.5);
}

.gallery-modal-image,
.gallery-modal .img-wrapper {
    order: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 0;
    height: 100%;
    min-height: 0;
    overflow: visible !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    align-self: center;
    position: relative;
}

.gallery-modal-image video,
.gallery-modal-video {
    display: block !important;
    width: auto !important;
    height: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    margin: auto !important;
}

.gallery-modal-header-box {
    width: 100%;
    padding: 24px 0 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: none;
    border-bottom: 1px solid #0000001a;
    background-color: #8caa76;
}

.gallery-modal-title {
    font-size: 1.5rem;
    font-weight: 850;
    color: #4a5568;
    text-align: center;
    margin-bottom: 1vh;
    margin-top: -1rem;
    letter-spacing: 0.01em;
}

.gallery-modal-img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

/* Ensure all main media fills available height while preserving aspect ratio */
.gallery-modal-image img,
.gallery-modal-image video {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gallery-modal-thumbnail {
    width: 110px;
    height: 80px;
    border-radius: 12px !important;
    cursor: pointer;
    object-fit: cover;
    transition: opacity 0.2s, border-color 0.2s;
    display: block;
    box-sizing: border-box;
    border: 2px solid transparent;
}
.gallery-modal-thumbnail img,
.gallery-modal-thumbnail video {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    display: block;
}
.gallery-modal-thumbnail:hover { opacity: 0.8; }
.gallery-modal-thumbnail.selected { border: 2px solid #91AE7E; }
.gallery-modal-thumbnails .gallery-modal-thumbnail { transition: filter 0.2s ease, opacity 0.2s ease; }
.gallery-modal-thumbnails .gallery-modal-thumbnail:not(.selected) { filter: brightness(0.55) saturate(0.95) !important; }
.gallery-modal-thumbnails .gallery-modal-thumbnail.selected { filter: none !important; }

.gallery-modal-thumbnail.is-video {
    position: relative;
    border-radius: 12px !important;
    overflow: hidden;
    box-sizing: border-box;
    width: 110px;
    height: 80px;
}
.gallery-modal-thumbnail.is-video video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: inherit;
    box-sizing: border-box;
    object-position: center;
    transform: translateZ(0);
}
.gallery-modal-thumbnail.is-video .thumb-play-icon {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}
.gallery-modal-thumbnail.is-video .thumb-play-icon {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.gallery-modal-thumbnail.is-video .thumb-play-icon::before {
    content: '';
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
    display: inline-block;
}
.gallery-modal-thumbnail.is-video .thumb-play-icon::after {
    content: '';
    position: absolute;
    width: 0; height: 0;
    border-left: 10px solid rgba(255, 255, 255, 0.95);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    transform: translate(2px, 0);
}

.gallery-modal-date {
    padding: 1.5rem 1.25rem;
    color: #4a5568;
    border-top: 1px solid rgba(0,0,0,0.1);
    background: rgba(140, 170, 118, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    gap: 1rem;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.modal-date-text {
    padding: 0.6rem 1rem;
    background: #f3f5f1;
    border-radius: var(--border-radius, 0.6vw);
    color: #4a5568;
    font-size: 0.95rem;
}

.gallery-modal-main-close {
    background: #aebbaa;
    border: none;
    border-radius: var(--border-radius, 0.6vw);
    color: #4a5568;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1;
    flex: 0 0 auto;
    min-width: max-content;
}
.gallery-modal-main-close:hover {
    background: #8caa76;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

@media (min-width: 1750px) {
    .gallery-modal-image {
        max-width: 100% !important;
        margin: 0 auto !important;
    }
    
    .gallery-modal-left {
        justify-content: center !important;
    }
}

@media (max-width: 900px) {
    :root { --border-radius: 1vw; }
}

@media (max-width: 768px) {
    .gallery-modal-main-row {
        flex-direction: column;
        padding: 0.5rem;
    }
    .gallery-modal-left {
        width: 100% !important;
        flex-direction: column !important;
        gap: 0.75rem;
        justify-content: center !important;
    }
    .gallery-modal-image,
    .gallery-modal .img-wrapper {
        max-width: 100% !important;
        max-height: 400px !important;
        height: min(70vh, 420px);
        position: relative;
        overflow: visible;
        box-sizing: border-box;
        padding-bottom: 32px;
        margin: 0 auto;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 240px;
    }
    .gallery-modal-thumbnails {
        display: none !important;
    }
    .gallery-modal-dots,
    .gallery-modal .img-wrapper .gallery-modal-dots {
        display: inline-flex;
        position: relative;
        inset: auto;
        bottom: 0;
        margin-top: 8px;
        transform: none;
    }
    .gallery-modal-image img,
    .gallery-modal-img {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        object-fit: contain !important;
    }
    .gallery-modal-date {
        padding: 1rem;
    }
}
