/* SLU Card Stack */

/* ── State model ──────────────────────────────────────────────────────────
   Two classes, deliberately separate:

   is-expanded : panel size, image zoom, overlay. JS applies it the moment a
                 panel is chosen, so the flex animation starts immediately.
   is-active   : content layout (title orientation, description + button
                 shown). JS applies it only AFTER the outgoing content has
                 faded out (is-fading), so every layout jump — writing-mode
                 swap, description expanding — happens while text is invisible.

   PHP renders both classes on the default panel so no-JS / first paint match.
   ──────────────────────────────────────────────────────────────────────── */

/* ── Wrapper ──────────────────────────────────────────────────────────── */
.slu-bs-wrap {
    /* Structural defaults — colours set by Elementor controls */
    --bs-active-flex:      4;
    --bs-inactive-flex:    1;
    --bs-min-size:         60px;
    --bs-height:           500px;
    --bs-duration:         0.8s;
    --bs-easing:           cubic-bezier(0.4, 0, 0.2, 1);
    --bs-radius:           0px;

    /* Content fade timings, all derived from --bs-duration.
       --bs-fade-out-ratio is ALSO read by background-switcher.js to time the
       content swap. Change it here only — the JS follows. */
    --bs-fade-out-ratio:   0.3;
    --bs-fade-out:         calc(var(--bs-duration) * var(--bs-fade-out-ratio));
    --bs-fade-in:          calc(var(--bs-duration) * 0.4);

    display: flex;
    width: 100%;
    height: var(--bs-height);
    border-radius: var(--bs-radius);
    overflow: hidden;
    gap: 0;
}

.slu-bs-wrap.is-vertical {
    flex-direction: column;
}

/* ── Individual panel ─────────────────────────────────────────────────── */
.slu-bs-panel {
    position: relative;
    flex: var(--bs-inactive-flex);
    min-width: var(--bs-min-size);
    min-height: var(--bs-min-size);
    overflow: hidden;
    cursor: pointer;
    transition: flex var(--bs-duration) var(--bs-easing);
}

.slu-bs-panel.is-expanded {
    flex: var(--bs-active-flex);
    cursor: default;
}

/* ── Background image ─────────────────────────────────────────────────── */
/* Start at scale(1) — collapsed panels scale UP to 1.05, expanded scales back to 1.
   This ensures the transition fires on ALL panels including the second one,
   because the state change is always from 1 → 1.05 or 1.05 → 1. */
.slu-bs-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transform: scale(1);
    transition:
        transform var(--bs-duration) var(--bs-easing);
}

.slu-bs-panel:not(.is-expanded) .slu-bs-bg {
    transform: scale(1.05);
}

/* ── Overlay ──────────────────────────────────────────────────────────── */
.slu-bs-overlay {
    position: absolute;
    inset: 0;
    background: var(--bs-overlay-inactive, rgba(0,0,0,0.55));
    transition: background var(--bs-duration) var(--bs-easing);
}

.slu-bs-panel.is-expanded .slu-bs-overlay {
    background: var(--bs-overlay-active, rgba(0,0,0,0.15));
}

/* ── Content ──────────────────────────────────────────────────────────── */
.slu-bs-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px 24px;
    color: var(--bs-content-color, #ffffff);
    z-index: 2;
}

/* ── Title ────────────────────────────────────────────────────────────── */
/* Opacity only — transform is intentionally NOT transitioned, otherwise the
   vertical title's rotate(180deg) visibly spins back as it fades in. */
.slu-bs-title {
    margin: 0 0 10px;
    color: var(--bs-content-color, #ffffff);
    opacity: 1;
    transition: opacity var(--bs-fade-in) var(--bs-easing);
}

/* Inactive horizontal — title pinned to bottom */
.slu-bs-wrap:not(.is-vertical) .slu-bs-panel:not(.is-active) .slu-bs-content {
    justify-content: flex-end;
    align-items: flex-start;
}

/* Inactive horizontal — vertical title option */
.slu-bs-wrap:not(.is-vertical).title-vertical .slu-bs-panel:not(.is-active) .slu-bs-content {
    justify-content: flex-end;
    align-items: center;
}
.slu-bs-wrap:not(.is-vertical).title-vertical .slu-bs-panel:not(.is-active) .slu-bs-title {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    margin: 0;
    white-space: nowrap;
    align-self: center;
}

/* Vertical inactive — title centred */
.slu-bs-wrap.is-vertical .slu-bs-panel:not(.is-active) .slu-bs-content {
    justify-content: center;
}

/* ── Description + button ─────────────────────────────────────────────── */
/* Collapsed with max-height:0 in inactive panels so they take no space.
   max-height is NOT animated — the expand/collapse happens while the content
   is faded out, so active panels can use max-height:none and never clip. */
.slu-bs-desc {
    margin: 0;
    color: var(--bs-content-color);
    max-width: 100%;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--bs-fade-in) var(--bs-easing),
                transform var(--bs-fade-in) var(--bs-easing);
    transition-delay: calc(var(--bs-duration) * 0.12);
}

.slu-bs-btn-wrap {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--bs-fade-in) var(--bs-easing),
                transform var(--bs-fade-in) var(--bs-easing);
    transition-delay: calc(var(--bs-duration) * 0.24);
}

/* Active panel — reveal desc and button (staggered by the delays above) */
.slu-bs-panel.is-active .slu-bs-desc {
    opacity: 1;
    transform: translateY(0);
    max-height: none;
    overflow: visible;
    margin: 0 0 16px;
}

.slu-bs-panel.is-active .slu-bs-btn-wrap {
    opacity: 1;
    transform: translateY(0);
    max-height: none;
    overflow: visible;
}

/* ── Switching — fade out ─────────────────────────────────────────────── */
/* Applied by JS to the outgoing and incoming panels while the content swap is
   pending. Must stay AFTER the is-active reveal rules: same specificity, so
   source order is what makes it win. No delay, shorter duration. */
.slu-bs-panel.is-fading .slu-bs-title,
.slu-bs-panel.is-fading .slu-bs-desc,
.slu-bs-panel.is-fading .slu-bs-btn-wrap {
    opacity: 0;
    transition-duration: var(--bs-fade-out);
    transition-delay: 0s;
}

/* ── Button styles ────────────────────────────────────────────────────── */
.slu-bs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
    white-space: nowrap;
    border: 2px solid transparent;
    background: var(--bs-btn-bg, #ffffff);
    color: var(--bs-btn-color, #111827) !important;
    border-color: var(--bs-btn-border, transparent);
    /* Button typography and spacing deferred to .elementor-button kit styles */
}

.slu-bs-btn:hover {
    background: var(--bs-btn-bg-hover, rgba(255,255,255,0.85));
    color: var(--bs-btn-color-hover, #111827);
    text-decoration: none;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
/* The stacked-view rules are NOT here. The breakpoint is a per-widget control
   (Stack Breakpoint: tablet / mobile_extra / mobile, resolved to px from the
   site's Elementor breakpoints), and a media query can't read a CSS variable.
   Background_Switcher_Widget::stack_css() emits them inline per widget, scoped
   by [data-bs-stack="<px>"]. Edit the stacked layout there. */
