/* © 2026 MEK.txt. All rights reserved. Part of the MEK design system; not licensed for reuse. */
/* MEK design system · motion
   The rules: things move in whole frames (steps()), by whole pixels. Hover dissolves with a dither; slides move 1px per display frame; other
   state changes are instant. No state or animation may change layout (see DESIGN.md "Stable layout").
   Nothing springs or bounces, and nothing moves on a curve but layout itself: the glide (--dur-glide, --ease-glide:
   the sidebar part, js/glide.js). Every animation stops under prefers-reduced-motion. */

/* ---------- Hover dissolve ----------
   Everything that reacts to hover dissolves into its hover look with a pixel dither, one frame per step:
   25% of pixels, 50% (checkerboard), 75%, 100%, and back out the same way. Text steps between its two inks in sync.
   --dz is the mix (0 = rest, 1 = hover). It's registered so it can be transitioned; steps() keeps it on whole frames.
   Built in for .btn, .link, .pick-btn and .pick-menu buttons. Add .dissolve to anything else: a .px-box with
   --edge-to / --fill-to set, and/or text with --ink / --ink-to set.
   .dissolve-links on a container does the same for every link and button inside it, for markup you can't class
   (text from a CMS or Markdown); set --ink / --ink-to on the container and they inherit.
   .dissolve-ink is text inside a dissolving element that flips with it (a box's title), from its own --ink / --ink-to.
   Focus and selected stay instant: keyboard focus jumps straight to the hover look. */
@property --dz { syntax: "<number>"; inherits: true; initial-value: 0; }

:where(.btn, .link, .pick-btn, .pick-menu button, .menu > button, .check, .range, .disclose > summary, .tree-group > summary, .dissolve, .dissolve-links :is(a, button)) {
  --dz: 0;
  transition: --dz var(--dur-dissolve) var(--ease-dissolve);
}
:is(.btn, .link, .pick-btn, .pick-menu button, .menu > button, .check, .disclose > summary, .tree-group > summary, .dissolve, .dissolve-links :is(a, button), .dissolve-ink) {
  /* Text colour comes from --ink (rest) and --ink-to (hover); set those, not color. Without them it inherits.
     :is() so it outranks the base reset (button, a { color: inherit }). */
  /* Flips at the halfway frame rather than blending, so text is always a real theme colour and stays legible. */
  color: color-mix(in srgb, var(--ink-to, currentColor) calc(clamp(0, (var(--dz) - .45) * 10000, 1) * 100%), var(--ink, currentColor));
}
/* :is(), not :where(): these must outrank the rest state (--dz: 0) that every .px-box sets. */
:is(.btn, .link, .pick-btn, .pick-menu button, .menu > button, .disclose > summary, .tree-group > summary, .dissolve, .dissolve-links :is(a, button)):hover:not(:disabled) { --dz: 1; }
.menu > button:focus { --dz: 1; transition-duration: 0s; }   /* a menu row takes focus from the arrows: it shows as hovered, at once */
:is(.btn, .link, .pick-btn, .pick-menu button, .disclose > summary, .tree-group > summary, .dissolve, .dissolve-links :is(a, button)):focus-visible { --dz: 1; transition-duration: 0s; }
/* A checkbox or radio (.check) dissolves from its label: the input inside it is what's disabled or focused. */
.check:hover:not(:has(> input:disabled)) { --dz: 1; }
.check:has(> input:focus-visible) { --dz: 1; transition-duration: 0s; }
/* A slider (.range) dissolves its handle while the pointer is on the input. */
.range:has(> input:hover:not(:disabled)) { --dz: 1; }
.range:has(> input:focus-visible) { --dz: 1; transition-duration: 0s; }
/* The ">" marker of .link.caret appears one frame into the dissolve. */
.link.caret:hover::before { transition: visibility 0s var(--frame); }

/* ---------- Theme wipe ----------
   Changing theme dithers the new theme in as a circle growing from the control you used (js/mek.js builds the mask
   and animates --wipe-r). The old page stays still underneath; nothing fades or blends.
   --wipe-r is registered so it interpolates smoothly, frame by display frame. */
