/**
 * Sticky property + agent bar — top fixed.
 *
 * Theme overrides: set custom properties on `.loop-property-sticky-agent-bar` from SCSS, e.g.
 *   .loop-property-sticky-agent-bar {
 *     --loop-property-sticky-bar-bg: #{$brand-dark};
 *     --loop-property-sticky-bar-color: #fff;
 *     --loop-property-sticky-bar-accent: #{$gold};
 *   }
 *
 * Variables (defaults are neutral #333 / white / #f4f4f4 accent):
 *   --loop-property-sticky-bar-bg
 *   --loop-property-sticky-bar-color          main text (title, stats numbers, agent name)
 *   --loop-property-sticky-bar-muted          secondary text (address)
 *   --loop-property-sticky-bar-muted-label    price label row
 *   --loop-property-sticky-bar-accent         stat icons + CTA + CTA hover uses lighter mix
 *   --loop-property-sticky-bar-surface        thumb / avatar placeholder wash
 *   --loop-property-sticky-bar-divider        vertical rule
 *   --loop-property-sticky-bar-border         bar bottom edge
 *   --loop-property-sticky-bar-shadow         drop shadow
 */

.loop-property-sticky-agent-bar {
    --loop-property-sticky-bar-bg: #333333;
    --loop-property-sticky-bar-color: #ffffff;
    --loop-property-sticky-bar-muted: rgba(255, 255, 255, 0.78);
    --loop-property-sticky-bar-muted-label: rgba(255, 255, 255, 0.72);
    --loop-property-sticky-bar-accent: #f4f4f4;
    --loop-property-sticky-bar-surface: rgba(255, 255, 255, 0.12);
    --loop-property-sticky-bar-divider: rgba(255, 255, 255, 0.28);
    --loop-property-sticky-bar-border: rgba(0, 0, 0, 0.2);
    --loop-property-sticky-bar-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);

    position: fixed;
    left: 0;
    right: 0;
    top: env(safe-area-inset-top, 0);
    z-index: 1;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0));
    background: var(--loop-property-sticky-bar-bg);
    color: var(--loop-property-sticky-bar-color);
    border-bottom: 1px solid var(--loop-property-sticky-bar-border);
    box-shadow: var(--loop-property-sticky-bar-shadow);
    transform: translateY(-100%);
    visibility: hidden;
    opacity: 0;
    /* Visibility waits until opacity finishes hiding (avoids invisible hit targets). */
    transition: transform 0.35s ease, opacity 0.35s ease, visibility 0s linear 0.35s;
    pointer-events: none;
    font-size: 0.875rem;
    line-height: 1.3;
}

body.admin-bar .loop-property-sticky-agent-bar {
    top: calc(32px + env(safe-area-inset-top, 0));
}

@media screen and (max-width: 782px) {
    body.admin-bar .loop-property-sticky-agent-bar {
        top: calc(46px + env(safe-area-inset-top, 0));
    }
}

body.loop-property-single-sticky-agent-visible .loop-property-sticky-agent-bar {
    transform: translateY(0);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    /* Lift above the Lux single-property occlusion stack (fixed hero
       slides sit at 0, body sections at 5). z-index 4 keeps the bar
       above the hero surface + its floating price panel + agent
       card, without competing with the modal system when a Loop
       Forms overlay opens on top. */
    z-index: 4;
    transition: transform 0.35s ease, opacity 0.35s ease, visibility 0s;
}

/* Hide the theme's fixed header while the sticky agent bar is showing.
 *
 * The bar slides in on scroll and is typically SHORTER than the theme
 * header (giro v2: #masthead.header). Relying on the bar's z-index to
 * cover the header left the header's taller bottom edge poking out
 * beneath the bar (the "header underlapping the contact bar" Kane
 * flagged). Hiding the header outright removes any underlap regardless
 * of the two elements' relative heights.
 *
 * Scoped to the sticky-visible body class (JS-toggled, single-property
 * only), so the header is untouched at the top of the page and returns
 * when the visitor scrolls back up and the class is removed. The fade
 * matches the bar's 0.35s slide-in so the swap reads as one motion.
 *
 * This plugin stylesheet loads AFTER the theme CSS, so it wins at equal
 * specificity — no !important needed. Targets both the .header class
 * and #masthead id to cover the giro v2 theme family (g2, g2x, Lux). */
