/* ============================================
   LISTING CARD + RAIL
   Views/Shared/Components/_ListingCard (article.bl-card) and _ListingRail (section.bl-rail).
   Behaviour: js/app/listing-card.js (photo strip dots/arrows, rail arrows). Loaded by _Layout
   on every page. Image-led and quiet: the photo carries the colour, the text stays ink and grey.
   ============================================ */

/* --- Card ---
   A size container: its body's facts turn compact below 200px (see "Body"). Its width always
   comes from the slot (grid cell, rail item), never from its content. */
.bl-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--color-text-muted);
    container: bl-card / inline-size;
}

/* The photo: a square (1:1, as the cards always were) scroll-snap strip of up to five photos.
   It sits above the stretched title link so a swipe scrolls it; its own (hidden) link makes a
   tap open the listing too. The <img> width/height attributes are square too, so nothing shifts. */
.bl-card__media {
    position: relative;
    z-index: 2;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 14px;
    background-color: var(--color-surface-muted);
    box-shadow: var(--shadow-1);
    isolation: isolate;
}

.bl-card__strip {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    color: inherit;
    text-decoration: none;
    -webkit-overflow-scrolling: touch;
}

.bl-card__strip::-webkit-scrollbar {
    display: none;
}

.bl-card__strip:focus {
    outline: none;
}

.bl-card__photo {
    display: block;
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* No photo at all: a soft brand wash instead of a broken image. */
.bl-card__photo--empty {
    background: linear-gradient(150deg, var(--green-50) 0%, var(--green-200) 100%);
}

/* In a grid a sideways swipe should never turn into the browser's back gesture. In a rail it
   may hand over to the row once the last photo is reached. */
.bl-card--grid .bl-card__strip {
    overscroll-behavior-x: contain;
}

/* Dots: which photo is showing. Decorative (the photos are not announced one by one) and hidden
   until the visitor first scrolls this card's photos (listing-card.js adds .is-browsed to the
   media, which never happens without the script), then they fade in. The active dot grows and
   brightens (scale + opacity, on the motion tokens). Absolutely placed: nothing shifts. */
.bl-card__dots {
    position: absolute;
    bottom: var(--space-2);
    left: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px;
    border-radius: var(--radius-pill);
    pointer-events: none;
    opacity: 0;
    translate: -50% 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}

.bl-card__media.is-browsed .bl-card__dots {
    opacity: 1;
}

.bl-card__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-surface);
    opacity: 0.55;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.35);
    transition: opacity var(--duration-base) var(--ease-out), scale var(--duration-base) var(--ease-out);
}

.bl-card__dot.is-active {
    opacity: 1;
    scale: 1.5;
}

/* Arrows: buttons after the title link in the DOM (tab order: link, arrows, heart), placed over
   the middle of the photo. The photo is square and starts at the card's top, so its middle is
   half the card's width down (50cqw: the card is a size container). Shown only with the script,
   which disables the arrow that has nowhere to go. The button is the 44px hit box; the visible
   disc (::before) is small. Touch screens: always shown, a 22px disc flush with the photo's
   edge. Desktop (below): they fade in while the card is hovered or an arrow has keyboard focus. */
.bl-card__arrow {
    display: none;
}

.bl-cards-js .bl-card__arrow {
    position: absolute;
    top: 50cqw;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--color-ink);
    font-size: 0.5625rem;
    cursor: pointer;
    translate: 0 -50%;
    transition: opacity var(--duration-fast) var(--ease-out), scale var(--press-duration) var(--press-ease);
    -webkit-tap-highlight-color: transparent;
}

.bl-cards-js .bl-card__arrow::before {
    content: "";
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    background-color: var(--color-surface);
    opacity: 0.9;
    box-shadow: var(--shadow-1);
}

.bl-cards-js .bl-card__arrow > i {
    position: relative;
}

.bl-cards-js .bl-card__arrow--prev {
    left: 0;
}

.bl-cards-js .bl-card__arrow--next {
    right: 0;
}

.bl-cards-js .bl-card__arrow:active {
    scale: 0.92;
}

.bl-cards-js .bl-card__arrow:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
}

