/* Type mechanics (the look lives in type-a.css). Markup: js/text.js.
   Every moment is a <section class="m k-<kind>">:
     .scrim        backdrop-coloured field behind the text block (--sc, set per frame from the light)
     .blk          the text block (title, captions, headers, collisions)
     .duo > .col   PL left, TR right, always the same styles
     .ln > .li     one line; .ln is the mask, .li moves
     .anch         word pair split around a projected 3D point (--px, --py); .lead = leader + dot
   States: .on (inside its scroll range), .up (left forward), .down (left backward). */

:root {
  --ink: #1F1A15; --ink2: rgba(31, 26, 21, .72); --acc: #C8321F; --sc: 241, 236, 223;
  --edge0: 16px; --gut: 20px;
  --edgeL: max(var(--edge0), calc(env(safe-area-inset-left, 0px) + 8px));
  --edgeR: max(var(--edge0), calc(env(safe-area-inset-right, 0px) + 8px));
  --top: calc(env(safe-area-inset-top, 0px) + 16px);
  --bot: calc(env(safe-area-inset-bottom, 0px) + 14px);
}
:root.dark { --ink: #F4EEE2; --ink2: rgba(244, 238, 226, .76); --acc: #FFC466; }

#ui { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; color: var(--ink);
  font-kerning: normal; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.m { position: absolute; inset: 0; visibility: hidden; transition: visibility 0s linear .5s; }
.m.on { visibility: visible; transition-delay: 0s; }

.scrim { position: absolute; left: 0; right: 0; opacity: 0; transition: opacity .35s ease; }
.m.on .scrim { opacity: 1; transition-duration: .6s; }

.blk { position: absolute; left: var(--edgeL); right: var(--edgeR); }
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--gut); }
.col.pl { text-align: right; }
.col.tr { text-align: left; }
p { margin: 0; }

/* masks: padded so accents (Ź, İ) and ogoneks (ą, ę) are never clipped */
.ln { display: block; overflow: hidden; white-space: nowrap; padding: .16em .1em .22em; margin: -.16em -.1em -.22em; }
.li { display: inline-block; }
.w, .lab { display: block; }

/* anchored pairs */
.anch { position: absolute; inset: 0; }
.lead { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.lead line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 1 1; stroke-dashoffset: 1; transition: stroke-dashoffset .2s ease-in; }
.m.on .lead line { stroke-dashoffset: 0; transition: stroke-dashoffset .5s cubic-bezier(.16, 1, .3, 1) .1s; }
.lead circle { fill: var(--acc); stroke: rgba(var(--sc), .95); stroke-width: 1.5; opacity: 0; transition: opacity .2s; }
.m.on .lead circle { opacity: 1; transition: opacity .3s .35s; }
.nolead .lead { visibility: hidden; }
.fw { position: absolute; top: var(--py, -999px); transform: translateY(-50%); white-space: nowrap; }
.fw.pl { right: calc(100% - var(--px, 0px) + var(--gap, 14px)); text-align: right; }
.fw.tr { left: calc(var(--px, 0px) + var(--gap, 14px)); text-align: left; }

/* kilometres and finds: fixed, quiet, inside the safe area */
#km, #finds { position: fixed; z-index: 3; pointer-events: none; color: var(--ink); opacity: 0; transition: opacity .4s; }
#km.on, #finds.on { opacity: 1; }
#km { display: flex; align-items: center; }
#km .kr { display: inline-flex; align-items: baseline; gap: .4em; }
#km .track { position: relative; display: block; height: 1px; background: currentColor; }
#km .track i { position: absolute; top: -3px; width: 1px; height: 7px; background: currentColor; }
#km .track b { position: absolute; top: -3px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--acc); }

/* reduced motion: text is simply there, no movement, no fades */
:root.rm #ui *, :root.rm #km, :root.rm #finds, :root.rm #finds * { transition: none !important; }
:root.rm #ui :is(.li, .lab), :root.rm #ui .col::before, :root.rm #ui .blk::before { transform: none !important; opacity: 1 !important; }
:root.rm #ui .lead line { stroke-dashoffset: 0; }
:root.rm .m { transition: none; }
@media (prefers-reduced-motion: reduce) {
  #ui *, #km, #finds, #finds * { transition: none !important; }
  #ui :is(.li, .lab), #ui .col::before, #ui .blk::before { transform: none !important; opacity: 1 !important; }
  #ui .lead line { stroke-dashoffset: 0; }
  .m { transition: none; }
}

/* ---------- no WebGL: hide the live layers (the fallback's own layout is css/fallback.css) ---------- */
body.nogl #gl, body.nogl #ui, body.nogl #spacer, body.nogl #km, body.nogl #finds { display: none; }