body.loop-property-single-sticky-agent-visible .header,
body.loop-property-single-sticky-agent-visible #masthead {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.loop-property-sticky-agent-bar-inner {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

/* --- Desktop row (hidden on small screens) --- */
.loop-property-sticky-agent-bar-desktop {
    display: none;
    align-items: center;
    gap: 1rem 1.25rem;
    flex-wrap: nowrap;
}

@media (min-width: 900px) {
    .loop-property-sticky-agent-bar-desktop {
        display: flex;
    }
}

.loop-property-sticky-agent-bar-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1 1 auto;
}

.loop-property-sticky-agent-bar-thumb {
    flex-shrink: 0;
    width: 76px;
    height: 76px;
    border-radius: 4px;
    overflow: hidden;
}

.loop-property-sticky-agent-bar-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loop-property-sticky-agent-bar-summary-text {
    min-width: 0;
}

.loop-property-sticky-agent-bar-title {
    font-weight: 700;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22rem;
    color: var(--loop-property-sticky-bar-color);
}

.loop-property-sticky-agent-bar-address {
    color: var(--loop-property-sticky-bar-muted);
    font-size: 0.8125rem;
    margin-top: 0.15rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 28rem;
}

/* Own column: qualifier on top, price below — right-aligned (between summary and stats) */
.loop-property-sticky-agent-bar-price-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.2rem;
    min-width: 5.5rem;
    max-width: 12rem;
    padding-inline: 0.25rem;
    text-align: right;
}

.loop-property-sticky-agent-bar-price-label {
    display: block;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--loop-property-sticky-bar-muted-label);
    text-align: right;
    width: 100%;
}

.loop-property-sticky-agent-bar-price-value {
    display: block;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--loop-property-sticky-bar-color);
    line-height: 1.2;
    text-align: right;
    width: 100%;
}

.loop-property-sticky-agent-bar-stats {
    display: flex;
    align-items: flex-end;
    gap: 1.25rem;
    flex-shrink: 0;
}

.loop-property-sticky-agent-bar-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.loop-property-sticky-agent-bar-stat-value {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    color: var(--loop-property-sticky-bar-color);
}

.loop-property-sticky-agent-bar-stat-icon {
    display: flex;
    color: var(--loop-property-sticky-bar-accent);
    line-height: 0;
}

.loop-property-sticky-agent-bar-stat-icon svg {
    display: block;
}

.loop-property-sticky-agent-bar-divider {
    width: 1px;
    align-self: stretch;
    min-height: 3rem;
    background: var(--loop-property-sticky-bar-divider);
    flex-shrink: 0;
}

.loop-property-sticky-agent-bar-agent {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex-shrink: 0;
}

@media (min-width: 900px) {
    .loop-property-sticky-agent-bar-agent {
        flex: 0 1 20rem;
        min-width: 13.5rem;
        max-width: 22rem;
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .loop-property-sticky-agent-bar-stats {
        gap: 0.85rem;
    }

    .loop-property-sticky-agent-bar-title {
        max-width: 18rem;
    }
}

.loop-property-sticky-agent-bar-avatar {
    flex-shrink: 0;
    width: 76px;
    height: 76px;
    border-radius: 4px;
    overflow: hidden;
}

.loop-property-sticky-agent-bar-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loop-property-sticky-agent-bar-agent-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1 1 auto;
}

.loop-property-sticky-agent-bar-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--loop-property-sticky-bar-color);
    display: block;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sibling of avatar + agent-text: phone + WhatsApp, not nested under the name block */
.loop-property-sticky-agent-bar-contact-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
    align-self: center;
}

