/* ─────────────────────────────────────────────
   CRM Gallery — gallery.css
   Lives in /wp-content/plugins/crm-sync/
   Enqueued only when [listing_gallery] is used.
   ───────────────────────────────────────────── */

/* ── WRAPPER ── */
.crm-gallery {
    position: relative !important;
    width: 100% !important;
    font-family: 'Figtree', sans-serif !important;
    overflow: hidden !important;
    border-radius: 12px !important;
    height: var(--glry-h, 60vh) !important;
    box-sizing: border-box !important;
}

.crm-gallery * {
    box-sizing: border-box !important;
}

/* ── IMAGE CELLS ── */
.crm-gallery-img {
    overflow: hidden !important;
    cursor: pointer !important;
    position: relative !important;
    background: #dde3ec !important;
}

.crm-gallery-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.4s ease !important;
}

.crm-gallery-img:hover img {
    transform: scale(1.04) !important;
}

/* ── +N OVERLAY ── */
.crm-gallery-more {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.45) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    font-size: 22px !important;
    font-weight: 800 !important;
    font-family: 'Figtree', sans-serif !important;
    pointer-events: none !important;
    border-radius: inherit !important;
}

/* ── FOR SALE BADGE ── */
.crm-for-sale {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    z-index: 10 !important;
    background: #fff !important;
    color: #11325C !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: 1px !important;
    padding: 5px 12px !important;
    border-radius: 4px !important;
    text-transform: uppercase !important;
}

/* ── PLAY BUTTON ── */
.crm-play-btn {
    position: absolute !important;
    bottom: 20px !important;
    left: 20px !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(6px) !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 10px 18px 10px 14px !important;
    font-family: 'Figtree', sans-serif !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #1a1a2e !important;
    cursor: pointer !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18) !important;
    transition: background 0.2s, transform 0.15s !important;
    text-decoration: none !important;
}

.crm-play-btn:hover {
    background: #fff !important;
    transform: scale(1.04) !important;
}

.crm-play-icon {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: #11325C !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.crm-play-icon svg {
    margin-left: 2px !important;
}


/* ════════════════════════════════════════════
   LAYOUT: 1 IMAGE
   ════════════════════════════════════════════ */

.crm-gallery-1 {
    height: 100% !important;
}

.crm-gallery-1 .crm-gallery-img {
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px !important;
}


/* ════════════════════════════════════════════
   LAYOUT: 2 IMAGES — 50/50
   ════════════════════════════════════════════ */

.crm-gallery-2 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr !important;
    gap: 6px !important;
    height: 100% !important;
}

.crm-gallery-2 .crm-gallery-img {
    height: 100% !important;
    border-radius: 8px !important;
}


/* ════════════════════════════════════════════
   LAYOUT: 3 IMAGES — equal thirds
   ════════════════════════════════════════════ */

.crm-gallery-3 {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    grid-template-rows: 1fr !important;
    gap: 6px !important;
    height: 100% !important;
}

.crm-gallery-3 .crm-gallery-img {
    height: 100% !important;
    border-radius: 8px !important;
}


/* ════════════════════════════════════════════
   LAYOUT: 4 IMAGES — 2×2 default, 1×4 on wide
   ════════════════════════════════════════════ */

.crm-gallery-4 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
    gap: 6px !important;
    height: 100% !important;
}

.crm-gallery-4 .crm-gallery-img {
    height: 100% !important;
    border-radius: 8px !important;
}

/* Wide: collapse to single row of 4 */
@media (min-width: 1400px) {
    .crm-gallery-4 {
        grid-template-columns: 1fr 1fr 1fr 1fr !important;
        grid-template-rows: 1fr !important;
    }
}


/* ════════════════════════════════════════════
   LAYOUT: 5+ IMAGES — hero + 2×2 thumbs
   ════════════════════════════════════════════ */

.crm-gallery-5plus {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
    grid-template-rows: 1fr !important;
    gap: 6px !important;
    height: 100% !important;
}

/* Hero */
.crm-gallery-5plus .crm-img-hero {
    grid-row: 1 / 2 !important;
    height: 100% !important;
    border-radius: 12px 0 0 12px !important;
}

