/*
 * Telamo home finder — the filter bar and the results grid.
 *
 * Self-contained: it shares no selectors with telamo-listings.css so the two grids can appear on
 * the same page without fighting. Everything is driven by the custom properties below, so the
 * palette and type scale are adjustable without touching a rule.
 */

.telamo-hf {
    --tlm-hf-primary: #113164;
    --tlm-hf-primary-dark: #0d2750;
    --tlm-hf-muted: #6b7280;
    --tlm-hf-border: #e5e7eb;
    --tlm-hf-rule: #e8eaee;
    --tlm-hf-surface: #ffffff;
    --tlm-hf-placeholder: #f3f4f6;

    /* The "Tell us where you're looking" link. */
    --tlm-hf-accent: #1f7a4d;

    --tlm-hf-heading-font: Newsreader, Georgia, "Times New Roman", serif;
    --tlm-hf-body-font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --tlm-hf-radius: 4px;
    --tlm-hf-media-radius: 6px;
    --tlm-hf-gap: 28px;

    /* Flush by default, matching the filtered screen. .telamo-hf--card boxes it instead. */
    --tlm-hf-panel-bg: transparent;
    --tlm-hf-panel-padding: 0;

    /*
     * How much room "Show homes" leaves above the results when it scrolls to them, so a sticky
     * theme header does not sit over the heading. Raise it to match a taller one.
     */
    --tlm-hf-scroll-offset: 96px;

    max-width: 1180px;
    margin-left: auto;
    margin-right: auto;
    font-family: var(--tlm-hf-body-font);
    color: var(--tlm-hf-primary);
    -webkit-font-smoothing: antialiased;
}

.telamo-hf *,
.telamo-hf *::before,
.telamo-hf *::after {
    box-sizing: border-box;
}

/* The boxed presentation: add class="telamo-hf--card" to the results shortcode. */
.telamo-hf--card {
    --tlm-hf-panel-bg: #ffffff;
    --tlm-hf-panel-padding: 40px;
}

.telamo-hf__panel {
    background: var(--tlm-hf-panel-bg);
    padding: var(--tlm-hf-panel-padding);
}

/* ─────────────────────────── Filter bar ─────────────────────────── */

.telamo-hf__filter {
    display: flex;
    align-items: center;
    background: var(--tlm-hf-surface);
    border: 1px solid var(--tlm-hf-border);
    padding: 10px;
    margin: 0;
}

.telamo-hf__filter-field {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 20px;
}

/* Hairline rules between the fields, but never before the first one. */
.telamo-hf__filter-field + .telamo-hf__filter-field {
    border-left: 1px solid var(--tlm-hf-border);
}

.telamo-hf__filter-label {
    display: block;
    margin: 0 0 7px;
    font-family: var(--tlm-hf-body-font);
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--tlm-hf-muted);
}

.telamo-hf__filter-control {
    position: relative;
    display: flex;
    align-items: center;
}

.telamo-hf__filter-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    margin: 0;
    padding: 0 22px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-family: var(--tlm-hf-body-font);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--tlm-hf-primary);
    cursor: pointer;
    text-overflow: ellipsis;
}

.telamo-hf__filter-select:focus {
    outline: none;
}

.telamo-hf__filter-select:focus-visible {
    outline: 2px solid var(--tlm-hf-primary);
    outline-offset: 3px;
}

.telamo-hf__filter-chevron {
    position: absolute;
    right: 0;
    color: var(--tlm-hf-muted);
    pointer-events: none;
}

.telamo-hf__filter-actions {
    flex: 0 0 auto;
    padding-left: 12px;
}

/* ─────────────────────────── Buttons ─────────────────────────── */

