/* ---------------------------------------------------------------------------
   Holiday carousel

   The cards stay in the same .lmhp-holiday-grid they have always been in; this
   sheet only turns that grid into a single horizontal scroll-snap row and adds
   the controls around it. Scrolling, momentum, swipe and rubber-banding are the
   browser's own, so the row still works with the script blocked or still
   loading — it is simply a strip you can scroll. The script adds the arrows,
   the dots and the tidy page-at-a-time stepping on top.

   Loaded after frontend-holiday-ui.css. Two rules there use !important on the
   grid (.lmhp-holiday-grid at the phone breakpoints), which is why the column
   declarations here have to as well.
   --------------------------------------------------------------------------- */

.lmhp-carousel {
    /* How many cards fit in the viewport. PHP writes --lmhp-per-view-max from
       the shortcode / setting; the breakpoints below only ever step it *down*,
       so a carousel set to 3 never becomes 4 on a wide screen. */
    --lmhp-per-view: min(var(--lmhp-per-view-max, 4), 4);
    --lmhp-carousel-gap: 22px;
    --lmhp-carousel-card: calc(
        (100% - (var(--lmhp-carousel-gap) * (var(--lmhp-per-view) - 1))) / var(--lmhp-per-view)
    );

    position: relative;
    display: grid;
    gap: 4px;
}

.lmhp-carousel__viewport {
    position: relative;
}

.lmhp-carousel .lmhp-holiday-grid--carousel {
    display: grid;
    grid-auto-flow: column;
    /* grid-template-columns from the base sheet would keep wrapping the cards
       into rows, and it is !important inside the phone media queries. */
    grid-template-columns: none !important;
    grid-auto-columns: var(--lmhp-carousel-card);
    gap: var(--lmhp-carousel-gap) !important;
    justify-content: start;
    align-items: stretch;

    overflow-x: auto;
    overflow-y: hidden;
    /* Swiping the carousel to its end should not then drag the page sideways
       or trigger the browser's back gesture. */
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;

    /* An overflow-x scroller cannot leave overflow-y visible, so the card's
       hover lift and its drop shadow would be sliced off at the top and bottom.
       This is the room they need. Padding stays off the inline axis: the step
       maths reads clientWidth as "one full page of cards". */
    padding: 10px 0 30px;

    scrollbar-width: none;
}

.lmhp-carousel .lmhp-holiday-grid--carousel::-webkit-scrollbar {
    display: none;
}

/* While the script is driving the row to the next page. Mandatory snapping and
   a scripted scroll pull against each other, and the tug shows. The script
   lands on a card edge anyway, so snapping has nothing to correct when it comes
   back on at the end. */
.lmhp-carousel .lmhp-holiday-grid--carousel.is-gliding {
    scroll-snap-type: none;
}

.lmhp-carousel .lmhp-holiday-grid--carousel > .lmhp-card {
    scroll-snap-align: start;
    /* Cards are equal height already — one grid row stretches them all — but a
       min-width of 0 stops a long unbroken word widening a column. */
    min-width: 0;
}

/* Nothing to scroll: no controls, and no scroll-snap to fight. */
.lmhp-carousel.is-static .lmhp-carousel__arrow,
.lmhp-carousel.is-static .lmhp-carousel__dots {
    display: none;
}

.lmhp-carousel.is-static .lmhp-holiday-grid--carousel {
    justify-content: center;
    scroll-snap-type: none;
}

/* ---------------------------------------------------------------------------
   Arrows

   Overlaid on the outer cards rather than parked beside them, so all of the
   container's width goes to the cards. Hidden until the script is ready, so a
   visitor never gets a dead button.
   --------------------------------------------------------------------------- */

/* These are the theme's buttons as far as the theme is concerned, and a theme
   with opinions about buttons — Hello Elementor and every builder on top of it —
   will happily hand them its own radius, border and padding. Hence !important on
   the shape: none of it is negotiable for a round arrow over a photo. */
