/*
 * Beweging voor elke site (Mitsn\SiteCore\Support\Motion). html.motion zet partials/motion vóór de eerste paint, niet bij
 * "minder beweging": zonder die class staat alles meteen stil op zijn plek. [data-motion] start pas in beeld
 * (motion.js zet .is-inview); koppen zonder [data-motion] en [data-intro] starten bij het laden (alleen CSS).
 * Alleen transform/opacity: niets verschuift de layout. Sites passen tempo en curve aan via de variabelen.
 */
:root {
    /* uitkomen en afremmen (Material 3 "emphasized decelerate"): voor alles wat binnenkomt */
    --mo-ease: cubic-bezier(0.05, 0.7, 0.1, 1);
    --mo-ease-soft: cubic-bezier(0.2, 0, 0, 1);
    --mo-duration: 0.8s;
    --mo-stagger: 55ms;
}

/*
 * Koppen (Motion::words), per niveau een andere stijl:
 *   lines  hero-kop: regel voor regel uit een masker (motion.js bepaalt de regels; zonder JS na 1 s toch)
 *   blur   sectiekop (standaard): elk woord van onscherp naar scherp, met een korte fade en een klein stukje omhoog
 *   rise   woord voor woord uit een masker
 *   fade   kleine kop: alleen een fade
 * Vertraging per woord begrensd (min(…, 12)): een lange kop loopt niet eindeloos door.
 */
.mo-w {
    display: inline-block;
    vertical-align: top;
}

.mo-rise,
.mo-lines {
    overflow: hidden;
    /* ruimte voor de staart van g/j/p binnen het masker */
    padding-bottom: 0.12em;
    margin-bottom: -0.12em;
}

.motion .mo-w > span {
    display: inline-block;
    animation-fill-mode: both;
}

.motion .mo-rise > span {
    animation-name: mo-rise;
    animation-duration: var(--mo-duration);
    animation-timing-function: var(--mo-ease);
    animation-delay: calc(min(var(--i, 0), 12) * var(--mo-stagger));
}

.motion .mo-lines > span {
    animation-name: mo-rise;
    animation-duration: calc(var(--mo-duration) * 1.1);
    animation-timing-function: var(--mo-ease);
    animation-delay: calc(var(--l, 0) * 110ms);
}

/* nog niet in regels verdeeld (motion.js nog niet geladen): wachten, maar nooit langer dan 1 s */
.motion :not([data-lines]) > .mo-lines > span {
    animation-delay: 1s;
}

.motion .mo-blur > span {
    animation-name: mo-blur;
    animation-duration: calc(var(--mo-duration) * 0.75);
    animation-timing-function: var(--mo-ease-soft);
    animation-delay: calc(min(var(--i, 0), 12) * 45ms);
}

.motion .mo-fade > span {
    animation-name: mo-fade;
    animation-duration: calc(var(--mo-duration) * 0.6);
    animation-timing-function: var(--mo-ease-soft);
    animation-delay: calc(min(var(--i, 0), 12) * 35ms);
}

@keyframes mo-rise {
    from { transform: translateY(110%); }
}

@keyframes mo-blur {
    from { opacity: 0; filter: blur(8px); transform: translateY(0.25em); }
}

@keyframes mo-fade {
    from { opacity: 0; }
}

/*
 * Teller: het echte cijfer (onzichtbaar) bepaalt breedte en basislijn, de rol 0–9 (::after) draait erover naar zijn
 * waarde. clip-path i.p.v. overflow: de basislijn blijft staan, en strak om de cijfers zodat de buren niet meegluren.
 */
.mo-n {
    position: relative;
    display: inline-block;
    /* de rol heeft ruimte nodig: lager dan ~1,15 gluurt het volgende cijfer mee (Tailwind text-4xl = 1,11) */
    line-height: 1.2;
    clip-path: inset(0.14em -0.2em 0.06em);
}

.mo-n > span {
    color: transparent;
}

.mo-n::after {
    content: "0\A 1\A 2\A 3\A 4\A 5\A 6\A 7\A 8\A 9";
    /* lege alt-tekst: schermlezers lezen alleen het echte cijfer, niet de rol 0–9 (oudere browsers: regel hierboven) */
    content: "0\A 1\A 2\A 3\A 4\A 5\A 6\A 7\A 8\A 9" / "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    text-align: center;
    white-space: pre;
    transform: translateY(calc(var(--d) * -10%));
}

.motion .mo-n::after {
    transition: transform calc(var(--mo-duration) * 2) var(--mo-ease) calc(var(--n, 0) * 90ms);
}

/* Meter: balk die tot zijn waarde vult; hoogte, kleur en achtergrond kiest de site */
.mo-meter {
    display: block;
    height: 0.375rem;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 14%, transparent);
}

.mo-meter > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: currentColor;
    transform: scaleX(var(--v));
    transform-origin: left;
}

.motion .mo-meter > span {
    transition: transform calc(var(--mo-duration) * 1.5) var(--mo-ease);
}

/* Sparkline: lijn die zichzelf tekent */
.mo-spark {
    display: block;
    width: 100%;
    height: 2rem;
    overflow: visible;
}

/* onthullen met clip-path i.p.v. stroke-dash: dat meet Chrome in schermpixels bij een uitgerekte, niet-schalende lijn */
.motion .mo-spark {
    clip-path: inset(-4px);
    transition: clip-path calc(var(--mo-duration) * 2) var(--mo-ease);
}

/* Hero-intro: kinderen komen na elkaar binnen (bij het laden) */
.motion [data-intro] > * {
    animation: mo-in var(--mo-duration) var(--mo-ease) both;
}

.motion [data-intro] > :nth-child(2) { animation-delay: 120ms; }
.motion [data-intro] > :nth-child(3) { animation-delay: 240ms; }
.motion [data-intro] > :nth-child(4) { animation-delay: 360ms; }
.motion [data-intro] > :nth-child(5) { animation-delay: 480ms; }
.motion [data-intro] > :nth-child(n + 6) { animation-delay: 600ms; }

/* een bewegende kop in de intro schuift al woord voor woord; niet ook nog als blok */
.motion [data-intro] > :has(.mo-w) { animation: none; }

@keyframes mo-in {
    from { opacity: 0; transform: translateY(0.75rem); }
}

/* Wachten tot het in beeld is */
.motion [data-motion]:not(.is-inview) .mo-w > span {
    animation: none;
    opacity: 0;
}

.motion [data-motion]:not(.is-inview) :is(.mo-rise, .mo-lines) > span {
    opacity: 1;
    transform: translateY(110%);
}

.motion [data-motion]:not(.is-inview) .mo-n::after {
    transform: none;
    transition: none;
}

.motion [data-motion]:not(.is-inview) .mo-meter > span {
    transform: scaleX(0);
    transition: none;
}

.motion [data-motion]:not(.is-inview) .mo-spark {
    clip-path: inset(-4px 100% -4px -4px);
    transition: none;
}
