/*
 * Motion: what moves on its own, the page wipe, the cursor. Everything
 * here is off for a reader who asked for less motion, and when the
 * visitor pauses it (html[data-motion="off"], the footer's switch). The
 * still state of each is the finished design, not a broken one.
 */

/* The page wipe: the next page opens through a gradient-edged star that
   grows from where you clicked (--wipe-x, --wipe-y, set by the script in
   the layout's head). Same-page parts (the header) stay put. */
@property --wipe {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
}

::view-transition-old(root) {
    animation: mdpt-recede var(--duration-wipe) var(--ease) both;
}

::view-transition-new(root) {
    animation: mdpt-star-wipe var(--duration-wipe) cubic-bezier(.65, 0, .35, 1) both;
    clip-path: polygon(
        calc(var(--wipe-x, 50%) + var(--wipe) * 0.0000) calc(var(--wipe-y, 50%) + var(--wipe) * -1.0000),
        calc(var(--wipe-x, 50%) + var(--wipe) * 0.2704) calc(var(--wipe-y, 50%) + var(--wipe) * -0.3721),
        calc(var(--wipe-x, 50%) + var(--wipe) * 0.9511) calc(var(--wipe-y, 50%) + var(--wipe) * -0.3090),
        calc(var(--wipe-x, 50%) + var(--wipe) * 0.4375) calc(var(--wipe-y, 50%) + var(--wipe) * 0.1421),
        calc(var(--wipe-x, 50%) + var(--wipe) * 0.5878) calc(var(--wipe-y, 50%) + var(--wipe) * 0.8090),
        calc(var(--wipe-x, 50%) + var(--wipe) * 0.0000) calc(var(--wipe-y, 50%) + var(--wipe) * 0.4600),
        calc(var(--wipe-x, 50%) + var(--wipe) * -0.5878) calc(var(--wipe-y, 50%) + var(--wipe) * 0.8090),
        calc(var(--wipe-x, 50%) + var(--wipe) * -0.4375) calc(var(--wipe-y, 50%) + var(--wipe) * 0.1421),
        calc(var(--wipe-x, 50%) + var(--wipe) * -0.9511) calc(var(--wipe-y, 50%) + var(--wipe) * -0.3090),
        calc(var(--wipe-x, 50%) + var(--wipe) * -0.2704) calc(var(--wipe-y, 50%) + var(--wipe) * -0.3721)
    );
}

@keyframes mdpt-star-wipe {
    from { --wipe: 0px; }
    to { --wipe: 260vmax; }
}

@keyframes mdpt-recede {
    to { scale: .97; opacity: .6; }
}

/* Text that rises in line by line waits hidden until it is split
   (js/reveal.js shows each one); the layout's head script sets the class
   only when things may move, and lifts it after a second regardless. */
.mdpt-reveal [data-lines]:not(.is-split) {
    visibility: hidden;
}

html[data-motion="off"]::view-transition-old(root),
html[data-motion="off"]::view-transition-new(root) {
    animation: none;
    clip-path: none;
}

