/* Manrope variable (OFL, assets/fonts/OFL-Manrope.txt). The skin names Manrope first but ships no file, so
   the browser fell back to a system font and weight scrubs (text-scrub) had no real axis to interpolate. */
/* Outfit variable (OFL, assets/fonts/OFL-Outfit.txt): the display face veloracss.io actually renders
   (the skin lists Space Grotesk first, which the official site does not load either). */


/* Velora theme engine adapter (PROPOSED, v0).
   Gives each motion channel its own animation clock on one node (enter, scroll, exit, loop).
   Ported from the SKIF Brasil adapter; selectors renamed to [data-velora-channels].
   Presets already in the core (focus, depth-push, path) are NOT patched here.
   This file is unlayered on purpose so it wins over the layered core. */

[data-velora-channels] {
    --velora-scroll-range: var(--vl-scroll-range, entry 5% cover 42%);
    animation-name: var(--vl-enter-name, none), var(--vl-scroll-name, none), var(--vl-exit-name, none), var(--vl-loop-name, none);
    animation-duration: var(--vl-enter-duration, var(--vl-motion-duration, 600ms)), 1ms, 1ms, var(--velora-loop-duration, var(--vl-loop-duration, 4s));
    animation-delay: var(--vl-enter-delay, var(--vl-motion-delay, 0s)), 0s, 0s, var(--velora-loop-delay, calc(var(--vl-enter-delay, var(--vl-motion-delay, 0s)) + var(--vl-enter-duration, var(--vl-motion-duration, 600ms))));
    animation-timing-function: var(--vl-enter-ease, var(--vl-motion-ease, ease)), linear, var(--vl-exit-ease, var(--vl-ease-out-soft, ease-out)), var(--vl-loop-ease, ease-in-out);
    animation-iteration-count: 1, 1, 1, var(--vl-loop-count, infinite);
    animation-direction: normal, var(--vl-scroll-direction, normal), normal, var(--vl-loop-direction, normal);
    animation-fill-mode: backwards, both, forwards, none;
    animation-timeline: auto, var(--vl-scroll-timeline, view(block)), view(block 0px), auto;
    animation-range: normal, var(--velora-scroll-range), exit var(--velora-exit-start, 0%) exit 100%, normal;
    animation-composition: replace, add, replace, add;
    animation-play-state: running;
}

/* vl-scroll="path": the core sets animation-name directly (not through --vl-scroll-name), so the per-channel
   lists above zeroed it. Feed the channel variables instead. Range default matches the core: entry 0% exit 100%. */
[data-velora-channels][vl-scroll="path"] {
    --vl-scroll-name: vl-path-travel;
    --vl-scroll-timeline: view(block);
    --velora-scroll-range: var(--vl-range, entry 0% exit 100%);
    animation-composition: replace, replace, replace, add;
}

/* vl-range: the 13 named values defined by the core plus "custom". Values mirror 03-motion.css. */
[data-velora-channels][vl-range="entry"]       { --velora-scroll-range: entry 0% entry 100%; }
[data-velora-channels][vl-range="entry-short"] { --velora-scroll-range: entry 15% cover 35%; }
[data-velora-channels][vl-range="entry-micro"] { --velora-scroll-range: entry 20% cover 30%; }
[data-velora-channels][vl-range="entry-long"]  { --velora-scroll-range: entry 0% cover 70%; }
[data-velora-channels][vl-range="scene-soft"]  { --velora-scroll-range: entry 0% cover 82%; }
[data-velora-channels][vl-range="scene-focus"] { --velora-scroll-range: entry 20% cover 65%; }
[data-velora-channels][vl-range="cinema-wide"] { --velora-scroll-range: entry 0% cover 90%; }
[data-velora-channels][vl-range="cover"],
[data-velora-channels][vl-range="full"]        { --velora-scroll-range: cover 0% cover 100%; }
[data-velora-channels][vl-range="contain"]     { --velora-scroll-range: contain 0% contain 100%; }
[data-velora-channels][vl-range="center"]      { --velora-scroll-range: contain 30% contain 70%; }
[data-velora-channels][vl-range="exit-short"]  { --velora-scroll-range: contain 70% exit 100%; }
[data-velora-channels][vl-range="exit"]        { --velora-scroll-range: exit 0% exit 100%; }
[data-velora-channels][vl-range="custom"]      { --velora-scroll-range: var(--vl-range, entry 5% cover 42%); }

