/**
 * Airsylvania Masonry Gallery Styles
 * Pure CSS masonry grid - fast, responsive, mobile-friendly
 * No JavaScript dependency for layout
 */

/* =====================================================
   CSS Variables
   ===================================================== */
:root {
    --masonry-gap: 8px;
    --masonry-radius: 8px;
    --masonry-columns: 4;
    --masonry-accent: #c9a227;
    --masonry-overlay: rgba(0, 0, 0, 0.92);
    --masonry-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================
   Masonry Gallery Container
   ===================================================== */
.masonry-gallery {
    width: 100%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

.masonry-container {
    display: flex;
    flex-direction: column;
    gap: var(--masonry-gap);
}

/* =====================================================
   Cover Image (First/Largest)
   ===================================================== */
.masonry-cover {
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: var(--masonry-radius);
    cursor: zoom-in;
}

.masonry-cover img {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.4s ease;
}

.masonry-cover:hover img {
    transform: scale(1.02);
}

/* =====================================================
   Horizontal Grid (like Instagram/Airbnb)
   Fixed aspect ratio - no gaps, clean grid
   ===================================================== */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(var(--masonry-columns), 1fr);
    gap: var(--masonry-gap);
}

.masonry-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--masonry-radius);
    cursor: zoom-in;
    transform: translateZ(0);
    aspect-ratio: 4 / 3;
}

.masonry-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.masonry-item:hover img {
    transform: scale(1.05);
}

/* Loading state */
.masonry-image {
    background: linear-gradient(
        135deg,
        #f5f5f5 0%,
        #ebebeb 50%,
        #f5f5f5 100%
    );
    background-size: 200% 200%;
    min-height: 100px;
}

.masonry-image[src]:not([src=""]) {
    background: none;
}

/* =====================================================
   Image Counter
   ===================================================== */
.masonry-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #f8f8f8;
    border-radius: 25px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    font-size: 0.9rem;
    color: #555;
}

.masonry-icon {
    font-size: 1.1rem;
}

/* =====================================================
   Lightbox (Full-screen viewer)
   ===================================================== */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--masonry-overlay);
    cursor: zoom-out;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox.active .lightbox-image {
    opacity: 1;
    transform: scale(1);
}

/* Lightbox Loader */
.lightbox-loader {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--masonry-accent);
    border-radius: 50%;
    animation: lightbox-spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-lightbox.loading .lightbox-loader {
    opacity: 1;
}

.gallery-lightbox.loading .lightbox-image {
    opacity: 0;
}

@keyframes lightbox-spin {
    to { transform: rotate(360deg); }
}

/* Lightbox Close Button */
.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--masonry-transition);
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.lightbox-close:focus {
    outline: 2px solid var(--masonry-accent);
    outline-offset: 2px;
}

.lightbox-close svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

/* Lightbox Navigation */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--masonry-transition);
    z-index: 10;
}

.lightbox-nav:hover {
    background: var(--masonry-accent);
}

.lightbox-nav:focus {
    outline: 2px solid var(--masonry-accent);
    outline-offset: 2px;
}

.lightbox-nav svg {
    width: 28px;
    height: 28px;
    stroke: white;
}

.lightbox-prev {
    left: 1.5rem;
}

.lightbox-next {
    right: 1.5rem;
}

/* Lightbox Counter */
.lightbox-counter {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 1px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
}

/* =====================================================
   Placeholder (No Images)
   ===================================================== */
.gallery-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: #fafafa;
    border-radius: var(--masonry-radius);
    text-align: center;
}

.gallery-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.gallery-placeholder h3 {
    margin: 0 0 0.5rem;
    color: #2c3e50;
    font-size: 1.25rem;
}

.gallery-placeholder p {
    margin: 0;
    color: #666;
    font-size: 0.95rem;
}

/* =====================================================
   Responsive Breakpoints
   ===================================================== */

/* Large tablets / small desktops */
@media (max-width: 1200px) {
    :root {
        --masonry-columns: 3;
    }
}

/* Tablets */
@media (max-width: 900px) {
    :root {
        --masonry-columns: 3;
        --masonry-gap: 6px;
    }

    .masonry-gallery {
        padding: 0 0.5rem;
        margin: 1.5rem auto;
    }

    .masonry-cover img {
        max-height: 50vh;
    }
}

/* Large phones / small tablets */
@media (max-width: 768px) {
    :root {
        --masonry-columns: 2;
        --masonry-gap: 5px;
        --masonry-radius: 6px;
    }

    .masonry-gallery {
        padding: 0;
        margin: 1rem 0;
    }

    .masonry-cover {
        border-radius: 0;
    }

    .masonry-cover img {
        max-height: 45vh;
    }

    /* Lightbox mobile adjustments */
    .lightbox-close {
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }

    .lightbox-nav {
        width: 44px;
        height: 44px;
    }

    .lightbox-prev {
        left: 0.5rem;
    }

    .lightbox-next {
        right: 0.5rem;
    }

    .lightbox-nav svg {
        width: 22px;
        height: 22px;
    }

    .lightbox-counter {
        bottom: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .masonry-counter {
        margin-top: 0.75rem;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    :root {
        --masonry-columns: 2;
        --masonry-gap: 4px;
        --masonry-radius: 4px;
    }

    .masonry-cover img {
        max-height: 40vh;
    }

    .lightbox-close {
        width: 40px;
        height: 40px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-close svg,
    .lightbox-nav svg {
        width: 20px;
        height: 20px;
    }
}

/* =====================================================
   Performance: Reduced Motion
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    .masonry-cover img,
    .masonry-item img,
    .lightbox-image,
    .lightbox-loader,
    .lightbox-nav,
    .lightbox-close {
        transition: none;
        animation: none;
    }

    .masonry-cover:hover img,
    .masonry-item:hover img {
        transform: none;
    }
}

/* =====================================================
   Print Styles
   ===================================================== */
@media print {
    .gallery-lightbox {
        display: none !important;
    }

    .masonry-gallery {
        page-break-inside: avoid;
    }

    .masonry-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .masonry-item,
    .masonry-cover {
        break-inside: avoid;
    }
}
