/* =========================================================
   Centrix Showreel Carousel
   Full-bleed 16:9 image carousel. Markup: template-parts/showreel.php
   Behaviour: assets/js/showreel.js
   ========================================================= */

.cx-carousel {
    position: relative;
    z-index: 10;
    --cx-ease: cubic-bezier(0.76, 0, 0.24, 1);
    --cx-speed: 900ms;
}

.cx-stagewrap {
    position: relative;
}

/* Stage */
.cx-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #0B1526;
    isolation: isolate;
    touch-action: pan-y;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
}

.cx-stage.is-grabbing {
    cursor: grabbing;
}

/* Phones in portrait, when a dedicated portrait image set has been supplied:
   take the shape of those images so they are shown whole.

   This media query MUST stay identical to $mobile_media in
   template-parts/showreel.php — that is what decides which image the browser
   downloads. If the two drift apart you get a portrait photo in a widescreen
   frame, or the reverse. */
@media (max-width: 767px) and (orientation: portrait) {
    .cx-carousel.has-mobile-art .cx-stage {
        aspect-ratio: var(--cx-mobile-ratio, 4 / 5);
    }
}

/* Landscape viewports are wide enough that a 16:9 frame covers them with
   only a sliver trimmed, so fill the screen outright. Portrait phones are
   not — there, hold the native 16:9 so the shot stays readable.

   Declared after the portrait rule so that on a short landscape window (which
   can match both) filling the viewport wins. */
@media (orientation: landscape) {
    .cx-stage {
        aspect-ratio: auto;
        height: 100vh;
        height: 100svh;
    }
}

/* Slides */
.cx-slide {
    position: absolute;
    inset: 0;
    margin: 0;
    overflow: hidden;
    z-index: 1;
    clip-path: inset(0 0 0 100%);
    transition: clip-path var(--cx-speed) var(--cx-ease);
}

/* Only hint the compositor while a wipe is actually in flight — a permanent
   will-change keeps every slide on its own layer and can leave the first
   one unpainted. */
.cx-carousel.is-animating .cx-slide {
    will-change: clip-path;
}

.cx-slide.is-leaving {
    clip-path: inset(0 0 0 0);
    z-index: 2;
}

.cx-slide.is-active {
    clip-path: inset(0 0 0 0);
    z-index: 3;
}

.cx-slide__shot {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
}

/* Every slide is 16:9 and the stage is filled edge to edge, so cover
   only ever trims the overflow axis — never letterboxes. */
.cx-slide__img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.cx-slide__caption {
    position: absolute;
    left: 24px;
    bottom: 104px;
    z-index: 5;
    max-width: 62%;
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 600ms var(--cx-ease) 250ms, transform 600ms var(--cx-ease) 250ms;
}

.cx-slide.is-active .cx-slide__caption {
    opacity: 1;
    transform: translateY(0);
}

/* Legibility veil */
.cx-veil {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background:
        linear-gradient(to top, rgba(11, 21, 38, 0.78) 0%, rgba(11, 21, 38, 0.18) 34%, rgba(11, 21, 38, 0) 58%),
        linear-gradient(to right, rgba(11, 21, 38, 0.32) 0%, rgba(11, 21, 38, 0) 45%);
}

/* Counter */
.cx-counter {
    position: absolute;
    left: 20px;
    bottom: 52px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.18em;
    pointer-events: none;
}

.cx-counter__now {
    font-size: 22px;
    line-height: 1;
    letter-spacing: 0;
    color: #FF5F06;
    display: inline-block;
    min-width: 30px;
}

.cx-counter__now.is-flip {
    animation: cxFlip 520ms var(--cx-ease);
}