@media (min-width: 900px) {
    .loop-property-sticky-agent-bar-contact-row {
        gap: 0.75rem;
        flex-wrap: nowrap;
    }
}

/* Phone: mobile = icon tap target; desktop = visible number (icon hidden). Number stays in DOM for screen readers on mobile. */
.loop-property-sticky-agent-bar-phone-number {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.loop-property-sticky-agent-bar-phone-icon-touch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
    color: inherit;
}

.loop-property-sticky-agent-bar-phone-icon-touch svg {
    display: block;
}

.loop-property-sticky-agent-bar-phone {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 2.75rem;
    min-height: 2.75rem;
    font-size: 0.8125rem;
    color: var(--loop-property-sticky-bar-muted);
    text-decoration: none;
}

.loop-property-sticky-agent-bar-phone:hover,
.loop-property-sticky-agent-bar-phone:focus-visible {
    color: var(--loop-property-sticky-bar-color);
    text-decoration: underline;
}

@media (min-width: 900px) {
    .loop-property-sticky-agent-bar-phone-number {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        overflow: visible;
        clip: auto;
        white-space: nowrap;
    }

    .loop-property-sticky-agent-bar-phone-icon-touch {
        display: none;
    }

    .loop-property-sticky-agent-bar-phone {
        position: static;
        display: inline;
        min-width: 0;
        min-height: 0;
        justify-content: flex-start;
    }
}

.loop-property-sticky-agent-bar-whatsapp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--loop-property-sticky-bar-accent);
    line-height: 0;
    text-decoration: none;
}

.loop-property-sticky-agent-bar-whatsapp:hover,
.loop-property-sticky-agent-bar-whatsapp:focus-visible {
    color: var(--loop-property-sticky-bar-color);
    opacity: 0.95;
}

.loop-property-sticky-agent-bar-whatsapp svg {
    display: block;
    width: 22px;
    height: 22px;
}

/* Mobile: match phone control hit area */
@media (max-width: 899px) {
    .loop-property-sticky-agent-bar-agent-mobile .loop-property-sticky-agent-bar-whatsapp {
        min-width: 2.75rem;
        min-height: 2.75rem;
    }
}

.loop-property-sticky-agent-bar-actions {
    flex-shrink: 0;
    margin-left: auto;
}

.loop-property-sticky-agent-bar-cta,
.loop-property-sticky-agent-bar-cta-link {
    appearance: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--loop-property-sticky-bar-accent);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.loop-property-sticky-agent-bar-cta:hover,
.loop-property-sticky-agent-bar-cta:focus-visible,
.loop-property-sticky-agent-bar-cta-link:hover,
.loop-property-sticky-agent-bar-cta-link:focus-visible {
    color: var(--loop-property-sticky-bar-color);
    text-decoration: underline;
}

/* --- Mobile row --- */
.loop-property-sticky-agent-bar-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

@media (min-width: 900px) {
    .loop-property-sticky-agent-bar-mobile {
        display: none;
    }
}

.loop-property-sticky-agent-bar-agent-mobile {
    flex: 1 1 auto;
    min-width: 0;
}

.loop-property-sticky-agent-bar-actions-mobile {
    margin-left: 0;
    flex-shrink: 0;
}

.loop-property-sticky-agent-bar-mobile-fallback {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.loop-property-sticky-agent-bar-mobile-fallback-title {
    font-weight: 700;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--loop-property-sticky-bar-color);
}

.loop-property-sticky-agent-bar-mobile-fallback-price {
    font-weight: 700;
    font-size: 1rem;
    color: var(--loop-property-sticky-bar-color);
}

.loop-property-sticky-agent-bar-reduced-motion,
body.loop-property-single-sticky-agent-visible .loop-property-sticky-agent-bar-reduced-motion {
    transition: none;
}

@media (prefers-reduced-motion: reduce) {
    .loop-property-sticky-agent-bar {
        transition: none;
    }
}
