/* Typing options (js/typeopts.js) as data-to-* attributes on <html>, and the word effects
   (js/app/combat/wordfx.js) on the word line (js/app/wordflow.js). Loaded on every page. */

/* ---------- wrong letters ---------- */
/* show what I typed: the wrong key sits small under the letter */
:root[data-to-typo="below"] .fw i.bad[data-t]::after,
:root[data-to-typo="below"] .typetext .bad[data-t]::after {
  content: attr(data-t); position: absolute; left: 50%; top: 1.02em; transform: translateX(-50%);
  font-size: .46em; line-height: 1; color: var(--red); opacity: .9; pointer-events: none;
}
/* hide: wrong letters look right until the word is sent (Monkeytype's blind mode) */
:root[data-to-typo="hide"] .fw.cur i.bad,
:root[data-to-typo="hide"] .fw.cur i.extra { color: var(--accent); }
:root[data-to-typo="hide"] .typetext .bad { color: var(--accent); text-decoration: none; background: none; }
:root[data-to-typo="hide"] .typetext .caret.err { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
:root[data-to-extra="hide"] .fw i.extra { display: none; }

/* ---------- typed words ---------- */
:root[data-to-typed="fade"] .fw.done { opacity: .32; }
:root[data-to-typed="hide"] .fw.done { visibility: hidden; }

/* ---------- caret ---------- */
:root[data-to-caret="block"] .fw i.at::before { left: 0; width: .6em; top: 16%; bottom: 10%; opacity: .45; }
:root[data-to-caret="block"] .fw i.at.end { width: .6em; }
:root[data-to-caret="under"] .fw i.at::before { left: 0; width: .6em; top: auto; bottom: 4%; height: 2px; }
:root[data-to-caret="under"] .fw i.at.end { width: .6em; }
:root[data-to-caret="off"] .fw i.at::before { display: none; }
:root[data-to-caret="block"] .typetext .caret { width: .6em; opacity: .45; }
:root[data-to-caret="under"] .typetext .caret { width: .6em; height: 2px !important; transform: translateY(1.1em); }
:root[data-to-caret="off"] .typetext .caret { display: none; }

/* ---------- size and font ---------- */
:root[data-to-size="s"] .fw-lines { zoom: .85; }
:root[data-to-size="l"] .fw-lines { zoom: 1.18; }
:root[data-to-size="xl"] .fw-lines { zoom: 1.36; }
:root[data-to-size="s"] .typetext { font-size: .85em; }
:root[data-to-size="l"] .typetext { font-size: 1.18em; }
:root[data-to-size="xl"] .typetext { font-size: 1.36em; }
:root[data-to-font="term"] .fw-lines, :root[data-to-font="term"] .typetext { font-family: var(--f-label); }
:root[data-to-font="sans"] .fw-lines, :root[data-to-font="sans"] .typetext { font-family: var(--f-head); }

/* ---------- a wrong key: the line shakes red, or only turns red with Reduce flashing ---------- */
:root[data-to-errflash="on"] .to-err .fw-lines, :root[data-to-errflash="on"] .typetext.to-err { animation: to-err 260ms ease-out; }
:root[data-to-errflash="on"][data-to-calm] .to-err .fw-lines, :root[data-to-errflash="on"][data-to-calm] .typetext.to-err { animation: to-err-calm 360ms ease-out; }
@keyframes to-err { 0% { transform: translateX(0); color: var(--red); } 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } 100% { transform: none; } }
@keyframes to-err-calm { 0% { color: var(--red); } 100% { } }

