/* ==========================================================================
   Hero Carousel — Production Styles
   WCAG 2.2 AA | Fully Responsive (Desktop / Tablet / Mobile)
   Follows project CSS conventions; scoped to .yds-hero-carousel
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Section wrapper — fills the first fold on desktop, adaptive on mobile
   -------------------------------------------------------------------------- */
.yds-hero-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    background: #181109;
}

/* --------------------------------------------------------------------------
   2. Height chain: section → carousel-items → flickity-viewport

   KEY: .flickity-viewport height MUST NOT use !important.
   Flickity's adaptiveHeight sets viewport.style.height via JS (inline style).
   CSS !important beats inline styles → viewport collapses to 0 → black screen.

   Fix: give .carousel-items an explicit 100vh so height:100% on the
   viewport resolves correctly on desktop; let adaptiveHeight win on mobile.
   -------------------------------------------------------------------------- */

/* Give carousel-items the same height as the section so that
   .flickity-viewport { height: 100% } resolves to 100vh on desktop */
.yds-hero-carousel .carousel-items {
    height: 100%;
}

/* NO !important — Flickity's adaptiveHeight JS must be able to override this */
.yds-hero-carousel .flickity-viewport {
    height: 100%;
    min-height: 400px; /* fallback before JS fires */
    transition: height 0.3s ease;
}

/* slider just needs to hold the absolute-positioned cells */
.yds-hero-carousel .flickity-slider {
    height: 100%;
}

/* --------------------------------------------------------------------------
   3. Individual slide
   -------------------------------------------------------------------------- */
.yds-hero-slide {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   4. Slide backgrounds / images
   -------------------------------------------------------------------------- */
.yds-hero-slide--bg {
    /* No background-image here — a <picture> element is used instead.
       CSS custom property url() is resolved relative to the stylesheet,
       not the HTML document, so we avoid that approach entirely. */
    transform: none !important;
    animation: none !important;
}

/* Full-bleed background picture element (Slide 1) */
.yds-hero-slide__bg-picture {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
}
.yds-hero-slide__bg-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.yds-hero-slide--banner {
    padding: 0;
    background: #181109;
}

.yds-hero-slide__picture {
    display: block;
    width: 100%;
    height: 100%;
}

.yds-hero-slide__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transition: transform 0.5s ease;
}

.yds-hero-slide__link {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    text-decoration: none;
}
.yds-hero-slide__link:focus-visible {
    outline: 3px solid #FFD54F;
    outline-offset: -4px;
}
.yds-hero-slide__link:hover .yds-hero-slide__img {
    transform: scale(1.02);
}

/* --------------------------------------------------------------------------
   5. Slide text overlay (Slide 1)
      The text container sits above the absolutely-positioned bg picture.
   -------------------------------------------------------------------------- */

/* Lift the text container above the bg picture on Slide 1 */
.yds-hero-slide--bg .container {
    position: relative;
    z-index: 1;
}

.yds-hero-slide__content {
    position: relative;
    z-index: 5;
    width: 100%;
    text-align: center;
    padding: 130px 24px 60px;
    box-sizing: border-box;
}
.yds-hero-slide__content h2 {
    margin: 0;
    padding: 0;
    text-shadow: 0 3px 16px rgba(0,0,0,0.65);
}

/* --------------------------------------------------------------------------
   6. Prev/Next navigation buttons — vertically centred, >=44px touch target
   -------------------------------------------------------------------------- */
