/* ============================================
   Gallery Section Styles (Figma-inspired)
   ============================================ */

.gallery-section {
    padding: 0 120px;
    width: 100%;
}

.gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.gallery-title {
    color: #005b68;
    font-family: 'IvyOra Display', serif;
    font-size: 32px;
    font-style: italic;
    font-weight: 500;
    margin-bottom: 40px;
    line-height: normal;
    letter-spacing: 0;
}

.gallery-grid {
    column-count: 3;
    column-gap: 32px;
}

/* When JS is enabled we switch to absolute positioning layout so DOM can
   remain row-major while JS performs masonry placement. The class is added
   by the inline script in the template. */
.gallery-grid.js-enabled {
    column-count: initial;
}

.gallery-grid.js-enabled {
    position: relative;
}

.gallery-grid.js-enabled .gallery-item {
    position: absolute;
    display: block;
    margin: 0 !important;
}

/* When JS handles layout, remove the static margin-top used for visual offsets
   so JS can apply equivalent offsets precisely. */
.gallery-grid.js-enabled .special-top-1 .gallery-image-wrapper,
.gallery-grid.js-enabled .special-top-3 .gallery-image-wrapper {
    margin-top: 0 !important;
}

.gallery-item {
    display: inline-block;
    width: 100%;
    margin: 0 0 32px;
    break-inside: avoid;
}

.gallery-image-wrapper {
    width: 100%;
    display: block;
    background: #f6f3ef;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(64, 57, 54, 0.04);
    position: relative;
    cursor: pointer;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-image-wrapper:hover .gallery-image {
    transform: scale(1.05);
}

/* Hover overlay with gradient */
.gallery-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%);
    padding: 24px 20px 20px 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Top-positioned overlay for cards with bottom rounded borders */
.gallery-item.special-last-1 .gallery-image-overlay,
.gallery-item.special-last-3 .gallery-image-overlay,
.gallery-item.special-last-center .gallery-image-overlay,
.gallery-item.mobile-special-last-1 .gallery-image-overlay {
    top: 0;
    bottom: auto;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%);
    padding: 20px 20px 24px 20px;
}

.gallery-image-wrapper:hover .gallery-image-overlay {
    opacity: 1;
}

.gallery-image-description {
    color: #ffffff;
    font-family: 'IBM Plex Sans', sans-serif;
    font-style: italic;
    font-size: 16px;
    font-style: italic;
    font-weight: 400;
    line-height: normal;
    margin: 0;
}

/* special item styles */
/* Special cards: responsive sizing using aspect-ratio so they scale with column width */
.special-center .gallery-image-wrapper {
    /* Desktop target: limit max width, but allow wrapper to size to column width */
    width: 100%;
    max-width: 381.512px;
    aspect-ratio: 381.512 / 523.642;
    /* preserves Figma proportions */
    border-radius: 200px 200px 23.415px 23.415px;

    overflow: hidden;
}

.special-last-1 .gallery-image-wrapper {
    width: 100%;
    max-width: 381.702px;
    aspect-ratio: 381.702 / 389.414;
    border-radius: 23.415px 23.415px 200px 200px;

    overflow: hidden;
}

.special-last-3 .gallery-image-wrapper {
    width: 100%;
    max-width: 381.512px;
    aspect-ratio: 381.512 / 502.849;
    border-radius: 23.415px 23.415px 200px 200px;
    overflow: hidden;
}

/* Bottom-center special for final single item in middle column */
.special-last-center .gallery-image-wrapper {
    width: 100%;
    max-width: 381.512px;
    aspect-ratio: 381.512 / 502.849;
    border-radius: 23.415px 23.415px 200px 200px;
    overflow: hidden;
}

.special-top-1 .gallery-image-wrapper,
.special-top-3 .gallery-image-wrapper {
    margin-top: 89px;
}

/* Images now fill wrappers using object-fit; wrapper background-image approach removed for special items */

.gallery-grid[data-masonry='false'] {
    /* fallback if needed */
}

@media (max-width: 1200px) {
    .gallery-section {
        margin: 0 auto;
        padding: 0 60px;
    }

    .gallery-grid {
        /* column-count: 2; */
        column-gap: 16px;
    }

    /* Reset special-card proportions on smaller screens to uniform small cards */
    .special-center .gallery-image-wrapper,
    .special-last-1 .gallery-image-wrapper,
    .special-last-3 .gallery-image-wrapper {
        max-width: 100%;
        /* aspect-ratio: 155 / 112; */
        border-radius: 8px;
    }

    .gallery-image-wrapper {
        /* max-width: 155px; */
        /* aspect-ratio: 155/112; */
        /* border-radius: 8px; */
    }

    .gallery-image {
        /* border-radius: 8px; */
    }

    .gallery-title {
        font-size: 24px;
        margin-bottom: 20px;
    }
}

@media (max-width: 1023px) {
    .gallery-title {
        font-size: 24px;
        margin-bottom: 0;
    }

    .gallery-grid {
        /* column-count: 2; */
        /* column-gap: 12px; */
    }

    .gallery-image-wrapper {
        /* max-width: 155px; */
        /* aspect-ratio: 155/112; */
        /* border-radius: 8px; */
    }

    .gallery-image {
        /* border-radius: 8px; */
    }
}

@media (max-width: 600px) {
    .gallery-section {
        margin: 0 auto;
        padding: 0 24px;
    }

    .special-top-1 .gallery-image-wrapper,
    .special-top-3 .gallery-image-wrapper {
        margin-top: 47px;
    }

    .gallery-container {
    }

    .gallery-title {
        font-size: 18px;
    }

    .gallery-image-overlay {
        padding: 16px 12px 12px 12px;
    }

    .gallery-item.mobile-special-last-1 .gallery-image-overlay {
        padding: 12px 12px 16px 12px;
    }

    .gallery-image-description {
        font-size: 12px;
    }

    .gallery-grid {
        column-count: 2;
        column-gap: 6px;
    }

    .gallery-image-wrapper {
        max-width: 100%;
        aspect-ratio: 155/112;
        border-radius: 8px;
    }

    .gallery-image {
        border-radius: 8px;
    }

    /* Mobile-specific special-item styling */
    .mobile-special-center .gallery-image-wrapper {
        width: 100%;
        height: 212.744px;
        border-radius: 200px 200px 8px 8px;
        overflow: hidden;
    }

    .mobile-special-last-1 .gallery-image-wrapper {
        width: 155px;
        height: 204.297px;
        /* exact pixel target from Figma */
        border-radius: 8px 8px 200px 200px;
        overflow: hidden;
    }

    .mobile-special-center .gallery-image,
    .mobile-special-last-1 .gallery-image {
        object-fit: cover;
        object-position: 50% 50%;
        width: 100%;
        height: 100%;
        display: block;
    }
}

/* Debug helpers for gallery (use by adding class 'debug' to .gallery-grid in browser)
   Example in console: document.querySelector('.gallery-grid').classList.add('debug') */
.gallery-grid.debug .gallery-item {
    position: relative;
}

.gallery-grid.debug .gallery-item::after {
    content: attr(data-idx) ' ' attr(data-vis);
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 20;
}

.gallery-grid.debug .gallery-item[data-idx='61'] {
    outline: 3px solid rgba(255, 0, 0, 0.9);
}
