/* =========================================================================
   Realtyna Patches — Map-Pin Preview Card   (PATCH-05)
   Author: Bitghost.com  ·  Support: ghost@bitghost.com
   -------------------------------------------------------------------------
   The grid-style fallback card the Map-Pin Preview Bridge renders inside WPL's
   lightbox when the true listing preview is unavailable (e.g. an empty
   internal_preview response for an MLS-On-The-Fly virtual pid). Layout mirrors
   the reference card — media · title · address · 5-stat icon row · price · CTA —
   rendered in the Bitghost house style: dark monochrome (#000 / #fff), the
   signature 22px frame, shimmer, and the 🧊 cube brand mark.

   Everything is scoped under .rp-preview-card / .rp-standalone-overlay so it can
   NEVER leak into the host theme, and it is fully responsive across desktop,
   laptop, tablet and mobile. Honors prefers-reduced-motion + prefers-color-scheme.
   ========================================================================= */

.rp-preview-card,
.rp-standalone-overlay {
    --rp-pc-bg:        #000000;
    --rp-pc-face:      #0a0a0a;
    --rp-pc-elevated:  #111111;
    --rp-pc-text:      #ffffff;
    --rp-pc-muted:     #9a9a9a;
    --rp-pc-accent:    #00ff41;
    --rp-pc-border:    #222222;
    --rp-pc-border-w:  22px;
    --rp-pc-hairline:  rgba(255, 255, 255, 0.10);
}

/* ---- Card shell : the signature 22px monochrome frame -------------------- */
.rp-preview-card {
    box-sizing: border-box;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: var(--rp-pc-face);
    color: var(--rp-pc-text);
    border: var(--rp-pc-border-w) solid var(--rp-pc-border);
    border-radius: 0;
    overflow: hidden;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    text-align: left;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    -webkit-font-smoothing: antialiased;
}
.rp-preview-card *,
.rp-preview-card *::before,
.rp-preview-card *::after { box-sizing: border-box; }

/* ---- Shimmer bar : animated monochrome strip across the top -------------- */
.rp-card-shimmerbar {
    height: 4px;
    width: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.85) 35%,
        var(--rp-pc-accent) 50%,
        rgba(255, 255, 255, 0.85) 65%,
        rgba(255, 255, 255, 0.04) 100%
    );
    background-size: 200% 100%;
    animation: rp-pc-shimmer 2.6s infinite linear;
}
@keyframes rp-pc-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Media : 16:10 hero image, cover-fit, cube placeholder --------------- */
.rp-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--rp-pc-bg);
    overflow: hidden;
}
/* Legacy fallback for browsers without aspect-ratio. */
@supports not (aspect-ratio: 1 / 1) {
    .rp-card-media { padding-top: 62.5%; }
    .rp-card-media > * { position: absolute; inset: 0; }
}
.rp-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s ease;
}
.rp-preview-card:hover .rp-card-img { transform: scale(1.04); }
.rp-card-noimg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 54px;
    color: var(--rp-pc-muted);
    background:
        radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.05), transparent 70%),
        var(--rp-pc-bg);
}

/* ---- Body ---------------------------------------------------------------- */
.rp-card-body {
    padding: 20px 22px 22px;
    background: var(--rp-pc-face);
}
.rp-card-title {
    margin: 0 0 6px;
    font-size: 20px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--rp-pc-text);
    word-wrap: break-word;
}
.rp-card-address {
    margin: 0 0 16px;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--rp-pc-muted);
}

/* ---- Stat row : Beds · Baths · Photos · Area · Views --------------------- */
.rp-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border: 2px solid var(--rp-pc-border);
    background: var(--rp-pc-bg);
    margin: 0 0 18px;
}
.rp-stat {
    flex: 1 1 0;
    min-width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 12px 6px;
    border-right: 1px solid var(--rp-pc-hairline);
    text-align: center;
}
.rp-stat:last-child { border-right: 0; }
.rp-stat-value {
    font-size: 17px;
    font-weight: 800;
    color: var(--rp-pc-text);
    line-height: 1;
}
.rp-stat-label {
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rp-pc-muted);
}