.yds-hero-carousel .flickity-button.flickity-prev-next-button {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 20 !important;
    margin: 0 !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    background: rgba(24,17,9,0.80) !important;
    border: 1.5px solid rgba(255,255,255,0.30) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.45) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease !important;
    opacity: 1 !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button svg {
    width: 20px !important;
    height: 20px !important;
    fill: none !important;
    stroke: #ffffff !important;
    stroke-width: 2.5 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transition: stroke 0.25s ease !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button:hover,
.yds-hero-carousel .flickity-button.flickity-prev-next-button:focus-visible {
    background: #FFD54F !important;
    border-color: #FFD54F !important;
    transform: translateY(-50%) scale(1.08) !important;
    box-shadow: 0 6px 24px rgba(255,213,79,0.45) !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button:hover svg,
.yds-hero-carousel .flickity-button.flickity-prev-next-button:focus-visible svg {
    stroke: #181109 !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button:focus {
    outline: 3px solid #FFD54F !important;
    outline-offset: 2px !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button::before,
.yds-hero-carousel .flickity-button.flickity-prev-next-button::after {
    display: none !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button.previous {
    left: 20px !important;
    right: auto !important;
}
.yds-hero-carousel .flickity-button.flickity-prev-next-button.next {
    right: 20px !important;
    left: auto !important;
}

/* --------------------------------------------------------------------------
   7. Pagination dots
   -------------------------------------------------------------------------- */
.yds-hero-carousel .flickity-page-dots {
    position: absolute !important;
    bottom: 24px !important;
    width: 100% !important;
    text-align: center !important;
    z-index: 20;
    padding: 0;
    margin: 0;
    list-style: none;
}
.yds-hero-carousel .flickity-page-dots .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin: 0 5px;
    background: rgba(255,255,255,0.55);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}
.yds-hero-carousel .flickity-page-dots .dot.is-selected {
    background: #FFD54F !important;
    border-color: #FFD54F;
    transform: scale(1.4);
}
.yds-hero-carousel .flickity-page-dots .dot:focus-visible,
.yds-hero-carousel .flickity-page-dots .dot:focus {
    outline: 3px solid #FFD54F;
    outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   8. Responsive — Tablet & Mobile (<= 991.98px)
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .yds-hero-carousel {
        height: auto !important;
        min-height: 280px;
    }
    /* On mobile carousel-items height must be auto so Flickity's
       adaptiveHeight JS (inline style) can set the viewport height freely */
    .yds-hero-carousel .carousel-items {
        height: auto;
    }
    .yds-hero-carousel .flickity-viewport {
        height: auto;
        min-height: 260px;
        /* transition already declared above in desktop rules */
    }
    .yds-hero-carousel .flickity-slider {
        height: 100%;
    }
    .yds-hero-slide {
        height: auto !important;
        min-height: 260px;
    }
    /* Slide 1: portrait mobile bg — handled by <picture> <source> in HTML */
    .yds-hero-slide--bg {
        min-height: 56vh !important;
        padding-top: 90px !important;
        padding-bottom: 40px !important;
    }
    /* The bg picture still fills the slide absolutely */
    .yds-hero-slide__bg-picture {
        position: absolute !important;
        inset: 0 !important;
    }
    .yds-hero-slide__bg-img {
        object-fit: cover !important;
        height: 100% !important;
    }
    /* Slide 2: landscape banner — same image on all viewports, fill width */
    .yds-hero-slide--banner {
        min-height: 56vh !important; /* match Slide 1 mobile height */
    }
    .yds-hero-slide__picture,
    .yds-hero-slide__link {
        height: 100% !important;
        display: block !important;
    }
    .yds-hero-slide__img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center center !important;
        /* No aspect-ratio override — landscape image fills the slide */
    }
    /* Buttons */
    .yds-hero-carousel .flickity-button.flickity-prev-next-button {
        width: 42px !important;
        height: 42px !important;
    }
    .yds-hero-carousel .flickity-button.flickity-prev-next-button.previous {
        left: 12px !important;
    }
    .yds-hero-carousel .flickity-button.flickity-prev-next-button.next {
        right: 12px !important;
    }
    /* Dots */
    .yds-hero-carousel .flickity-page-dots {
        bottom: 12px !important;
    }
}

@media (max-width: 575.98px) {
    .yds-hero-slide--bg {
        min-height: 60vh !important;
    }
    .yds-hero-carousel .flickity-button.flickity-prev-next-button.previous {
        left: 8px !important;
    }
    .yds-hero-carousel .flickity-button.flickity-prev-next-button.next {
        right: 8px !important;
    }
}

/* --------------------------------------------------------------------------
   9. Single-slide safety: hide nav & pagination
   -------------------------------------------------------------------------- */
.yds-hero-carousel[data-slide-count="1"] .flickity-prev-next-button,
.yds-hero-carousel[data-slide-count="1"] .flickity-page-dots {
    display: none !important;
}

/* --------------------------------------------------------------------------
   10. Reduced-motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .yds-hero-slide__img,
    .yds-hero-slide__link:hover .yds-hero-slide__img {
        transition: none !important;
        transform: none !important;
    }
    .yds-hero-carousel .flickity-slider,
    .yds-hero-carousel .flickity-page-dots .dot,
    .yds-hero-carousel .flickity-button.flickity-prev-next-button {
        transition: none !important;
    }
}

/* --------------------------------------------------------------------------
   11. Visually-hidden helper for screen-reader labels in HTML
   -------------------------------------------------------------------------- */
.yds-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
