/* ============================================================
   GRUMB — Loading screen (kunai throw through wordmark)
   Injected by loader.js · themes: light (site) / dark
   Colors = site tokens (styles.css)
   ============================================================ */

.gloader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--gl-bg);
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.gloader[data-theme="dark"] {
  --gl-bg: #111110;           /* site --ink */
  --gl-ink: #f5f2ed;          /* site --cream */
  --gl-mask: #1d1d1d;
  --gl-eye: #f5f2ed;
  --gl-rust: #c8440e;         /* site --rust */
  --gl-dust: rgba(245, 242, 237, 0.4);
  --gl-vign: rgba(0, 0, 0, 0.5);
  --gl-shock: rgba(255, 255, 255, 0.6);
}
.gloader[data-theme="light"] {
  --gl-bg: #f5f2ed;           /* site --cream */
  --gl-ink: #111110;          /* site --ink */
  --gl-mask: #111110;
  --gl-eye: #ffffff;
  --gl-rust: #c8440e;
  --gl-dust: rgba(17, 17, 16, 0.35);
  --gl-vign: transparent;     /* no edge-darkening in light — keeps the page edge flush with the app around it */
  --gl-shock: rgba(17, 17, 16, 0.25);
}
.gloader.is-done { opacity: 0; pointer-events: none; }

/* breathing vignette */
.gloader::before {
  content: ""; position: absolute; inset: -12%;
  background: radial-gradient(ellipse at center, transparent 46%, var(--gl-vign) 100%);
  opacity: 0.7; pointer-events: none;
}
.gloader.is-playing::before { animation: gl-vign 4.6s ease-in-out infinite; }
@keyframes gl-vign {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.04); }
}

/* ---- ambient dust (JS-animated dots) ---- */
.gl-dust { position: absolute; inset: 0; pointer-events: none; }
.gl-mote { position: absolute; border-radius: 50%; background: var(--gl-dust); }

/* ---- sumi-e ink wash ---- */
.gl-wash {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(46vmax 30vmax at 24% 28%, var(--gl-dust) 0%, transparent 62%),
    radial-gradient(38vmax 26vmax at 78% 72%, var(--gl-dust) 0%, transparent 60%);
  opacity: 0;
}
.gloader.is-playing .gl-wash { animation: gl-wash-in 2s ease 0.1s forwards; }
@keyframes gl-wash-in { to { opacity: 0.16; } }

/* ---- enso circle (brush-drawn, incomplete) ---- */
.gl-enso {
  position: absolute; left: 50%; top: 50%;
  width: min(620px, 92vmin); height: min(620px, 92vmin);
  transform: translate(-50%, -52%);
  opacity: 0.13; pointer-events: none;
}
.gloader[data-theme="dark"] .gl-enso { opacity: 0.17; }
.gl-enso svg { display: block; width: 100%; height: 100%; }
.gl-enso circle { fill: none; stroke: var(--gl-ink); stroke-linecap: round; }
.gl-enso .gl-enso-a { stroke-width: 11; opacity: 0.8; stroke-dasharray: 87 100; stroke-dashoffset: 87; }
.gl-enso .gl-enso-b { stroke-width: 4; opacity: 0.45; stroke-dasharray: 79 100; stroke-dashoffset: 79; }
.gloader.is-playing .gl-enso-a { animation: gl-draw 1.8s cubic-bezier(0.4, 0, 0.2, 1) 0.1s forwards; }
.gloader.is-playing .gl-enso-b { animation: gl-draw 1.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards; }
@keyframes gl-draw { to { stroke-dashoffset: 0; } }