/* Nothing to go back to / nothing after the last photo. */
.bl-cards-js .bl-card__arrow:disabled {
    opacity: 0;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    /* They grow under the pointer too: a plain press, never the release's bounce (the curve
       can't tell a release from the pointer leaving, and a hover never springs). */
    .bl-cards-js .bl-card__arrow {
        font-size: 0.6875rem;
        opacity: 0;
        transition: opacity var(--duration-fast) var(--ease-out), scale var(--duration-press) var(--ease-out);
    }

    .bl-cards-js .bl-card__arrow--prev {
        left: var(--space-1);
    }

    .bl-cards-js .bl-card__arrow--next {
        right: var(--space-1);
    }

    /* A 28px disc on desktop. */
    .bl-cards-js .bl-card__arrow::before {
        inset: 8px;
    }

    .bl-cards-js .bl-card:hover .bl-card__arrow:not(:disabled),
    .bl-cards-js .bl-card:has(.bl-card__arrow:focus-visible) .bl-card__arrow:not(:disabled) {
        opacity: 1;
    }

    .bl-cards-js .bl-card__arrow:hover {
        scale: 1.08;
    }

    .bl-cards-js .bl-card__arrow:hover::before {
        opacity: 1;
    }

    .bl-cards-js .bl-card__arrow:active {
        scale: 0.94;
    }
}

/* --- Save heart (favorites.js toggles .active, the icon and the label) --- */
.bl-card .favorite-btn.bl-card__save {
    position: absolute;
    top: var(--space-1);
    right: var(--space-1);
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    box-shadow: none;
    color: var(--color-ink);
    font-size: 15px;
    opacity: 1;
    pointer-events: auto;
    -webkit-text-stroke: 0;
    transform: none;
    transition: scale var(--press-duration) var(--press-ease);
}

/* The visible disc is smaller than the 44px tap target. */
.bl-card .favorite-btn.bl-card__save::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background-color: var(--color-surface);
    opacity: 0.92;
    box-shadow: var(--shadow-1);
}

.bl-card .favorite-btn.bl-card__save > i {
    position: relative;
}

.bl-card .favorite-btn.bl-card__save.active {
    color: var(--color-danger);
}

.bl-card .favorite-btn.bl-card__save:active {
    scale: 0.92;
}

.bl-card .favorite-btn.bl-card__save:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
}

/* One pop when a listing is saved (favorites.js adds .is-popping). */
@keyframes bl-heart-pop {
    0% { scale: 1; }
    40% { scale: 1.3; }
    100% { scale: 1; }
}

.bl-card .favorite-btn.bl-card__save.is-popping > i {
    animation: bl-heart-pop 0.35s var(--ease-out);
}

/* Desktop: as before the redesign, the heart waits for the card to be hovered (or focused, or
   saved), fades in, and grows under the pointer. Touch screens always show it (:hover sticks
   after a tap there). */
@media (hover: hover) and (pointer: fine) {
    .bl-card .favorite-btn.bl-card__save {
        opacity: 0;
        transition: opacity var(--duration-fast) var(--ease-out), scale var(--duration-fast) var(--ease-out);
    }

    .bl-card:hover .favorite-btn.bl-card__save,
    .bl-card:focus-within .favorite-btn.bl-card__save,
    .bl-card .favorite-btn.bl-card__save.active {
        opacity: 1;
    }

    .bl-card .favorite-btn.bl-card__save::before {
        opacity: 0.7;
        transition: opacity var(--duration-fast) var(--ease-out);
    }

    .bl-card .favorite-btn.bl-card__save:hover {
        scale: 1.1;
    }

    .bl-card .favorite-btn.bl-card__save:hover::before {
        opacity: 0.96;
    }

    .bl-card .favorite-btn.bl-card__save:active {
        scale: 0.95;
    }
}

/* --- New Year icon on the photo (newyear.css styles it) ---
   Top left, as before the redesign; the heart owns the top right, so the two never meet (the
   narrowest card is 155px). Mirrors the heart's 34px disc (9px from its corner): the 28px icon
   is centred on the same line. Shown only while the listing is still free for New Year's. */
.bl-card .bl-card__media .ny-badge {
    top: 12px;
    right: auto;
    left: 12px;
}

/* --- Body ---
   The title on its own line, then one wrapping row of facts with the price at its end: the
   facts list is display: contents, so its items and the price share the body's flex lines. The
   price (margin-left: auto) sits on the right next to the last fact, or on the right of the next
   line when they don't fit; a New Year offer sits in the same place. The card is
   a size container (.bl-card, above), so a narrow card (under 200px) shows compact facts. */
.bl-card__body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--space-3);
    padding: var(--space-3) 2px 0;
}

.bl-card__title {
    flex: 0 0 100%;
    min-width: 0;
    margin: 0 0 var(--space-1);
    overflow: hidden;
    color: var(--color-ink);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Verified listings: the seal (Components/_VerifiedSeal) right after "{Type} in {City}".
   The title turns into a row so a long name still truncates with an ellipsis while the seal
   stays whole at its end. The link's ::after keeps covering the card (its containing block is
   the card, so the link's own overflow doesn't clip it). */
.bl-card__title--verified {
    display: flex;
    align-items: center;
    gap: 5px;
}