@property --wipe-r { syntax: "<length>"; inherits: false; initial-value: 0px; }
html.mek-theme-wipe::view-transition-old(root),
html.mek-theme-wipe::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* Idle loops */
@keyframes mek-bop   { 50% { translate: 0 -4px; } }            /* hint sprite, "look here" */
@keyframes mek-blink { 50% { opacity: 0; } }                   /* cursor, recording dot */
@keyframes mek-scan  { from { background-position: 0 0; } to { background-position: 0 4px; } }

/* Entrances */
@keyframes mek-pop-in  { 0% { opacity: 0; } 50% { opacity: var(--fade); translate: 0 2px; } 100% { opacity: 1; translate: 0 0; } }
/* A busy progress bar (.meter): 3 lit cells from just off the left to just off the right, one cell a frame. */
@keyframes mek-meter-march { from { background-position: calc(-3 * (var(--meter-cell) + var(--meter-gap))) 0, 0 0; } to { background-position: calc(var(--meter-span) + var(--meter-gap)) 0, 0 0; } }   /* span + gap: a whole number of cells */
/* A tag's glint (.tag): a 4px dither band from just off the left, 1px a step (a display frame a pixel), the whole
   --tag-glint (250 steps in 4s): 246px in all, so it crosses any tag up to 242px wide and then rests off its right
   edge for the rest of the beat. (It used to stop at 96px, cutting the glint off midway on wider tags.) */
@keyframes mek-tag-glint {
  from { -webkit-mask-position: -4px 0; mask-position: -4px 0; }
  to { -webkit-mask-position: 246px 0; mask-position: 246px 0; }
}
/* The spinner's keyframes (mek-spin) are drawings: they live in css/components/states.css, by the Spinner editor. */
@keyframes mek-pop-out { 0% { opacity: 1; } 50% { opacity: var(--fade); translate: 0 2px; } 100% { opacity: 0; translate: 0 2px; } }   /* .anim-leave */
/* A reveal (.anim-wipe, a disclosure opening): as .anim-pop, but from above. Four frames, held (--ease-step), so every
   one is a whole pixel: it fades in through --fade and settles 4px down into place, a pixel a frame (-4, -3, -2, -1,
   then home). It used to clip in from the top a band at a time, which read as lag; nothing is clipped now, so a menu
   inside can hang out at once. */
@keyframes mek-wipe-in {
  0% { opacity: 0; translate: 0 -4px; }
  25% { opacity: var(--fade); translate: 0 -3px; }
  50% { opacity: var(--fade); translate: 0 -2px; }
  75% { opacity: 1; translate: 0 -1px; }
  100% { opacity: 1; translate: 0 0; }
}
@keyframes mek-type-in { from { width: 0; } }

/* Feedback */
@keyframes mek-shake { 25% { translate: -2px 0; } 50% { translate: 2px 0; } 75% { translate: -1px 0; } }
@keyframes mek-flash { 50% { background: var(--accent); color: var(--100); } }

.anim-bop   { animation: mek-bop var(--dur-loop) var(--ease-step) infinite; }
.anim-blink { animation: mek-blink var(--dur-loop) var(--ease-step) infinite; }
.anim-pop   { animation: mek-pop-in var(--dur-bar) var(--ease-frames-4) both; }   /* 4 frames */
.anim-leave { animation: mek-pop-out var(--dur-bar) var(--ease-frames-4) both; }  /* 4 frames: .anim-pop backwards */
.anim-wipe  { animation: mek-wipe-in var(--dur-bar) var(--ease-step) backwards; }   /* 4 frames: a reveal, .anim-pop from above */
.anim-shake { animation: mek-shake var(--dur-bar) var(--ease-frames-4); }
.anim-flash { animation: mek-flash var(--dur-beat) var(--ease-step) 2; }
/* Typewriter: set --chars to the text length. Needs a mono face for an exact fit. */
.anim-type  { display: inline-block; overflow: hidden; white-space: nowrap; width: calc(var(--chars) * 1ch);
  animation: mek-type-in calc(var(--chars) * var(--dur-type)) steps(var(--chars), end) both; }