/* Opacity scrubs replace rather than add opacity to the entry channel. */
[data-velora-channels]:is([vl-scroll="crossfade"], [vl-scroll="reveal"], [vl-scroll="depth-drift"], [vl-scroll="depth-push"]) {
    animation-composition: replace, replace, replace, add;
}

/* Scroll scrubs that animate a property other than transform/opacity/filter must REPLACE the base value.
   With "add" the keyframe is summed onto the base: background-size grew to 200% and font-weight pinned at 1000. */
[data-velora-channels]:is([vl-scroll="text-highlight"], [vl-scroll="text-scrub"], [vl-scroll="ink-scrub"], [vl-scroll="letterbox"]) {
    animation-composition: replace, replace, replace, add;
}
[data-velora-channels][vl-in-view]:is([vl-scroll="text-highlight"], [vl-scroll="text-scrub"], [vl-scroll="ink-scrub"], [vl-scroll="letterbox"]) {
    animation-composition: replace, replace, replace, add, replace;
}

/* Names belong to their node: inherited parent presets must not add channels. */
[data-velora-channels]:not([vl-enter])       { --vl-enter-name: none; }
[data-velora-channels]:not([vl-scroll])      { --vl-scroll-name: none; }
[data-velora-channels]:not([vl-exit])        { --vl-exit-name: none; }
[data-velora-channels]:not([vl-loop-effect]) { --vl-loop-name: none; }

/* The entry releases its fill so hover can act. Restore the host's base opacity under a gate. */
[vl-in-view] [data-velora-channels][vl-enter] {
    opacity: 1;
    visibility: visible;
}

@supports not (animation-timeline: view()) {
    [data-velora-channels] {
        animation-name: var(--vl-enter-name, none), none, none, var(--vl-loop-name, none);
    }
}

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

/* In-view gate: hold entry (and pause loops) until the wrapper is on screen. */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        @container vl-in-view style(--vl-in-view-state: 0) {
            [vl-in-view] [data-velora-channels][vl-loop-effect]:not(.velora-editor-host, .velora-editor-host *) {
                animation-play-state: running, running, running, paused;
            }
            [vl-in-view] [data-velora-channels][vl-enter]:not(.velora-editor-host, .velora-editor-host *) {
                opacity: 0;
                visibility: hidden;
                animation-name: none, var(--vl-scroll-name, none), var(--vl-exit-name, none), var(--vl-loop-name, none);
            }
        }
    }
}

/* Touch screens: keep elapsed entry time instead of replaying on every return. */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        @media (max-width: 782px), (hover: none) and (pointer: coarse) {
            @container vl-in-view style(--vl-in-view-state: 0) {
                [vl-in-view] [data-velora-channels][vl-enter]:not(.velora-editor-host, .velora-editor-host *) {
                    animation-name: var(--vl-enter-name, none), var(--vl-scroll-name, none), var(--vl-exit-name, none), var(--vl-loop-name, none);
                    animation-play-state: paused, running, running, paused;
                }
            }
        }
    }
}

/* vl-enter="focus": the core sets fill-mode and range for it but no animation name. */
[vl-enter="focus"] { --vl-enter-name: vl-blur-in; } /* not tied to the marker: scene acts have none */