.telamo-hf__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 26px;
    border: 1px solid transparent;
    border-radius: var(--tlm-hf-radius);
    font-family: var(--tlm-hf-body-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.telamo-hf__btn--primary {
    min-width: 190px;
    background: var(--tlm-hf-primary);
    border-color: var(--tlm-hf-primary);
    color: #ffffff;
}

.telamo-hf__btn--primary:hover,
.telamo-hf__btn--primary:focus {
    background: var(--tlm-hf-primary-dark);
    border-color: var(--tlm-hf-primary-dark);
    color: #ffffff;
}

.telamo-hf__btn--outline {
    background: var(--tlm-hf-surface);
    border-color: var(--tlm-hf-primary);
    color: var(--tlm-hf-primary);
}

.telamo-hf__btn--outline:hover,
.telamo-hf__btn--outline:focus {
    background: var(--tlm-hf-primary);
    color: #ffffff;
}

/* ─────────────────────────── Results header ─────────────────────────── */

.telamo-hf__header {
    margin: 0 0 26px;
}

.telamo-hf__header--split {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.telamo-hf__header-text {
    min-width: 0;
}

.telamo-hf__heading {
    margin: 0;
    font-family: var(--tlm-hf-heading-font);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--tlm-hf-primary);
}

.telamo-hf__subheading {
    margin: 9px 0 0;
    font-family: var(--tlm-hf-body-font);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--tlm-hf-muted);
}

/* Applies to the anchor jump and to the scripted scroll alike. */
.telamo-hf--results {
    scroll-margin-top: var(--tlm-hf-scroll-offset);
}

/* The filtered state separates the header from the grid with a rule. */
.telamo-hf--results.is-filtered .telamo-hf__header {
    padding-bottom: 22px;
    border-bottom: 1px solid var(--tlm-hf-rule);
}

.telamo-hf__view-all {
    flex: 0 0 auto;
}

/* ─────────────────────────── Grid ─────────────────────────── */

.telamo-hf__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--tlm-hf-gap);
}

.telamo-hf__grid--cols-1 { grid-template-columns: minmax(0, 1fr); }
.telamo-hf__grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.telamo-hf__grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ─────────────────────────── Card ─────────────────────────── */

.telamo-hf__card {
    position: relative;
}

/*
 * The hover surface bleeds outward from behind the card rather than being padding on it, so
 * lifting a card never nudges its text.
 */
.telamo-hf__card::before {
    content: "";
    position: absolute;
    inset: -14px -14px -18px;
    border-radius: 10px;
    background: var(--tlm-hf-surface);
    box-shadow: 0 10px 30px rgba(17, 49, 100, 0.10);
    opacity: 0;
    transition: opacity 0.18s ease;
    z-index: 0;
    pointer-events: none;
}

.telamo-hf__card:hover::before,
.telamo-hf__card:focus-within::before {
    opacity: 1;
}

.telamo-hf__card-link {
    position: relative;
    z-index: 1;
    display: block;
    color: inherit;
    text-decoration: none;
}

.telamo-hf__card-link:focus-visible {
    outline: 2px solid var(--tlm-hf-primary);
    outline-offset: 4px;
}

.telamo-hf__media {
    position: relative;
    overflow: hidden;
    border-radius: var(--tlm-hf-media-radius);
    background: var(--tlm-hf-placeholder);
}

.telamo-hf__image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

/* Browsers without aspect-ratio still get a portrait frame. */
@supports not (aspect-ratio: 4 / 5) {
    .telamo-hf__image {
        height: 420px;
    }
}

.telamo-hf__pill {
    position: absolute;
    top: 14px;
    left: 14px;
    padding: 7px 10px;
    border-radius: var(--tlm-hf-radius);
    background: var(--tlm-hf-surface);
    font-family: var(--tlm-hf-body-font);
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    color: var(--tlm-hf-primary);
    box-shadow: 0 1px 3px rgba(17, 49, 100, 0.14);
    white-space: nowrap;
}

.telamo-hf__card-body {
    padding-top: 18px;
}

.telamo-hf__card-title {
    margin: 0;
    font-family: var(--tlm-hf-heading-font);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--tlm-hf-primary);
}

.telamo-hf__card-location {
    margin: 6px 0 0;
    font-family: var(--tlm-hf-body-font);
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
    color: var(--tlm-hf-muted);
}

.telamo-hf__card-price {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin: 14px 0 0;
    font-family: var(--tlm-hf-body-font);
}

.telamo-hf__card-amount {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--tlm-hf-primary);
}

.telamo-hf__card-period {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--tlm-hf-muted);
}

.telamo-hf__card-meta,
.telamo-hf__card-rule {
    margin: 14px 0 0;
    padding: 12px 0 0;
    border: 0;
    border-top: 1px solid var(--tlm-hf-rule);
}

.telamo-hf__card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    font-family: var(--tlm-hf-body-font);
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
    color: var(--tlm-hf-muted);
}

