/* =======================================================================
   Parallax Block — CSS Scroll-Driven Animation Engine
   Uses animation-timeline: view() with @keyframes perron-parallax-scroll.
   Polyfill (scroll-timeline.js) handles Safari / Firefox support.
   ======================================================================= */

.wp-block-perron-parallax {
    position: relative;
    /* height: calc(var(--scroll-height, 50) * 1svh - var(--wp-admin--admin-bar--height, 0px)); */
    height: calc(var(--scroll-height, 50) * 1svh);
    /* min-height: clamp(28rem, 40vh, 46rem); */
    min-height: 30vh;
    overflow: clip;
    contain: layout;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(0 2rem, 2rem 0, calc(100% - 2rem) 0, 100% 2rem, 100% calc(100% - 2rem), calc(100% - 2rem) 100%, 2rem 100%, 0 calc(100% - 2rem));
    filter: drop-shadow(0 1.4rem 4rem color-mix(in oklch, var(--accentcolor), transparent 78%));
    background:
        radial-gradient(circle at 20% 20%, color-mix(in oklch, var(--accentcolor), transparent 72%), transparent 26rem),
        var(--background);
    isolation: isolate;
}

.wp-block-perron-parallax::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.08) 48%, rgba(0, 0, 0, 0.5)),
        radial-gradient(circle at 50% 50%, transparent 0 36%, rgba(0, 0, 0, 0.34) 100%);
}

.wp-block-perron-parallax.alignfull {
    clip-path: none;
    filter: none;
}

.wp-block-perron-parallax:has(+ p) {
    margin-block-end: 1rem;
}

/* Inside a layout cell, fill the cell */
@media (min-width: 768px) {
    html body .perron-layout-cell .wp-block-perron-parallax {
        height: 100%;
    }
}

/* --- Background image layer --- */
.wp-block-perron-parallax .parallax-bg {
    --speed-y: 0;
    --abs-speed: max(var(--speed-y), calc(var(--speed-y) * -1));
    position: absolute;
    inset-inline: 0;
    top: calc(var(--abs-speed) * -50lvh);
    height: calc(100% + var(--abs-speed) * 100lvh);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
    pointer-events: none;
    animation: perron-parallax-scroll linear both;
    animation-timeline: view();
    animation-range: cover 0% cover 100%;
}

/* --- Caption layer --- */
.wp-block-perron-parallax .parallax-captionbg {
    --speed-y: -0.4;
    position: relative;
    z-index: 3;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    will-change: transform;
    animation: perron-parallax-scroll linear both;
    animation-timeline: view();
    animation-range: cover 0% cover 100%;
}

.wp-block-perron-parallax .parallax-caption {
    color: #fff;
    text-align: center;
    padding: clamp(1.4rem, 2.5vw, 3rem) clamp(1.8rem, 4vw, 5rem);
    background-color: rgba(5, 10, 20, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: clamp(1.6rem, 2.5vw, 3.2rem);
    corner-shape: bevel square bevel square;
    font-family: var(--font-secondary, inherit);
    font-size: clamp(2.1rem, 3vw, 3.8rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.04em;
    text-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    text-wrap: balance;
    max-width: min(90%, 36ch);
    box-shadow: 0 2rem 8rem rgba(0, 0, 0, 0.24);
}

/* --- Keyframes (reference: parallax-antigravity/style.css) --- */
@keyframes perron-parallax-scroll {
    0% {
        transform: translateY(calc(var(--speed-y, 0) * 50lvh));
    }

    100% {
        transform: translateY(calc(var(--speed-y, 0) * -50lvh));
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {

    .wp-block-perron-parallax .parallax-bg,
    .wp-block-perron-parallax .parallax-captionbg {
        animation: none !important;
        top: 0;
        height: 100%;
    }
}