/* Entrance trigger, native CSS and no JavaScript (progressive enhancement).
   Where animation-trigger / timeline-trigger exist (Chromium 145+), each element is triggered by its own
   view timeline: the entrance plays when it scrolls into view. Leaving is controlled by the same trigger:
   - default (replay): the trigger stays active until the element has fully left the screen (active range
     ends at "exit 100%"), then resets off screen, so the entrance replays on return. Resetting at the first
     pixel of exit ("exit 0%") made the element vanish in the middle of the screen and hid vl-exit.
   - vl-leave="reverse": the entrance plays backwards as soon as the element starts to leave.
   - vl-once: play-once, the entrance never replays.
   Elsewhere the container gate below stays in charge; vl-once and vl-leave then behave like a normal
   entrance (it replays), which is the documented fallback. Reverse is evaluated on scroll progress: an
   instant jump (an anchor link) can skip the leave step, and the entrance then simply replays on return. */
@supports (animation-trigger: --velora-t play-once) and (timeline-trigger: --velora-t view()) {
    [data-velora-channels][vl-enter] {
        trigger-scope: --velora-t;
        timeline-trigger: --velora-t view() entry 30% exit 0% / entry 30% exit 100%;
        animation-trigger: --velora-t play reset, none, none, none;
    }
    [data-velora-channels][vl-enter][vl-once] {
        animation-trigger: --velora-t play-once, none, none, none;
    }
    [data-velora-channels][vl-enter][vl-leave="reverse"]:not([vl-once]) {
        timeline-trigger: --velora-t view() entry 30% exit 0%;
        animation-trigger: --velora-t play-forwards play-backwards, none, none, none;
    }
    /* The element owns its trigger, so the ancestor gate must not hold it back. */
    [vl-in-view] [data-velora-channels][vl-enter][vl-enter]:not(.velora-editor-host, .velora-editor-host *) {
        opacity: 1;
        visibility: visible;
        animation-name: var(--vl-enter-name, none), var(--vl-scroll-name, none), var(--vl-exit-name, none), var(--vl-loop-name, none);
    }
}

/* A gate that also animates (exit, scroll, loop) must keep its gate clock. The animation lists above
   replace the core's single-animation gate rule, so append the gate as a fifth entry. Without this the
   gate state stays 0 and every descendant stays hidden. */
[data-velora-channels][vl-in-view] {
    animation-name: var(--vl-enter-name, none), var(--vl-scroll-name, none), var(--vl-exit-name, none), var(--vl-loop-name, none), vl-in-view-gate;
    animation-duration: var(--vl-enter-duration, var(--vl-motion-duration, 600ms)), 1ms, 1ms, var(--velora-loop-duration, var(--vl-loop-duration, 4s)), 1ms;
    animation-delay: var(--vl-enter-delay, var(--vl-motion-delay, 0s)), 0s, 0s, var(--velora-loop-delay, calc(var(--vl-enter-delay, var(--vl-motion-delay, 0s)) + var(--vl-enter-duration, var(--vl-motion-duration, 600ms)))), 0s;
    animation-timing-function: var(--vl-enter-ease, var(--vl-motion-ease, ease)), linear, var(--vl-exit-ease, var(--vl-ease-out-soft, ease-out)), var(--vl-loop-ease, ease-in-out), linear;
    animation-iteration-count: 1, 1, 1, var(--vl-loop-count, infinite), 1;
    animation-direction: normal, var(--vl-scroll-direction, normal), normal, var(--vl-loop-direction, normal), normal;
    animation-fill-mode: backwards, both, forwards, none, both;
    animation-timeline: auto, var(--vl-scroll-timeline, view(block)), view(block 0px), auto, view(block);
    animation-range: normal, var(--velora-scroll-range), exit var(--velora-exit-start, 0%) exit 100%, normal, entry exit;
    animation-composition: replace, add, replace, add, replace;
    animation-play-state: running;
}

/* Scene acts on a pinned track. The core maps act ranges as plain percentages of the track's whole "cover"
   range, which includes the unpinned entry and exit, so the first act starts early and the last one ends
   after the stage is released. "contain" is exactly the pinned span of a track taller than the viewport,
   so acts map onto what the visitor actually sees. Verified live; to be proposed to the core. */
[vl-scene][vl-timeline="view"][vl-pin] [vl-stage] > :is([vl-enter], [vl-scroll], [vl-effect], [vl-exit]):not([vl-range]) {
    animation-range: contain var(--vl-act-start) contain var(--vl-act-end);
}

