/*
 * AvgustPanov Motion Engine v1.9
 * Scroll-linked motion. No autoplay. No scroll-jacking.
 */

:root {
    --ap-hold-top: 1rem;
    --ap-flow-top: 1rem;
    --ap-flow-fade-top: 1.35rem;
    --ap-flow-fade-bottom: 3.2rem;
    --ap-motion-ink: 35, 40, 43;
    --ap-motion-surface: 255, 255, 255;
    --ap-horizon-width: 98vw;
    --ap-horizon-start-scale: 0.62;
}

html.ap-motion-enabled .ap-reveal,
html.ap-motion-enabled .ap-drift,
html.ap-motion-enabled .ap-glide,
html.ap-motion-enabled .ap-horizon,
html.ap-motion-enabled .ap-flow-sticky-pair,
html.ap-motion-enabled .ap-navigare {
    will-change: transform, opacity;
}

/* Composite transform so standard motion types can coexist. */
html.ap-motion-enabled .ap-reveal,
html.ap-motion-enabled .ap-drift,
html.ap-motion-enabled .ap-glide,
html.ap-motion-enabled .ap-navigare {
    transform: translate3d(
        0,
        calc(
            var(--ap-reveal-y, 0px) +
            var(--ap-drift-y, 0px) +
            var(--ap-glide-y, 0px) +
            var(--ap-navigare-y, 0px)
        ),
        0
    );
}

/* REVEAL */
html.ap-motion-enabled .ap-reveal {
    opacity: var(--ap-reveal-opacity, 1);
}

/* DRIFT */
html.ap-motion-enabled .ap-drift {
    --ap-drift-y: 0px;
}

/* GLIDE */
html.ap-motion-enabled .ap-glide {
    --ap-glide-y: 0px;
}

/* HORIZON */
.ap-horizon {
    position: relative;
    left: 50%;
    width: var(--ap-horizon-width);
    max-width: none;
    height: 18px;
    margin-block: 1.75rem 0.35rem;
    margin-left: 0;
    overflow: hidden;
    transform: translateX(-50%);
}

.ap-horizon::before {
    content: "";
    position: absolute;
    left: 0;
    top: 7px;
    width: 100%;
    height: 10px;
    box-sizing: border-box;
    border-top: 1px solid rgba(var(--ap-motion-ink), 0.30);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    transform: scaleX(var(--ap-horizon-scale, 1));
    transform-origin: center center;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 16%, #000 84%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, #000 16%, #000 84%, transparent 100%);
}

.ap-horizon--short,
.ap-horizon--medium,
.ap-horizon--long {
    width: var(--ap-horizon-width);
    max-width: none;
}

.ap-horizon.ap-horizon--contained {
    left: 0;
    width: 100%;
    max-width: 100%;
    transform: none;
}

/* Legacy isolated hold */
.ap-section {
    position: relative;
    overflow: visible;
}

@media (min-width: 901px) {
    .ap-section .ap-hold {
        position: sticky;
        top: var(--ap-hold-top);
        z-index: 8;
    }
}

/*
 * NARRATIVE FLOW v1.8
 * H2 + optional .ap-flow-accent are wrapped by JS into one sticky unit.
 * This prevents desktop desynchronisation and closes the visual gap through
 * which scrolling body text could previously be seen.
 */
.ap-flow {
    position: relative;
    overflow: visible !important;
}

.ap-flow-sticky-pair {
    position: sticky;
    top: var(--ap-flow-top);
    z-index: 12;
    width: 100%;
    box-sizing: border-box;
    background: rgb(var(--ap-motion-surface));
    opacity: var(--ap-flow-opacity, 1);
    transform: translate3d(0, var(--ap-flow-push, 0px), 0);
    isolation: isolate;
    padding-top: 0.08em;
    padding-bottom: 0.46em;
}

.ap-flow-heading,
.ap-flow-accent {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    width: 100%;
    box-sizing: border-box;
    background: transparent !important;
    opacity: 1 !important;
    transform: none !important;
}