.lmhp-carousel .lmhp-carousel__arrow {
    position: absolute;
    top: 50%;
    /* Centre on the cards, not on the viewport box: the track's 10px top and
       30px bottom padding sit the cards' true middle 10px higher. */
    transform: translateY(-50%) translateY(-10px);
    z-index: 3;

    display: none;
    place-items: center;
    box-sizing: border-box;
    width: 46px !important;
    height: 46px !important;
    min-width: 0;
    min-height: 0;
    padding: 0 !important;
    border: 1px solid var(--lmhp-border) !important;
    border-radius: 999px !important;
    background: var(--lmhp-surface) !important;
    color: var(--lmhp-ink) !important;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease, background 180ms ease;
}

.lmhp-carousel.is-ready .lmhp-carousel__arrow {
    display: grid;
}

.lmhp-carousel .lmhp-carousel__arrow--prev {
    left: 8px;
}

.lmhp-carousel .lmhp-carousel__arrow--next {
    right: 8px;
}

.lmhp-carousel .lmhp-carousel__arrow svg {
    width: 20px;
    height: 20px;
    display: block;
}

.lmhp-carousel .lmhp-carousel__arrow:hover {
    background: var(--lmhp-accent) !important;
    color: #fff !important;
    border-color: var(--lmhp-accent) !important;
    /* Re-state the centring: a bare scale() would drop it and the arrow would
       jump half its own height on hover. */
    transform: translateY(-50%) translateY(-10px) scale(1.06);
    box-shadow: 0 14px 32px rgba(var(--lmhp-accent-rgb), 0.32);
}

.lmhp-carousel .lmhp-carousel__arrow:focus-visible {
    outline: 2px solid var(--lmhp-accent);
    outline-offset: 3px;
}

/* Faded rather than removed, so the row does not shift by 46px the moment you
   reach an end. */
.lmhp-carousel .lmhp-carousel__arrow[disabled] {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateY(-10px) scale(0.9);
}

/* ---------------------------------------------------------------------------
   Dots — one per page of cards, not one per card.
   --------------------------------------------------------------------------- */

.lmhp-carousel__dots {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: -6px;
}

.lmhp-carousel.is-ready .lmhp-carousel__dots {
    display: flex;
}

/* Same story as the arrows: without !important a theme's button rules turn
   these into little rounded rectangles. */
.lmhp-carousel .lmhp-carousel__dot {
    box-sizing: border-box;
    width: 9px !important;
    height: 9px !important;
    min-width: 0;
    min-height: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: rgba(15, 23, 42, 0.18) !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: width 260ms ease, background 260ms ease;
}

.lmhp-carousel .lmhp-carousel__dot:hover {
    background: rgba(15, 23, 42, 0.34) !important;
}

.lmhp-carousel .lmhp-carousel__dot[aria-current="true"] {
    width: 28px !important;
    background: var(--lmhp-accent) !important;
}

.lmhp-carousel .lmhp-carousel__dot:focus-visible {
    outline: 2px solid var(--lmhp-accent);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------------------
   Responsive: step the count down, never up. At phone width one card sits with
   a sliver of the next one showing, which says "there is more" better than any
   arrow does.
   --------------------------------------------------------------------------- */

@media (max-width: 1100px) {
    .lmhp-carousel {
        --lmhp-per-view: min(var(--lmhp-per-view-max, 4), 3);
    }
}

@media (max-width: 860px) {
    .lmhp-carousel {
        --lmhp-per-view: min(var(--lmhp-per-view-max, 4), 2);
        --lmhp-carousel-gap: 18px;
    }
}

@media (max-width: 620px) {
    .lmhp-carousel {
        --lmhp-per-view: 1;
        --lmhp-carousel-gap: 16px;
        --lmhp-carousel-card: calc(100% - 44px);
    }

    .lmhp-carousel .lmhp-carousel__arrow {
        width: 40px !important;
        height: 40px !important;
    }

    .lmhp-carousel .lmhp-carousel__arrow--prev {
        left: 2px;
    }

    .lmhp-carousel .lmhp-carousel__arrow--next {
        right: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lmhp-carousel .lmhp-carousel__arrow,
    .lmhp-carousel .lmhp-carousel__dot {
        transition: none;
    }

    /* Still centred — only the scale goes. */
    .lmhp-carousel .lmhp-carousel__arrow:hover {
        transform: translateY(-50%) translateY(-10px);
    }
}