/* A scene on a WordPress group set to full/wide width. The core gives [vl-scene] width: 100%, which cancels the
   negative inline margins WordPress uses to bleed an alignfull/alignwide block past the global padding. The track
   (and the stage inside it) then ended 32px short of the viewport. Let the block size itself again. */
[vl-scene]:where(.alignfull, .alignwide) {
    width: auto;
}

/* Text marks (PROPOSED, v0): vl-mark="sweep | color | glow | underline" on a text block animates the editor's own
   inline formats inside it: Highlight (<mark>), links and underline. Each inline element runs on its own view
   timeline (scroll-driven, no JavaScript), so it plays as that word crosses the screen. Everything lives inside
   the supports/motion guard: without scroll-driven animations or with reduced motion the author's own formatting
   shows untouched (the marker is complete, the link keeps its normal underline).
   Parameters: --vl-mark-color (sweep: set from the Highlight's own colour by PHP, default the accent at 35%),
   --vl-mark-height (sweep, default 100%), --vl-mark-thickness (underline, default .08em),
   --vl-mark-from (color, the starting colour), --vl-mark-range (any animation-range).
   Known limit: an inline element that wraps onto two lines animates all its lines together. */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        [vl-mark] :is(mark, a, span[style*="underline" i]) {
            animation-duration: 1ms;
            animation-timing-function: linear;
            animation-fill-mode: both;
            animation-timeline: view(block);
            animation-range: var(--vl-mark-range, var(--_mark-range, entry 10% cover 40%));
            -webkit-box-decoration-break: clone;
            box-decoration-break: clone;
        }
        /* sweep: the marker is painted as a gradient whose width grows (a Highlight background cannot be scrubbed).
           The block editor keeps the author's own highlight as is: PHP copies its colour on the front end only. */
        [vl-mark="sweep"] mark:not(.editor-styles-wrapper *) {
            --_c: var(--vl-mark-color, color-mix(in oklch, var(--vl-color-accent, var(--vl-color-primary, currentColor)) 35%, transparent));
            background-color: transparent !important;
            background-image: linear-gradient(var(--_c), var(--_c));
            background-repeat: no-repeat;
            background-position: 0 100%;
            background-size: 100% var(--vl-mark-height, 100%);
            animation-name: vl-mark-sweep;
        }
        [vl-mark="color"] mark { animation-name: vl-mark-color; }
        [vl-mark="glow"] {
            --_mark-range: cover 0% cover 100%; /* the glow peaks when the word is mid-screen */
        }
        [vl-mark="glow"] mark { animation-name: vl-mark-glow; }
        /* underline: replaces the text-decoration with a line that draws in. A Highlight keeps its own background. */
        [vl-mark="underline"] :is(mark, a, span[style*="underline" i]) {
            text-decoration: none !important;
            background-image: linear-gradient(currentColor, currentColor);
            background-repeat: no-repeat;
            background-position: 0 100%;
            background-size: 100% var(--vl-mark-thickness, .08em);
            animation-name: vl-mark-underline;
        }
    }
    @keyframes vl-mark-sweep {
        from { background-size: 0% var(--vl-mark-height, 100%); }
        to   { background-size: 100% var(--vl-mark-height, 100%); }
    }
    @keyframes vl-mark-color {
        from { color: var(--vl-mark-from, color-mix(in oklch, var(--vl-text-primary, CanvasText) 35%, transparent)); }
    }
    @keyframes vl-mark-glow {
        /* One shadow with a plain colour: lists of different length, or colour-mix() inside the shadow, do not
           interpolate in Chrome (they flip at the halfway point instead of fading). */
        0%, 100% { text-shadow: 0 0 0 transparent; }
        50%      { text-shadow: 0 0 .6em currentColor; }
    }
    @keyframes vl-mark-underline {
        from { background-size: 0% var(--vl-mark-thickness, .08em); }
        to   { background-size: 100% var(--vl-mark-thickness, .08em); }
    }
}