.bl-card__title--verified .bl-card__link {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bl-card__verified {
    display: inline-flex;
    flex: none;
}

/* The title link covers the whole card: one tab stop, one target. */
.bl-card__link {
    color: inherit;
    text-decoration: none;
}

.bl-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: 14px;
}

.bl-card__link:hover,
.bl-card__link:focus {
    color: inherit;
    text-decoration: none;
}

.bl-card__link:focus-visible {
    outline: none;
}

.bl-card__link:focus-visible::after {
    outline: 2px solid var(--color-focus);
    outline-offset: 4px;
}

/* Its items join the body's row (see above); the list keeps the font for them. */
.bl-card__facts {
    display: contents;
    font-size: 0.875rem;
    line-height: 1.4;
    list-style: none;
}

.bl-card__facts li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.bl-card__facts i {
    width: 1em;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

/* "$120 for 1 night", amount bold, at the end of the facts row, on the right. */
.bl-card__price {
    margin-left: auto;
    text-align: right;
}

.bl-card__rate {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: nowrap;
}

.bl-card__rate strong {
    color: var(--color-ink);
    font-size: 1rem;
    font-weight: 700;
}

/* The New Year offer takes the price's place (end of the facts line, on the right); newyear.css
   makes it gold. */
.bl-card__price--offer .ny-offer {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
}

.bl-card__price--offer .ny-offer strong {
    font-size: 1rem;
}

/* Narrow cards (phone rails, the two-column phone grid): a slightly smaller title and price, and
   compact facts: the icon and the number (data-short, as content with empty alt text so it is
   never read out), the long text ("3 bedrooms") hidden visually only. */
@container bl-card (max-width: 199.98px) {
    .bl-card__title {
        font-size: 0.9375rem;
    }

    .bl-card__body {
        column-gap: var(--space-2);
    }

    .bl-card__facts {
        font-size: 0.8125rem;
    }

    .bl-card__facts li[data-short] {
        gap: 4px;
    }

    .bl-card__facts li[data-short]::after {
        content: attr(data-short) / "";
    }

    .bl-card__facts li[data-short] .bl-card__fact-long {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .bl-card__rate,
    .bl-card__price--offer .ny-offer {
        font-size: 0.8125rem;
    }

    .bl-card__rate strong,
    .bl-card__price--offer .ny-offer strong {
        font-size: 0.9375rem;
    }
}

/* One quiet lift on desktop hover; :hover sticks after a tap, so pointer devices only. */
@media (hover: hover) and (pointer: fine) {
    .bl-card {
        transition: translate var(--duration-base) var(--ease-out);
    }

    .bl-card:hover {
        translate: 0 -3px;
    }
}

/* ============================================
   RAIL: a titled, horizontally scrolling row of cards
   ============================================ */
.bl-rail {
    width: 100%;
    max-width: calc(var(--page-max) + 2 * var(--gutter));
    margin: 0 auto;
    padding: var(--space-6) var(--gutter) 0;
}

/* Inside a page's own column (a rail in main, e.g. the listing page's "More places in …"): the
   column already has the page width and gutters, so the rail adds none and its heading lines up
   with the page content. Home rails sit straight in body and keep their own frame. */
main .bl-rail {
    max-width: none;
    padding-inline: 0;
}

/* Header: the h2 on the left and View all on the right of one line, vertically centred, close
   above the cards (the 44px View all sets the line's height); a subtitle, when there is one,
   on the line under them. Whatever else sits in the header (the Recently viewed Clear button,
   moved in by recently-viewed.js) takes View all's place. A long title wraps, balanced, beside
   View all rather than pushing it to a line of its own. */
.bl-rail .bl-rail__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--space-4);
    margin: 0;
    padding: 0;
}

.bl-rail .bl-rail__header > * {
    grid-row: 1;
    grid-column: 2;
}

.bl-rail .bl-rail__header > h2 {
    grid-column: 1;
    min-width: 0;
    margin: 0;
    color: var(--color-ink);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-wrap: balance;
}

