/* ui-craft fx: effects for websites, measured from the anchors (references/motion.md).
   Needs kit.css (tokens) and fx.js (reveal, spotlight, count, nav). Never for the terminal app:
   feel.md §3 still holds there.
   Every effect here moves only transform, opacity or filter, or paints a static gradient,
   so the gate's smoothness pass (scripts/ui-motion.mjs) stays green. Each one turns off with
   prefers-reduced-motion and with :root[data-k-motion="off"]. */

:root {
  /* Measured 2026-11-14 on Vercel, Resend, Linear, Raycast, Mercury: interactions 150-200ms,
     entrances 400-700ms on a strong ease-out, no overshoot, no hover lift, no box-shadow glow. */
  --fx-out: cubic-bezier(0.23, 1, 0.32, 1);     /* Raycast's entrance curve (ease-out-quint) */
  --fx-drawer: cubic-bezier(0.32, 0.72, 0, 1);  /* Linear's sheets and drawers */
  --fx-hover: 200ms;
  --fx-enter: 600ms;
  --fx-stagger: 60ms;
  --fx-rise: 12px;
  --fx-blur: 6px;
  --fx-glow: rgb(255 255 255 / 0.06);
  --fx-spot: rgb(255 255 255 / 0.07);
  --fx-spot-edge: rgb(255 255 255 / 0.22);
}

/* ---------- reveal on scroll: opacity + rise + blur, once (Linear blurs, Resend rises) */
.fx-js [data-fx~="reveal"], .fx-js [data-fx~="stagger"] > * {
  opacity: 0; transform: translateY(var(--fx-rise)); filter: blur(var(--fx-blur));
  transition: opacity var(--fx-enter) var(--fx-out), transform var(--fx-enter) var(--fx-out), filter var(--fx-enter) var(--fx-out);
  transition-delay: calc(min(var(--fx-i, 0), 6) * var(--fx-stagger));
}
.fx-js [data-fx~="reveal"].fx-in, .fx-js [data-fx~="stagger"].fx-in > * { opacity: 1; transform: none; filter: none; }

/* ---------- spotlight: a soft light that follows the pointer inside a card (fx.js sets --mx/--my) */
.fx-spotlight { position: relative; isolation: isolate; }
.fx-spotlight::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 0%), var(--fx-spot), transparent 70%);
  opacity: 0; transition: opacity var(--fx-hover) var(--fx-out);
}
.fx-spotlight::after { /* the same light on the 1px edge */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), var(--fx-spot-edge), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0; transition: opacity var(--fx-hover) var(--fx-out);
}
.fx-spotlight:hover::before, .fx-spotlight:hover::after, .fx-spotlight[data-force~="hover"]::before, .fx-spotlight[data-force~="hover"]::after { opacity: 1; }

/* ---------- beam: a light that travels round the border. A rotating layer, so it is composited. */
.fx-beam { position: relative; isolation: isolate; overflow: hidden; }
.fx-beam::before {
  content: ""; position: absolute; z-index: -2; left: 50%; top: 50%; width: 200%; aspect-ratio: 1; translate: -50% -50%;
  background: conic-gradient(from 0deg, transparent 0 80%, var(--fx-spot-edge) 90%, transparent 100%);
  animation: fx-spin 6s linear infinite;
}
.fx-beam::after { content: ""; position: absolute; z-index: -1; inset: 1px; border-radius: calc(var(--k-r-card) - 1px); background: var(--k-card); }
@keyframes fx-spin { to { transform: rotate(1turn); } }

/* ---------- glow: static light behind a hero (anchors use radial gradients, never box-shadow glows) */
.fx-glow { position: relative; isolation: isolate; overflow-x: clip; /* the light must not widen the page */ }
.fx-glow::before {
  content: ""; position: absolute; z-index: -1; inset: -20% -10% auto; height: 120%; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 0%, var(--fx-glow), transparent 70%);
}

/* ---------- grain: a faint noise layer over the whole page (put .fx-grain on body) */
.fx-grain::after {
  content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- fade edges: the most common effect on the anchors (Linear 22 masks, Raycast 13) */
.fx-fade-x { -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.fx-fade-b { -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }

/* ---------- shimmer: a light passing over grey text, once per 4s. Paints; one per page at most. */
.fx-shimmer {
  background: linear-gradient(100deg, var(--k-text-2) 40%, var(--k-text) 50%, var(--k-text-2) 60%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: fx-shimmer 4s var(--fx-out) infinite;
}
@keyframes fx-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- marquee: a row of logos that drifts; fx.js doubles the content */
.fx-marquee { overflow: hidden; }
.fx-marquee > .fx-track { display: flex; width: max-content; gap: var(--k-s-9); animation: fx-marquee var(--fx-marquee, 40s) linear infinite; }
.fx-marquee:hover > .fx-track { animation-play-state: paused; }
@keyframes fx-marquee { to { transform: translateX(-50%); } }

/* ---------- count: numbers hold their final width while they count (no layout shift) */
[data-fx~="count"] { font-variant-numeric: tabular-nums; display: inline-block; }

/* ---------- smooth in-page scroll and cross-page fades */
@media (prefers-reduced-motion: no-preference) {
  html:has(.fx-js) { scroll-behavior: smooth; }
  @view-transition { navigation: auto; }
}
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 240ms; animation-timing-function: var(--fx-out); }

/* ---------- off switches */
:root[data-k-motion="off"] .fx-js [data-fx~="reveal"], :root[data-k-motion="off"] .fx-js [data-fx~="stagger"] > * { opacity: 1; transform: none; filter: none; transition: none; }
:root[data-k-motion="off"] .fx-beam::before, :root[data-k-motion="off"] .fx-shimmer, :root[data-k-motion="off"] .fx-marquee > .fx-track { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .fx-js [data-fx~="reveal"], .fx-js [data-fx~="stagger"] > * { opacity: 1; transform: none; filter: none; transition: none; }
  .fx-beam::before, .fx-shimmer, .fx-marquee > .fx-track { animation: none; }
  .fx-shimmer { color: var(--k-text-2); background: none; }
  .fx-spotlight::before, .fx-spotlight::after { transition: none; }
}
