/* ACC — مكتبة الحركات المشتركة. أي صفحة بتقدر تستخدمها: <link rel="stylesheet" href="/fx.css"> + <script src="/fx.js"></script> */
:root {
  --fx-purple: #5B45F5; --fx-lime: #B4FF5C; --fx-pink: #FF5FD2; --fx-blue: #2E9BFF; --fx-orange: #FF8A1F; --fx-green: #7CD53F; --fx-yellow: #FFD84A;
  --fx-spring: cubic-bezier(.34, 1.56, .64, 1);
  --fx-out: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- جزيئات (شرار، كونفيتي، غبار، خطوط) ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
.fx-p { position: absolute; left: 0; top: 0; will-change: transform, opacity; border-radius: 99px; }

/* ---------- هايلايتر ليموني ورا الكلمة (بيترسم) ---------- */
.fx-hl { position: relative; display: inline-block; z-index: 0; padding: 0 .12em; white-space: nowrap; }
.fx-hl::before {
  content: ""; position: absolute; z-index: -1; inset: .12em -.08em .02em -.08em; background: var(--hl, var(--fx-lime));
  border-radius: .18em .5em .22em .4em / .4em .2em .5em .25em; transform: rotate(-1.6deg) scaleX(0); transform-origin: right center;
  animation: fx-hl .9s var(--fx-out) forwards; animation-delay: var(--hl-delay, .35s);
}
@keyframes fx-hl { to { transform: rotate(-1.6deg) scaleX(1); } }

/* ---------- سهم مرسوم باليد (بيترسم) ---------- */
.fx-doodle path { stroke-dasharray: 400; stroke-dashoffset: 400; animation: fx-draw 1.4s var(--fx-out) forwards; animation-delay: var(--d, .6s); }
.fx-doodle path + path { animation-delay: calc(var(--d, .6s) + .9s); animation-duration: .5s; }
@keyframes fx-draw { to { stroke-dashoffset: 0; } }

/* ---------- دخول متدرّج ---------- */
/* fill-mode: backwards — بعد ما تخلص الحركة بتترك العنصر حر (عشان الميلان والهوفر يشتغلوا) */
.fx-rise { animation: fx-rise .8s var(--fx-out) backwards; animation-delay: calc(var(--i, 0) * 70ms + var(--base, 0ms)); }
@keyframes fx-rise { from { opacity: 0; transform: translateY(26px) scale(.97); } }
.fx-pop { animation: fx-pop .55s var(--fx-spring) backwards; animation-delay: calc(var(--i, 0) * 60ms + var(--base, 0ms)); }
@keyframes fx-pop { from { opacity: 0; transform: scale(.6) rotate(-4deg); } }

/* ---------- ميلان 3D مع لمعة بتلحق الماوس ---------- */
.fx-tilt { transform-style: preserve-3d; transition: transform .5s var(--fx-out), box-shadow .5s var(--fx-out); position: relative; }
.fx-tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .55), transparent 45%);
  mix-blend-mode: soft-light;
}
.fx-tilt:hover::after { opacity: 1; }

/* ---------- حلقة قوس قزح بتلف (زي فيديو ٣) ---------- */
.fx-iri { position: relative; isolation: isolate; }
.fx-iri::before, .fx-iri::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit; z-index: -1; opacity: 0; transition: opacity .35s;
  background: conic-gradient(from var(--fx-a, 0deg), #ff4d4d, #ffb84d, #fff36b, #6bff9a, #4dd2ff, #7a5cff, #ff5fd2, #ff4d4d);
  animation: fx-spin 2.4s linear infinite;
}
.fx-iri::after { filter: blur(12px); inset: -6px; }
.fx-iri:hover::before, .fx-iri:hover::after, .fx-iri.on::before, .fx-iri.on::after { opacity: 1; }
.fx-iri.on::after { opacity: .7; }
@property --fx-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes fx-spin { to { --fx-a: 360deg; } }