@keyframes cxFlip {
    0% {
        /* never fully transparent, so the number can't vanish on a dropped frame */
        opacity: 0.2;
        transform: translateY(60%);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.cx-counter__rule {
    width: 26px;
    height: 1px;
    background: rgba(255, 255, 255, 0.45);
}

.cx-counter__all {
    opacity: 0.75;
}

/* Line the overlay controls up with the page's content gutters */
@media (min-width: 640px) {
    .cx-counter {
        left: 40px;
        bottom: 60px;
    }

    .cx-counter__now {
        font-size: 28px;
        min-width: 38px;
    }
}

@media (min-width: 1024px) {
    .cx-counter {
        left: 80px;
        bottom: 68px;
    }
}

/* Arrows */
.cx-nav {
    position: absolute;
    right: 18px;
    bottom: 50px;
    z-index: 6;
    display: flex;
    gap: 8px;
}

@media (min-width: 640px) {
    .cx-nav {
        right: 40px;
        bottom: 58px;
    }
}

@media (min-width: 1024px) {
    .cx-nav {
        right: 80px;
        bottom: 66px;
    }
}

.cx-arrow {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
    transition: background 300ms ease, border-color 300ms ease, transform 300ms var(--cx-ease);
}

.cx-arrow:hover {
    background: #FF5F06;
    border-color: #FF5F06;
}

.cx-arrow:active {
    transform: scale(0.92);
}

.cx-arrow:focus-visible {
    outline: 2px solid #FF5F06;
    outline-offset: 3px;
}

.cx-arrow .material-symbols-outlined {
    font-size: 20px;
}

@media (min-width: 640px) {
    .cx-arrow {
        width: 48px;
        height: 48px;
    }
}

/* Progress rail — overlaid on the image, pinned to the bottom edge */
.cx-rail-wrap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    padding: 0 24px 18px;
}

@media (min-width: 640px) {
    .cx-rail-wrap {
        padding: 0 40px 22px;
    }
}

@media (min-width: 1024px) {
    .cx-rail-wrap {
        padding: 0 80px 26px;
    }
}

.cx-rail {
    display: flex;
    gap: 6px;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

.cx-tick {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 20px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cx-tick::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.3);
    transition: height 300ms var(--cx-ease), background-color 300ms ease;
}

.cx-tick:hover::before {
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
}

.cx-tick:focus-visible {
    outline: 2px solid #FF5F06;
    outline-offset: 2px;
}

.cx-tick.is-active::before {
    height: 4px;
}

.cx-tick__fill {
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 2px;
    background: #FF5F06;
    transform: translateY(-50%) scaleX(0);
    transform-origin: left center;
    transition: height 300ms var(--cx-ease);
}

.cx-tick.is-active .cx-tick__fill {
    height: 4px;
}

.cx-tick.is-done .cx-tick__fill {
    transform: translateY(-50%) scaleX(1);
    background: rgba(255, 255, 255, 0.55);
}

.cx-tick.is-active .cx-tick__fill.is-running {
    animation: cxFill var(--cx-dur, 5200ms) linear forwards;
}

.cx-carousel.is-paused .cx-tick__fill.is-running {
    animation-play-state: paused;
}

@keyframes cxFill {
    from {
        transform: translateY(-50%) scaleX(0);
    }

    to {
        transform: translateY(-50%) scaleX(1);
    }
}

/* Screen-reader-only live region (theme relies on Tailwind's sr-only, this is a fallback) */
.cx-live {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion: no wipes, no autoplay */
@media (prefers-reduced-motion: reduce) {

    .cx-slide,
    .cx-slide__caption {
        transition-duration: 1ms !important;
    }

    .cx-slide {
        clip-path: none !important;
        opacity: 0;
        visibility: hidden;
    }

    .cx-slide.is-active {
        opacity: 1;
        visibility: visible;
    }

    .cx-tick.is-active .cx-tick__fill.is-running {
        animation: none;
        transform: translateY(-50%) scaleX(1);
    }
}

/* =========================================================
   Carousel — responsive vertical gap
   Applied to both the homepage instance (.cx-showreel--homepage)
   and every auto-placed instance on other pages (.centrix-showreel--auto).
   Adds breathing room between adjacent sections at every breakpoint.
   ========================================================= */

.cx-showreel--homepage,
.centrix-showreel--auto {
    margin-top: 24px;
    margin-bottom: 24px;
}

@media (min-width: 375px) {
    .cx-showreel--homepage,
    .centrix-showreel--auto {
        margin-top: 28px;
        margin-bottom: 28px;
    }
}

@media (min-width: 640px) {
    .cx-showreel--homepage,
    .centrix-showreel--auto {
        margin-top: 36px;
        margin-bottom: 36px;
    }
}

@media (min-width: 768px) {
    .cx-showreel--homepage,
    .centrix-showreel--auto {
        margin-top: 48px;
        margin-bottom: 48px;
    }
}

@media (min-width: 1024px) {
    .cx-showreel--homepage,
    .centrix-showreel--auto {
        margin-top: 64px;
        margin-bottom: 64px;
    }
}

@media (min-width: 1280px) {
    .cx-showreel--homepage,
    .centrix-showreel--auto {
        margin-top: 80px;
        margin-bottom: 80px;
    }
}
