/* ===================================
   CONDO GALLERY STYLES
   Following theme-gallery-description.md specifications
   Only gallery-specific code - other content moved to appropriate files
   =================================== */

/* Condo Gallery Section */
.sp-condo-gallery-section {
    padding-top: 40px;
    padding-bottom: 20px;
    background-color: #fff !important;
    margin: 0 auto;
    max-width: 1280px;
}

/* Main Grid Configuration - According to documentation */
.sp-condo-gallery-grid {
    display: grid;
    grid-template-columns: calc(70% - 20px) 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 6px;
    width: 100%;
    height: 600px;
}

/* Grid Positioning - Specific item placement */
.sp-condo-gallery-item {
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgb(0 0 0 / 10%);
    cursor: pointer;
    background: #fff;
}

/* 1st Item - Dominant image (spans all 3 rows, takes 70% width) */
.sp-condo-gallery-item:nth-child(1) {
    grid-row: 1 / 4;
    grid-column: 1;
}

/* 2nd-3rd Items - Row 1, columns 2-3 */
.sp-condo-gallery-item:nth-child(2) {
    grid-row: 1;
    grid-column: 2;
}

.sp-condo-gallery-item:nth-child(3) {
    grid-row: 1;
    grid-column: 3;
}

/* 4th-5th Items - Row 2, columns 2-3 */
.sp-condo-gallery-item:nth-child(4) {
    grid-row: 2;
    grid-column: 2;
}

.sp-condo-gallery-item:nth-child(5) {
    grid-row: 2;
    grid-column: 3;
}

/* 6th-7th Items - Row 3, columns 2-3 */
.sp-condo-gallery-item:nth-child(6) {
    grid-row: 3;
    grid-column: 2;
}

.sp-condo-gallery-item:nth-child(7) {
    grid-row: 3;
    grid-column: 3;
}

/* 8+ Items - Hidden as per documentation */
.sp-condo-gallery-item:nth-child(n+8) {
    display: none;
}

/* Image Styling */
.sp-condo-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Mouseover Effects - Matching taxonomy-location.php */
.sp-condo-gallery-item:hover {
    filter: brightness(1.1);
}

/* Video Elements */
.sp-condo-gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sp-condo-gallery-item .sp-video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgb(255 255 255 / 90%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #333;
    z-index: 3;
    cursor: pointer;
}

.sp-condo-gallery-item:hover .sp-video-play-button {
    background: rgb(255 255 255 / 100%);
}

/* Gallery Counter */
.sp-gallery-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgb(0 0 0 / 80%);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 4;
    pointer-events: none;
}

/* No Image Placeholder */
.property-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5 !important;
    border: 2px dashed #ddd;
    cursor: default;
}

.no-image-placeholder {
    text-align: center;
    color: #999;
}

.no-image-icon {
    display: block;
    font-size: 3rem;
    margin-bottom: 10px;
}

.no-image-text {
    font-size: 1rem;
}

/* Alternative Gallery Grid Layout */
.sp-property-gallery-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Alternative Gallery Grid - Auto-fit layout */
.sp-condo-gallery-grid.alt-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.sp-condo-gallery-grid.alt-layout .sp-condo-gallery-item {
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sp-condo-gallery-grid.alt-layout .sp-condo-gallery-item img {
    height: 250px;
    transition: filter 0.3s ease;
}

/* Force Light Mode - Override any dark theme preferences */
.sp-condo-gallery-section,
.sp-condo-gallery-item {
    background: #fff !important;
    color: #333 !important;
}

/* ===================================
   RESPONSIVE BEHAVIOR - Per Documentation
   =================================== */

/* Tablet (768px - 1024px) */
@media (width <= 1024px) and (width >= 768px) {
    .sp-condo-gallery-grid {
        grid-template-columns: 50% 1fr 1fr;
        height: 300px;
        gap: 4px;
    }

    .sp-condo-gallery-item:nth-child(2) {
        grid-column: 2 / 4; /* Spans both right columns */
        grid-row: 1;
    }

    .sp-condo-gallery-item:nth-child(n+3) {
        display: none; /* Hide items 3+ */
    }
}

/* Mobile (< 768px) - Single Image Carousel */
@media (width <= 768px) {
    .sp-condo-gallery-section {
        padding-top: 20px;
        padding-bottom: 0;
        margin-bottom:20px;
    }

    .sp-condo-gallery-grid {
        position: relative;
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: hidden;
        gap: 0;
    }

    .sp-condo-gallery-item {
        flex-shrink: 0;
        width: 100%;
        height: auto;
        grid-column: 1 !important;
        grid-row: auto !important;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
        pointer-events: none;
    }

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

    /* Show only the active slide */
    .sp-condo-gallery-item.active {
        opacity: 1;
        pointer-events: auto;
        z-index: 2;
    }

    /* Position all non-active items absolutely to not affect container height */
    .sp-condo-gallery-item:not(.active) {
        position: absolute;
        top: 0;
        left: 0;
    }

    /* Show all items initially (will be hidden by JS) */
    .sp-condo-gallery-item:nth-child(n+1) {
        display: block;
    }

    /* Mobile Gallery Counter - Always visible */
    .sp-gallery-counter {
        display: block;
        position: absolute;
        bottom: 12px;
        right: 12px;
        background: rgb(0 0 0 / 85%);
        color: white;
        padding: 8px 14px;
        border-radius: 6px;
        font-size: 0.9rem;
        font-weight: 600;
        z-index: 10;
        pointer-events: none;
    }

    /* Mobile Navigation Arrows */
    .sp-mobile-gallery-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: rgb(255 255 255 / 90%);
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        font-size: 20px;
        color: #333;
        cursor: pointer;
        z-index: 5;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgb(0 0 0 / 20%);
        transition: background 0.2s ease;
        margin-top: 0;
    }

    .sp-mobile-gallery-nav:hover {
        background: rgb(255 255 255 / 100%);
    }

    .sp-mobile-gallery-nav.prev {
        left: 10px;
    }

    .sp-mobile-gallery-nav.next {
        right: 10px;
    }

    /* Hide desktop counter on mobile */
    .sp-condo-gallery-item:nth-child(7) .sp-gallery-counter {
        display: none;
    }
}

@media (width <= 480px) {
    .sp-condo-gallery-grid {
        padding: 0;
    }
}

/* Accessibility improvements */
.sp-condo-gallery-item:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}
