/* ═══════════════════════════════════════════════════════════════════════════
   Lyndsie Clark — Motion
   Loaded last. Depends on lc-tokens.css for its easings and durations.

   THE RULE THIS FILE FOLLOWS
   Motion is spent in one place, not sprinkled. Fading every section up as it
   enters the viewport is the default that every generated page does, and it
   reads as filler. So:

     · ONE orchestrated moment — the home hero resolving on load. It is the
       first thing anyone sees and the only place with a scripted sequence.
     · ONE deliberate reveal — the book covers, because the covers are the
       point of the page and a stagger makes you look at each one.
     · Everything else earns its motion by answering a person: hover, focus,
       opening, confirming. That motion shows what changed, so it stays.

   Nothing here animates layout properties. Only transform, opacity, filter
   and clip-path — the four the compositor can handle without reflowing the
   page, which is what keeps this smooth on the 2 GB box it runs on.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── The reduced-motion contract ─────────────────────────────────────────── */
/* Someone who has asked their system for less motion gets the finished state
   immediately — never a half-played animation, never a hidden element that
   only script would have revealed. Written as one block at the top so it is
   impossible to add an animation below and forget to opt it out. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .lc-reveal, .lc-hero-stage > * { opacity: 1 !important; transform: none !important; }
    .lc-ember-line { display: none; }
}

/* ═══ 1 · The hero sequence ══════════════════════════════════════════════
   Runs once, on load, on the home page only. The photograph settles out of a
   slight over-scale while the type arrives under it in four steps. The whole
   thing is over in 1.4s and never repeats — a sequence you have to sit through
   twice is an obstacle, not an entrance.

   .lc-hero-stage is put on the hero by site.js only after it confirms the
   page was not restored from bfcache and motion is allowed, so a hero with no
   JavaScript is simply visible — never blank. */
.lc-hero-stage .lc-hero-media img {
    animation: lc-hero-settle 1600ms var(--lc-ease-out) both;
}
@keyframes lc-hero-settle {
    from { transform: scale(1.08); filter: saturate(0.6) brightness(0.7); }
    to   { transform: scale(1);    filter: saturate(1)   brightness(1); }
}

/* The four type steps. Each starts before the one above finishes, so it reads
   as one movement rather than four. */
.lc-hero-stage .lc-hero-body > * { animation: lc-rise 760ms var(--lc-ease-out) both; }
.lc-hero-stage .lc-hero-body > :nth-child(1) { animation-delay: 160ms; }
.lc-hero-stage .lc-hero-body > :nth-child(2) { animation-delay: 300ms; }
.lc-hero-stage .lc-hero-body > :nth-child(3) { animation-delay: 440ms; }
.lc-hero-stage .lc-hero-body > :nth-child(4) { animation-delay: 580ms; }

@keyframes lc-rise {
    from { opacity: 0; transform: translate3d(0, 22px, 0); }
    to   { opacity: 1; transform: none; }
}

/* The ember rule under the hero headline draws itself left-to-right as the
   last beat of the sequence — the one flourish, and it is the signal colour
   introducing itself. */
.lc-hero-stage .lc-rule {
    animation: lc-draw 620ms var(--lc-ease-out) 700ms both;
    transform-origin: left center;
}
@keyframes lc-draw {
    from { transform: scaleX(0); opacity: 0; }
    to   { transform: scaleX(1); opacity: 0.95; }
}

/* ═══ 2 · The cover reveal ═══════════════════════════════════════════════
   The books rise in sequence the first time they come into view, and only the
   first time. site.js adds .is-in and then stops observing them.

   Covers rise further and slower than ordinary content (26px / 720ms) because
   they are large objects — the same distance that reads as brisk on a line of
   text reads as a twitch on a 400px image. */
.lc-reveal {
    opacity: 0;
    transform: translate3d(0, 26px, 0);
    transition:
        opacity   var(--lc-dur-reveal) var(--lc-ease-out),
        transform var(--lc-dur-reveal) var(--lc-ease-out);
    /* Promoted only while it has work to do; site.js clears will-change when
       the transition ends, so a long page does not hold dozens of layers. */
    will-change: opacity, transform;
}
.lc-reveal.is-in { opacity: 1; transform: none; }
.lc-reveal.is-done { will-change: auto; }

/* The stagger is a custom property the markup sets per item, so a row of three
   and a row of six both read correctly without a CSS rule per position. */
.lc-reveal { transition-delay: calc(var(--lc-stagger, 0) * 90ms); }

/* ═══ 3 · The ember line ═════════════════════════════════════════════════
   A 2px reading-progress rule across the top of the header, in the accent of
   whatever work the page belongs to. It is information — how far through a
   long post you are — not decoration, which is the only reason it is allowed
   to move on its own.

   Where the browser supports scroll-driven animations it is done entirely in
   CSS, off the main thread. Where it does not, site.js writes --lc-progress on
   a rAF-throttled scroll listener. */
.lc-ember-line {
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    transform-origin: left center;
    transform: scaleX(var(--lc-progress, 0));
    background: linear-gradient(90deg, var(--lc-work), var(--lc-cyan));
    pointer-events: none;
}
@supports (animation-timeline: scroll()) {
    .lc-ember-line {
        transform: scaleX(0);
        animation: lc-progress linear both;
        animation-timeline: scroll(root block);
    }
    @keyframes lc-progress { to { transform: scaleX(1); } }
}

/* ═══ 4 · Interaction ════════════════════════════════════════════════════
   Motion that answers something a person did. No observer, no sequence —
   it happens because they acted, and it shows what changed. */

/* Pressed state on anything clickable. 1px is enough to feel; more reads as a
   bug on a touchscreen where there is no hover to precede it. */
.lc-press { transition: transform var(--lc-dur-fast) var(--lc-ease); }
.lc-press:active { transform: translateY(1px) scale(0.995); }

/* The cover tilts very slightly toward the cursor. --lc-tilt-x/y are written
   by site.js from pointer position, and only on devices that actually have a
   hover-capable pointer. */
@media (hover: hover) and (pointer: fine) {
    .lc-tilt {
        transform:
            perspective(900px)
            rotateX(calc(var(--lc-tilt-y, 0) * -3deg))
            rotateY(calc(var(--lc-tilt-x, 0) * 3deg))
            translateZ(0);
        transition: transform var(--lc-dur) var(--lc-ease-out);
    }
}

/* A field that was submitted and accepted. One pulse of the work's colour —
   the interface confirming, in the same language as its buttons. */
.lc-confirm { animation: lc-confirm 900ms var(--lc-ease-out) both; }
@keyframes lc-confirm {
    0%   { box-shadow: 0 0 0 0 var(--lc-work); }
    70%  { box-shadow: 0 0 0 10px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* Offcanvas/dropdown/modal all come from Bootstrap and already animate; they
   are re-timed here onto the site's easing so nothing moves on a curve the
   rest of the page never uses. */
.offcanvas, .dropdown-menu, .modal-dialog {
    transition-timing-function: var(--lc-ease-out) !important;
    transition-duration: var(--lc-dur) !important;
}

/* ═══ 5 · Page transitions ═══════════════════════════════════════════════
   Cross-document view transitions, where the browser supports them: clicking
   from the blog index into a post keeps the cover and the title in place
   instead of reloading the whole frame. Progressive enhancement — nothing is
   lost where it is unsupported, and it is off entirely under reduced motion
   via the block at the top of this file. */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: var(--lc-dur-slow);
    animation-timing-function: var(--lc-ease-out);
}
