/* Visual effects (own plain-CSS recreations in the style of Magic UI; no libraries, nothing copied).
   Everything is dormant until fx.js puts an "fx-e-<name>" class on <html> and an "fx-m-<name>" class on the elements it
   targets. With the effects switched off none of these rules match anything. Animated parts only run when the system is
   not asking for reduced motion, and they pause while the window is hidden. */

@property --fx-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

html.fx-site-app { --fx1: var(--accent, #6c7bff); --fx2: #ff6fa5; --fx3: var(--gold, #ffc15a); --fx-ok: var(--green, #4cd68e); --fx-line: var(--line, #252c52); --fx-card: var(--panel, #131830); }
html.fx-site-panel { --fx1: var(--blurple, #5865f2); --fx2: #ff6fa5; --fx3: #ffc15a; --fx-ok: var(--up, #3ba55d); --fx-line: var(--border, #2b2d31); --fx-card: var(--card, #1e1f22); }

/* ---------------------------------------------------------------- spotlight (a soft glow follows the pointer) */
html.fx-e-spotlight .fx-m-spotlight:hover {
  background-image: radial-gradient(260px circle at var(--fx-x, 50%) var(--fx-y, 50%), color-mix(in srgb, var(--fx1) 20%, transparent), transparent 70%);
  border-color: color-mix(in srgb, var(--fx1) 55%, var(--fx-line));
}

/* ---------------------------------------------------------------- tilt (cards lean towards the pointer) */
html.fx-e-tilt .fx-m-tilt { transform: perspective(800px) rotateX(var(--fx-rx, 0deg)) rotateY(var(--fx-ry, 0deg)); transition: transform 0.14s ease-out, border-color 0.12s; }
html.fx-e-tilt .fx-m-tilt.fx-tilting { will-change: transform; }

/* ---------------------------------------------------------------- magnetic (buttons drift a few pixels towards the pointer) */
html.fx-e-magnetic .fx-m-magnetic { translate: var(--fx-mx, 0) var(--fx-my, 0); transition: translate 0.18s ease-out, transform 0.12s ease, border-color 0.12s, background 0.12s; }

/* ---------------------------------------------------------------- gradient text */
html.fx-e-gradtext .fx-m-gradtext {
  background-image: linear-gradient(90deg, var(--fx1), var(--fx2), var(--fx3), var(--fx1)); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}

/* ---------------------------------------------------------------- shimmer button */
html.fx-e-shimmer .fx-m-shimmer { position: relative; overflow: hidden; isolation: isolate; }
html.fx-e-shimmer .fx-m-shimmer::after { content: ''; position: absolute; inset: 0; pointer-events: none; transform: translateX(-130%) skewX(-20deg); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent); z-index: 1; }

/* ---------------------------------------------------------------- pulse (a calm "press me" ring) */
html.fx-e-pulse .fx-m-pulse { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fx1) 60%, transparent); }

/* ---------------------------------------------------------------- border beam (a light travels round the edge) */
html.fx-e-beam .fx-m-beam { position: relative; }
html.fx-e-beam .fx-m-beam::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 2px; pointer-events: none; z-index: 2;
  background: conic-gradient(from var(--fx-a), transparent 0 62%, var(--fx1) 82%, var(--fx2) 96%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }

/* ---------------------------------------------------------------- ripple (rings spread from live dots) */
html.fx-e-ripple .fx-m-ripple { position: relative; }
html.fx-e-ripple .fx-m-ripple:not(.fx-pill)::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--fx-ok); opacity: 0; pointer-events: none; }
html.fx-e-ripple .conn:not(.ok) .fx-m-ripple::after { display: none; }

/* ---------------------------------------------------------------- progress bars (a shine slides along the fill) */
html.fx-e-progress .fx-m-progress { position: relative; overflow: hidden; }
html.fx-e-progress .fx-m-progress::after { content: ''; position: absolute; inset: 0; pointer-events: none; transform: translateX(-100%); background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.5) 50%, transparent 65%); }

/* ---------------------------------------------------------------- dock (items near the pointer grow a little) */
html.fx-e-dock .fx-m-dock { scale: var(--fx-s, 1); transition: scale 0.1s ease-out; transform-origin: left center; }
html.fx-e-dock .fx-m-dock-h { transform-origin: bottom center; }

