/**
 * IMPress Listings (IDX Broker) Integration Styles
 * ================================================
 *
 * The IMPress Listings plugin renders the `listing` post type with its own
 * templates and stylesheet (wp-listings.min.css), neither of which match this
 * theme. Out of the box that produces:
 *
 *   1. #primary carries Tailwind's .container class, which caps the content at
 *      the current breakpoint width, does NOT center it, and adds no padding -
 *      so listings sit left-aligned against the viewport edge.
 *   2. The archive title renders at body size in the body font.
 *   3. #sidebar prints WordPress' default widget set (Search / Pages /
 *      Archives / Categories), which is never wanted here.
 *   4. Cards use a float-based "one-third" grid, a hard-coded green palette,
 *      and a "View Listing" button that the plugin hides on archives.
 *
 * SCOPE: `body.bsr-impress` is added by the plugin (see
 * add_impress_listings_body_class in wp-bootstrapr.php) and covers the listing
 * archive, single listings, and listing taxonomy archives.
 *
 * SPECIFICITY: the plugin scopes its rules as `.archive .listing-wrap
 * span.listing-status` (three classes deep), so the card rules below carry
 * enough weight to outrank it deterministically rather than relying on
 * stylesheet load order.
 *
 * Colors, radius, and surfaces all read from the theme's CSS custom
 * properties, so each site inherits its own brand automatically.
 *
 * Loaded only on listing views - see the enqueue in wp-bootstrapr.php.
 */

/* ===========================================================================
   Layout - undo the uncentered, unpadded Tailwind .container
   Also matches the optional Custom Wrapper class (.bsr-impress-wrap) so this
   works whether or not the wrapper fields are filled in on the IDX settings
   screen.
   =========================================================================== */
body.bsr-impress #primary.content-area,
body.bsr-impress .bsr-impress-wrap {
    width: 100%;
    max-width: 1280px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 3.5rem 1.5rem 5rem !important;
    box-sizing: border-box;
}

/* The default widget dump the plugin's template prints after the content */
body.bsr-impress #sidebar {
    display: none !important;
}

/* ===========================================================================
   Archive header
   =========================================================================== */
body.bsr-impress .archive-header {
    grid-column: 1 / -1;
    margin: 0 0 2.25rem;
    text-align: center;
}

body.bsr-impress .archive-title,
body.bsr-impress .entry-title {
    font-family: var(--bsr-font-display, var(--bsr-font-body, inherit));
    font-size: clamp(1.9rem, 4vw, 2.75rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--bsr-text-primary, #0f172a);
    margin: 0;
}

/* ===========================================================================
   Card grid - replaces the plugin's float-based .one-third columns
   =========================================================================== */
body.bsr-impress:not(.single-listing) #content.site-content {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.75rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    body.bsr-impress:not(.single-listing) #content.site-content {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    body.bsr-impress:not(.single-listing) #content.site-content {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Neutralize the plugin's float/width column classes inside the grid */
body.bsr-impress:not(.single-listing) article.listing {
    float: none !important;
    width: auto !important;
    margin: 0 !important;
    clear: none !important;
}

/* ===========================================================================
   Listing card - mirrors .bsr-property-card from style.css
   =========================================================================== */
body.bsr-impress:not(.single-listing) .listing-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bsr-bg-surface, #ffffff);
    border: 1px solid var(--bsr-border, rgba(10, 46, 93, 0.10));
    border-radius: var(--bsr-radius-lg, 14px);
    overflow: hidden;
    box-shadow: 0 6px 22px rgba(10, 46, 93, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body.bsr-impress:not(.single-listing) .listing-wrap:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(10, 46, 93, 0.14);
}

/* --- Media --- */
body.bsr-impress:not(.single-listing) .listing-wrap .listing-widget-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--bsr-bg-surface-alt, #eef2f6);
    overflow: hidden;
}

body.bsr-impress:not(.single-listing) .listing-wrap .listing-widget-thumb a {
    display: block;
    width: 100%;
    height: 100%;
}

body.bsr-impress:not(.single-listing) .listing-wrap .listing-widget-thumb a img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

body.bsr-impress:not(.single-listing) .listing-wrap:hover .listing-widget-thumb a img {
    transform: scale(1.05);
}

/* --- Status badge: replace the plugin's rotated corner ribbon with a pill --- */
body.bsr-impress:not(.single-listing) .listing-wrap span.listing-status {
    top: 12px;
    left: 12px;
    right: auto;
    width: auto;
    padding: 0.35rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    line-height: 1.4;
    letter-spacing: 0.06em;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    background: var(--bsr-brand-primary, #0A2E5D);
}

body.bsr-impress:not(.single-listing) .listing-wrap span.listing-status.active {
    background: #15803d;
}

/* --- Price / type strip over the image --- */
body.bsr-impress:not(.single-listing) .listing-wrap .listing-thumb-meta {
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
}

body.bsr-impress:not(.single-listing) .listing-wrap .listing-thumb-meta span.listing-property-type {
    padding: 0.3rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    line-height: 1.3;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.45);
}

