/* ==========================================================================
   TSF Listing Archive Card Grid
   Flat-markup replacement for the old Elementor Loop Grid + "Listing Card -
   Default" loop-item template. See tsf_render_listing_card() in
   listing-archive.php.
   ========================================================================== */

/* The "Scare Factor Custom" @font-face is registered ONCE, site-wide, by the
   canonical token layer (tsf-core/assets/tsf-tokens.css). The duplicate
   plugin-level registration (family alias "Scare Factor") was removed —
   --tsf-font-display carries the old name as a fallback in its stack. */

/* Overrides the Elementor heading widget's own typography setting (Bebas
   Neue) for the [tsf_listing_archive_heading] shortcode's <h1>. The ID
   selector already outranks Elementor's ".elementor-element-<id> h1.tsf-
   archive-heading" class-based rule, but !important guards against load
   order if Elementor's CSS gets regenerated/re-ordered later. */
#tsf-dynamic-heading.tsf-archive-heading {
    font-family: var(--tsf-font-display, "Scare Factor Custom", "Bebas Neue", sans-serif) !important;
}

.tsf-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--tsf-space-5, 13px);
}

@media (max-width: 1024px) {
    .tsf-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .tsf-card-grid {
        grid-template-columns: 1fr;
    }
}

.tsf-card {
    display: flex;
    flex-direction: column;
    border: 2px solid var(--tsf-line, #3F3F3F);
    border-radius: var(--tsf-radius-xl, 31px);
    background-color: var(--tsf-surface, #0F0F0F) !important;
    box-shadow: var(--tsf-shadow-card, 0 13px 50px -13px #000000);
    transition: box-shadow var(--tsf-transition, 180ms ease-in-out);
    overflow: hidden;
}

.tsf-card:hover {
    box-shadow: var(--tsf-shadow-card-hover, 0 13px 50px -13px #500000);
}

/* === CARD BACKGROUND COLORS BY LISTING TYPE === */
.tsf-card.type-haunted-houses { background-color: var(--tsf-type-haunt-surface, #1C1A24); }
.tsf-card.type-paranormal     { background-color: var(--tsf-type-paranormal-surface, #191C1F); }
.tsf-card.type-spooky-spots   { background-color: var(--tsf-type-spooky-surface, #1C1C1C); }

/* === SUB-TYPE PILL COLORS BY LISTING TYPE === */
.tsf-card.type-haunted-houses .listing-subtype-pill {
    background-color: var(--tsf-type-haunt, #FF6A00);
    color: #fff;
}
.tsf-card.type-paranormal .listing-subtype-pill {
    background-color: var(--tsf-type-paranormal, #00B4B4);
    color: #fff;
}
.tsf-card.type-spooky-spots .listing-subtype-pill {
    background-color: var(--tsf-type-spooky, #C77DFF);
    color: #111;
}

/* === HOVER: BORDER + SHADOW BY LISTING TYPE === */
.tsf-card.type-haunted-houses:hover {
    box-shadow: 0 0 0 2px var(--tsf-red-hover, #C00000) inset, 0 4px 20px rgba(255, 106, 0, 0.4);
}
.tsf-card.type-paranormal:hover {
    box-shadow: 0 0 0 2px var(--tsf-type-paranormal, #00B4B4) inset, 0 4px 20px rgba(0, 180, 180, 0.4);
}
.tsf-card.type-spooky-spots:hover {
    box-shadow: 0 0 0 2px var(--tsf-type-spooky, #C77DFF) inset, 0 4px 20px rgba(199, 125, 255, 0.4);
}

.tsf-card-logo-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    padding: 0 5px;
}

.tsf-card-logo {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--tsf-radius-lg, 13px);
}

.tsf-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 15px 20px;
}

.tsf-card-title {
    font-size: 20px;
    margin: 0 0 4px;
}

.tsf-card-title a {
    color: inherit;
    text-decoration: none;
}

.tsf-card-city {
    font-style: italic;
    color: #ACACAC;
    margin: 0 0 4px;
}

.tsf-card-notes {
    font-weight: 600;
    color: var(--tsf-orange, #FF6600);
    margin: 0 0 8px;
}

.tsf-card-footer {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: space-evenly;
    gap: 10px;
    width: 100%;
    padding: 0 0.5vw;
    margin-top: 8px;
}

.tsf-card-footer .listing-subtype-pill {
    display: inline-block;
    padding: 0.25em 0.6em;
    border: 2px solid var(--tsf-orange, #FF6600);
    border-radius: var(--tsf-radius-xl, 31px);
    color: var(--tsf-text, #CBCBCB);
    background-color: var(--tsf-bg, #131313);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tsf-card-footer .mini-guest-rating {
    text-align: right;
    font-size: 13px;
}

.tsf-nothing-found {
    text-align: center;
    grid-column: 1 / -1;
}

.tsf-nothing-found p {
    color: var(--tsf-text, #CBCBCB);
}

/* === Grid/List view toggle buttons ===
   Originally lived as custom_css on the Elementor Loop Grid widget (element
   5b54df3c), which got deleted when that widget was replaced with the
   [facetwp template="tsf_listing_cards"] shortcode. The button markup/script
   itself is in a separate HTML widget and was never touched, but its
   styling went away with the deleted widget -- restoring it here. */
.tsf-view-toggle-wrapper {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 15px;
}

.tsf-view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--tsf-surface-panel, #1A1A1A);
    border: 1px solid var(--tsf-line-strong, #333333);
    color: var(--tsf-text-muted, #8A8A8A);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.tsf-view-btn:hover, .tsf-view-btn.active {
    background: var(--tsf-orange, #FF6600);
    color: white;
    border-color: var(--tsf-orange, #FF6600);
}
.tsf-view-btn svg { fill: currentColor; }

@media (max-width: 767px) {
    .tsf-view-toggle-wrapper {
        display: none !important;
    }
}

/* === List view toggle (see tsf-listing-archive-shell HTML widget JS) === */
@media (min-width: 768px) {
    #tsf-listing-grid.tsf-layout-list .tsf-card-grid {
        grid-template-columns: 1fr;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card {
        background-color: transparent !important;
        border: none !important;
        border-bottom: 2px solid var(--tsf-line-strong, #333333) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 8px 10px !important;
        flex-direction: row !important;
        align-items: center !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card:hover {
        background-color: #111 !important;
        box-shadow: none !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-logo-wrap {
        display: none !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-body {
        width: 100% !important;
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
        text-align: left;
        padding: 0 !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-title {
        width: auto !important;
        margin: 0 !important;
        flex-grow: 0;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-title h3,
    #tsf-listing-grid.tsf-layout-list .tsf-card-title {
        font-size: 16px !important;
        white-space: nowrap;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-city {
        width: auto !important;
        font-size: 14px !important;
        color: var(--tsf-text-faint, #999999) !important;
        margin: 0 !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-notes {
        width: auto !important;
        flex-grow: 1;
        font-size: 12px !important;
        font-style: italic !important;
        margin: 0 !important;
        line-height: 1.2;
        text-align: left !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-card-footer {
        width: auto !important;
        margin-left: auto !important;
        padding: 0 !important;
    }

    /* Review button: the full-size logo/button image (tsf_reviews_for_listing
       shortcode output) is sized for grid view; in list view, hide the image
       and render the link as a small text pill instead -- same approach the
       original template used before the Loop Grid rebuild. */
    #tsf-listing-grid.tsf-layout-list .tsf-review-links-wrapper {
        width: auto !important;
        flex-grow: 0 !important;
        margin: 0 0 0 auto !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-review-button-image {
        display: none !important;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-review-main-image-link {
        display: inline-block;
        background-color: var(--tsf-red, #FF0000);
        color: white !important;
        padding: 5px 12px;
        border-radius: var(--tsf-radius-lg, 13px);
        font-size: 13px;
        font-weight: bold;
        text-transform: uppercase;
        text-decoration: none;
        line-height: 1;
    }

    #tsf-listing-grid.tsf-layout-list .tsf-review-main-image-link::after {
        content: "Read Review";
    }
}

@media (max-width: 767px) {
    #tsf-listing-grid.tsf-layout-list .tsf-card-body {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 8px !important;
    }
}

/* ==========================================================================
   LIST VIEW — Haunt Advisor card (.ha-card) compact rows
   The archive renders .ha-card (HA_Card static mode) instead of .tsf-card, so
   the grid/list toggle needs its own row layout for .ha-card. One line on
   desktop + tablet; wraps to at most two lines on mobile, with the Save/Bucket
   icons and thumbs kept horizontal (never stacked into their own column).

   How the one-line row is built without touching the card DOM: .ha-card-media
   and .ha-card-body are set to display:contents so THEIR children (logo, action
   icons, title, meta, review, footer) become direct flex items of .ha-card and
   can be ordered left-to-right. The #tsf-listing-grid.tsf-layout-list ID scope
   out-ranks the inline .ha-card base styles, so no !important is needed.
   ========================================================================== */

/* ---- Desktop + tablet: single line ---- */
@media (min-width: 768px) {
    #tsf-listing-grid.tsf-layout-list .ha-card {
        flex-direction: row;
        align-items: center;
        gap: 14px;
        background: transparent;
        border: none;
        border-bottom: 2px solid var(--tsf-line-strong, #333333);
        border-radius: 0;
        box-shadow: none;
        padding: 8px 10px;
        overflow: hidden;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card:hover {
        background: rgba(255, 255, 255, 0.03);
        border-color: var(--tsf-red-ink, #5C0000);
        box-shadow: none;
    }

    /* Flatten the two wrappers so their children join the row. */
    #tsf-listing-grid.tsf-layout-list .ha-card-media,
    #tsf-listing-grid.tsf-layout-list .ha-card-body {
        display: contents;
    }

    /* Logo — small square, far left. */
    #tsf-listing-grid.tsf-layout-list .ha-card-logo-link {
        order: 1;
        flex: 0 0 auto;
        width: 54px;
        height: 54px;
        border-radius: 10px;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-logo-link.is-empty { display: none; }
    #tsf-listing-grid.tsf-layout-list .ha-card-logo { height: 54px; padding: 4px; }

    /* Title — truncates so it never forces a wrap. */
    #tsf-listing-grid.tsf-layout-list .ha-card-title {
        order: 2;
        flex: 0 1 auto;
        min-width: 0;
        max-width: 28ch;
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Location + rating take the flexible slack in the middle. */
    #tsf-listing-grid.tsf-layout-list .ha-card-meta {
        order: 3;
        flex: 1 1 auto;
        justify-content: flex-start;
        gap: 12px;
        min-width: 0;
    }

    /* Notes are supplementary — hidden in the compact row (still in grid + detail). */
    #tsf-listing-grid.tsf-layout-list .ha-card-notes { display: none; }

    /* Review image → compact "Read Review" text pill (mirrors the old tsf list view). */
    #tsf-listing-grid.tsf-layout-list .ha-card-review { order: 4; flex: 0 0 auto; margin: 0; }
    #tsf-listing-grid.tsf-layout-list .ha-card-review .tsf-review-button-image { display: none; }
    #tsf-listing-grid.tsf-layout-list .ha-card-review .tsf-review-main-image-link {
        display: inline-block;
        background: var(--tsf-red, #FF0000);
        color: #fff;
        padding: 5px 12px;
        border-radius: var(--tsf-radius-lg, 13px);
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        text-decoration: none;
        line-height: 1;
        white-space: nowrap;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-review .tsf-review-main-image-link::after { content: "Read Review"; }

    /* Footer (subtype pill + thumbs) stays an inline cluster. */
    #tsf-listing-grid.tsf-layout-list .ha-card-footer {
        order: 5;
        flex: 0 0 auto;
        width: auto;
        margin: 0;
        padding: 0;
        gap: 10px;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-reactions { flex: 0 0 auto; }

    /* Save/Bucket icons — un-absoluted, far right, kept side by side. */
    #tsf-listing-grid.tsf-layout-list .ha-card-actions {
        order: 6;
        position: static;
        flex: 0 0 auto;
        flex-wrap: nowrap;
    }
}

/* ---- Mobile: at most two lines, icons/thumbs never stacked ----
   Line 1: logo · title (fills) · Save · Bucket
   Line 2: location/rating · subtype · thumbs   (review pill dropped to hold 2 lines) */
@media (max-width: 767px) {
    #tsf-listing-grid.tsf-layout-list .ha-card {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 10px;
        background: transparent;
        border: none;
        border-bottom: 2px solid var(--tsf-line-strong, #333333);
        border-radius: 0;
        box-shadow: none;
        padding: 8px 6px;
        overflow: hidden;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card:hover { box-shadow: none; }

    #tsf-listing-grid.tsf-layout-list .ha-card-media,
    #tsf-listing-grid.tsf-layout-list .ha-card-body {
        display: contents;
    }

    #tsf-listing-grid.tsf-layout-list .ha-card-logo-link {
        order: 1;
        flex: 0 0 auto;
        width: 40px;
        height: 40px;
        border-radius: 8px;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-logo-link.is-empty { display: none; }
    #tsf-listing-grid.tsf-layout-list .ha-card-logo { height: 40px; padding: 3px; }

    /* Title fills line 1 and pushes the icons to the right edge. */
    #tsf-listing-grid.tsf-layout-list .ha-card-title {
        order: 2;
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Save/Bucket ride line 1, far right, never stacked. */
    #tsf-listing-grid.tsf-layout-list .ha-card-actions {
        order: 3;
        position: static;
        flex: 0 0 auto;
        flex-wrap: nowrap;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-actions .ha-fav-icon,
    #tsf-listing-grid.tsf-layout-list .ha-card-actions .ha-bucket-icon {
        width: 32px;
        height: 32px;
    }

    /* Line 2. Location truncates (base .ha-card-loc > span already ellipsizes). */
    #tsf-listing-grid.tsf-layout-list .ha-card-meta {
        order: 4;
        flex: 1 1 auto;
        justify-content: flex-start;
        gap: 10px;
        min-width: 0;
        font-size: 0.82rem;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-notes { display: none; }
    #tsf-listing-grid.tsf-layout-list .ha-card-review { display: none; }
    #tsf-listing-grid.tsf-layout-list .ha-card-footer {
        order: 5;
        flex: 0 0 auto;
        width: auto;
        margin: 0;
        padding: 0;
        gap: 8px;
    }
    #tsf-listing-grid.tsf-layout-list .ha-card-reactions { flex: 0 0 auto; }
}
