/*
 * BootHack carousel — framework-agnostic styles (no Bootstrap CSS dependency).
 * Colours inherit BootHack tokens (--bh-*) when present, with literal fallbacks
 * so the plugin styles correctly under any adapter or standalone.
 */

/* =============================================================================
   Shared control chevron (CSS-drawn — no icon font dependency)
   Used by both the simple and multi-item controls.
============================================================================= */

.bh-carousel__control-icon {
    display: inline-block;
    width: 0.8rem;
    height: 0.8rem;
    border-style: solid;
    border-color: currentColor;
    border-width: 0 0.2rem 0.2rem 0;
}

.bh-carousel__control--prev .bh-carousel__control-icon,
.bh-multi-carousel__control--prev .bh-carousel__control-icon {
    transform: rotate(135deg);
    margin-left: 0.2rem;
}

.bh-carousel__control--next .bh-carousel__control-icon,
.bh-multi-carousel__control--next .bh-carousel__control-icon {
    transform: rotate(-45deg);
    margin-right: 0.2rem;
}

/* =============================================================================
   Simple / single-item carousel (engine: js/boothack-carousel.js)
============================================================================= */

.bh-carousel {
    width: 100%;
}

/*
 * The viewport wraps the track + controls (image and caption overlay) only —
 * indicators sit below it. Shadow/rounding utility classes from the
 * shortcode's `class` attribute land here, so effects hug the image box.
 */
.bh-carousel__viewport {
    position: relative;
    overflow: hidden;
}

.bh-carousel__track {
    display: flex;
    transition: transform 0.6s ease-in-out;
    will-change: transform;
}

.bh-carousel__item {
    position: relative;
    flex: 0 0 100%;
    max-width: 100%;
    min-width: 0;
}

.bh-carousel__item > a {
    display: block;
}

/*
 * Root-prefixed selector on purpose: typography systems (e.g. Tailwind
 * Typography's `.prose :where(img)`) give content images 2em vertical
 * margins, which opens a gap under the image that the caption overlay
 * would span. The extra class outranks those rules and zeroes margins
 * so items fit their media exactly.
 */
.bh-carousel .bh-carousel__item img,
.bh-carousel .bh-carousel__item picture,
.bh-carousel .bh-carousel__item video {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

/*
 * The container must fit its contents exactly: trim the top/bottom margins
 * that themes give headings and paragraphs when they sit at the edges of a
 * slide or caption, so no phantom inner space changes the carousel height.
 */
.bh-carousel__item > :first-child,
.bh-carousel__item > a > :first-child,
.bh-carousel__caption > :first-child {
    margin-top: 0;
}

.bh-carousel__item > :last-child,
.bh-carousel__item > a > :last-child,
.bh-carousel__caption > :last-child {
    margin-bottom: 0;
}

/*
 * Fade variant: stack every item in the same grid cell and crossfade.
 * Unlike absolute positioning, grid stacking means all slides contribute to
 * the track height, so the container always fits its tallest slide and never
 * moves vertically on transitions or while images are still loading.
 */
.bh-carousel--fade .bh-carousel__track {
    display: grid;
    align-items: start;
    transition: none;
}

.bh-carousel--fade .bh-carousel__item {
    grid-area: 1 / 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease-in-out;
}

.bh-carousel--fade .bh-carousel__item.is-active {
    z-index: 1;
    opacity: 1;
    pointer-events: auto;
}

.bh-carousel__caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1.25rem;
    color: #fff;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.6);
}