/* ---- Price band ---------------------------------------------------------- */
.rp-card-price {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--rp-pc-accent);
    text-align: center;
    padding: 14px 0;
    margin: 0 0 16px;
    border-top: 2px solid var(--rp-pc-border);
    border-bottom: 2px solid var(--rp-pc-border);
    text-shadow: 0 0 18px rgba(0, 255, 65, 0.35);
}

/* ---- CTA ----------------------------------------------------------------- */
.rp-card-actions { text-align: center; }
.rp-card-cta {
    display: inline-block;
    width: 100%;
    padding: 13px 20px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    color: #000 !important;
    background: var(--rp-pc-text);
    border: 2px solid var(--rp-pc-text);
    position: relative;
    overflow: hidden;
    transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.rp-card-cta::after {
    content: "";
    position: absolute;
    top: 0; left: -120%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 65, 0.45), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}
.rp-card-cta:hover {
    color: var(--rp-pc-accent) !important;
    background: #000;
    border-color: var(--rp-pc-accent);
    box-shadow: 0 0 22px rgba(0, 255, 65, 0.35);
}
.rp-card-cta:hover::after { left: 130%; }

/* ---- Note + brand -------------------------------------------------------- */
.rp-card-note {
    margin: 14px 0 0;
    font-size: 11px;
    font-style: italic;
    line-height: 1.5;
    color: var(--rp-pc-muted);
    text-align: center;
}
.rp-card-brand {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--rp-pc-hairline);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rp-pc-muted);
    text-align: center;
}

/* ---- Loading skeleton (shown the instant the lightbox opens) ------------- */
.rp-preview-loading .rp-card-media { aspect-ratio: 16 / 10; }
.rp-shimmer {
    position: relative;
    overflow: hidden;
    background: var(--rp-pc-elevated);
}
.rp-shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 45%,
        rgba(255, 255, 255, 0.14) 50%,
        rgba(255, 255, 255, 0.08) 55%,
        transparent 100%
    );
    animation: rp-pc-skel 1.5s infinite;
}
@keyframes rp-pc-skel {
    100% { transform: translateX(100%); }
}
.rp-skel {
    border-radius: 0;
    margin: 0 0 12px;
}
.rp-skel-title { height: 22px; width: 80%; }
.rp-skel-line  { height: 14px; width: 55%; }
.rp-skel-stats { height: 48px; width: 100%; margin-bottom: 16px; }
.rp-card-loading-label {
    margin-top: 6px;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rp-pc-muted);
    text-align: center;
}

/* =========================================================================
   Standalone overlay — last-resort full-screen host used ONLY if WPL's
   lightbox API is entirely unavailable. Keeps the brand + dismiss affordance.
   ========================================================================= */