/* ---------------------------------------------------------------- aurora and meteors (a soft backdrop behind the top of the page) */
.fx-stage { position: absolute; left: 0; right: 0; top: 0; height: 300px; overflow: hidden; pointer-events: none; z-index: 0;
  -webkit-mask-image: linear-gradient(#000 25%, transparent); mask-image: linear-gradient(#000 25%, transparent); }
html.fx-site-panel .fx-stage { position: fixed; height: 340px; z-index: 0; }
html.fx-e-aurora main > section, html.fx-e-meteors main > section { position: relative; z-index: 1; }
.fx-aurora i { position: absolute; width: 52%; aspect-ratio: 1; border-radius: 50%; filter: blur(48px); opacity: 0.22; }
.fx-aurora i:nth-child(1) { background: var(--fx1); left: -10%; top: -60%; }
.fx-aurora i:nth-child(2) { background: var(--fx2); right: -10%; top: -30%; }
.fx-aurora i:nth-child(3) { background: var(--fx3); left: 28%; top: -85%; opacity: 0.16; }
.fx-meteors i { position: absolute; top: -20px; width: 2px; height: 70px; background: linear-gradient(to bottom, transparent, var(--fx1)); transform: rotate(35deg); opacity: 0; }
.fx-meteors i:nth-child(1) { left: 92%; } .fx-meteors i:nth-child(2) { left: 74%; } .fx-meteors i:nth-child(3) { left: 58%; }
.fx-meteors i:nth-child(4) { left: 84%; } .fx-meteors i:nth-child(5) { left: 40%; } .fx-meteors i:nth-child(6) { left: 66%; }

/* ---------------------------------------------------------------- neon HUD (gamer panels breathe a soft glow) */
html.fx-e-neon .fx-m-neon { border-color: color-mix(in srgb, var(--fx1) 60%, var(--fx-line)); box-shadow: 0 0 10px color-mix(in srgb, var(--fx1) 28%, transparent); }

/* ---------------------------------------------------------------- glitch (a title flickers when you hover it) */
html.fx-e-glitch .fx-m-glitch { position: relative; }
html.fx-e-glitch .fx-m-glitch::before, html.fx-e-glitch .fx-m-glitch::after { content: attr(data-fx-t); position: absolute; inset: 0; clip-path: inset(0 0 100% 0); pointer-events: none; -webkit-text-fill-color: currentColor; background: none; }
html.fx-e-glitch .fx-m-glitch::before { color: var(--fx2); }
html.fx-e-glitch .fx-m-glitch::after { color: var(--fx1); }

/* ---------------------------------------------------------------- confetti */
.fx-confetti { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 9999; }
.fx-confetti i { position: absolute; left: 0; top: 0; width: 8px; height: 12px; border-radius: 2px; }

/* ---------------------------------------------------------------- the on/off button on the panel */
.fx-fab { position: fixed; right: 16px; bottom: 16px; z-index: 9990; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--fx-line, #444); background: var(--fx-card, #1e1f22); color: var(--fg, #eee); cursor: pointer; font-size: 17px; display: grid; place-items: center; opacity: 0.75; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); }
.fx-fab:hover, .fx-fab:focus-visible { opacity: 1; outline: 2px solid var(--fx1, #5865f2); outline-offset: 2px; }
.fx-pop { position: fixed; right: 16px; bottom: 62px; z-index: 9991; width: min(320px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow: auto; background: var(--fx-card, #1e1f22); color: var(--fg, #eee); border: 1px solid var(--fx-line, #444); border-radius: 14px; padding: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); font: 13px/1.45 var(--font, system-ui, sans-serif); }
.fx-pop[hidden] { display: none; }
.fx-pop h3 { margin: 0 0 2px; font-size: 14px; }
.fx-pop p { margin: 0 0 10px; color: var(--muted, #999); font-size: 12px; }
.fx-pop label { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.fx-pop label small { color: var(--muted, #999); margin-left: auto; font-size: 11px; text-align: right; }
.fx-pop .fx-master { font-weight: 600; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--fx-line, #444); }
.fx-pop select { width: 100%; margin: 4px 0 8px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--fx-line, #444); background: var(--bg, #111); color: inherit; font: inherit; }
.fx-pop .fx-list[hidden] { display: none; }

/* ---------------------------------------------------------------- the moving parts: only when motion is welcome */
@media (prefers-reduced-motion: no-preference) {
  html.fx-e-gradtext .fx-m-gradtext { animation: fxFlow 6s linear infinite; }
  html.fx-e-shimmer .fx-m-shimmer::after { animation: fxSweep 3.2s ease-in-out infinite; }
  html.fx-e-pulse .fx-m-pulse { animation: fxPulse 2s infinite; }
  html.fx-e-beam .fx-m-beam::before { animation: fxSpin 4.5s linear infinite; }
  html.fx-e-ripple .fx-m-ripple:not(.fx-pill)::after { animation: fxPing 2s ease-out infinite; }
  html.fx-e-ripple .fx-m-ripple.fx-pill:not(.off):not(.wait) { animation: fxPulseOk 2.4s infinite; }
  html.fx-e-progress .fx-m-progress::after { animation: fxShine 1.6s linear infinite; }
  .fx-aurora i { animation: fxDrift 11s ease-in-out infinite alternate; }
  .fx-aurora i:nth-child(2) { animation-delay: -4s; } .fx-aurora i:nth-child(3) { animation-delay: -7s; }
  .fx-meteors i { animation: fxFall 3.4s linear infinite; }
  .fx-meteors i:nth-child(2) { animation-delay: -1.1s; } .fx-meteors i:nth-child(3) { animation-delay: -2s; }
  .fx-meteors i:nth-child(4) { animation-delay: -2.6s; } .fx-meteors i:nth-child(5) { animation-delay: -.6s; } .fx-meteors i:nth-child(6) { animation-delay: -1.7s; }
  html.fx-e-neon .fx-m-neon { animation: fxBreathe 2.6s ease-in-out infinite alternate; }
  html.fx-e-glitch .fx-m-glitch:hover::before { animation: fxGl1 0.9s steps(1) 1; }
  html.fx-e-glitch .fx-m-glitch:hover::after { animation: fxGl2 0.9s steps(1) 1; }
  html.fx-e-blurin main > section.on > h1, html.fx-e-blurin .fx-m-blurin { animation: fxBlurIn 0.7s both; }
  html.fx-e-blurin main > section.on > .lead, html.fx-e-blurin main > section.on .hero .lead { animation: fxBlurIn 0.8s 0.12s both; }
  .fx-confetti i { animation: fxBurst 1s ease-out forwards; }
}
html.fx-paused * , html.fx-paused *::before, html.fx-paused *::after { animation-play-state: paused !important; }
/* lighter mode (slower PCs): keep the cheap effects, drop the ones that repaint a lot */
html.fx-lite .fx-stage { display: none; }
html.fx-lite .fx-m-tilt { transform: none !important; }
html.fx-lite .fx-m-beam::before, html.fx-lite .fx-m-neon, html.fx-lite .fx-m-pulse, html.fx-lite .fx-m-ripple::after, html.fx-lite .fx-m-ripple { animation: none !important; }

@keyframes fxFlow { to { background-position: -300% 0; } }
@keyframes fxSweep { 0%, 35% { transform: translateX(-130%) skewX(-20deg); } 80%, 100% { transform: translateX(130%) skewX(-20deg); } }
@keyframes fxPulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fx1) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes fxPulseOk { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fx-ok) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
@keyframes fxSpin { to { --fx-a: 360deg; } }
@keyframes fxPing { 0% { transform: scale(1); opacity: 0.55; } 100% { transform: scale(3); opacity: 0; } }
@keyframes fxShine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes fxDrift { to { transform: translate(14%, 18%) scale(1.18); } }
@keyframes fxFall { 0% { transform: translate(0, 0) rotate(35deg); opacity: 0; } 12% { opacity: 0.9; } 100% { transform: translate(-170px, 240px) rotate(35deg); opacity: 0; } }
@keyframes fxBreathe { from { box-shadow: 0 0 6px color-mix(in srgb, var(--fx1) 25%, transparent); } to { box-shadow: 0 0 22px color-mix(in srgb, var(--fx1) 55%, transparent); } }
@keyframes fxGl1 { 0% { clip-path: inset(15% 0 55% 0); transform: translate(-5px); } 33% { clip-path: inset(62% 0 8% 0); transform: translate(4px); } 66% { clip-path: inset(30% 0 40% 0); transform: translate(-2px); } 100% { clip-path: inset(0 0 100% 0); transform: none; } }
@keyframes fxGl2 { 0% { clip-path: inset(48% 0 22% 0); transform: translate(5px); } 33% { clip-path: inset(8% 0 70% 0); transform: translate(-4px); } 66% { clip-path: inset(70% 0 5% 0); transform: translate(3px); } 100% { clip-path: inset(0 0 100% 0); transform: none; } }
@keyframes fxBlurIn { from { opacity: 0; filter: blur(8px); transform: translateY(8px); } }
@keyframes fxBurst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
