/* ============================================================
   pinterest-grid-test.css
   Styles ONLY for the Design "Pinterest test" page
   (Design/Index-Pinterest-Test.cshtml + _Partial_Design_Data_Pinterest.cshtml).
   Deliberately isolated from dev-trial-style.css / component.css so this
   experiment cannot affect the live /design page.
   ============================================================ */
/* Small breathing room on mobile so the grid doesn't touch the screen's
   left/right edges. #grid-wrapper is this page's own element (not a
   shared class), and PinterestGrid measures whatever width it actually
   ends up with via ResizeObserver on #design-grid-gallery (a child that
   fills its parent), so narrowing the wrapper here is picked up
   automatically -- no JS changes needed, and the live /design page (which
   doesn't use this stylesheet) is unaffected. */
@media (max-width: 767.98px) {
    #grid-wrapper {
        padding-left: 10px;
        padding-right: 10px;
        box-sizing: border-box;
    }
}

/* dev-trial-style.min.css (shared sitewide) already has an UNRELATED rule
   `.ptxLoadMoreButton[data-hide-loader] { visibility: hidden; pointer-events: none; }`
   -- a naming collision with the data-hide-loader attribute we set purely
   to satisfy pagination.js's own unrelated check (see
   loadMoreBtn.setAttribute('data-hide-loader', ...) in
   Index-Pinterest-Test.cshtml) to skip its full-page loader. Setting that
   attribute silently hid AND disabled clicks on the button via that other
   rule. This ID selector's specificity (0,1,1,0) always beats the shared
   rule's class+attribute specificity (0,0,2,0) regardless of stylesheet
   order, so it reliably wins without needing !important -- scoped to this
   page only since pinterest-grid-test.css only loads here. */
#loadMoreButton[data-hide-loader] {
    visibility: visible;
    pointer-events: auto;
}

/* Load More button's own inline loading state -- see the comment next to
   loadMoreBtn.setAttribute('data-hide-loader', ...) in
   Index-Pinterest-Test.cshtml. #loadMoreButton is shared markup (the same
   id/partial renders it on the live /design page too), but this rule only
   takes effect while this stylesheet is loaded, i.e. only on this test
   page, so the live page is unaffected. */
#loadMoreButton.pg-loading {
    pointer-events: none;
    opacity: 0.7;
}

#loadMoreButton .pg-spinner {
    display: none;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    vertical-align: -2px;
    border: 2px solid rgba(0,0,0,0.15);
    border-top-color: #1a4599;
    border-radius: 50%;
    animation: pg-spin 0.8s linear infinite;
}

#loadMoreButton.pg-loading .pg-spinner {
    display: inline-block;
}

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

#design-grid-gallery.pg-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

    #design-grid-gallery.pg-grid li.pg-item {
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0;
        will-change: transform;
        list-style: none;
    }

        #design-grid-gallery.pg-grid li.pg-item.pg-placed {
            opacity: 1;
        }

        /* Every .pg-item card is an absolutely-positioned sibling with no
           z-index of its own, so by default they stack purely by DOM
           order -- whichever card happens to come later always paints on
           top of an earlier one, regardless of which one's popover is
           actually open. .pg-pin-popover's own z-index:5 only wins WITHIN
           its own card (li.pg-item establishes a stacking context via
           will-change:transform); it can't out-rank a completely separate
           sibling <li>. That's why an open popover -- which can extend
           outside its own card's box -- was rendering underneath a later
           neighboring card's image instead of on top of it. Raising the
           z-index of the card that currently owns an open popover (not
           just the popover itself) fixes the real problem: draw order
           between sibling cards, not transparency/opacity. */
        #design-grid-gallery.pg-grid li.pg-item:has(.pg-pin-popover-open) {
            z-index: 20;
        }

/* Card = image (in .pg-pin-media) + a thin dots-row below it (.pg-pin-meta).
   No overflow:hidden here (unlike .pg-pin-media) so the popover, which is
   position:absolute and can extend below the card, is never clipped. */
.pg-pin-card {
    position: relative;
}

/* Image area only -- rounded corners + clipping live here, not on the
   whole card, since the card no longer visually "ends" at the image. */
.pg-pin-media {
    position: relative;
    cursor: pointer;
    border-radius: 16px;
    overflow: hidden;
    background: #efefef; /* shows while image is still fetching pixels */
    /* A pure-white (or near-white) tile photo has no visible edge against
       the page's own white background once it's loaded and filling this
       box -- #efefef above only shows before the image loads. A plain
       border (not a subtle inset shadow, which read as invisible) gives
       every card a clear boundary regardless of how light the tile itself
       is. box-sizing:border-box keeps the border from adding to the
       column width the masonry engine already computed. */
    box-sizing: border-box;
    border: 1px solid #d9d9d9;
}

    .pg-pin-media img {
        width: 100%;
        display: block;
    }