.rp-standalone-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.82);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: rp-pc-fade 0.25s ease;
}
@keyframes rp-pc-fade { from { opacity: 0; } to { opacity: 1; } }
.rp-standalone-box {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 92vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.rp-standalone-close {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 5;
    width: 40px;
    height: 40px;
    line-height: 36px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    color: var(--rp-pc-text);
    background: #000;
    border: 2px solid var(--rp-pc-border);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.rp-standalone-close:hover {
    color: var(--rp-pc-accent);
    border-color: var(--rp-pc-accent);
}

/* =========================================================================
   Responsiveness — desktop · laptop · tablet · mobile
   ========================================================================= */
@media (max-width: 600px) {
    .rp-preview-card { --rp-pc-border-w: 12px; max-width: 100%; }
    .rp-card-body { padding: 16px 16px 18px; }
    .rp-card-title { font-size: 18px; }
    .rp-card-price { font-size: 23px; }
    .rp-stat { min-width: 48px; padding: 10px 4px; }
    .rp-stat-value { font-size: 15px; }
}
@media (max-width: 380px) {
    .rp-preview-card { --rp-pc-border-w: 8px; }
    .rp-card-stats { flex-wrap: wrap; }
    .rp-stat { flex: 1 1 33%; border-bottom: 1px solid var(--rp-pc-hairline); }
}

/* Tablet / large-phone landscape — give the frame a touch more presence. */
@media (min-width: 601px) and (max-width: 1024px) {
    .rp-preview-card { --rp-pc-border-w: 18px; }
}

/* =========================================================================
   Accessibility & environment preferences
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    .rp-card-shimmerbar,
    .rp-shimmer::after,
    .rp-card-img,
    .rp-card-cta,
    .rp-card-cta::after,
    .rp-standalone-overlay { animation: none !important; transition: none !important; }
    .rp-preview-card:hover .rp-card-img { transform: none; }
}

/* The card is intentionally dark-first (Bitghost brand). If the host lightbox
   forces a light context, keep our own dark surface but soften the outer frame
   so it still reads as a deliberate, framed card rather than a heavy slab. */
@media (prefers-color-scheme: light) {
    .rp-preview-card { box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35); }
}

/* =========================================================================
   PATCH-05 · v1.2.1 — WPL map-pin lightbox: center · white surface · gallery
   -------------------------------------------------------------------------
   The Map-Pin Preview Bridge tags <html> while its lightbox is open:
     .rp-mp-open  → center the WPL lightbox (applies to every map-pin open)
     .rp-mp-true  → the real WPL internal_preview is showing → white surface
     .rp-mp-card  → our own dark grid card is showing → transparent surface
   Everything is scoped to these markers so NO other WPL lightbox (e.g. the
   full-screen gallery on a property page) is affected.
   ========================================================================= */

/* ---- Center the modal (both axes), let tall content scroll inside it ----- */
html.rp-mp-open #realtyna-js-lightbox-overlay {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: auto !important;
    padding: 24px !important;
    -webkit-overflow-scrolling: touch;
}
html.rp-mp-open #realtyna-js-lightbox-wrapper {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    margin: 0 auto !important;
    max-height: 90vh !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
}
/* WPL adds this lock class to <html>; keep the page from double-scrolling. */
html.realtyna-lightbox-lock.rp-mp-open { overflow: hidden !important; }

/* ---- True WPL preview → clean white, readable surface -------------------- */
html.rp-mp-true #realtyna-js-lightbox-wrapper {
    background: #ffffff !important;
    width: min(960px, 94vw) !important;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55) !important;
}
html.rp-mp-true #realtyna-js-lightbox-content {
    background: #ffffff !important;
    color: #222222 !important;
    padding: 0 0 10px !important;
}

/* ---- Our dark grid card already has its own surface → keep it transparent - */
html.rp-mp-card #realtyna-js-lightbox-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    width: min(460px, 94vw) !important;
    overflow: visible !important;
}

/* ---- Gallery: tame the featured image, reveal the carousel beneath it ----- */
html.rp-mp-true #realtyna-js-lightbox-content .lSSlideOuter,
html.rp-mp-true #realtyna-js-lightbox-content .wpl_show_gallery {
    max-width: 100% !important;
}
html.rp-mp-true #realtyna-js-lightbox-content .lSSlideWrapper img,
html.rp-mp-true #realtyna-js-lightbox-content .lslide img {
    max-height: 56vh !important;
    object-fit: contain !important;
}
/* the lightSlider thumbnail strip WPL appends below the main image */
html.rp-mp-true #realtyna-js-lightbox-content .wpl-lSSlider-thumbnails,
html.rp-mp-true #realtyna-js-lightbox-content .lSPager.lSGallery {
    display: block !important;
    visibility: visible !important;
    margin-top: 8px !important;
}
html.rp-mp-true #realtyna-js-lightbox-content .lSPager.lSGallery li { opacity: 1 !important; }
html.rp-mp-true #realtyna-js-lightbox-content .lSAction > a { opacity: 1 !important; }

/* ---- Small screens: full-bleed, comfortable padding ---------------------- */
@media (max-width: 600px) {
    html.rp-mp-open #realtyna-js-lightbox-overlay { padding: 10px !important; }
    html.rp-mp-true #realtyna-js-lightbox-wrapper { width: 100% !important; }
    html.rp-mp-true #realtyna-js-lightbox-content .lSSlideWrapper img,
    html.rp-mp-true #realtyna-js-lightbox-content .lslide img { max-height: 46vh !important; }
}