/* Rolling glyphs: mek.type(el, text, { roll }) (js/mek.js) has each glyph roll through random ones before it lands,
   a swap each --dur-type. A rolling glyph is a .type-roll span in one of four colours, picked at random each frame:
   --type-roll-1…4, the accent and the three status colours by default (set your own on :root or any [data-theme]).
   "inverse" draws it inverse, the colour its ground; "muted" rolls in the muted ink until its last frame. Mono text
   only: every glyph is one cell, so nothing shifts. */
:root, [data-theme] { --type-roll-1: var(--accent); --type-roll-2: var(--good); --type-roll-3: var(--warn); --type-roll-4: var(--bad); }
.type-roll { color: var(--roll, var(--accent)); }
.type-roll.inverse { background: var(--roll, var(--accent)); color: var(--bg); }
.type-roll.muted { color: var(--text-muted); }
/* Scanlines overlay for CRT moments. Put on a positioned element; it draws over its content. */
.scanlines { position: relative; }
.scanlines::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--scanlines);   /* a faithful theme: solid ground rows */
  animation: mek-scan var(--dur-loop) steps(4) infinite; }

/* Idle loops out of view: js/mek.js adds .mek-paused, so nothing repaints where no one can see it. */
.mek-paused, .mek-paused::before, .mek-paused::after { animation-play-state: paused !important; }

/* Stagger children in by frames: <ul class="stagger"> with style="--i: n" on each child (or nth-child below). */
.stagger > * { animation: mek-pop-in var(--dur-bar) var(--ease-frames-4) both; animation-delay: calc(var(--i, 0) * var(--frame) * 2); }
.stagger > :nth-child(2) { --i: 1; } .stagger > :nth-child(3) { --i: 2; } .stagger > :nth-child(4) { --i: 3; }
.stagger > :nth-child(5) { --i: 4; } .stagger > :nth-child(6) { --i: 5; } .stagger > :nth-child(7) { --i: 6; }

/* Keys: the key of a control just pressed by its key, or of a switch button just chosen, blinks in the full accent
   for two frames, then settles. js/mek.js adds .flip (never on load) and removes it when the blink ends. */
@keyframes mek-key-blink { from { color: var(--accent); } to { color: var(--accent); } }
.flip > kbd { animation: mek-key-blink var(--dur-beat) var(--ease-step); }

/* Dialogs and menus appear in two frames. */
.dialog[open], .pick-menu:not([hidden]), .flyout-panel:not([hidden]) { animation: mek-pop-in var(--dur-beat) var(--ease-frames-2) both; }

/* A phone's bottom sheet (a .dialog.large, dialog.css) slides up on the glide (a Deviation, as the glide is: the one
   smooth motion, on transform only, so the phone's compositor runs it) and away in --dur-leave, speeding up. Dragged,
   it follows the finger (.sheet-dragging); let go short of shutting, it springs back on the same glide. js/mek.js
   marks it .sheet-up once it's up (so a spring back never slides it up again) and .sheet-leaving as it goes. */
@media (width <= 640px) {   /* --bp-phone */
  .dialog.large[open]:not([data-sheet="off"]) { animation: mek-sheet-up var(--dur-glide) var(--ease-glide) both;
    transition: transform var(--dur-glide) var(--ease-glide); will-change: transform; }
  .dialog.large.sheet-up:not([data-sheet="off"]) { animation: none; }
  .dialog.large.sheet-dragging:not([data-sheet="off"]) { animation: none; transition: none; }
  .dialog.large.sheet-leaving:not([data-sheet="off"]) { animation: mek-sheet-down var(--dur-leave) var(--ease-leave) both; }
}
@keyframes mek-sheet-up { from { transform: translateY(100%); } }
@keyframes mek-sheet-down { from { transform: translateY(var(--sheet-from, 0px)); } to { transform: translateY(100%); } }

/* ---------- Icons that point (hover) ----------
   Hover a control and its icon moves the way it means, once: out 2px, back 1px, home, a frame each (3 frames). Next's
   arrow goes right, Download's down, Upload's up, the external arrow up and out, a close (×) 1px in. By the icon it
   draws (the sprite's arrow-*, download, upload, external, close), so every button, link and close in every app does
   it with nothing added; .point-right, -left, -up, -down, -out, -in on any other .icon. --point-x/-y the move,
   --point-hx/-hy its half on the way back (whole pixels). */