.bh-carousel__control {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10%;
    min-width: 2.5rem;
    padding: 0;
    color: var(--bh-carousel-control-color, #fff);
    cursor: pointer;
    background: transparent;
    border: 0;
    opacity: 0.75;
    transition: opacity 0.15s ease;
}

.bh-carousel__control:hover,
.bh-carousel__control:focus-visible {
    opacity: 1;
}

.bh-carousel__control:focus-visible {
    outline: 2px dashed currentColor;
    outline-offset: -4px;
}

.bh-carousel__control--prev {
    left: 0;
}

.bh-carousel__control--next {
    right: 0;
}

.bh-carousel__indicators {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 1rem;
    padding: 0;
    list-style: none;
}

.bh-carousel__indicator {
    width: 30px;
    height: 3px;
    padding: 0;
    cursor: pointer;
    background-color: var(--bh-content-link-color, var(--bh-primary, #442a85));
    border: 0;
    border-radius: 5px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.bh-carousel__indicator.is-active {
    opacity: 1;
}

.bh-carousel__indicator:focus-visible {
    outline: 2px dashed currentColor;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .bh-carousel__track,
    .bh-carousel--fade .bh-carousel__item {
        transition: none;
    }
}

/* =============================================================================
   Multi-item carousel (engine: js/boothack-carousel-multi.js)
============================================================================= */

.bh-multi-carousel {
    width: 100%;
}

/* Viewport wraps track + controls; indicators sit below it (see simple). */
.bh-multi-carousel__viewport {
    position: relative;
    overflow-x: hidden;
}

.bh-multi-carousel__track {
    display: flex;
    /* stretch, not center: centred items shift vertically as images load. */
    align-items: stretch;
    gap: 1rem;
    transition: transform 0.6s ease-in-out;
    will-change: transform;
}

.bh-multi-carousel__item {
    box-sizing: border-box;
    position: relative;
    flex: 0 0 calc((100% - (1rem * 3)) / 4);
    scroll-snap-align: start;
    opacity: 1;
    transition: opacity 0.6s ease-in-out;
    overflow: hidden;
}

.bh-multi-carousel__item.is-hidden {
    opacity: 0;
}

.bh-multi-carousel__item > a {
    display: block;
}

/* Descendant selector on purpose: linked slides wrap the image in an <a>,
   and an inline image leaves a baseline gap below it (phantom padding).
   margin: 0 with a root-prefixed selector beats typography-system rules
   (e.g. Tailwind's `.prose :where(img) { margin: 2em 0 }`) — see simple. */
.bh-multi-carousel .bh-multi-carousel__item img,
.bh-multi-carousel .bh-multi-carousel__item picture,
.bh-multi-carousel .bh-multi-carousel__item video {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.bh-multi-carousel__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.75rem;
    color: #fff;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.7);
}

/* Fit contents exactly: no phantom heading/paragraph margins at slide edges. */
.bh-multi-carousel__item > :first-child,
.bh-multi-carousel__item > a > :first-child,
.bh-multi-carousel__caption > :first-child {
    margin-top: 0;
}

.bh-multi-carousel__item > :last-child,
.bh-multi-carousel__item > a > :last-child,
.bh-multi-carousel__caption > :last-child {
    margin-bottom: 0;
}

.bh-multi-carousel__indicators {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    list-style: none;
}

.bh-multi-carousel__indicators button {
    width: 30px;
    height: 3px;
    margin: 0 3px;
    cursor: pointer;
    background-color: var(--bh-content-link-color, var(--bh-primary, #442a85));
    opacity: 0.5;
    border: none;
    transition: opacity 0.6s ease;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.bh-multi-carousel__indicators .is-active {
    opacity: 1;
}

.bh-multi-carousel__control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10%;
    background: transparent;
    border: none;
    color: var(--bh-carousel-control-color, #fff);
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.15s ease;
    padding: 0;
}

.bh-multi-carousel__control:hover,
.bh-multi-carousel__control:focus-visible {
    opacity: 0.9;
}

.bh-multi-carousel__control--prev {
    left: 10px;
    padding-left: 0.5rem;
}

.bh-multi-carousel__control--next {
    right: 10px;
    padding-right: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .bh-multi-carousel__track,
    .bh-multi-carousel__item {
        transition: none;
    }
}

/* Responsive breakpoints */
@media (max-width: 992px) {
    .bh-multi-carousel__item {
        flex: 0 0 calc((100% - (1rem * 2)) / 3);
    }
}

@media (max-width: 768px) {
    .bh-multi-carousel__item {
        flex: 0 0 calc((100% - 1rem) / 2);
    }
}

@media (max-width: 576px) {
    .bh-multi-carousel__item {
        flex: 0 0 100%;
    }
    .bh-multi-carousel__control--prev {
        left: 10px;
    }
    .bh-multi-carousel__control--next {
        right: 10px;
    }
}