/* ---------- Caps Lock ---------- */
.caps-warn { position: absolute; top: 6px; right: 8px; z-index: 6; padding: 3px 8px; border-radius: 4px; pointer-events: none;
  font: 700 11px/1.2 var(--f-label); letter-spacing: .08em; color: #1a0a00; background: var(--amber, #ffb020); }

/* ---------- word effects ----------
   Every effect lands with a short ring in its colour (--fxe is how long ago it landed, as a negative
   delay) and then holds still, so a word never changes while you type it. Vanishing is the exception. */
.fw.wfx { display: inline-block; vertical-align: baseline; --fc: #c9d6dd; }
.fw.wfx:not(.cur) { animation: wfx-land 520ms ease-out var(--fxe, 0s) both; }
@keyframes wfx-land {
  0% { box-shadow: 0 0 0 0 var(--fc); background: color-mix(in srgb, var(--fc) 30%, transparent); }
  100% { box-shadow: 0 0 0 .5em transparent; background: transparent; }
}
.fw.wfx-crossed { --fc: #ff4d5e; text-decoration: line-through; text-decoration-color: rgba(255,77,94,.9); text-decoration-thickness: .09em; }
.fw.wfx-fog { --fc: #b9c9d4; filter: blur(.055em); text-shadow: 0 0 .3em rgba(200,215,225,.75); }
.fw.wfx-fog:not(.cur) { color: color-mix(in srgb, var(--ink-3) 70%, #c9d6dd); }
.fw.wfx-flicker { --fc: #3ee6ff; }
.fw.wfx-flicker:not(.cur) { animation: wfx-land 520ms ease-out var(--fxe, 0s) both, wfx-flicker 1.4s steps(1) var(--fxe, 0s) infinite; color: color-mix(in srgb, var(--ink-3) 60%, #3ee6ff); }
.fw.cur.wfx-flicker { animation: wfx-flicker 1.4s steps(1) var(--fxe, 0s) infinite; }
/* under 2 dips a second, and never below 40% */
@keyframes wfx-flicker { 0%, 100% { opacity: 1; } 12% { opacity: .4; } 18% { opacity: 1; } 55% { opacity: .55; } 61% { opacity: 1; } }
:root[data-to-calm] .fw.wfx-flicker:not(.cur) { animation: wfx-land 520ms ease-out var(--fxe, 0s) both, wfx-breathe 1.8s ease-in-out var(--fxe, 0s) infinite alternate; }
:root[data-to-calm] .fw.cur.wfx-flicker { animation: wfx-breathe 1.8s ease-in-out var(--fxe, 0s) infinite alternate; }
@keyframes wfx-breathe { from { opacity: 1; } to { opacity: .6; } }
.fw.wfx-drift { --fc: #4fe0c0; }
.fw.wfx-drift:not(.cur) { animation: wfx-land 520ms ease-out var(--fxe, 0s) both, wfx-drift 2.6s ease-in-out var(--fxe, 0s) infinite alternate; }
.fw.cur.wfx-drift { animation: wfx-drift 2.6s ease-in-out var(--fxe, 0s) infinite alternate; }
@keyframes wfx-drift { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(.14em, -.24em) rotate(-6deg); } 100% { transform: translate(-.1em, .14em) rotate(5deg); } }
.fw.wfx-mirror { --fc: #ffb020; transform: scaleX(-1); }
.fw.wfx-upside { --fc: #ffb020; transform: scaleY(-1); }
.fw.wfx-mirror:not(.cur), .fw.wfx-upside:not(.cur) { color: color-mix(in srgb, var(--ink-3) 65%, #ffcf7a); }
/* scrambled: each letter shows a glyph, then turns into itself, 80 ms apart, starting 0.3 s after it lands */
.fw.wfx-scramble { --fc: #a35bff; }
.fw.wfx-scramble i.sc { font-style: normal; position: relative; -webkit-text-fill-color: transparent;
  animation: wfx-unsc 1ms linear calc(var(--fxe, 0s) + 300ms + var(--k) * 80ms) forwards; }
.fw.wfx-scramble i.sc::before { content: attr(data-g); position: absolute; left: 0; top: 0; color: #c49bff; -webkit-text-fill-color: #c49bff;
  animation: wfx-unsc-g 1ms linear calc(var(--fxe, 0s) + 300ms + var(--k) * 80ms) forwards; }
@keyframes wfx-unsc { to { -webkit-text-fill-color: currentColor; } }
@keyframes wfx-unsc-g { to { opacity: 0; } }
/* redacted: a black bar until it's the next word, then the bar wipes off to the right */
.fw.wfx-redacted { --fc: #e9edf0; }
.fw.wfx-redacted::before { content: ""; position: absolute; left: -.08em; right: -.08em; top: .3em; bottom: .22em; pointer-events: none; transform-origin: right;
  background: repeating-linear-gradient(-45deg, #2b3137 0 .14em, #22272c .14em .28em); box-shadow: inset 0 0 0 1px rgba(233,237,240,.35), 0 0 8px rgba(0,0,0,.6); }
.fw.wfx-redacted.wfx-open::before { animation: wfx-wipe 260ms ease-in var(--fxo, 0s) forwards; }
@keyframes wfx-wipe { to { transform: scaleX(0); opacity: 0; } }
/* vanishing: a dotted line under it ahead, then the letters you haven't typed fade once you start it */
.fw.wfx-vanish { --fc: #c58bff; text-decoration: underline dotted rgba(197,139,255,.75); text-decoration-thickness: .06em; text-underline-offset: .22em; }
.fw.cur.wfx-vanish.wfx-go i:not(.ok):not(.bad) { animation: wfx-van 450ms ease-in var(--fxv, 0s) forwards; }
.fw.cur.wfx-vanish.wfx-go { text-decoration-color: transparent; }
@keyframes wfx-van { to { color: transparent; } }

/* Sliced (Sovereign Protocol's sword): a red cut line across the word at the swing's angle while it waits; when it's
   the word you're on the line flashes once and the cut half of each letter you haven't typed slides off */
.fw.wfx-slice { --fc: #ff3a4a; }
.fw.wfx-slice::after { content: ""; position: absolute; pointer-events: none; border-radius: 1px;
  background: linear-gradient(90deg, transparent, #ff3a4a 12%, #ffe1e1 50%, #ff3a4a 88%, transparent);
  box-shadow: 0 0 .25em rgba(255,58,74,.7); }
.fw.wfx-cut-h::after { left: -.2em; right: -.2em; top: calc(56% - .035em); height: .07em; transform: rotate(var(--fa, 0deg)); }
.fw.wfx-cut-v::after { top: -.15em; bottom: -.15em; left: calc(var(--cx, .5) * 100% - .035em); width: .07em; transform: rotate(var(--fa, 0deg));
  background: linear-gradient(180deg, transparent, #ff3a4a 12%, #ffe1e1 50%, #ff3a4a 88%, transparent); }
.fw.wfx-slice.wfx-open::after { animation: wfx-cutline 300ms ease-out var(--fxo, 0s) forwards; }
@keyframes wfx-cutline { 0% { opacity: 1; filter: brightness(1.6); } 100% { opacity: 0; } }
.fw i.cut { -webkit-text-fill-color: transparent; }
.fw i.cut > b { position: absolute; left: 0; top: 0; line-height: normal; font-weight: inherit; -webkit-text-fill-color: currentColor; pointer-events: none; }
.fw i.cut > b.gh { animation: wfx-gh-up 340ms cubic-bezier(.3,.6,.4,1) var(--fxo, 0s) forwards; }
.fw.wfx-cut-h.wfx-s1 i.cut > b.gh { animation-name: wfx-gh-down; }
.fw.wfx-cut-v.wfx-s0 i.cut > b.gh { animation-name: wfx-gh-left; }
.fw.wfx-cut-v.wfx-s1 i.cut > b.gh { animation-name: wfx-gh-right; }
@keyframes wfx-gh-up { to { transform: translate(.06em, -.42em) rotate(-5deg); opacity: 0; } }
@keyframes wfx-gh-down { to { transform: translate(.06em, .42em) rotate(5deg); opacity: 0; } }
@keyframes wfx-gh-left { to { transform: translate(-.4em, .18em) rotate(-8deg); opacity: 0; } }
@keyframes wfx-gh-right { to { transform: translate(.4em, .18em) rotate(8deg); opacity: 0; } }
/* the cut edge glows red on the half that stays */

/* Knocked out (Sovereign Protocol's blades): a small blade over the letter while it waits; on the word you're on the
   letter is gone, leaving a red slot. The right letter fills it, a wrong one shows the key you pressed in red */
.fw.wfx-gap { --fc: #ffb020; }
.fw.wfx-gap::after { content: ""; position: absolute; pointer-events: none; left: calc(var(--gk, .5) * 100%); top: -.3em; width: .17em; height: .58em;
  transform: translateX(-50%) rotate(14deg); transform-origin: 50% 100%;
  background: linear-gradient(180deg, #fff3d0, #ffb020 45%, #ff3a4a); clip-path: polygon(50% 100%, 0 30%, 15% 0, 85% 0, 100% 30%);
  filter: drop-shadow(0 0 .12em rgba(255,140,40,.8)); }
.fw.wfx-gap.wfx-open::after { animation: wfx-blade-out 260ms ease-in var(--fxo, 0s) forwards; }
@keyframes wfx-blade-out { to { transform: translate(-50%, .2em) rotate(14deg); opacity: 0; } }
.fw i.gap { -webkit-text-fill-color: transparent; }
.fw i.gap::after { content: ""; position: absolute; left: .08em; right: .08em; bottom: .12em; height: .07em; background: #ff3a4a; box-shadow: 0 0 .2em rgba(255,58,74,.8);
  animation: wfx-slot 260ms ease-out var(--fxo, 0s) both; }
@keyframes wfx-slot { from { transform: scaleX(0); } to { transform: none; } }
.fw.cur i.gapf { color: #fff; text-shadow: 0 0 .3em rgba(255,255,255,.6); }

@media (prefers-reduced-motion: reduce) {
  .fw.wfx:not(.cur) { animation: none; }
  .fw.wfx-drift, .fw.cur.wfx-drift, .fw.wfx-drift:not(.cur) { animation: none; transform: translateY(-.1em) rotate(-4deg); }
  .fw.wfx-flicker:not(.cur), .fw.cur.wfx-flicker { animation: none; opacity: .7; }
  .fw.wfx-redacted.wfx-open::before { animation: none; display: none; }
  .fw i.cut > b.gh { animation: none; display: none; }
  .fw.wfx-slice.wfx-open::after, .fw.wfx-gap.wfx-open::after { animation: none; display: none; }
  .fw i.gap::after { animation: none; }
}

/* the bonus on an effect word typed clean */
.wfx-pop { position: absolute; right: 10px; top: 0; z-index: 4; pointer-events: none; font: 700 15px/1 var(--f-label); color: var(--gold); text-shadow: 0 1px 3px #000;
  animation: wfx-pop 900ms ease-out forwards; }
@keyframes wfx-pop { from { opacity: 1; transform: translateY(6px); } to { opacity: 0; transform: translateY(-14px); } }
@media (prefers-reduced-motion: reduce) { .wfx-pop { animation: wfx-pop-calm 900ms linear forwards; } @keyframes wfx-pop-calm { 0%, 70% { opacity: 1; } 100% { opacity: 0; } } }

/* the combo rule's line on a results card (Combat.ruleScore) */
.gg-rule, .sb-rule, .re-rule { margin: 6px 0 0; font: 400 13px/1.35 var(--f-label); letter-spacing: .03em; color: var(--ink-2); }
.rb-rules { margin: 8px 0 12px; }
/* a flipped word keeps its special's label readable */
.fw.wfx-mirror .fw-lbl { transform: scaleX(-1); transform-origin: 50% 50%; }
.fw.wfx-upside .fw-lbl { transform: scaleY(-1); }

/* Word lines (Gid, 4 Dec 2026): with 2 lines or 1 the World Boss and Boss Rush arenas take the room the words gave up (48 px a line) */
:root[data-to-lines="2"] .page-boss .boss-stage { --stage-h: clamp(240px, calc(100svh - var(--reserve) + 48px), 760px); }
:root[data-to-lines="1"] .page-boss .boss-stage { --stage-h: clamp(240px, calc(100svh - var(--reserve) + 96px), 800px); }