.icon:has(> use[href$="#icon-arrow-right"]), .icon.point-right { --point-x: 2px; --point-y: 0px; --point-hx: 1px; --point-hy: 0px; }
.icon:has(> use[href$="#icon-arrow-left"]), .icon.point-left { --point-x: -2px; --point-y: 0px; --point-hx: -1px; --point-hy: 0px; }
.icon:has(> use[href$="#icon-arrow-up"]), .icon:has(> use[href$="#icon-upload"]), .icon.point-up { --point-x: 0px; --point-y: -2px; --point-hx: 0px; --point-hy: -1px; }
.icon:has(> use[href$="#icon-arrow-down"]), .icon:has(> use[href$="#icon-download"]), .icon.point-down { --point-x: 0px; --point-y: 2px; --point-hx: 0px; --point-hy: 1px; }
.icon:has(> use[href$="#icon-external"]), .icon.point-out { --point-x: 2px; --point-y: -2px; --point-hx: 1px; --point-hy: -1px; }
.icon:has(> use[href$="#icon-close"]), .icon.point-in, .close > .icon { --point-x: 0px; --point-y: 1px; --point-hx: 0px; --point-hy: 0px; }
@keyframes mek-point { 0% { translate: var(--point-x) var(--point-y); } 34% { translate: var(--point-hx) var(--point-hy); } 67%, 100% { translate: 0 0; } }
:is(.btn, .link, .pick-btn, .close, .tag-x):not(:disabled, [aria-disabled="true"]):hover > :is(.icon:has(> use[href$="#icon-arrow-right"]), .icon.point-right, .icon:has(> use[href$="#icon-arrow-left"]), .icon.point-left, .icon:has(> use[href$="#icon-arrow-up"]), .icon:has(> use[href$="#icon-upload"]), .icon.point-up, .icon:has(> use[href$="#icon-arrow-down"]), .icon:has(> use[href$="#icon-download"]), .icon.point-down, .icon:has(> use[href$="#icon-external"]), .icon.point-out, .icon:has(> use[href$="#icon-close"]), .icon.point-in, .close > .icon) {
  animation: mek-point calc(3 * var(--frame)) step-end; }

/* ---------- Aim: corner brackets (hover) ----------
   <div class="aim px-box">…</div>: a thing you can choose (a picker card, a library card, a game menu's card) is aimed
   at. Pointed at or focused, pixel brackets in the accent close in on its four corners, 8px out to 4px, a pixel a
   frame (4 frames), and stay while it's aimed at; they go at once. js/mek.js adds the brackets (.aim-marks) to every
   .aim, now and later. A positioned box (a .px-box is). */
@property --aim-k { syntax: "<length>"; inherits: false; initial-value: 0px; }
:where(.aim) { position: relative; }
.aim-marks { position: absolute; inset: -8px; pointer-events: none; opacity: 0; color: var(--accent); --aim-k: 0px;
  background:
    linear-gradient(currentColor, currentColor) var(--aim-k) var(--aim-k) / 8px 1px no-repeat,
    linear-gradient(currentColor, currentColor) var(--aim-k) var(--aim-k) / 1px 8px no-repeat,
    linear-gradient(currentColor, currentColor) calc(100% - var(--aim-k)) var(--aim-k) / 8px 1px no-repeat,
    linear-gradient(currentColor, currentColor) calc(100% - var(--aim-k)) var(--aim-k) / 1px 8px no-repeat,
    linear-gradient(currentColor, currentColor) var(--aim-k) calc(100% - var(--aim-k)) / 8px 1px no-repeat,
    linear-gradient(currentColor, currentColor) var(--aim-k) calc(100% - var(--aim-k)) / 1px 8px no-repeat,
    linear-gradient(currentColor, currentColor) calc(100% - var(--aim-k)) calc(100% - var(--aim-k)) / 8px 1px no-repeat,
    linear-gradient(currentColor, currentColor) calc(100% - var(--aim-k)) calc(100% - var(--aim-k)) / 1px 8px no-repeat; }
