/* ============================================================
 * BUG2 FIX — Grid listing-card gallery first-card leak
 * Authored 2026-06-10 (substrate, Chairman bug report)
 *
 * SYMPTOM: On grid listing pages (city/area pages), the FIRST
 *   listing card occasionally rendered its ENTIRE photo gallery
 *   stacked vertically instead of a single thumbnail with the
 *   slick slider. Root cause = a JS init timing race: custom.js
 *   gridImageGallery() builds a slick carousel per card with
 *   adaptiveHeight:true; for the first (above-the-fold, eagerly
 *   loaded) card the height can be measured before the image is
 *   sized, so the slick track is not constrained and every
 *   .slide-img remains visible until a reflow. All cards have
 *   IDENTICAL server-side HTML (verified), so this is a pure
 *   front-end guard, not a template/loop defect.
 *
 * FIX: Until slick adds .slick-initialized to the carousel,
 *   clip the carousel to exactly its first slide. Once slick
 *   initializes, slick's own CSS governs the slides (this rule
 *   no longer applies because :not(.slick-initialized) fails).
 *   Purely additive, scoped to grid item cards, fully reversible.
 *
 * REVERSIBILITY: delete this file + remove its wp_enqueue_style
 *   block (marker BUG2 GALLERY FIRSTCARD) from child functions.php.
 * ============================================================ */

/* Pre-init / failed-init guard: only the first slide is shown,
 * the carousel cannot exceed the first image's box. */
.item-listing-wrap .houzez-listing-carousel:not(.slick-initialized) {
    overflow: hidden;
    /* establish a flow root so floated/inline-block slides are clipped */
    position: relative;
}

.item-listing-wrap .houzez-listing-carousel:not(.slick-initialized) > .slide-img {
    display: none;
}

.item-listing-wrap .houzez-listing-carousel:not(.slick-initialized) > .slide-img:first-child {
    display: block;
}

/* Also guard the wrapper element used before the carousel is built,
 * in case the data-images expansion runs before slick. */
.item-listing-wrap .listing-gallery-wrap:not(.slick-initialized-parent) .houzez-listing-carousel:not(.slick-initialized) {
    max-height: none; /* slick adaptiveHeight will size it post-init */
}
