/**
 * Scroll FX - Core Styles
 * Initial states for animations. GPU-accelerated via transform + opacity.
 * will-change hints applied by JS only when animating (then removed).
 */

/* ── Entrance animations: initial hidden states ─────── */

[data-sfx="fade-up"],
[data-sfx="fade-down"],
[data-sfx="fade-left"],
[data-sfx="fade-right"],
[data-sfx="zoom-in"],
[data-sfx="zoom-out"],
[data-sfx="flip"],
[data-sfx="rotate"],
[data-sfx="blur-in"],
[data-sfx="clip-reveal"] {
    opacity: 0;
}

[data-sfx="fade-up"]    { transform: translateY(var(--sfx-distance, 40px)); }
[data-sfx="fade-down"]  { transform: translateY(calc(-1 * var(--sfx-distance, 40px))); }
[data-sfx="fade-left"]  { transform: translateX(var(--sfx-distance, 40px)); }
[data-sfx="fade-right"] { transform: translateX(calc(-1 * var(--sfx-distance, 40px))); }
[data-sfx="zoom-in"]    { transform: scale(var(--sfx-scale-from, 0.8)); }
[data-sfx="zoom-out"]   { transform: scale(var(--sfx-scale-from, 1.2)); }
[data-sfx="flip"]       { transform: perspective(800px) rotateY(var(--sfx-degrees, 90deg)); }
[data-sfx="rotate"]     { transform: rotate(var(--sfx-degrees, 15deg)); }
[data-sfx="blur-in"]    { filter: blur(var(--sfx-blur, 10px)); }

[data-sfx="clip-reveal"] {
    clip-path: inset(0 100% 0 0);
}

/* Animated state */
[data-sfx].sfx-visible {
    opacity: 1;
    transform: none;
    filter: none;
    clip-path: inset(0 0 0 0);
    transition:
        opacity var(--sfx-duration, 0.6s) var(--sfx-easing, cubic-bezier(.16,1,.3,1)),
        transform var(--sfx-duration, 0.6s) var(--sfx-easing, cubic-bezier(.16,1,.3,1)),
        filter var(--sfx-duration, 0.6s) var(--sfx-easing, cubic-bezier(.16,1,.3,1)),
        clip-path var(--sfx-duration, 0.6s) var(--sfx-easing, cubic-bezier(.16,1,.3,1));
    transition-delay: var(--sfx-delay, 0s);
}

/* Stagger children */
[data-sfx="stagger"] > * {
    opacity: 0;
    transform: translateY(var(--sfx-distance, 30px));
}

[data-sfx="stagger"].sfx-visible > * {
    opacity: 1;
    transform: none;
    transition:
        opacity var(--sfx-duration, 0.5s) var(--sfx-easing, cubic-bezier(.16,1,.3,1)),
        transform var(--sfx-duration, 0.5s) var(--sfx-easing, cubic-bezier(.16,1,.3,1));
}

/* ── Horizontal scroll ──────────────────────────────── */

.sfx-hscroll-wrap {
    position: relative;
}

[data-sfx="horizontal-scroll"] {
    position: sticky;
    top: var(--sfx-pin-top, 0px);
    height: calc(100vh - var(--sfx-pin-top, 0px));
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow: visible;
}

/* Panel sizing: excludes the progress track by SPECIFICITY, not source order —
   the freezer inlines CSS into multiple chunks and does not preserve cascade
   order, so equal-specificity overrides flip on frozen pages. Height is 100%
   of the container (which is already viewport minus the header offset). */
[data-sfx="horizontal-scroll"] > :not(.sfx-hscroll__progress) {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100%;
}

/* ── Gallery mode: full-height photo rail ─────────────
   (0,3,0) selectors so they beat the 100vw panel sizing above by
   SPECIFICITY — never by source order (freezer reorders chunks). */
[data-sfx="horizontal-scroll"].sfx-hscroll--gallery {
    gap: var(--sfx-hgap, 0px);
    align-items: center;
}
[data-sfx="horizontal-scroll"].sfx-hscroll--gallery > .sfx-hgallery-item {
    flex: 0 0 auto !important;
    width: auto !important;
    height: var(--sfx-gallery-h, 100%) !important;
    overflow: hidden;
}
/* !important is deliberate: theme/global `img { height:auto; max-width:100% }`
   rules otherwise win and render photos at natural size (blown out + cropped). */
