/* Ink Motion · primitives (build spec update 4 §1.1, D3–D5; port of the direction's ink.css §5–§7 with the two critique
   fixes: texture inset 2 px, figure reserve). Self-hosted OFL fonts, the ensō timer ring, the vermilion seal, the brush
   swash, the ink splash and the paper grain. The four textures are same-origin WebP alpha masks in img/ink/; url()
   appears only here and in style.css and never inside a custom property (engines resolve those against different bases).
   - The ensō is driven by the same --p (remaining %, 0–100) that ui/ sets on .dial once per second; --p is never declared
     on .enso itself (it inherits). The only animated mask is the one-shot draw (enso-draw, 700 ms).
   - Loops animate transform/opacity only; a masked element that rotates or scales is its own compositor layer
     (will-change), otherwise Chrome draws a hairline along its box edge. */

/* 1 · FONTS — swap: a first visit without the service worker never shows invisible text */
@font-face{font-family:"Barlow";src:url(../fonts/barlow-latin-500-normal.woff2) format("woff2");font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:"Barlow";src:url(../fonts/barlow-latin-600-normal.woff2) format("woff2");font-weight:600;font-style:normal;font-display:swap}
@font-face{font-family:"Barlow";src:url(../fonts/barlow-latin-700-normal.woff2) format("woff2");font-weight:700;font-style:normal;font-display:swap}
@font-face{font-family:"Barlow";src:url(../fonts/barlow-latin-800-normal.woff2) format("woff2");font-weight:800 900;font-style:normal;font-display:swap}
@font-face{font-family:"Barlow Condensed";src:url(../fonts/barlow-condensed-latin-700-normal.woff2) format("woff2");font-weight:700;font-style:normal;font-display:swap}
@font-face{font-family:"Barlow Condensed";src:url(../fonts/barlow-condensed-latin-800-normal.woff2) format("woff2");font-weight:800;font-style:normal;font-display:swap}
@font-face{font-family:"Barlow Condensed";src:url(../fonts/barlow-condensed-latin-900-normal.woff2) format("woff2");font-weight:900;font-style:normal;font-display:swap}
@font-face{font-family:"Fraunces";src:url(../fonts/fraunces-800.woff2) format("woff2");font-weight:700 900;font-style:normal;font-display:swap}

/* 2 · RING PROGRESS — registered so the one-shot draw can tween it; ui/ steps it once per second */
@property --p{syntax:'<number>';inherits:true;initial-value:100}

/* 3 · ENSŌ — <div class="enso"><i class="trk"></i><i class="arc"></i></div>: the ghost of the whole stroke + the remaining
   ink. Texture (stroke clockwise from the head at 2° to the dry tail at 345°) ∩ a conic gradient whose 5° feathered edge
   reads as thinning ink. Both layers are inset 2 px per side (critique fix 1: no hairline on the scaled rest ring). */
.enso{--a0:2deg;--span:343deg;--tx-in:calc(100% - 4px) calc(100% - 4px);position:relative;width:var(--d,280px);height:var(--d,280px);flex:none}
.enso>.trk,.enso>.arc{position:absolute;inset:0;pointer-events:none;
  -webkit-mask:url(../img/ink/enso.webp) center/var(--tx-in) no-repeat;mask:url(../img/ink/enso.webp) center/var(--tx-in) no-repeat}
/* the ink is painted as an image, not a background-color: contrast checkers (axe) cannot see masks and would take a
   ring's colour for the digits' backdrop; the digits sit inside the clear centre (AC 20), on the field */