.telamo-hf__card-meta-item {
    margin: 0;
}

.telamo-hf__card-meta-item + .telamo-hf__card-meta-item::before {
    content: "\00B7";
    margin: 0 7px;
}

/* ─────────────────────────── Footer ─────────────────────────── */

.telamo-hf__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 22px;
    margin-top: 36px;
}

.telamo-hf__help {
    margin: 0;
    font-family: var(--tlm-hf-body-font);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--tlm-hf-muted);
}

.telamo-hf__help-link {
    color: var(--tlm-hf-accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.telamo-hf__help-link:hover {
    color: var(--tlm-hf-accent);
    text-decoration: none;
}

/* ─────────────────────────── Empty & notices ─────────────────────────── */

.telamo-hf__empty,
.telamo-hf__notice {
    margin: 0;
    padding: 20px 22px;
    border: 1px solid var(--tlm-hf-border);
    border-radius: var(--tlm-hf-radius);
    background: var(--tlm-hf-surface);
    font-family: var(--tlm-hf-body-font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--tlm-hf-muted);
}

.telamo-hf__notice--error {
    border-color: #f0c9cf;
    background: #fdf4f5;
    color: #8c2f3c;
}

.telamo-hf__notice--info {
    border-color: #c9d8f0;
    background: #f4f7fd;
    color: var(--tlm-hf-primary);
}

/* ─────────────────────────── Responsive ─────────────────────────── */

@media (max-width: 1024px) {
    .telamo-hf {
        --tlm-hf-gap: 22px;
    }

    .telamo-hf__heading {
        font-size: 26px;
    }

    .telamo-hf__filter-field {
        padding: 6px 14px;
    }

    .telamo-hf__btn--primary {
        min-width: 150px;
    }
}

@media (max-width: 900px) {
    .telamo-hf__filter {
        flex-wrap: wrap;
        gap: 4px;
    }

    .telamo-hf__filter-field {
        flex: 1 1 calc(50% - 4px);
        padding: 10px 14px;
    }

    /* Re-draw the rules for a two-per-row layout: no rule on either first column. */
    .telamo-hf__filter-field + .telamo-hf__filter-field {
        border-left: 1px solid var(--tlm-hf-border);
    }

    .telamo-hf__filter-field:nth-of-type(odd) {
        border-left: 0;
    }

    .telamo-hf__filter-actions {
        flex: 1 1 100%;
        padding: 6px 0 0;
    }

    .telamo-hf__btn--primary {
        width: 100%;
    }

    .telamo-hf__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .telamo-hf__grid--cols-1 {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .telamo-hf--card {
        --tlm-hf-panel-padding: 22px;
    }

    .telamo-hf__header--split {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
    }

    .telamo-hf__heading {
        font-size: 23px;
    }

    .telamo-hf__filter-field {
        flex: 1 1 100%;
        border-left: 0;
    }

    .telamo-hf__filter-field + .telamo-hf__filter-field {
        border-left: 0;
        border-top: 1px solid var(--tlm-hf-border);
    }

    .telamo-hf__grid,
    .telamo-hf__grid--cols-2,
    .telamo-hf__grid--cols-3,
    .telamo-hf__grid--cols-4 {
        grid-template-columns: minmax(0, 1fr);
    }

    .telamo-hf__image {
        aspect-ratio: 4 / 3;
    }

    .telamo-hf__footer {
        gap: 16px;
    }

    .telamo-hf__btn {
        width: 100%;
    }
}

/* ─────────────────────────── Live results ─────────────────────────── */

/*
 * The live refresh toggles the footer, the subheading and the "View all results" link with
 * [hidden], and each of those carries a display of its own that would otherwise win.
 */
.telamo-hf [hidden] {
    display: none !important;
}

/*
 * Fading rather than emptying: the previous results stay readable while the next batch is
 * fetched, so dragging the slider never flashes the panel to blank.
 */
.telamo-hf__body {
    transition: opacity 140ms ease;
}

.telamo-hf--results.is-loading .telamo-hf__body {
    opacity: 0.45;
}

@media (prefers-reduced-motion: reduce) {
    .telamo-hf__card::before,
    .telamo-hf__btn,
    .telamo-hf__body {
        transition: none;
    }
}