/* ---------- Wishlist heart, top-right of the image ---------- */
.pg-pin-heart-btn {
    position: absolute;
    top: 5px;
    right: 10px;
    z-index: 2; /* above .pg-pin-view-link's inset:0 overlay (z-index:1) so it stays clickable */
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 1px 6px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #444;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

    .pg-pin-heart-btn:hover {
        background: #fff;
        color: #e0245e;
        transform: scale(1.08);
    }

    /* Filled/active state -- toggled via TFWishlist (wwwroot/view-js/wishlist.js),
       see the wishlist wiring in Index-Pinterest-Test.cshtml. */
    .pg-pin-heart-btn.is-active {
        color: #e0245e;
    }

        .pg-pin-heart-btn.is-active svg {
            fill: currentColor;
        }

.pg-pin-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    pointer-events: none;
}

.pg-pin-media:hover .pg-pin-overlay {
    opacity: 1;
    background: rgba(0,0,0,0.08);
}

.pg-pin-view-link {
    position: absolute;
    inset: 0;
    display: block;
    z-index: 1;
}

/* ---------- Thin dots-row below the image ----------
   This is the only part of the card (besides the image) that adds real
   height -- PinterestGrid measures it via metaSelector (default
   '.pg-pin-meta') and packs columns accordingly. Keep it visually small
   and constant-height; if it ever grows/shrinks per-card the engine still
   handles that correctly (it re-measures per item), but there's no reason
   for it to vary here. */
.pg-pin-meta {
    position: relative;
    display: flex;
    justify-content: flex-end;
    padding: 6px 4px;
}

.pg-pin-dots-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

    .pg-pin-dots-btn:hover,
    .pg-pin-dots-btn[aria-expanded="true"] {
        background: #efefef;
        color: #111;
    }

/* ---------- Popover ----------
   Anchored to .pg-pin-meta (position:relative), opens below-right of the
   dots button. Hidden by default via opacity/visibility (not display:none)
   so it can transition smoothly; JS toggles .pg-pin-popover-open on
   .pg-pin-card (see Index-Pinterest-Test.cshtml wiring script).

   --pg-popover-shift-x is set by that same JS, right after opening, to
   nudge the popover back on-screen when its fixed 220px width would
   otherwise overflow the viewport edge -- e.g. the left column on a
   narrow (2-column mobile) layout, where right:0 anchoring pushes most of
   the popover's 220px off the left edge of the screen entirely, cutting
   off its content. A CSS var (not a plain inline transform) so the JS-set
   horizontal shift composes with this rule's own vertical open/close
   slide instead of one overwriting the other. */
.pg-pin-popover {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 220px;
    max-width: calc(100vw - 20px); /* never wider than the viewport itself, minus a small margin */
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.18);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translate(var(--pg-popover-shift-x, 0px), -4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 5;
}

.pg-pin-card.pg-pin-popover-open .pg-pin-popover {
    opacity: 1;
    visibility: visible;
    transform: translate(var(--pg-popover-shift-x, 0px), 0);
}

.pg-pin-popover-header {
    padding: 8px 10px 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 4px;
}

.pg-pin-popover-name {
    font-size: 14px;
    font-weight: 700;
    color: #111;
    margin: 0 0 2px;
    line-height: 1.3;
}

.pg-pin-popover-size {
    font-size: 12px;
    font-weight: 400;
    color: #6e6e6e;
    margin: 0;
    line-height: 1.3;
}

.pg-pin-popover-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #111;
    text-decoration: none;
    transition: background 0.12s ease;
}

    .pg-pin-popover-row svg {
        flex-shrink: 0;
        color: #555;
    }

    .pg-pin-popover-row:hover {
        background: #f2f2f2;
        color: #111;
    }

/* "No Designs Found" state (see _Partial_DesignDataCityWiseForStaticDesign.cshtml).
   This <li> is deliberately NOT .pg-item, so pinterest-grid.js's layout()
   never touches it -- but that also means _updateContainerHeight() collapses
   #design-grid-gallery's height to 0px (it only measures .pg-item columns),
   while this li, a plain normal-flow child, keeps rendering past that
   collapsed box. The message ends up visually pinned to the very top,
   overflowing outside the ul's box, with the rest of #grid-wrapper's
   min-height:600px (see Index.cshtml/SizeIndex.cshtml/BathroomIndex.cshtml)
   left behind it as dead empty space instead of surrounding it.
   Overriding the JS-set inline height back to auto lets this li's own
   height (below) become the ul's real, un-collapsed content height, so the
   flexbox centers the message within it instead of leaving it stranded at
   the top of a phantom-height container. */
#design-grid-gallery.pg-grid:has(.pg-no-results) {
    height: auto !important;
}

.pg-no-results {
    position: static;
    width: 100%;
    box-sizing: border-box;
    min-height: 560px; /* fills ~#grid-wrapper's own min-height:600px reservation */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

    .pg-no-results .no-records-content {
        max-width: 420px;
        margin: 0 auto;
    }

@media (max-width: 767.98px) {
    .pg-no-results {
        min-height: 320px;
    }
}