.ap-flow-heading {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

/* Paired accent/kicker, e.g. “Reality · Visibility · Action”. */
.ap-flow-sticky-pair > .ap-flow-accent {
    margin-top: 0.18rem !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

.ap-flow-sticky-pair.ap-flow-past {
    opacity: 0 !important;
    pointer-events: none;
}

.ap-flow-sticky-pair.ap-flow-active {
    z-index: 30;
}

/* Continuous upper fade attached to the whole sticky unit. */
.ap-flow-sticky-pair.ap-flow-active::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% - 1px);
    height: var(--ap-flow-fade-top);
    pointer-events: none;
    opacity: var(--ap-flow-mask-opacity, 1);
    background: linear-gradient(
        to top,
        rgba(var(--ap-motion-surface), 1) 0%,
        rgba(var(--ap-motion-surface), 0.98) 28%,
        rgba(var(--ap-motion-surface), 0.68) 64%,
        rgba(var(--ap-motion-surface), 0) 100%
    );
}

/* Continuous lower fade begins only after the accent (or H2 if no accent). */
.ap-flow-sticky-pair.ap-flow-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 1px);
    height: var(--ap-flow-fade-bottom);
    pointer-events: none;
    opacity: var(--ap-flow-mask-opacity, 1);
    background: linear-gradient(
        to bottom,
        rgba(var(--ap-motion-surface), 1) 0%,
        rgba(var(--ap-motion-surface), 0.98) 18%,
        rgba(var(--ap-motion-surface), 0.76) 46%,
        rgba(var(--ap-motion-surface), 0.30) 78%,
        rgba(var(--ap-motion-surface), 0) 100%
    );
}

/* Final signature */
.ap-navigare {
    margin-top: 0.35rem;
    text-align: right;
    font-style: italic;
    color: rgba(var(--ap-motion-ink), 0.30);
    opacity: var(--ap-navigare-opacity, 1);
}

.ap-navigare em {
    font-style: inherit;
    color: inherit;
}

.ap-motion-soft {
    --ap-motion-soft: 1;
}

body.admin-bar {
    --ap-hold-top: calc(1rem + 32px);
    --ap-flow-top: calc(1rem + 32px);
}

@media (max-width: 900px) {
    :root {
        --ap-flow-top: 0.65rem;
        --ap-flow-fade-top: 1.05rem;
        --ap-flow-fade-bottom: 2.6rem;
    }

    .ap-flow-sticky-pair {
        padding-bottom: 0.40em;
    }

    .ap-flow-sticky-pair > .ap-flow-accent {
        margin-top: 0.14rem !important;
    }
}

@media (max-width: 782px) {
    body.admin-bar {
        --ap-flow-top: calc(0.65rem + 46px);
    }
}

@media (max-width: 600px) {
    :root {
        --ap-flow-top: 0.45rem;
        --ap-flow-fade-top: 0.90rem;
        --ap-flow-fade-bottom: 2.25rem;
    }

    .ap-flow-sticky-pair {
        padding-top: 0.06em;
        padding-bottom: 0.34em;
    }

    .ap-flow-sticky-pair > .ap-flow-accent {
        margin-top: 0.10rem !important;
    }

    body.admin-bar {
        --ap-flow-top: calc(0.45rem + 46px);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    html.ap-motion-enabled .ap-reveal,
    html.ap-motion-enabled .ap-drift,
    html.ap-motion-enabled .ap-glide,
    html.ap-motion-enabled .ap-navigare,
    html.ap-motion-enabled .ap-flow-sticky-pair {
        transform: none !important;
        opacity: 1 !important;
        will-change: auto !important;
    }

    .ap-horizon::before {
        transform: scaleX(1) !important;
    }

    .ap-section .ap-hold,
    .ap-flow-sticky-pair {
        position: static !important;
    }

    .ap-flow-sticky-pair::before,
    .ap-flow-sticky-pair::after {
        display: none !important;
    }
}