.aim:is(:hover, :focus-visible) > .aim-marks { opacity: 1; --aim-k: 4px; transition: --aim-k calc(4 * var(--frame)) steps(4, end); }

/* ---------- Link underline (hover) ----------
   A text link (a .link with words, no box) draws a dotted 1px underline in on hover, 1 on 1 off, from its start: in
   about 12 display frames (~200ms) whatever its length, a whole even number of pixels a frame, so it lands on whole
   pixels and keeps its rhythm (js/mek.js measures the link's words as the pointer arrives: --ul-at where they start,
   --ul-to their length, --ul-n frames), so it's under the words alone, not a leading or trailing icon or the rest of a
   box that stretches. It goes at once. Drawn as the link's own background, so it never hangs out of its box. */
:is(a, button).link:not(.caret, .px-box, [aria-label]) {
  background-image: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 2px);
  background-position: var(--ul-at, 0) 100%; background-repeat: no-repeat; background-size: 0 1px; }
:is(a, button).link:not(.caret, .px-box, [aria-label]):hover:not(:disabled) {
  background-size: var(--ul-to, 100%) 1px;
  transition: --dz var(--dur-dissolve) var(--ease-dissolve), background-size calc(var(--ul-n, 12) * var(--px-frame)) steps(var(--ul-n, 12), end); }

/* ---------- Dither in and out ----------
   .anim-dither-in: something appears through the theme wipe's dither, 25, 50, 75%, solid, a frame each (4 frames), in
   2px grains; .anim-dither-out leaves the same way back and stays gone. Every toast comes and goes this way; for a
   card, a picture. */
