/* =============================================================
   CBC Interactive Bar — Frontend Styles
   Cards sit in a fixed row. The active card scales up in place
   and lifts above its neighbours. Focus moves on hover, via the
   arrows, or via the dots — the row itself never scrolls.
   ============================================================= */

/* ── Bar wrapper ────────────────────────────────────────────── */
.cbcib-bar {
    /* Fallback defaults. The widget's responsive controls override these via
       Elementor's generated CSS, which has higher specificity.
       --cbcib-per-view is deliberately NOT defaulted here: its presence is
       what switches carousel mode on, so it must stay unset until a device
       actually has a "Cards Per View" value. */
    --cbcib-active-scale: 1.12;
    --cbcib-active-opacity: 1;
    --cbcib-inactive-opacity: 1;
    --cbcib-gap: 16px;
    --cbcib-peek: 0px;
    --cbcib-speed: 400ms;

    position: relative;
    width: 100%;
    /* Room for the scaled card to grow without being clipped, plus
       space below for the dots. */
    padding: 40px 30px 46px;
    overflow: visible;
}

/* ── Track (the fixed row) ──────────────────────────────────── */
.cbcib-track {
    display: flex;
    align-items: center;
    gap: var(--cbcib-gap);
}

/* ── Item (flex child; owns the scale) ──────────────────────── */
.cbcib-item {
    flex: 1 1 0;
    min-width: 0;
    transform: scale(1);
    transform-origin: center center;
    opacity: var(--cbcib-inactive-opacity);
    z-index: 1;
    transition: transform var(--cbcib-speed) cubic-bezier(0.4, 0, 0.2, 1),
                opacity   var(--cbcib-speed) ease,
                box-shadow var(--cbcib-speed) ease;
    will-change: transform, opacity;
}

.cbcib-item.is-active {
    transform: scale(var(--cbcib-active-scale, 1.12));
    opacity: var(--cbcib-active-opacity, 1);
    z-index: 10;
}

/* ── Card ───────────────────────────────────────────────────── */
a.cbcib-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.cbcib-card {
    display: block;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    /* A transformed child (the active card's image zoom) can bleed past a
       rounded, overflow-hidden parent in WebKit, which shows up as a corner
       that looks cut off. The mask forces clipping to the rounded shape and
       isolation keeps the stacking context self-contained. */
    -webkit-mask-image: -webkit-radial-gradient(#ffffff, #000000);
    isolation: isolate;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: box-shadow var(--cbcib-speed) ease;
    outline: none;
}

.cbcib-item.is-active .cbcib-card {
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.28);
}

/* Keyboard focus ring on the focusable card. */
.cbcib-card:focus-visible {
    outline: 3px solid rgba(26, 115, 232, 0.85);
    outline-offset: 3px;
}

/* ── Image wrap ─────────────────────────────────────────────── */
.cbcib-card__image-wrap {
    position: relative;
    aspect-ratio: 3 / 4; /* fallback; per-device value comes from the control */
    height: auto;
    overflow: hidden;
    /* Follow the card's rounding rather than carrying a separate value. */
    border-radius: inherit;
}

.cbcib-card__image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s ease;
}

.cbcib-item.is-active .cbcib-card__image-wrap img {
    transform: scale(1.04);
}

/* ── Overlay (solid or gradient — set via inline style) ─────── */
.cbcib-card__overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity var(--cbcib-speed) ease;
}

/* Slightly lighten the overlay on the active card so the focused
   image reads a touch brighter. */
.cbcib-item.is-active .cbcib-card__overlay {
    opacity: 0.85;
}

/* ── Text content box ───────────────────────────────────────── */
.cbcib-card__content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 20px;
    background-color: #ffffff;
    transition: background-color 0.3s ease;
}

.cbcib-card__title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.3;
}

.cbcib-card__descriptor {
    margin: 0;
    font-size: 0.9rem;
    color: #555577;
    line-height: 1.6;
}

/* ── Card icon ──────────────────────────────────────────────── */
.cbcib-card__icon {
    display: block;
    margin-top: 12px;
    font-size: 32px;
    color: #1a73e8;
    line-height: 1;
}

.cbcib-card__icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
    display: inline-block;
    vertical-align: middle;
}

/* ── Navigation arrows ──────────────────────────────────────── */
.cbcib-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    /* Sized explicitly, not from font-size, so the icon width control is the
       single source of truth for how big the chevron reads. */
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease,
                transform 0.2s ease, opacity 0.2s ease;
}