/* ---- sakura petals (JS-animated) ---- */
.gl-petals { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.gl-petal {
  position: absolute;
  border-radius: 100% 0 100% 0;
  will-change: transform, opacity;
}

/* ---- lockup column ---- */
.gl-lockup {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  gap: 26px;
}

/* mask icon — enters with the wordmark, before the slash */
.gl-mask { width: min(150px, 30vw); opacity: 0; transform: translateY(12px) scale(0.96); }
.gl-mask svg { display: block; width: 100%; height: auto; overflow: visible; }
.gl-mask .gl-i { fill: var(--gl-mask); }
.gl-mask .gl-e { fill: var(--gl-eye); }
.gl-mask .gl-r { fill: var(--gl-rust); }
.gloader.is-playing .gl-mask {
  opacity: 1; transform: translateY(0) scale(1);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.6s,
              transform 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.6s;
}
/* knot micro-flick once the mask lands */
.gl-knot { transform-box: fill-box; transform-origin: 15% 95%; }
.gloader.reveal .gl-knot { animation: gl-knot 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.62s; }
@keyframes gl-knot {
  0%, 100% { transform: rotate(0deg); }
  40%      { transform: rotate(-8deg); }
}

/* ---- wordmark (two clipped halves along the cut) ---- */
.gl-wordwrap { position: relative; }
.gl-cut, .gl-shine {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(44px, 8.5vw, 76px);
  letter-spacing: 0.24em; text-indent: 0.24em;
  line-height: 1.1;
  white-space: nowrap;
}
.gl-cut { color: var(--gl-ink); transition: transform 0.14s cubic-bezier(0.55, 0, 0.85, 0.35); }
.gl-cut-top { clip-path: polygon(-2% -20%, 102% -20%, 102% 34%, -2% 66%); }
.gl-cut-bot {
  position: absolute; inset: 0;
  clip-path: polygon(-2% 66%, 102% 34%, 102% 120%, -2% 120%);
}
/* staggered letter entrance */
.gl-cut span { display: inline-block; opacity: 0; }
.gloader.is-playing .gl-cut span {
  animation: gl-ltr 0.65s cubic-bezier(0.16, 1, 0.3, 1) calc(0.35s + var(--i) * 0.09s) forwards;
}
@keyframes gl-ltr {
  0%   { opacity: 0; transform: translateY(0.4em) scale(1.04); filter: blur(3px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
/* metallic sheen sweep after the letters land */
.gl-shine {
  position: absolute; inset: 0;
  color: transparent; pointer-events: none;
  background: linear-gradient(105deg,
    transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%);
  background-size: 260% 100%;
  background-position: 130% 0;
  -webkit-background-clip: text; background-clip: text;
  opacity: 0;
}
.gloader.is-playing .gl-shine { animation: gl-shine 0.9s ease-in-out 1.25s; }
@keyframes gl-shine {
  0%   { opacity: 0; background-position: 130% 0; }
  15%  { opacity: 0.85; }
  85%  { opacity: 0.85; }
  100% { opacity: 0; background-position: -130% 0; }
}
/* split on slash — harder displacement, edges heat up */
.gloader.slashed .gl-cut-top { transform: translate(-13px, -8px) rotate(-0.5deg); }
.gloader.slashed .gl-cut-bot { transform: translate(13px, 8px) rotate(0.5deg); }
.gloader.slashed .gl-cut { text-shadow: 0 0 20px rgba(200, 68, 14, 0.4); }
.gloader.healed .gl-cut { text-shadow: none; transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1), text-shadow 0.9s ease; }
/* impact shake — whole lockup jolts */
.gloader.slashed .gl-lockup { animation: gl-shake 0.46s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes gl-shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
  12% { transform: translate(calc(-50% - 11px), calc(-50% + 7px)) rotate(-0.7deg); }
  26% { transform: translate(calc(-50% + 10px), calc(-50% - 6px)) rotate(0.6deg); }
  42% { transform: translate(calc(-50% - 7px), calc(-50% + 4px)) rotate(-0.3deg); }
  58% { transform: translate(calc(-50% + 5px), calc(-50% - 2px)) rotate(0.2deg); }
  76% { transform: translate(calc(-50% - 2px), calc(-50% + 1px)) rotate(0deg); }
}
/* vermilion ink burst behind the split logo */
.gl-inkburst {
  position: absolute; left: 50%; top: 50%;
  width: 150%; height: 380%;
  transform: translate(-50%, -50%) scale(0.7);
  background: radial-gradient(ellipse at center,
    rgba(200, 68, 14, 0.38) 0%, rgba(200, 68, 14, 0.13) 42%, transparent 68%);
  filter: blur(6px);
  opacity: 0; pointer-events: none; z-index: -1;
}
.gloader.slashed .gl-inkburst {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  transition: opacity 0.16s ease-out, transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.gloader.healed .gl-inkburst { opacity: 0; transition: opacity 0.9s ease; }
/* heal — slow luxurious return */
.gloader.healed .gl-cut {
  transform: translate(0, 0);
  transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

/* est line — hidden until reveal, tracks in */
.gl-est {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 600; font-size: 12px;
  letter-spacing: 13px; text-indent: 13px;
  color: var(--gl-rust);
  opacity: 0; transform: translateY(6px);
}
.gloader.reveal .gl-est {
  opacity: 1; transform: translateY(0);
  letter-spacing: 7px; text-indent: 7px;
  transition: opacity 0.75s ease 0.2s,
              transform 0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.2s,
              letter-spacing 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.2s,
              text-indent 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.2s;
}

/* ---- slash axis through word center ---- */
.gl-axis {
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  transform: rotate(-4deg);
  pointer-events: none;
}

/* slash line — persists after cut, fades on heal */
.gl-line {
  position: absolute; left: -70vmax; top: -1.25px;
  width: 140vmax; height: 2.5px;
  background: linear-gradient(90deg, transparent, var(--gl-ink) 30%, var(--gl-ink) 70%, transparent);
  transform: scaleX(0); transform-origin: left center;
  opacity: 0;
  transition: opacity 0.3s linear, transform 0.3s linear;
}
.gloader.slashed .gl-line {
  opacity: 0.95; transform: scaleX(1); height: 3px; top: -1.5px;
  box-shadow: 0 0 14px rgba(255, 150, 70, 0.85), 0 0 34px rgba(200, 68, 14, 0.5);
}
.gloader.healed .gl-line { opacity: 0; transition: opacity 0.9s ease; }

/* stitch — rust thread sews the cut closed on heal */
.gl-stitch {
  position: absolute; left: -185px; top: -1px;
  width: 370px; height: 2px;
  background: repeating-linear-gradient(90deg, var(--gl-rust) 0 8px, transparent 8px 15px);
  transform: scaleX(0); transform-origin: left center;
  opacity: 0; pointer-events: none;
}
.gloader.healed .gl-stitch { animation: gl-stitch 1.05s cubic-bezier(0.4, 0, 0.2, 1) 0.1s forwards; }
@keyframes gl-stitch {
  0%   { opacity: 0.9; transform: scaleX(0); }
  55%  { opacity: 0.9; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}

/* frayed cloth fibers at the cut edge (JS-animated) */
.gl-threads { position: absolute; left: 0; top: 0; pointer-events: none; }
.gl-thread { position: absolute; width: 1.4px; border-radius: 1px; will-change: transform, opacity; }

/* light streak trailing the slash */
.gl-streak {
  position: absolute; left: -30vmax; top: -14px;
  width: 60vmax; height: 28px;
  background: radial-gradient(ellipse at center,
    rgba(255, 255, 255, 0.55) 0%, rgba(200, 68, 14, 0.12) 45%, transparent 70%);
  filter: blur(6px);
  opacity: 0; pointer-events: none;
}
/* streak = the throw's wake along the cut; chases the kunai through the word */
.gloader.is-playing .gl-streak { animation: gl-streak 0.4s cubic-bezier(0.55, 0, 0.85, 0.35) 2.35s; }
@keyframes gl-streak {
  0%   { opacity: 0; transform: translateX(-40vmax) scaleX(0.6); }
  25%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateX(48vmax) scaleX(1.15); }
}

/* ---- kunai — thrown from off-screen left along the cut axis ----
   Swap art via KUNAI_SVG in loader.js. Sized 190×34px; adjust width/
   height/left/top together (left = -width, top = -height/2). */
.gl-kunai {
  position: absolute;
  width: 210px; height: 38px;  /* ADJUSTED: larger render so the blade facets & ring read in flight */
  left: -210px; top: -19px;    /* tip (right end) sits at cut-line x=0 when tx=0 */
  transform-origin: 100% 50%;  /* pivot/scale from the tip: new asset dimensions never offset the intersection */
  opacity: 0;
  z-index: 3;
  will-change: transform, opacity, filter;
}
.gl-kunai svg { display: block; width: 100%; height: 100%; }
/* ADJUSTED: 0.72s flight (sweet spot — inside the 0.4–0.75s snappy range).
   Impact wall-clock times UNCHANGED: tip @ word-left = 2.40s (T_LAND),
   tip @ center = 2.49s (T_SLASH). Solved: (2.40−2.08)/0.72 = 44.5%,
   (2.49−2.08)/0.72 = 57%. */
.gloader.is-playing .gl-kunai { animation: gl-kunai-throw 0.72s linear 2.08s forwards; }
/* THE THROW — launch → fractional slow-mo at the word → sharp exit.
   Blur kept minimal so the silhouette stays clean; speed is conveyed by
   keyframe spacing + a modest tail-stretch (scaleX from the tip). */
@keyframes gl-kunai-throw {
  0% {   /* launch — covers ~60vmax in 320ms, decelerating into the word */
    opacity: 0;
    filter: blur(1.8px) drop-shadow(0 0 14px rgba(255, 178, 122, 0.7));
    transform: translateX(-68vmax) rotate(-5deg) scale(1.9, 1.2);
    animation-timing-function: cubic-bezier(0.16, 0.84, 0.44, 1);
  }
  5%   { opacity: 1; }
  44.5% { /* tip meets word-left edge (2.40s) — smear nearly gone */
    filter: blur(0.8px) drop-shadow(0 0 16px rgba(255, 178, 122, 0.85));
    transform: translateX(-190px) rotate(-2.5deg) scale(1.4, 1.28);
    animation-timing-function: linear;
  }
  57% {  /* tip at word center (2.49s = split frame) — crisp, details register */
    filter: blur(0.3px) drop-shadow(0 0 18px rgba(255, 178, 122, 0.9));
    transform: translateX(0) rotate(-1.5deg) scale(1.3, 1.3);
    animation-timing-function: linear;
  }
  67% {  /* tip clears word-right — begin hard re-acceleration */
    filter: blur(0.5px) drop-shadow(0 0 16px rgba(255, 178, 122, 0.8));
    transform: translateX(190px) rotate(0deg) scale(1.32, 1.28);
    animation-timing-function: cubic-bezier(0.7, 0, 0.84, 0);
  }
  94%  { opacity: 1; }
  100% { /* momentum exit — stretch returns as it whips off-screen */
    opacity: 0;
    filter: blur(2.5px) drop-shadow(0 0 12px rgba(255, 178, 122, 0.5));
    transform: translateX(72vmax) rotate(3deg) scale(1.8, 1.2);
  }
}
/* wake trail — streams off the kunai's tail; dims during the readable
   crossing, re-ignites on exit (rides inside .gl-kunai, inherits its motion) */
.gl-ktrail {
  position: absolute; right: 100%; top: calc(50% - 4.5px);
  width: 30vmax; height: 9px;  /* ADJUSTED: slimmer — focus stays on the kunai silhouette */
  background: linear-gradient(270deg,
    color-mix(in oklab, var(--gl-ink) 55%, transparent),
    color-mix(in oklab, #c8440e 22%, transparent) 45%,
    transparent 85%);
  filter: blur(3px);
  opacity: 0; pointer-events: none;
}
/* ADJUSTED: retimed to the 0.72s / 2.08s flight */
.gloader.is-playing .gl-ktrail { animation: gl-ktrail 0.72s linear 2.08s; }
@keyframes gl-ktrail {
  0%    { opacity: 0; }
  8%    { opacity: 0.75; }
  44.5% { opacity: 0.3; }
  67%   { opacity: 0.65; }
  100%  { opacity: 0; }
}

/* pre-throw cue — a glint at the left edge of the cut axis telegraphs
   where the throw will come from (replaces the sword's wind-up) */
.gl-cue {
  position: absolute; left: -46vmax; top: 0;
  width: 12vmax; height: 12vmax; margin: -6vmax 0 0 -6vmax;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 255, 255, 0.75) 0%, rgba(200, 68, 14, 0.2) 40%, transparent 65%);
  filter: blur(2px);
  opacity: 0; pointer-events: none;
}
/* ADJUSTED: cue leads the 2.08s launch */
.gloader.is-playing .gl-cue { animation: gl-cue 0.32s ease-out 1.86s; }
@keyframes gl-cue {
  0%   { opacity: 0; transform: scale(0.5); }
  35%  { opacity: 0.85; }
  100% { opacity: 0; transform: scale(1.15); }
}
/* ---- impact flash ---- */
.gl-flash {
  position: absolute; left: -26vmin; top: -26vmin;
  width: 52vmin; height: 52vmin;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(200, 68, 14, 0.16) 38%,
    transparent 62%);
  opacity: 0; pointer-events: none;
}
.gloader.is-playing .gl-flash { animation: gl-flash 0.6s ease-out 2.4s; }
@keyframes gl-flash {
  0%   { opacity: 0; transform: scale(0.6); }
  14%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.3); }
}

/* full-screen shock frame at the instant of impact */
.gl-whiteout { position: absolute; inset: 0; background: var(--gl-shock); opacity: 0; pointer-events: none; }
.gloader.is-playing .gl-whiteout { animation: gl-whiteout 0.3s ease-out 2.4s; }
@keyframes gl-whiteout {
  0%   { opacity: 0; }
  14%  { opacity: 1; }
  100% { opacity: 0; }
}

/* craft status line — apparel captions during the sequence */
.gl-status {
  position: absolute; left: 50%; bottom: 9vh;
  transform: translate(-50%, 0);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 600; font-size: 10px;
  letter-spacing: 4px; text-indent: 4px; text-transform: uppercase;
  color: var(--gl-ink); opacity: 0;
  white-space: nowrap; pointer-events: none;
}

/* ---- sparks (JS-animated) ---- */
.gl-sparks { position: absolute; inset: 0; pointer-events: none; }
.gl-spark { position: absolute; left: 50%; top: 50%; border-radius: 50%; }

/* ---- reduced motion: quiet fade-in of final lockup ---- */
@media (prefers-reduced-motion: reduce) {
  .gloader .gl-kunai, .gloader .gl-ktrail, .gloader .gl-cue, .gloader .gl-flash,
  .gloader .gl-streak, .gloader .gl-line, .gloader .gl-shine,
  .gloader .gl-petals, .gloader .gl-inkburst, .gloader .gl-whiteout,
  .gloader .gl-threads, .gloader .gl-stitch, .gloader .gl-status { display: none; }
  .gloader.slashed .gl-lockup { animation: none; }
  .gloader.is-playing::before { animation: none; }
  .gloader.is-playing .gl-cut span { animation: none; opacity: 1; }
  .gloader.is-playing .gl-mask { transition: none; opacity: 1; transform: none; }
  .gloader .gl-enso circle { animation: none; stroke-dashoffset: 0; }
  .gloader.is-playing .gl-wash { animation: none; opacity: 0.16; }
}