.bl-rail .bl-rail__header > .bl-rail__subtitle {
    grid-row: 2;
    grid-column: 1 / -1;
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.bl-rail .bl-rail__all {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--green-700);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.bl-rail .bl-rail__all:hover {
    color: var(--green-800);
    text-decoration: underline;
}

.bl-rail .bl-rail__all:focus-visible {
    border-radius: var(--radius-sm);
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.bl-rail .bl-rail__wrapper {
    position: relative;
}

/* The track bleeds to the screen edges on phones, so the next card peeks in. */
.bl-rail .bl-rail__track {
    display: flex;
    gap: var(--space-3);
    margin: 0 calc(-1 * var(--gutter));
    /* Room for the cards' hover lift and focus ring, which the scroller would otherwise clip. */
    padding: var(--space-2) var(--gutter) var(--space-4);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}

.bl-rail .bl-rail__track::-webkit-scrollbar {
    display: none;
}

/* Rail cards keep the fixed widths the home rows had before the redesign (155 / 180 / 210 /
   220 / 250px, gaps 12 / 16 / 20px), so a phone shows two cards and a bit. */
.bl-rail .bl-rail__item {
    flex: 0 0 155px;
    min-width: 0;
    scroll-snap-align: start;
}

.bl-rail .bl-card--rail {
    width: auto;
    margin: 0;
}

/* Arrows: desktop pointer only (a finger or trackpad scrolls the row). */
.bl-rail .bl-rail__arrow {
    display: none;
}

@media (min-width: 768px) {
    .bl-rail {
        padding-top: var(--space-8);
    }

    .bl-rail .bl-rail__header {
        margin-bottom: var(--space-1);
    }

    .bl-rail .bl-rail__header > h2 {
        font-size: 1.75rem;
    }

    .bl-rail .bl-rail__track {
        gap: var(--space-4);
    }

    .bl-rail .bl-rail__item {
        flex-basis: 180px;
    }
}

@media (min-width: 992px) {
    .bl-rail .bl-rail__track {
        gap: var(--space-5);
    }

    .bl-rail .bl-rail__item {
        flex-basis: 210px;
    }
}

@media (min-width: 1024px) {
    /* Aligned with the header, with just enough inner room for the focus ring. */
    .bl-rail .bl-rail__track {
        margin: 0 calc(-1 * var(--space-2));
        padding-inline: var(--space-2);
        scroll-padding-inline: var(--space-2);
    }
}

@media (min-width: 1200px) {
    .bl-rail .bl-rail__item {
        flex-basis: 220px;
    }
}

@media (min-width: 2100px) {
    .bl-rail .bl-rail__item {
        flex-basis: 250px;
    }
}

@media (hover: hover) and (pointer: fine) {
    .bl-cards-js .bl-rail .bl-rail__arrow {
        position: absolute;
        /* Roughly centred on the square photos, below the track's top padding. */
        top: calc(var(--space-2) + 36%);
        z-index: 4;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 1px solid var(--color-border-light);
        border-radius: 50%;
        background-color: var(--color-surface);
        color: var(--color-ink);
        box-shadow: var(--shadow-1);
        cursor: pointer;
        opacity: 0;
        translate: 0 -50%;
        transition: opacity var(--duration-fast) var(--ease-out), scale var(--press-duration) var(--press-ease);
    }

    .bl-cards-js .bl-rail .scroll-arrow-left {
        left: calc(-1 * var(--space-5));
    }

    .bl-cards-js .bl-rail .scroll-arrow-right {
        right: calc(-1 * var(--space-5));
    }

    .bl-cards-js .bl-rail .bl-rail__wrapper:hover .bl-rail__arrow:not(.hidden) {
        opacity: 1;
    }

    .bl-cards-js .bl-rail .bl-rail__arrow:active {
        scale: 0.94;
    }

    .bl-cards-js .bl-rail .bl-rail__arrow.hidden {
        opacity: 0;
        pointer-events: none;
    }
}

/* 1840px = --page-max (1760) + two 16px gutters + room for the arrows outside the row (media
   queries can't read the token: keep the two in step). */
@media (hover: hover) and (pointer: fine) and (max-width: 1840px) {
    /* No room outside the row: tuck the arrows inside its edges. */
    .bl-cards-js .bl-rail .scroll-arrow-left {
        left: var(--space-2);
    }

    .bl-cards-js .bl-rail .scroll-arrow-right {
        right: var(--space-2);
    }
}

/* Reduced motion: no lift, no pop, no growing, no smooth scrolling; fades stay short. */
@media (prefers-reduced-motion: reduce) {
    .bl-card,
    .bl-card__dots,
    .bl-card__arrow,
    .bl-rail .bl-rail__arrow {
        transition: opacity var(--duration-fast) linear;
    }

    /* The dots just switch. */
    .bl-card__dot {
        transition: none;
    }

    .bl-cards-js .bl-card__arrow:hover {
        scale: none;
    }

    .bl-card:hover {
        translate: none;
    }

    .bl-card .favorite-btn.bl-card__save.is-popping > i {
        animation: none;
    }

    /* The heart still fades in on desktop, but doesn't grow. */
    .bl-card .favorite-btn.bl-card__save {
        transition: opacity var(--duration-fast) linear;
    }

    .bl-card .favorite-btn.bl-card__save:hover {
        scale: none;
    }

    .bl-card__strip,
    .bl-rail .bl-rail__track {
        scroll-behavior: auto;
    }
}