@keyframes mek-dither-in {
  0% { -webkit-mask-image: conic-gradient(#000 0 25%, transparent 0); mask-image: conic-gradient(#000 0 25%, transparent 0); }
  25% { -webkit-mask-image: conic-gradient(#000 0 25%, transparent 0 50%, #000 0 75%, transparent 0); mask-image: conic-gradient(#000 0 25%, transparent 0 50%, #000 0 75%, transparent 0); }
  50% { -webkit-mask-image: conic-gradient(#000 0 75%, transparent 0); mask-image: conic-gradient(#000 0 75%, transparent 0); }
  75%, 100% { -webkit-mask-image: none; mask-image: none; } }
@keyframes mek-dither-out {
  0% { -webkit-mask-image: conic-gradient(#000 0 75%, transparent 0); mask-image: conic-gradient(#000 0 75%, transparent 0); }
  25% { -webkit-mask-image: conic-gradient(#000 0 25%, transparent 0 50%, #000 0 75%, transparent 0); mask-image: conic-gradient(#000 0 25%, transparent 0 50%, #000 0 75%, transparent 0); }
  50% { -webkit-mask-image: conic-gradient(#000 0 25%, transparent 0); mask-image: conic-gradient(#000 0 25%, transparent 0); }
  75%, 100% { opacity: 0; } }
.anim-dither-in, .anim-dither-out { -webkit-mask-size: 4px 4px; mask-size: 4px 4px; }
.anim-dither-in { animation: mek-dither-in var(--dur-bar) step-end both; }
.anim-dither-out { animation: mek-dither-out var(--dur-bar) step-end both; }

/* ---------- Marching ants ----------
   mek.ants(el) / mek.ants(el, false): while something is a target or selected (a drop zone while you drag over it, a
   selection, a box Claude is making), a dashed 1px outline in the ink steps round it, 2 on, 2 off, a pixel a frame,
   3px outside it. Only while that lasts; it pauses off screen. (.ants, put in the element by js/mek.js.) */
.ants { --p: var(--ants-px, 1px); position: absolute; inset: calc(-3 * var(--p)); pointer-events: none; --ants-ink: var(--text-strong);
  background:
    repeating-linear-gradient(90deg, var(--ants-ink) 0 calc(2 * var(--p)), transparent 0 calc(4 * var(--p))) 0 0 / 100% var(--p) no-repeat,
    repeating-linear-gradient(90deg, var(--ants-ink) 0 calc(2 * var(--p)), transparent 0 calc(4 * var(--p))) 0 100% / 100% var(--p) no-repeat,
    repeating-linear-gradient(0deg, var(--ants-ink) 0 calc(2 * var(--p)), transparent 0 calc(4 * var(--p))) 0 0 / var(--p) 100% no-repeat,
    repeating-linear-gradient(0deg, var(--ants-ink) 0 calc(2 * var(--p)), transparent 0 calc(4 * var(--p))) 100% 0 / var(--p) 100% no-repeat;
  animation: mek-march calc(4 * var(--frame)) steps(4, end) infinite; }
/* --ants-px: one of its pixels (1px). A canvas that zooms sets it to a screen pixel (Buildermek: calc(1px * its
   inverse zoom)), so the line stays 1px on screen. */
@keyframes mek-march { to { background-position: calc(4 * var(--p)) 0, calc(-4 * var(--p)) 100%, 0 calc(-4 * var(--p)), 100% calc(4 * var(--p)); } }

/* ---------- Hop ----------
   .anim-hop: up 2px, home, up, home, a frame each (4 frames), once: something new arrived (a bell, an inbox). */
@keyframes mek-hop { 0%, 50% { translate: 0 -2px; } 25%, 75%, 100% { translate: 0 0; } }
.anim-hop { animation: mek-hop var(--dur-bar) step-end; }

/* ---------- Card turn ----------
   <div class="px-box anim-turn"><span class="turn-back">…</span><span class="turn-face">…</span></div>: a card turns
   over on its upright axis, 8 frames (2 × --dur-bar), every step whole card pixels. It lifts a pixel and drops a hard
   silhouette shadow, narrows to its edge (|cos| of 0, 45, 70 and 90°: 40, 28, 14, 2 pixels of a 40-pixel card), is
   only its edge edge-on, widens again with its other side and lands flat. The width is a clip, never a scale, so its
   lines and its glyphs stay crisp; two lines at the clip's sides keep it a card and meet edge-on as one solid edge.
   Nothing reflows. mek.turn(el) (js/mek.js) runs it: it adds the shadow and the edge (.turn-shadow, .turn-edge), turns
   it face up (.up) or back down, and resolves when it lands. By hand: those two spans, then .up and .turning, and
   take .turning off on its animationend for mek-turn.
   Dials: --turn-u, one card pixel (1px; a card drawn at 3× sets 3px); --turn-w, its width in those pixels (mek.turn
   measures it; 40 without); --turn-pad, how far in its back and face sit (measured too; 0 without), so they keep to
   the narrowed card and never show over the shadow; --turn-shadow, the shadow's tone (--motif-4, a frame's shadow);
   --turn-i, frames to wait first (a row turns column by column: its column). Under reduced motion it's over at once. */
@property --turn-x { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --turn-u { syntax: "<length>"; inherits: true; initial-value: 1px; }
:where(.anim-turn) { position: relative; display: grid; place-items: center; }
.anim-turn { --turn-shadow: var(--motif-4); --turn-d: calc(2 * var(--dur-bar)); --turn-wait: calc(var(--turn-i, 0) * var(--frame));
  /* The inset each side, a frame at a time: (1 − cos) / 2 of the width, rounded to whole card pixels; edge-on, 2 left. */
  --turn-1: round(calc(var(--turn-w, 40) * var(--turn-u) * .1464), var(--turn-u));
  --turn-2: round(calc(var(--turn-w, 40) * var(--turn-u) * .329), var(--turn-u));
  --turn-3: round(down, calc(var(--turn-w, 40) * var(--turn-u) / 2 - var(--turn-u)), var(--turn-u)); }
.anim-turn > :is(.turn-back, .turn-face) { grid-area: 1 / 1; }
.anim-turn > .turn-face, .anim-turn.up > .turn-back { visibility: hidden; }
.anim-turn.up > .turn-face { visibility: visible; }
.anim-turn > :is(.turn-shadow, .turn-edge) { position: absolute; inset-block: 0; inset-inline: var(--turn-x); visibility: hidden; pointer-events: none; }
.anim-turn > .turn-shadow { z-index: -3; background: var(--turn-shadow); translate: calc(2 * var(--turn-u)) calc(3 * var(--turn-u)); }   /* under the box's fill: shows only where it's offset */
.anim-turn > .turn-edge { z-index: 1; border-inline: var(--turn-u) solid var(--edge, var(--line)); }
/* While it turns, it's clipped to the narrowed card and the shadow's band, 2 right and 3 down (lifted 1, dropped 2). */
.anim-turn.turning {
  animation: mek-turn var(--turn-d) step-end var(--turn-wait);
  clip-path: polygon(var(--turn-x) 0, calc(100% - var(--turn-x)) 0, calc(100% - var(--turn-x)) calc(3 * var(--turn-u)),
    calc(100% - var(--turn-x) + 2 * var(--turn-u)) calc(3 * var(--turn-u)), calc(100% - var(--turn-x) + 2 * var(--turn-u)) calc(100% + 3 * var(--turn-u)),
    calc(var(--turn-x) + 2 * var(--turn-u)) calc(100% + 3 * var(--turn-u)), calc(var(--turn-x) + 2 * var(--turn-u)) 100%, var(--turn-x) 100%); }
.anim-turn.turning > :is(.turn-back, .turn-face) { clip-path: inset(0 max(0px, var(--turn-x) - var(--turn-pad, 0) * var(--turn-u))); }
/* The side that was up goes at the edge-on frame; the other shows from the next. Face up (.up) or back down. */
.anim-turn.turning.up > .turn-back, .anim-turn.turning:not(.up) > .turn-face { animation: mek-turn-out var(--turn-d) step-end var(--turn-wait) both; }
.anim-turn.turning.up > .turn-face, .anim-turn.turning:not(.up) > .turn-back { animation: mek-turn-in var(--turn-d) step-end var(--turn-wait) both; }
.anim-turn.turning > .turn-shadow { animation: mek-turn-lift var(--turn-d) step-end var(--turn-wait); }
.anim-turn.turning > .turn-edge { animation: mek-turn-edge var(--turn-d) step-end var(--turn-wait); }
@keyframes mek-turn {
  0% { --turn-x: 0px; translate: 0 calc(-1 * var(--turn-u)); }
  12.5% { --turn-x: var(--turn-1); }
  25% { --turn-x: var(--turn-2); }
  37.5% { --turn-x: var(--turn-3); }
  50% { --turn-x: var(--turn-2); }
  62.5% { --turn-x: var(--turn-1); }
  75%, 100% { --turn-x: 0px; }
  87.5%, 100% { translate: 0 0; }
}
@keyframes mek-turn-out { 0% { visibility: visible; } 37.5%, 100% { visibility: hidden; } }
@keyframes mek-turn-in { 0% { visibility: hidden; } 50%, 100% { visibility: visible; } }
@keyframes mek-turn-lift { 0% { visibility: visible; } 87.5%, 100% { visibility: hidden; } }
@keyframes mek-turn-edge { 0% { visibility: hidden; } 12.5% { visibility: visible; } 75%, 100% { visibility: hidden; } }

/* ---------- Zoom outlines, bursts: the effects layer ----------
   js/mek.js draws them in one layer over everything (a popover, so over an open dialog too). Zoom: opening a dialog
   (.dialog) from a button, seven outlines step from the button to the dialog, the system's stepped 1px edge, 2 display
   frames each (~230ms in all), then it's there; closing, they step back. data-zoom="off" on a dialog: none. Burst:
   mek.burst(el): eight 2px sparks in the accent out of the top of el (or { x, y }), 4 frames, then gone. */
.mek-fx { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: none; overflow: visible; pointer-events: none; z-index: var(--z-fx); }
.mek-fx > .mek-zoom { position: absolute; --edge: var(--text-strong); --fill: transparent; }
.mek-fx > .mek-burst { position: absolute; width: 0; height: 0; }
.mek-burst > i { position: absolute; width: 2px; height: 2px; background: var(--accent); }

/* ---------- Counting (mek.count) ----------
   A number rolls to its new value: in 6 steps, each digit that changes showing half of the old and half of the new for
   a frame, then the new (2 frames a step). */
.count-cell { display: inline-block; overflow-y: clip; vertical-align: top; }
.count-col { display: grid; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition: none !important; }
  .cursor::after, .anim-blink { animation: none !important; }
}