/* ---------- توهّج الحقول (زي فيديو ١) ---------- */
.fx-aurora { position: relative; isolation: isolate; border-radius: 18px; }
.fx-aurora::before {
  content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: inherit; opacity: 0; transition: opacity .4s;
  background: conic-gradient(from var(--fx-a, 0deg), transparent 0 12%, #FFD84A 22%, #B4FF5C 32%, #2EE6C9 42%, transparent 55% 70%, #5B45F5 82%, transparent 92%);
  animation: fx-spin 3.2s linear infinite;
}
.fx-aurora::after {
  content: ""; position: absolute; inset: 10% 6% -18%; z-index: -2; border-radius: 50%; opacity: 0; transition: opacity .5s;
  background: radial-gradient(60% 60% at 70% 80%, rgba(255, 216, 74, .55), transparent 70%), radial-gradient(60% 60% at 30% 90%, rgba(46, 230, 201, .45), transparent 70%);
  filter: blur(18px);
}
.fx-aurora:focus-within::before, .fx-aurora:focus-within::after, .fx-aurora.on::before, .fx-aurora.on::after { opacity: 1; }

/* ---------- سويتش نيون (زي فيديو ٥) ---------- */
.fx-switch { --w: 58px; --h: 32px; position: relative; width: var(--w); height: var(--h); border-radius: 99px; border: 0; padding: 0; cursor: pointer; flex: none;
  background: #1d1a2b; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .12); transition: background .5s, box-shadow .5s; isolation: isolate; }
.fx-switch::before { /* البلازما */
  content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0; transition: opacity .45s;
  background: linear-gradient(90deg, #7a5cff, #ff5fd2 45%, #ffb84d 75%, #fff36b);
  box-shadow: 0 0 16px 2px rgba(255, 95, 210, .65), 0 0 36px 6px rgba(122, 92, 255, .4);
}
.fx-switch i { position: absolute; top: 4px; inset-inline-start: 4px; width: calc(var(--h) - 8px); height: calc(var(--h) - 8px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #d9d9e3); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: inset-inline-start .5s var(--fx-spring), background .4s, box-shadow .4s; z-index: 1; }
.fx-switch[aria-checked="true"]::before { opacity: 1; animation: fx-plasma 2.6s ease-in-out infinite alternate; }
.fx-switch[aria-checked="true"] i { inset-inline-start: calc(var(--w) - var(--h) + 4px); background: radial-gradient(circle at 40% 35%, #2b2640, #0c0a14); box-shadow: 0 0 0 2px #ffb84d, 0 0 14px #ff5fd2; }
@keyframes fx-plasma { from { filter: hue-rotate(0deg) saturate(1.1); } to { filter: hue-rotate(-40deg) saturate(1.4); } }

/* ---------- عدّاد أرقام بيلف (زي فيديو ٢) ---------- */
.fx-roll { display: inline-flex; direction: ltr; overflow: hidden; vertical-align: bottom; line-height: 1; }
.fx-roll .col { display: inline-block; height: 1em; overflow: hidden; }
.fx-roll .strip { display: flex; flex-direction: column; transition: transform 1.1s var(--fx-out); }
.fx-roll .strip span { height: 1em; display: block; text-align: center; }

/* ---------- مقياس سائل جديد (SVG) ---------- */
.fx-liquid { display: block; overflow: visible; }
.fx-liquid .track { fill: var(--fx-track, rgba(20, 16, 31, .06)); }
.fx-liquid .rim { stroke: var(--fx-rim, rgba(20, 16, 31, .08)); }
.fx-liquid .ticks line { stroke: var(--fx-tick, rgba(20, 16, 31, .14)); stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 2 4; }
:root[data-theme="dark"] .fx-liquid { --fx-track: rgba(255, 255, 255, .06); --fx-rim: rgba(255, 255, 255, .1); --fx-tick: rgba(255, 255, 255, .18); }

/* ---------- مقياس سائل قديم (زي فيديو ٤) ---------- */
.fx-gauge { position: relative; height: 54px; border-radius: 99px; overflow: hidden; background: rgba(0, 0, 0, .28);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .18), inset 0 6px 14px rgba(0, 0, 0, .25); }
.fx-gauge .liq { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; transition: width 1.6s var(--fx-out), filter 1s;
  background: linear-gradient(90deg, var(--c1, #ff4d4d), var(--c2, #ffb84d)); box-shadow: 0 0 22px var(--c2, #ffb84d); border-radius: 99px 0 0 99px; }
[dir="rtl"] .fx-gauge .liq { border-radius: 0 99px 99px 0; }
.fx-gauge .liq svg { position: absolute; top: -10%; inset-inline-end: -14px; height: 120%; width: 28px; }
[dir="rtl"] .fx-gauge .liq svg { transform: scaleX(-1); }
.fx-gauge .liq svg path { animation: fx-wave 1.6s ease-in-out infinite alternate; }
.fx-gauge .gloss { position: absolute; inset: 6px 14px auto; height: 30%; border-radius: 99px; background: linear-gradient(rgba(255, 255, 255, .45), transparent); pointer-events: none; }
@keyframes fx-wave { from { d: path("M0 0 Q18 15 4 30 Q-8 45 10 60 L0 60 Z"); } to { d: path("M0 0 Q-6 15 12 30 Q22 45 2 60 L0 60 Z"); } }

/* ---------- ضغطة نابضة ---------- */
.fx-press { transition: transform .35s var(--fx-spring); }
.fx-press:active { transform: scale(.94); }

@media (prefers-reduced-motion: reduce) {
  .fx-rise, .fx-pop { animation: none; opacity: 1; transform: none; }
  .fx-hl::before { animation: none; transform: rotate(-1.6deg); }
  .fx-doodle path { animation: none; stroke-dashoffset: 0; }
  .fx-iri::before, .fx-iri::after, .fx-aurora::before { animation: none; }
}

/* ---------- سويتش نيون «ART MODE» (زي فيديو ٥) ----------
   <button class="neon" role="switch" aria-checked style="--h1;--h2;--h3">
     <span class="nz-halo"></span><span class="nz-track"><i class="p1"></i><i class="p2"></i><i class="p3"></i></span>
     <span class="nz-knob"><span class="nz-ic">☀</span></span><span class="nz-floor"></span></button>
   مطفي: كرة بيضاء على مسار غامق. شغّال: كسوف غامق بحلقة متوهجة + بلازما بتتحرك + هالة ضوء + انعكاس على الأرض، والألوان بتلف. */
.neon { --w: 66px; --hh: 36px; --k: 28px; --h1: #FFD84A; --h2: #FF5FD2; --h3: #7A5CFF;
  position: relative; width: var(--w); height: var(--hh); border: 0; padding: 0; background: transparent; cursor: pointer; isolation: isolate; flex: none; }
.neon:focus-visible { outline: 2px solid var(--h2); outline-offset: 4px; border-radius: 99px; }
.nz-track { position: absolute; inset: 0; border-radius: 99px; background: #17141f; overflow: hidden;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .2), inset 0 3px 8px rgba(0, 0, 0, .6); transition: box-shadow .5s, background .5s; }
.nz-track i { position: absolute; width: 26px; height: 26px; border-radius: 50%; filter: blur(5px); opacity: 0; transition: opacity .6s; mix-blend-mode: screen; }
.nz-track .p1 { background: var(--h1); inset-inline-start: 2px; top: 4px; animation: nz-b1 2.8s ease-in-out infinite alternate; }
.nz-track .p2 { background: var(--h2); inset-inline-start: 18px; top: 8px; animation: nz-b2 2.2s ease-in-out infinite alternate; }
.nz-track .p3 { background: var(--h3); inset-inline-start: 30px; top: 2px; animation: nz-b3 3.4s ease-in-out infinite alternate; }
@keyframes nz-b1 { to { transform: translate(20px, 6px) scale(1.35); } }
@keyframes nz-b2 { to { transform: translate(-14px, -7px) scale(.75); } }
@keyframes nz-b3 { to { transform: translate(-24px, 9px) scale(1.25); } }
.nz-knob { position: absolute; top: calc((var(--hh) - var(--k)) / 2); inset-inline-start: calc((var(--hh) - var(--k)) / 2); width: var(--k); height: var(--k); border-radius: 50%; z-index: 2;
  display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #fff, #e4e4ee 55%, #b7b6c6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45); transition: inset-inline-start .6s cubic-bezier(.34, 1.56, .64, 1), background .45s, box-shadow .45s; }
.nz-ic { font: 900 12px/1 var(--acc-font, system-ui); color: #6F6A80; transition: color .4s, transform .6s cubic-bezier(.34, 1.56, .64, 1); }
.neon:hover .nz-knob { box-shadow: 0 0 10px 3px rgba(255, 255, 255, .75), 0 2px 6px rgba(0, 0, 0, .45); }
.nz-halo { position: absolute; inset: -16px -22px; border-radius: 99px; z-index: -1; opacity: 0; transition: opacity .6s;
  background: radial-gradient(closest-side, var(--h2), color-mix(in srgb, var(--h3) 40%, transparent) 60%, transparent); filter: blur(12px); }
.nz-floor { position: absolute; inset-inline: 8%; bottom: -16px; height: 10px; border-radius: 50%; z-index: -1; opacity: 0; transition: opacity .6s;
  background: radial-gradient(closest-side, var(--h1), transparent); filter: blur(5px); }
.neon[aria-checked="true"] { animation: nz-hue 9s linear infinite; }
.neon[aria-checked="true"] .nz-track { background: linear-gradient(90deg, var(--h3), var(--h2) 45%, var(--h1));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .4), 0 0 16px 2px var(--h2); }
.neon[aria-checked="true"] .nz-track i { opacity: .95; }
.neon[aria-checked="true"] .nz-knob { inset-inline-start: calc(var(--w) - var(--k) - (var(--hh) - var(--k)) / 2);
  background: radial-gradient(circle at 40% 35%, #2b2640, #07060c 70%);
  box-shadow: 0 0 0 2px var(--h2), 0 0 10px 3px var(--h2), 0 0 24px 4px var(--h1), inset 0 0 6px rgba(255, 255, 255, .18); }
.neon[aria-checked="true"] .nz-ic { color: #fff; transform: rotate(360deg); }
.neon[aria-checked="true"] .nz-halo { opacity: .75; }
.neon[aria-checked="true"] .nz-floor { opacity: .65; }
.neon.flash .nz-knob { animation: nz-flash .6s ease-out; }
@keyframes nz-flash { 0% { box-shadow: 0 0 0 0 #fff, 0 0 40px 14px #fff; } }
@keyframes nz-hue { to { filter: hue-rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .neon, .nz-track i { animation: none !important; } }

/* =========== أيقونات مرسومة (/icons.js — مشتركة للقلعة والداشبوردات) + حركاتها =========== */
.ai { width: 1em; height: 1em; display: inline-block; vertical-align: -.16em; flex: none; overflow: visible; }
.ai g, .ai path, .ai circle { transform-box: view-box; }
.ai-rays { transform-origin: 12px 12px; animation: ai-spin 9s linear infinite; }
.ai-spin { transform-origin: 12px 12px; animation: ai-spin 5s linear infinite; }
.ai-spin-slow { animation: ai-spin 7s linear infinite; }
.ai-hand { transform-origin: 12px 12px; animation: ai-spin 3.2s steps(24) infinite; }
.ai-rise { animation: ai-rise 1.8s ease-in-out infinite; }
.ai-up { animation: ai-up 1.4s ease-in-out infinite; }
.ai-down { animation: ai-down 1.4s ease-in-out infinite; }
.ai-drift { animation: ai-drift 2.2s ease-in-out infinite; }
.ai-sway { transform-origin: 12px 12px; animation: ai-sway 2.6s ease-in-out infinite; }
.ai-twinkle { transform-origin: center; transform-box: fill-box; animation: ai-twinkle 1.6s ease-in-out infinite; }
.ai-twinkle.d2 { animation-delay: -.8s; }
.ai-bob { animation: ai-bob 1.4s ease-in-out infinite; }
.ai-page { animation: ai-fade 1.8s ease-in-out infinite; }
.ai-shine { stroke: #FFD84A; stroke-width: 2.4; animation: ai-fade 1.6s ease-in-out infinite; }
.ai-ring { transform-origin: 12px 4px; animation: ai-ring 2.2s ease-in-out infinite; }
.ai-dots circle { fill: currentColor; stroke: none; animation: ai-dot 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.ai-dots circle:nth-child(2) { animation-delay: .18s; } .ai-dots circle:nth-child(3) { animation-delay: .36s; }
.ai-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ai-draw .55s var(--out, ease-out) .05s forwards; }
.ai-bars path { transform-origin: 50% 100%; transform-box: fill-box; animation: ai-bar 1.4s ease-in-out infinite; }
.ai-bars path:nth-child(2) { animation-delay: -.45s; } .ai-bars path:nth-child(3) { animation-delay: -.9s; }
.ai-lift { animation: ai-bob 1.1s ease-in-out infinite; }
.ai-glow, .ai-fade-in, .ai-windows, .ai-write { animation: ai-fade 1.8s ease-in-out infinite; }
.ai-beat { transform-origin: center; transform-box: fill-box; animation: ai-beat 1.2s ease-in-out infinite; }
.ai-fly { animation: ai-fly 1.8s ease-in-out infinite; }
.ai-shake { animation: ai-drift 1.1s ease-in-out infinite; }
@keyframes ai-bar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.45); } }
@keyframes ai-beat { 0%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(.95); } 45% { transform: scale(1.12); } }
@keyframes ai-fly { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(2.4px, -2.4px); } }
.ai-flag { transform-origin: 12px 4.9px; animation: ai-flag 1.2s ease-in-out infinite; }
.ai-turn { transform-origin: 12px 12px; animation: ai-sway 2.4s ease-in-out infinite; }
.ai-shackle { animation: ai-up 1.6s ease-in-out infinite; }
.ai-slide { animation: ai-drift 1.4s ease-in-out infinite; }
.ai-flicker { transform-origin: 50% 100%; transform-box: fill-box; animation: ai-flicker .9s ease-in-out infinite alternate; }
.ai-waves path { animation: ai-fade 1.2s ease-in-out infinite; } .ai-waves path:nth-child(2) { animation-delay: .3s; }
.ai-flip { transform-origin: 12px 12px; animation: ai-flip 2.4s ease-in-out infinite; }
@keyframes ai-flag { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.7); } }
@keyframes ai-flicker { from { transform: scale(1, 1); } to { transform: scale(.9, 1.1); } }
@keyframes ai-flip { 0%, 60%, 100% { transform: scaleX(1); } 80% { transform: scaleX(-1); } }
.ai-steam path { animation: ai-steam 1.6s ease-in-out infinite; } .ai-steam path:nth-child(2) { animation-delay: .5s; }
@keyframes ai-steam { 0% { transform: translateY(1.5px); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(-2px); opacity: 0; } }
.ai-needle { animation: ai-sway 2s ease-in-out infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-rise { 0%, 100% { transform: translateY(2px); opacity: .4; } 50% { transform: translateY(-2.4px); opacity: 1; } }
@keyframes ai-up { 0%, 100% { transform: translateY(1.6px); } 50% { transform: translateY(-2.6px); } }
@keyframes ai-down { 0%, 100% { transform: translateY(-1.6px); } 50% { transform: translateY(2.6px); } }
@keyframes ai-drift { 0%, 100% { transform: translateX(-1.8px); } 50% { transform: translateX(1.8px); } }
@keyframes ai-sway { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(12deg); } }
@keyframes ai-twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .25; transform: scale(.55); } }
@keyframes ai-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.8px); } }
@keyframes ai-fade { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes ai-ring { 0%, 55%, 100% { transform: rotate(0); } 63% { transform: rotate(20deg); } 71% { transform: rotate(-17deg); } 79% { transform: rotate(11deg); } 87% { transform: rotate(-6deg); } }
@keyframes ai-dot { 0%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-2.4px); opacity: 1; } }
@keyframes ai-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .ai *, .ai { animation: none !important; } .ai-draw { stroke-dashoffset: 0; } }