/* No shadow of any kind, in any state. box-shadow alone isn't enough — themes
   commonly apply a drop-shadow filter or text-shadow on button hover, which a
   box-shadow reset won't touch. */
.cbcib-arrow,
.cbcib-arrow:hover,
.cbcib-arrow:focus,
.cbcib-arrow:focus-visible,
.cbcib-arrow:active {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}

.cbcib-arrow:hover {
    transform: translateY(-50%) scale(1.1);
}

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

.cbcib-arrow[disabled] {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* The icon is an SVG sized by width; height follows its own proportions.
   Elementor may render it bare, inside a wrapper <span>, or as an <img>. */
.cbcib-arrow i,
.cbcib-arrow svg,
.cbcib-arrow img {
    display: block;
    pointer-events: none;
    line-height: 1;
}

/* Collapse any wrapper so the sizing lands on the SVG itself. */
.cbcib-arrow span {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    max-width: 100%;
    max-height: 100%;
}

.cbcib-arrow svg {
    width: 30px;
    height: auto;
    /* An SVG with no viewBox has no intrinsic ratio, so `auto` height can
       collapse or balloon — never let it exceed the button. */
    max-width: 100%;
    max-height: 100%;
    fill: currentColor;
    flex-shrink: 0;
}

.cbcib-arrow img {
    width: 30px;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    flex-shrink: 0;
}

.cbcib-arrow i {
    font-size: 30px;
}

/* Default position: flush to the bar edge. The "Horizontal Offset" control
   can push the arrows outside the bar (positive) or inward over the cards
   (negative). */
.cbcib-arrow--prev { left: 0; }
.cbcib-arrow--next { right: 0; }

/* ── Dots (focus indicators) ────────────────────────────────── */
.cbcib-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
}

.cbcib-dot {
    width: 11px;
    height: 11px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: #cccccc;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.cbcib-dot:hover { transform: scale(1.2); }

.cbcib-dot.is-active {
    background-color: #1a73e8;
    transform: scale(1.35);
}

.cbcib-dot:focus-visible {
    outline: 2px solid rgba(26, 115, 232, 0.8);
    outline-offset: 2px;
}

/* ── Editor preview ─────────────────────────────────────────── */
.cbcib-editor-preview .cbcib-item {
    /* Keep transitions calm inside the editor. */
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .cbcib-bar { padding: 32px 22px 40px; }
}

/* Carousel mode — engaged whenever "Cards Per View" is set for the device.
   Cards swipe through the centre with the previous/next peeking in at the
   edges. The container scrolls, but the scrollbar chrome is hidden in every
   engine: the swipe is the affordance, and a visible scrollbar around the
   container is exactly what we're avoiding. */
.cbcib-bar.cbcib-has-carousel .cbcib-track {
    overflow-x: auto;
    /* Paired with overflow-x, the block axis must be hidden rather than
       visible, or the browser turns it into a second scroll container. */
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Symmetric padding is what lets the first and last cards reach the
       centre, and it's what reveals the peek on each side. */
    padding-inline: var(--cbcib-peek, 0px);
    /* Vertical room so card shadows (and any active scale) aren't clipped by
       the hidden block-axis overflow. */
    padding-block: 24px;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* legacy Edge */
}

.cbcib-bar.cbcib-has-carousel .cbcib-track::-webkit-scrollbar {
    display: none;              /* WebKit / Blink */
    width: 0;
    height: 0;
}

.cbcib-bar.cbcib-has-carousel .cbcib-item {
    /* Fallback first: one card per view. If the calc below is unsupported or
       invalid, that declaration is dropped and this still gives a usable
       single-card carousel rather than collapsing the cards. */
    flex: 0 0 100%;
    /* Percentages resolve against the track's content box, which the padding
       above has already reduced by the peek — so no double-subtraction. */
    flex-basis: calc(
        (100% - (var(--cbcib-gap, 16px) * (var(--cbcib-per-view, 1) - 1)))
        / var(--cbcib-per-view, 1)
    );
    max-width: none;
    scroll-snap-align: center;
}

@media (max-width: 767px) {
    .cbcib-bar { padding: 20px 12px 38px; }

    /* Cards are the same size on mobile by default — the centred one is
       distinguished by opacity. Active Card Scale has its own mobile value
       (100%) if you'd rather it grow. */
    .cbcib-bar.cbcib-has-carousel .cbcib-track {
        padding-block: 18px;
    }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cbcib-item,
    .cbcib-card,
    .cbcib-card__image-wrap img,
    .cbcib-card__overlay,
    .cbcib-arrow,
    .cbcib-dot {
        transition: none !important;
    }
}