body.bsr-impress:not(.single-listing) .listing-wrap .listing-thumb-meta span.listing-price {
    padding: 0;
    font-size: 1.15rem;
    line-height: 1.1;
    font-weight: 800;
    color: #ffffff;
    background: none;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* The plugin outputs the raw price field (e.g. "1,350") with no currency
   symbol. Remove this rule if listings are entered with the symbol already. */
body.bsr-impress:not(.single-listing) .listing-wrap .listing-thumb-meta span.listing-price::before {
    content: '$';
}

/* --- Details: drop the plugin's inner borders and set padding once on the
       container instead of on each child --- */
body.bsr-impress:not(.single-listing) .listing-widget-details {
    flex: 1 1 auto;
    padding: 1.1rem 1.25rem 0.25rem;
    border: 0;
    background: transparent;
    color: var(--bsr-text-secondary, #64748b);
    line-height: 1.5;
}

body.bsr-impress:not(.single-listing) .listing-widget-details h3.listing-title {
    font-family: var(--bsr-font-display, var(--bsr-font-body, inherit));
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    padding: 0;
    margin: 0 0 0.3rem;
}

body.bsr-impress:not(.single-listing) .listing-widget-details h3.listing-title a {
    font-size: inherit;
    color: var(--bsr-text-primary, #0f172a);
    text-decoration: none;
}

body.bsr-impress:not(.single-listing) .listing-widget-details h3.listing-title a:hover {
    color: var(--bsr-brand-primary, #0A2E5D);
}

body.bsr-impress:not(.single-listing) .listing-widget-details p.listing-address {
    padding: 0;
    margin: 0;
}

body.bsr-impress:not(.single-listing) .listing-widget-details span.listing-address,
body.bsr-impress:not(.single-listing) .listing-widget-details span.listing-city-state-zip {
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--bsr-text-secondary, #64748b);
}

/* --- Beds / baths / sqft: keep the plugin's three-column layout, restyle --- */
body.bsr-impress:not(.single-listing) .listing-widget-details .listing-beds-baths-sqft {
    padding: 0.85rem 0 0;
    margin: 0.85rem 0 0;
    border-top: 1px solid var(--bsr-border, rgba(10, 46, 93, 0.08));
    list-style: none;
}

body.bsr-impress:not(.single-listing) .listing-widget-details .listing-beds-baths-sqft li {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--bsr-text-primary, #0f172a);
}

body.bsr-impress:not(.single-listing) .listing-widget-details .listing-beds-baths-sqft li span {
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--bsr-text-secondary, #64748b);
}

/* --- CTA: the plugin hides this on archives; bring it back on brand --- */
body.bsr-impress:not(.single-listing) .listing-wrap a.more-link {
    display: block;
    margin: 0 1.25rem 1.25rem;
    padding: 0.7rem 1rem;
    border: 0;
    border-radius: var(--bsr-radius, 8px);
    background: var(--bsr-brand-primary, #0A2E5D);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: background 0.2s ease, transform 0.2s ease;
}

body.bsr-impress:not(.single-listing) .listing-wrap a.more-link:hover {
    background: var(--bsr-brand-secondary, #3D7CC9);
    transform: translateY(-1px);
    color: #ffffff;
}

/* ===========================================================================
   Single listing view
   =========================================================================== */

/* Comments are forced closed in PHP (see close_listing_comments in
   wp-bootstrapr.php). This is a fallback in case another plugin renders a
   comment form on listings regardless of comment_status. */
body.bsr-impress #comments,
body.bsr-impress #respond,
body.bsr-impress .comments-area,
body.bsr-impress .comment-respond,
body.bsr-impress .comments-link {
    display: none !important;
}

body.bsr-impress.single-listing #content.site-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--bsr-radius, 8px);
}

/* Detail tables the plugin renders for property features */
body.bsr-impress.single-listing #content.site-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.92rem;
}

body.bsr-impress.single-listing #content.site-content table td,
body.bsr-impress.single-listing #content.site-content table th {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--bsr-border, rgba(10, 46, 93, 0.08));
    text-align: left;
    color: var(--bsr-text-secondary, #64748b);
}

body.bsr-impress.single-listing #content.site-content table th {
    color: var(--bsr-text-primary, #0f172a);
    font-weight: 700;
}
