/*
 * Botcrawl Homepage Hero Slider
 * Loads only when enabled.
 */

/*
 * CLS fix: lock the slider to a stable height so auto-advance never causes layout shift.
 *
 * The root cause of the CLS cluster at ~8-9 s (the first autoplay tick) is that
 * fade mode keeps the active slide in normal flow (position:relative) while all
 * other slides are position:absolute. If slide 2 has different content height
 * than slide 1, the viewport height changes, pushing every element below the
 * slider (.bc-section, pagination, etc.) — recorded as a layout shift.
 *
 * Strategy:
 *  1. CSS gives the slider root a hard height via --bc-slider-height (set by JS
 *     in the same animation frame as the first paint). This is NOT min-height —
 *     it must be an exact height so it never grows or shrinks.
 *  2. The viewport fills the root 100% and clips overflow.
 *  3. contain: layout isolates internal relayouts from the page.
 *  4. Dots and arrows are position:absolute inside the slider root (which now
 *     has a stable height), so they never shift.
 */
.bc-hero-slider {
    position: relative;
    height: var(--bc-slider-height, 400px);
    contain: layout;
    border-radius: var(--bc-radius);
    overflow: hidden;
}

@media (max-width: 768px) {
    .bc-hero-slider {
        height: var(--bc-slider-height, 280px);
    }
}

.bc-hero-slider__viewport {
    height: 100%;
    overflow: hidden;
}

.bc-hero-slider__track {
    display: flex;
    width: 100%;
    transition: transform var(--bc-hero-slider-transition, 500ms) ease;
    will-change: transform;
}

.bc-hero-slider__slide {
    flex: 0 0 100%;
}

/* Fade mode */
.bc-hero-slider--fade .bc-hero-slider__track {
    position: relative;
    display: block;
    width: 100%;
    /* Track fills the viewport exactly so absolute slides have a stable reference. */
    height: 100%;
    transition: none;
}

.bc-hero-slider--fade .bc-hero-slider__slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--bc-hero-slider-transition, 500ms) ease;
}

.bc-hero-slider--fade .bc-hero-slider__slide.is-active {
    opacity: 1;
    pointer-events: auto;
    /* Keep in absolute flow (not relative) so height never changes during transition. */
    position: absolute;
}

/* Arrows */
.bc-hero-slider__arrows {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    pointer-events: none;
    z-index: 10;
}

.bc-hero-slider__btn {
    pointer-events: auto;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.45);
    color: rgba(255, 255, 255, 0.92);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.bc-hero-slider__btn:hover {
    background: rgba(0, 0, 0, 0.58);
    border-color: rgba(255, 255, 255, 0.28);
    transform: scale(1.03);
}

.bc-hero-slider__btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* Dots - Fixed positioning for proper display on all screen sizes */
.bc-hero-slider__dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 32px; /* Increased from 18px for better visibility on desktop */
    display: flex;
    justify-content: center;
    gap: 8px;
    pointer-events: auto;
    z-index: 10;
    padding: 0 1rem; /* Add padding to prevent edge clipping */
}

/* Mobile: Adjust dots position to be lower and more visible */
@media (max-width: 768px) {
    .bc-hero-slider__dots {
        bottom: 20px; /* Lower position on mobile for better visibility */
    }
}

/* Hide slider arrows on mobile when requested. */
@media (max-width: 768px) {
  .bc-hero-slider--no-arrows-mobile .bc-hero-slider__arrows { display: none; }
}

/* Hide slider dots on mobile when requested. */
@media (max-width: 768px) {
  .bc-hero-slider--no-dots-mobile .bc-hero-slider__dots { display: none; }
}

/* Stabilize slide height by clamping hero typography inside the slider. */
.bc-hero-slider .bc-hero__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.bc-hero-slider .bc-hero__excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.bc-hero-slider__dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    padding: 0;
}

.bc-hero-slider__dot.is-active,
.bc-hero-slider__dot[aria-current="true"] {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(255, 255, 255, 0.34);
}

.bc-hero-slider__dot:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 3px;
}

@media (max-width: 768px) {
    .bc-hero-slider__arrows {
        padding: 0 8px;
    }

    .bc-hero-slider__btn {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bc-hero-slider__track,
    .bc-hero-slider--fade .bc-hero-slider__slide {
        transition: none;
    }
}