.enso>.trk{background-image:linear-gradient(var(--enso-trk),var(--enso-trk))}
.enso>.arc{background-image:linear-gradient(var(--enso),var(--enso));
  -webkit-mask:url(../img/ink/enso.webp) center/var(--tx-in) no-repeat,
    conic-gradient(from var(--a0),#000 calc(var(--p,100) * var(--span) / 100 - 5deg),#0000 calc(var(--p,100) * var(--span) / 100)) center/var(--tx-in) no-repeat;
  -webkit-mask-composite:source-in;
  mask:url(../img/ink/enso.webp) center/var(--tx-in) no-repeat,
    conic-gradient(from var(--a0),#000 calc(var(--p,100) * var(--span) / 100 - 5deg),#0000 calc(var(--p,100) * var(--span) / 100)) center/var(--tx-in) no-repeat;
  mask-composite:intersect}
/* round start / first paint: the brush draws the stroke once (the only animated mask) */
.enso.draw>.arc{animation:enso-draw var(--t-reveal) var(--e-brush) both}
/* rest: 4 s in, 4 s out (transform only) */
.enso.breathe{animation:enso-breathe var(--t-breath) ease-in-out infinite}
/* engines without mask compositing: a plain conic ring cut by one radial mask (no texture, same --p) */
@supports not ((mask-composite:intersect) or (-webkit-mask-composite:source-in)){
  .enso>.trk,.enso>.arc{-webkit-mask:radial-gradient(closest-side,#0000 89%,#000 89.6%,#000 99%,#0000 100%);
    mask:radial-gradient(closest-side,#0000 89%,#000 89.6%,#000 99%,#0000 100%)}
  .enso>.arc{background:conic-gradient(from var(--a0),var(--enso) calc(var(--p,100) * var(--span) / 100),#0000 0)}
}

/* 4 · SEAL — vermilion brush-square stamp (--s size; --seal-c colour) with an inner border and paper specks */
.seal{--s:150px;position:relative;isolation:isolate;width:var(--s);height:var(--s);display:grid;place-items:center;align-content:center;
  rotate:-6deg;color:var(--on-verm);text-align:center;flex:none}
.seal::before{content:"";position:absolute;inset:0;z-index:-2;background:var(--seal-c,var(--verm));clip-path:var(--seal)}
.seal::after{content:"";position:absolute;inset:9%;z-index:-1;border:max(1.5px,calc(var(--s) * .022)) solid var(--on-verm);
  border-radius:5% 8% 4% 7%;opacity:.92}
.seal>.speck{position:absolute;inset:0;z-index:-1;background:var(--paper);opacity:.5;clip-path:var(--seal);pointer-events:none;
  -webkit-mask:url(../img/ink/grain.webp) 0 0/120px 120px repeat;mask:url(../img/ink/grain.webp) 0 0/120px 120px repeat}
.seal svg{--fig:var(--on-verm);--fig-wash:var(--on-verm);--strike:var(--on-verm);color:var(--on-verm)}

/* 5 · SWASH + SPLASH — brush stroke (4.05 : 1; call backdrop, CTA) and sumi ink splash (floods, Geschafft) */
.swash{position:absolute;aspect-ratio:4.05;background:var(--swash-c,var(--verm));pointer-events:none;
  -webkit-mask:url(../img/ink/swash.webp) center/100% 100% no-repeat;mask:url(../img/ink/swash.webp) center/100% 100% no-repeat}
.splash{position:absolute;aspect-ratio:1;background:var(--splash-c,var(--ink));pointer-events:none;
  -webkit-mask:url(../img/ink/splash.webp) center/contain no-repeat;mask:url(../img/ink/splash.webp) center/contain no-repeat}
.enso,.swash,.splash,.seal{will-change:transform}

/* 6 · PRIMARY ACTION — one real brush stroke: the swash texture with its dry tail cropped off-canvas, so the label always
   sits on solid ink (every other control keeps its clip-path shape) */
.btn-primary::before,.btn-start::before{clip-path:none;inset:-5px calc(-1 * var(--gut)) -5px -6px;
  -webkit-mask:url(../img/ink/swash.webp) 0 50%/150% 100% no-repeat;mask:url(../img/ink/swash.webp) 0 50%/150% 100% no-repeat}

/* 7 · PAPER GRAIN — one static fixed layer UNDER the content of a paper screen (an overlay above composited, animated
   layers shows seams at their bounds); never animated. The opaque bars that content scrolls under (the sticky foot,
   the Einstellungen bar) carry their own copy, so the paper never turns flat behind them. */
.screen.paper::before{content:"";position:fixed;inset:0;z-index:-1;pointer-events:none;background:var(--grain-c);opacity:var(--grain-o);
  -webkit-mask:url(../img/ink/grain.webp) 0 0/256px 256px repeat;mask:url(../img/ink/grain.webp) 0 0/256px 256px repeat}
.paper .foot::before,.s-settings .bar::before{content:"";position:absolute;inset:0;z-index:-1;
  pointer-events:none;background:var(--grain-c);opacity:var(--grain-o);
  -webkit-mask:url(../img/ink/grain.webp) 0 0/256px 256px repeat;mask:url(../img/ink/grain.webp) 0 0/256px 256px repeat}

/* 8 · KEYFRAMES — ensō draw (--p 0 → value) and breath, seal press, rise-in, splash splat, duration dab */
@keyframes enso-draw{from{--p:0}}
@keyframes enso-breathe{0%,100%{transform:scale(.86)}50%{transform:scale(1)}}
@keyframes seal-press{0%{opacity:0;transform:scale(1.8) rotate(-12deg)}55%{opacity:1;transform:scale(.92) rotate(0deg)}100%{opacity:1;transform:none}}
@keyframes rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes splat{from{opacity:0;transform:scale(.18) rotate(-30deg)}30%{opacity:1}to{opacity:1;transform:none}}
@keyframes dab-in{from{opacity:0;transform:scale(.4) rotate(-40deg)}to{opacity:1;transform:none}}

/* 9 · REDUCED MOTION — the global kill in style.css stops every animation; the breathing ring rests at full size */
@media (prefers-reduced-motion:reduce){
  .enso.breathe{transform:none}
}