@media (prefers-reduced-motion: no-preference) {
    html:not([data-motion="off"]) .blob {
        animation: mdpt-breathe 14s ease-in-out infinite alternate;
    }

    html:not([data-motion="off"]) .blob-b {
        animation-duration: 18s;
        animation-direction: alternate-reverse;
    }


    /* The launch page (page/coming_soon): the sun breathes up and down,
       the stars float, the dot pulses. */
    html:not([data-motion="off"]) .landing-sun-ring {
        animation: mdpt-sun 9s ease-in-out infinite alternate;
    }

    html:not([data-motion="off"]) .landing-sun-core {
        animation: mdpt-sun 7s ease-in-out infinite alternate-reverse;
    }

    html:not([data-motion="off"]) .landing-star {
        animation: mdpt-float 6s ease-in-out infinite;
    }

    html:not([data-motion="off"]) .landing-star-b {
        animation-duration: 7s;
        animation-delay: -3s;
    }

    html:not([data-motion="off"]) .landing-star-c {
        animation-duration: 5s;
        animation-delay: -1.5s;
    }

    html:not([data-motion="off"]) .landing-dot {
        animation: mdpt-pulse 1.8s ease-in-out infinite;
    }

    html:not([data-motion="off"]) .motion-toggle-star {
        animation: mdpt-spin 9s linear infinite;
    }

    html:not([data-motion="off"]) .cursor-star::before {
        animation: mdpt-spin 6s linear infinite;
    }

    /* The phone menu's stack comes in line by line. */
    .site-head[data-nav-open] .nav > .nav-item {
        animation: mdpt-rise .6s var(--ease) both;
    }

    .site-head[data-nav-open] .nav > .nav-item:nth-child(2) { animation-delay: .06s; }
    .site-head[data-nav-open] .nav > .nav-item:nth-child(3) { animation-delay: .12s; }
    .site-head[data-nav-open] .nav > .nav-item:nth-child(4) { animation-delay: .18s; }
    .site-head[data-nav-open] .nav > .nav-item:nth-child(5) { animation-delay: .24s; }
    .site-head[data-nav-open] .nav > .nav-item:nth-child(n + 6) { animation-delay: .3s; }
}

@keyframes mdpt-breathe {
    0% { border-radius: 62% 38% 46% 54% / 55% 45% 55% 45%; rotate: 0deg; }
    50% { border-radius: 40% 60% 58% 42% / 42% 58% 42% 58%; }
    100% { border-radius: 52% 48% 36% 64% / 60% 40% 60% 40%; rotate: 24deg; }
}

@keyframes mdpt-spin {
    to { rotate: 1turn; }
}

@keyframes mdpt-sun {
    to { translate: -50% -1.6vh; }
}

@keyframes mdpt-float {
    50% { translate: 0 -12px; rotate: 9deg; }
}

@keyframes mdpt-pulse {
    50% { scale: 1.6; opacity: .4; }
}

@keyframes mdpt-rise {
    from { opacity: 0; translate: 0 1.2em; }
}

/* The star cursor (motion/cursor.js): the logo's own star, in the
   gradient, that trails the pointer. The system cursor stays: this is
   decoration, not a replacement. */
.cursor-star {
    position: fixed;
    top: 0;
    left: 0;
    z-index: calc(var(--z-overlay) + 1);
    display: grid;
    place-items: center;
    width: 1.9rem;
    aspect-ratio: 1;
    margin: -.95rem 0 0 -.95rem;
    pointer-events: none;
    transition: width var(--duration) var(--ease-spring), margin var(--duration) var(--ease-spring);
}

.cursor-star::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--brand-gradient);
    mask: url("logo-star.svg") center / contain no-repeat;
    transition: opacity var(--duration-fast);
}

.cursor-star-label {
    position: relative;
    font-size: .7rem;
    font-weight: var(--weight-black);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink);
    opacity: 0;
    transition: opacity var(--duration-fast);
}

.cursor-star.is-link {
    width: 3.2rem;
    margin: -1.6rem 0 0 -1.6rem;
}

.cursor-star.has-label {
    width: 5.5rem;
    margin: -2.75rem 0 0 -2.75rem;
}

.cursor-star.has-label .cursor-star-label {
    opacity: 1;
}

/* Over a player's controls and a film playing: out of the way. */
.cursor-star.is-away::before {
    opacity: 0;
}

.burst-star {
    position: fixed;
    z-index: calc(var(--z-overlay) + 1);
    width: .9rem;
    aspect-ratio: 1;
    background: var(--brand-gradient);
    mask: url("logo-star.svg") center / contain no-repeat;
    pointer-events: none;
}

/* On paper: no moving parts, no decorations over the work, no shapes to
   spend ink on. */
@media print {
    .cursor-star,
    .burst-star,
    .sticker,
    .hover-picture,
    .blob,
    .marquee-pause,
    .mesh-canvas,
    .page-freeform::before,
    .project-page::before {
        display: none !important;
    }
}