[data-sfx="horizontal-scroll"].sfx-hscroll--gallery .sfx-hgallery-item img {
    height: 100% !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    display: block;
}
.sfx-hgallery-item--rounded { border-radius: 12px; }
.sfx-hgallery-item--rounded img { border-radius: 12px; }

/* ── Video scrub ────────────────────────────────────── */

.sfx-video-wrap {
    position: relative;
}

[data-sfx="video-scrub"] {
    position: sticky;
    top: var(--sfx-pin-top, 0px);
    height: calc(100vh - var(--sfx-pin-top, 0px));
    overflow: hidden;
}

[data-sfx="video-scrub"] video,
[data-sfx="video-scrub"] canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Sticky pin ─────────────────────────────────────── */

.sfx-pin-wrap {
    position: relative;
}

[data-sfx="pin"] {
    position: sticky;
    top: var(--sfx-pin-top, 0px);
    height: calc(100vh - var(--sfx-pin-top, 0px));
    overflow: hidden;
}

/* Children inside pin animate based on data-sfx-at */
[data-sfx="pin"] [data-sfx-at] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

[data-sfx="pin"] [data-sfx-at].sfx-at-active {
    opacity: 1;
    transform: none;
}

/* ── Parallax ───────────────────────────────────────── */

[data-sfx="parallax"] {
    will-change: transform;
}

/* ── Text reveal ────────────────────────────────────── */

[data-sfx="text-reveal"] .sfx-unit {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.3em);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

[data-sfx="text-reveal"].sfx-visible .sfx-unit {
    opacity: 1;
    transform: none;
}

/* Typewriter */
[data-sfx="typewriter"] .sfx-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: currentColor;
    margin-left: 2px;
    animation: sfxBlink 0.8s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes sfxBlink {
    50% { opacity: 0; }
}

/* ── Before/After Compare ───────────────────────────── */

.sfx-compare {
    position: relative;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
}

.sfx-compare img {
    display: block;
    width: 100%;
    height: auto;
}