/* 2×2 thumb grid */
.crm-gallery-5plus .crm-thumbs {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
    gap: 6px !important;
    height: 100% !important;
}

/* Thumb cells — 1:1 aspect ratio */
.crm-gallery-5plus .crm-thumbs .crm-gallery-img {
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    width: 100% !important;
}

/* Corner radii */
.crm-gallery-5plus .crm-thumbs .crm-gallery-img:nth-child(1) { border-radius: 0 12px 0 0 !important; }
.crm-gallery-5plus .crm-thumbs .crm-gallery-img:nth-child(2) { border-radius: 0 !important; }
.crm-gallery-5plus .crm-thumbs .crm-gallery-img:nth-child(3) { border-radius: 0 !important; }
.crm-gallery-5plus .crm-thumbs .crm-gallery-img:nth-child(4) { border-radius: 0 0 12px 0 !important; }


/* ════════════════════════════════════════════
   RESPONSIVE — Tablet (769–1024px)
   ════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .crm-gallery {
        height: var(--glry-h-tablet, 45vh) !important;
    }

    /* 4-image back to 2×2 on tablet */
    .crm-gallery-4 {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1fr 1fr !important;
    }
}


/* ════════════════════════════════════════════
   RESPONSIVE — Mobile portrait (≤768px)
   ════════════════════════════════════════════ */

@media (max-width: 768px) {
    .crm-gallery {
        height: auto !important;
        border-radius: 8px !important;
    }

    /* 2 images: stack vertically */
    .crm-gallery-2 {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
        height: auto !important;
    }
    .crm-gallery-2 .crm-gallery-img {
        aspect-ratio: 16 / 9 !important;
        height: auto !important;
    }

    /* 3 images: 2 col top, 1 full bottom */
    .crm-gallery-3 {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        height: auto !important;
    }
    .crm-gallery-3 .crm-gallery-img {
        aspect-ratio: 4 / 3 !important;
        height: auto !important;
    }
    .crm-gallery-3 .crm-gallery-img:last-child {
        grid-column: 1 / -1 !important;
        aspect-ratio: 16 / 9 !important;
    }

    /* 4 images: 2×2 stays, but shorter */
    .crm-gallery-4 {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        height: auto !important;
    }
    .crm-gallery-4 .crm-gallery-img {
        aspect-ratio: 4 / 3 !important;
        height: auto !important;
    }

    /* 5+: hero stacks above 2×2 thumbs */
    .crm-gallery-5plus {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
        height: auto !important;
    }
    .crm-gallery-5plus .crm-img-hero {
        grid-row: auto !important;
        height: var(--glry-h-mobile, 33vh) !important;
        border-radius: 8px 8px 0 0 !important;
        aspect-ratio: unset !important;
    }
    .crm-gallery-5plus .crm-thumbs {
        height: auto !important;
        grid-template-rows: auto auto !important;
    }
    .crm-gallery-5plus .crm-thumbs .crm-gallery-img {
        aspect-ratio: 1 / 1 !important;
        height: auto !important;
    }
    .crm-gallery-5plus .crm-thumbs .crm-gallery-img:nth-child(1) { border-radius: 0 !important; }
    .crm-gallery-5plus .crm-thumbs .crm-gallery-img:nth-child(4) { border-radius: 0 0 8px 8px !important; }

    /* Play + badge */
    .crm-play-btn {
        bottom: 14px !important;
        left: 14px !important;
        padding: 8px 14px 8px 10px !important;
        font-size: 13px !important;
    }
    .crm-play-icon {
        width: 24px !important;
        height: 24px !important;
    }
    .crm-for-sale {
        font-size: 10px !important;
        padding: 4px 9px !important;
    }
}


/* ════════════════════════════════════════════
   RESPONSIVE — Mobile landscape / very small
   ════════════════════════════════════════════ */

@media (max-width: 480px) and (orientation: portrait) {
    .crm-gallery-3 {
        grid-template-columns: 1fr !important;
    }
    .crm-gallery-3 .crm-gallery-img {
        aspect-ratio: 16 / 9 !important;
        grid-column: auto !important;
    }
    .crm-gallery-4 {
        grid-template-columns: 1fr !important;
        grid-template-rows: repeat(4, auto) !important;
    }
}