.sfx-compare__before {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.sfx-compare__after {
    position: relative;
}

/* Legacy solid-bar handle — ONLY for bare handles without the block's
   line/grip children (shortcode usage). The block design lives further down. */
.sfx-compare__handle:not(:has(.sfx-compare__handle-grip)) {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #fff;
    cursor: ew-resize;
    z-index: 2;
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.sfx-compare__handle:not(:has(.sfx-compare__handle-grip))::before,
.sfx-compare__handle:not(:has(.sfx-compare__handle-grip))::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.sfx-compare__handle:not(:has(.sfx-compare__handle-grip))::before { left: -14px; transform: translateY(-50%); }
.sfx-compare__handle:not(:has(.sfx-compare__handle-grip))::after { right: -14px; transform: translateY(-50%); }

/* ── Tilt ───────────────────────────────────────────── */

[data-sfx="tilt"] {
    transform-style: preserve-3d;
    perspective: 1000px;
}

[data-sfx="tilt"] .sfx-glare {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: inherit;
}

/* ── Scroll scale/rotate ────────────────────────────── */

[data-sfx="scroll-scale"],
[data-sfx="scroll-rotate"] {
    will-change: transform;
}

/* ── Image sequence canvas ──────────────────────────── */

[data-sfx="image-sequence"] {
    position: sticky;
    top: var(--sfx-pin-top, 0px);
    height: calc(100vh - var(--sfx-pin-top, 0px));
}

[data-sfx="image-sequence"] canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── Reduced motion ─────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    [data-sfx] {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        clip-path: none !important;
        transition: none !important;
        animation: none !important;
    }

    [data-sfx="stagger"] > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ── Block: Horizontal Scroll ───────────────────────── */

.sfx-hscroll-section { position: relative; }

.sfx-hpanel {
    flex: 0 0 100vw !important;
    width: 100vw !important;
    height: 100% !important; /* container height = viewport minus header offset */
    display: grid !important;
    place-items: center !important;
    place-content: center !important;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

/* Panels are grid containers — side-by-side layouts use grid columns
   (flex-direction on a grid container does nothing). */
.sfx-hpanel--text-center { text-align: center; }
.sfx-hpanel--text-left,
.sfx-hpanel--text-right {
    grid-template-columns: 1fr 1fr !important;
    place-content: center !important;
    gap: 48px;
}
.sfx-hpanel--text-left  .sfx-hpanel__content { grid-column: 1; grid-row: 1; }
.sfx-hpanel--text-left  .sfx-hpanel__image   { grid-column: 2; grid-row: 1; }
.sfx-hpanel--text-right .sfx-hpanel__content { grid-column: 2; grid-row: 1; }
.sfx-hpanel--text-right .sfx-hpanel__image   { grid-column: 1; grid-row: 1; }
.sfx-hpanel--image-full { text-align: center; }

.sfx-hpanel__content { max-width: 560px; z-index: 1; }
.sfx-hpanel__headline { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 900; margin: 0 0 16px; line-height: 1.1; }
.sfx-hpanel__text { font-size: 1.125rem; line-height: 1.7; opacity: 0.85; }

.sfx-hpanel__image { max-width: 100%; }
.sfx-hpanel--text-left .sfx-hpanel__image,
.sfx-hpanel--text-right .sfx-hpanel__image { width: 100%; }
.sfx-hpanel__image img { width: 100%; height: auto; border-radius: 12px; }
.sfx-hpanel__image--below { margin-top: 32px; max-width: 480px; }
.sfx-hpanel__image--below img { border-radius: 12px; }

.sfx-hpanel--image-full .sfx-hpanel__image {
    position: absolute; inset: 0; max-width: none;
}
.sfx-hpanel--image-full .sfx-hpanel__image img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 0;
}
.sfx-hpanel--image-full .sfx-hpanel__content {
    position: relative; z-index: 2;
    text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.sfx-hscroll__progress {
    position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
    background: rgba(255,255,255,0.15); z-index: 10;
}
.sfx-hscroll__progress-fill {
    height: 100%; background: #fff; width: 0;
}

/* ── Block: Video Scrub ─────────────────────────────── */

.sfx-vscrub-section { position: relative; background: #000; }

.sfx-vscrub {
    position: sticky; top: var(--sfx-pin-top, 0px); height: calc(100vh - var(--sfx-pin-top, 0px));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

.sfx-vscrub video {
    width: 100%; height: 100%; display: block;
}

.sfx-vscrub__overlay {
    position: absolute; z-index: 2; padding: 32px;
    max-width: 560px; color: #fff;
}
.sfx-vscrub__overlay--center { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.sfx-vscrub__overlay--bottom-left { bottom: 48px; left: 48px; }
.sfx-vscrub__overlay--bottom-center { bottom: 48px; left: 50%; transform: translateX(-50%); text-align: center; }

.sfx-vscrub__headline { font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 900; margin: 0 0 12px; }
.sfx-vscrub__text { font-size: 1.0625rem; line-height: 1.6; opacity: 0.85; }

/* ── Block: Pinned Section ──────────────────────────── */

.sfx-pinned-section { position: relative; }

.sfx-pinned {
    position: sticky; top: var(--sfx-pin-top, 0px); height: calc(100vh - var(--sfx-pin-top, 0px));
    display: flex; align-items: center; overflow: hidden;
}

.sfx-pinned__inner { width: 100%; }

.sfx-pinned__split.sfx-pinned--right-left .sfx-pinned__text-side { order: 2; }
.sfx-pinned__split.sfx-pinned--right-left .sfx-pinned__media-side { order: 1; }

.sfx-pinned__text-side {
    display: grid;
}
.sfx-pinned__media-side {
    display: grid;
}

/* All steps/media occupy the same grid cell — perfectly stacked */
.sfx-pinned__step {
    grid-row: 1; grid-column: 1;
    opacity: 0;
    transition: opacity 0.4s ease;
    align-self: center;
}

.sfx-pinned__step.sfx-at-active {
    opacity: 1;
}

.sfx-pinned__step--full {
    text-align: center; max-width: 640px; margin: 0 auto;
}

.sfx-pinned__media {
    grid-row: 1; grid-column: 1;
    opacity: 0;
    transition: opacity 0.4s ease;
    align-self: center;
}
.sfx-pinned__media.sfx-at-active { opacity: 1; }
.sfx-pinned__media img { width: 100%; height: auto; border-radius: 12px; }

.sfx-pinned__counter {
    display: block; font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    opacity: 0.4; margin-bottom: 8px;
}

.sfx-pinned__headline { font-size: clamp(1.5rem, 3vw, 2.5rem); font-weight: 800; margin: 0 0 12px; line-height: 1.2; }
.sfx-pinned__text { font-size: 1.0625rem; line-height: 1.7; opacity: 0.8; }
.sfx-pinned__img { max-width: 480px; margin: 24px auto 0; border-radius: 12px; }

.sfx-pinned__dots {
    position: absolute; right: -32px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 8px;
}
.sfx-pinned__dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: currentColor; opacity: 0.2;
    transition: opacity 0.3s;
}
.sfx-pinned__dot--active { opacity: 1; }

/* Desktop: show split, hide mobile combined */
.sfx-pinned__split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.sfx-pinned__mobile { display: none; }

/* ── Block: Before/After ────────────────────────────── */

.sfx-compare-section .sfx-compare__headline {
    text-align: center; font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 800; margin: 0 0 24px;
}

.sfx-compare { position: relative; overflow: hidden; cursor: ew-resize; user-select: none; }
.sfx-compare--rounded { border-radius: 12px; }
.sfx-compare.sfx-compare--vertical { cursor: ns-resize; } /* specificity-proof vs base cursor (freezer reorders CSS) */

.sfx-compare img { display: block; width: 100%; height: auto; }

.sfx-compare__before {
    position: absolute; inset: 0; z-index: 1; clip-path: inset(0 50% 0 0);
}
.sfx-compare__before img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.sfx-compare__after { position: relative; z-index: 0; }

.sfx-compare__handle {
    position: absolute; top: 0; bottom: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center;
    transform: translateX(-50%); /* center on the split position */
}
.sfx-compare__handle-line { flex: 1; width: 2px; background: #fff; }

/* Vertical mode: handle spans horizontally, tracks top offset */
.sfx-compare--vertical .sfx-compare__handle {
    top: auto; bottom: auto; left: 0; right: 0;
    flex-direction: row;
    transform: translateY(-50%);
}
.sfx-compare--vertical .sfx-compare__handle-line { width: auto; height: 2px; flex: 1; }
.sfx-compare__handle-grip {
    width: 40px; height: 40px; border-radius: 50%;
    background: #fff; color: #18181b;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.sfx-compare__label {
    position: absolute; bottom: 12px; padding: 4px 12px;
    background: rgba(0,0,0,0.6); color: #fff; font-size: 12px;
    font-weight: 600; border-radius: 4px; text-transform: uppercase;
    letter-spacing: 0.05em; z-index: 3;
}
.sfx-compare__label--before { left: 12px; }
.sfx-compare__label--after { right: 12px; }

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 768px) {
    .sfx-hpanel { padding: 24px; }
    /* Stack side-by-side layouts into one column. Double-class selectors so
       mobile beats desktop by SPECIFICITY — the freezer reorders CSS chunks,
       so equal-specificity media overrides can lose on frozen pages. */
    .sfx-hpanel.sfx-hpanel--text-left, .sfx-hpanel.sfx-hpanel--text-right { grid-template-columns: 1fr !important; gap: 24px; }
    .sfx-hpanel.sfx-hpanel--text-left .sfx-hpanel__content,
    .sfx-hpanel.sfx-hpanel--text-right .sfx-hpanel__content { grid-column: 1; grid-row: 1; }
    .sfx-hpanel.sfx-hpanel--text-left .sfx-hpanel__image,
    .sfx-hpanel.sfx-hpanel--text-right .sfx-hpanel__image { grid-column: 1; grid-row: 2; }
    .sfx-hpanel__image { max-width: 100%; }

    /* Pinned section: hide split, show mobile combined */
    .sfx-pinned__split { display: none !important; }
    .sfx-pinned__mobile {
        display: grid !important;
    }

    /* All combined steps stack in the same grid cell, top-aligned */
    .sfx-pinned__step--combined {
        grid-row: 1;
        grid-column: 1;
        text-align: center;
        align-self: start;
        padding: 20px 16px 0;
    }

    .sfx-pinned__step--combined img {
        height: 35vh !important;
        width: 100% !important;
        object-fit: contain !important;
        border-radius: 8px !important;
        margin-top: 16px !important;
    }

    .sfx-pinned__headline { font-size: 1.5rem; }

    .sfx-vscrub__overlay--bottom-left { bottom: 24px; left: 24px; }
}

/* ── Block: Image Sequence ──────────────────────────── */

.sfx-imgseq-section { position: relative; }

.sfx-imgseq {
    position: sticky; top: var(--sfx-pin-top, 0px); height: calc(100vh - var(--sfx-pin-top, 0px));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

.sfx-imgseq canvas {
    width: 100%; height: 100%; display: block;
}

.sfx-imgseq__overlay {
    position: absolute; z-index: 2; padding: 32px;
    max-width: 560px;
}
.sfx-imgseq__overlay--center { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.sfx-imgseq__overlay--bottom-left { bottom: 48px; left: 48px; }
.sfx-imgseq__overlay--bottom-center { bottom: 48px; left: 50%; transform: translateX(-50%); text-align: center; }
.sfx-imgseq__overlay--top-center { top: 48px; left: 50%; transform: translateX(-50%); text-align: center; }

.sfx-imgseq__headline { font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 900; margin: 0 0 12px; }
.sfx-imgseq__text { font-size: 1.0625rem; line-height: 1.6; opacity: 0.85; }

.sfx-imgseq__loading {
    position: absolute; inset: 0; z-index: 5;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; color: rgba(255,255,255,0.5);
    font-size: 13px; background: inherit;
    transition: opacity 0.4s;
}
.sfx-imgseq__loading--done { opacity: 0; pointer-events: none; }
.sfx-imgseq__loading-bar { width: 120px; height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.sfx-imgseq__loading-fill { height: 100%; background: #fff; width: 0; transition: width 0.2s; }

/* ── Block: Parallax Section ────────────────────────── */

.sfx-parallax-section {
    display: flex; align-items: center;
}

.sfx-parallax-bg {
    will-change: transform;
}

.sfx-parallax__headline { text-shadow: 0 2px 20px rgba(0,0,0,0.2); }

/* ── Block: Scroll Cinema ───────────────────────────── */

.sfx-cinema-section { position: relative; }

.sfx-cinema {
    position: sticky; top: var(--sfx-pin-top, 0px); height: calc(100vh - var(--sfx-pin-top, 0px));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

.sfx-cinema__canvas {
    width: 100%; height: 100%; display: block;
}

.sfx-cinema__overlay {
    position: absolute; z-index: 2; padding: 32px;
    max-width: 560px;
}
.sfx-cinema__overlay--center { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.sfx-cinema__overlay--bottom-left { bottom: 48px; left: 48px; }
.sfx-cinema__overlay--bottom-center { bottom: 48px; left: 50%; transform: translateX(-50%); text-align: center; }
.sfx-cinema__overlay--top-center { top: 48px; left: 50%; transform: translateX(-50%); text-align: center; }

.sfx-cinema__headline { font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 900; margin: 0 0 12px; }
.sfx-cinema__text { font-size: 1.0625rem; line-height: 1.6; opacity: 0.85; }

.sfx-cinema__loading {
    position: absolute; inset: 0; z-index: 5;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; color: rgba(255,255,255,0.5);
    font-size: 13px; background: inherit;
    transition: opacity 0.4s;
}
.sfx-cinema__loading-bar { width: 160px; height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.sfx-cinema__loading-fill { height: 100%; background: #fff; width: 0; transition: width 0.15s; }

/* Placeholder (admin only, no frames yet) */
.sfx-cinema--placeholder { min-height: 300px; display: flex; align-items: center; justify-content: center; }
.sfx-cinema-placeholder { text-align: center; color: rgba(255,255,255,0.6); padding: 48px; }
.sfx-cinema-placeholder__icon { font-size: 48px; margin-bottom: 16px; }
.sfx-cinema-placeholder h3 { color: #fff; margin: 0 0 8px; }
.sfx-cinema-placeholder p { margin: 0 0 8px; font-size: 14px; }
.sfx-cinema-placeholder__url { font-family: monospace; font-size: 12px; opacity: 0.4; }
