/* ==========================================================================
   Scar Alpha AI — الأساس: الألوان، الخطوط، الخلفية، العناصر المشتركة
   ========================================================================== */
:root {
  /* الهوية */
  --void: #020101;        /* Black — خلفية الشعار والتصميم */
  --red: #DD0101;         /* Primary Red */
  --blood: #7D0101;       /* Secondary — الظلال والعناصر الثانوية */
  --graphite: #434142;    /* Dark Gray */
  --bone: #D9D9D9;        /* White — لون الخط */

  /* درجات مشتقة */
  --red-hi: #FF2B1C;
  --ink: #F3EFEF;
  --text: var(--bone);
  --muted: #9C9596;
  --faint: #847D7E;
  --s0: #060303;
  --s1: #0C0707;
  --s2: #130B0B;
  --s3: #1B1011;
  --s4: #251617;
  --line: rgba(217, 217, 217, .075);
  --line-2: rgba(217, 217, 217, .13);
  --red-line: rgba(221, 1, 1, .35);

  /* دلالات */
  --up: #2BE3A0;
  --up-bg: rgba(43, 227, 160, .1);
  --down: #FF4D5E;
  --down-bg: rgba(255, 77, 94, .1);
  --amber: #FFB547;

  /* المقاييس */
  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);

  --f-display: 'Noto Kufi Arabic', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans Arabic', 'Noto Kufi Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --f-brand: 'Orbitron', 'Noto Kufi Arabic', sans-serif;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--void);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--f-display); color: var(--ink); margin: 0; line-height: 1.35; font-weight: 700; }
p { margin: 0; }
::selection { background: rgba(221, 1, 1, .45); color: #fff; }
:focus-visible { outline: 2px solid var(--red-hi); outline-offset: 3px; border-radius: 8px; }

.num { direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.is-na { color: var(--faint) !important; font-size: .78em !important; font-weight: 500 !important; letter-spacing: 0 !important; font-family: var(--f-body) !important; direction: rtl; }
.up { color: var(--up); }
.down { color: var(--down); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── الخلفية الضوئية ── */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.backdrop .glow {
  position: absolute; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(221, 1, 1, .22), rgba(125, 1, 1, .08) 55%, transparent 75%);
  will-change: transform;
}
.backdrop .glow.g1 { width: 70vmax; height: 70vmax; top: -38vmax; inset-inline-end: -22vmax; animation: drift1 28s var(--ease-io) infinite alternate; }
.backdrop .glow.g2 { width: 56vmax; height: 56vmax; bottom: -34vmax; inset-inline-start: -18vmax; opacity: .7; animation: drift2 34s var(--ease-io) infinite alternate; }
.backdrop .grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(217, 217, 217, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(217, 217, 217, .035) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 20%, transparent 75%);
}
/* «الندبة»: خط ضوئي مائل بزاوية اللوغو يمرّ فيه وميض */
.backdrop .scar {
  position: absolute; top: 18%; left: -20%; width: 140%; height: 1px;
  transform: rotate(-24deg);
  background: linear-gradient(90deg, transparent, rgba(221, 1, 1, .28) 30%, rgba(255, 60, 40, .35) 50%, rgba(221, 1, 1, .2) 70%, transparent);
}
.backdrop .scar::after {
  content: ''; position: absolute; top: -1px; height: 3px; width: 180px; left: 0;
  background: linear-gradient(90deg, transparent, #ff5a3c, #fff2, transparent);
  filter: blur(.5px);
  border-radius: 3px;
  animation: scarRun 9s var(--ease-io) infinite;
  opacity: 0;
}
.backdrop .scar.s2 { top: 72%; transform: rotate(-24deg); opacity: .5; }
.backdrop .scar.s2::after { animation-delay: 4.5s; }
@keyframes scarRun { 0% { transform: translateX(0); opacity: 0; } 8% { opacity: 1; } 40% { opacity: 1; } 55% { transform: translateX(140vw); opacity: 0; } 100% { transform: translateX(140vw); opacity: 0; } }
@keyframes drift1 { to { transform: translate3d(-8vmax, 6vmax, 0) scale(1.08); } }
@keyframes drift2 { to { transform: translate3d(9vmax, -5vmax, 0) scale(1.12); } }

/* ── الأزرار ── */
.btn {
  --h: 46px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--h); padding: 0 20px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 15px; white-space: nowrap; isolation: isolate; overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .3s var(--ease), background-color .25s, border-color .25s, color .25s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #F0140F, var(--red) 55%, #B80101);
  box-shadow: 0 0 0 1px rgba(255, 90, 70, .35) inset, 0 1px 0 rgba(255, 255, 255, .25) inset, 0 10px 30px -10px rgba(221, 1, 1, .8);
}
.btn-primary::after { /* لمعة مائلة عند المرور */
  content: ''; position: absolute; inset: -40% auto -40% -30%; width: 38%; z-index: -1;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-24deg) translateX(-200%);
  transition: transform .8s var(--ease);
}
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(255, 110, 90, .55) inset, 0 1px 0 rgba(255, 255, 255, .3) inset, 0 14px 38px -10px rgba(255, 30, 10, .95); }
.btn-primary:hover::after { transform: skewX(-24deg) translateX(520%); }
.btn-ghost { background: rgba(217, 217, 217, .04); border: 1px solid var(--line-2); color: var(--text); }
.btn-ghost:hover { background: rgba(217, 217, 217, .08); border-color: rgba(217, 217, 217, .22); }
.btn-quiet { color: var(--muted); padding: 0 10px; }
.btn-quiet:hover { color: var(--ink); }
.btn-sm { --h: 36px; padding: 0 14px; font-size: 13.5px; gap: 7px; }
.btn[disabled], .btn.is-busy { pointer-events: none; opacity: .62; }
.btn .spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── الحقول ── */
.field { display: grid; gap: 8px; }
.field > label { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.input {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 14px; border-radius: var(--r-md);
  background: rgba(2, 1, 1, .55); border: 1px solid var(--line-2);
  transition: border-color .25s, box-shadow .25s, background-color .25s;
}
.input .ic { color: var(--faint); flex: none; transition: color .25s; }
.input input { flex: 1; min-width: 0; width: 100%; height: 100%; background: transparent; border: 0; outline: 0; font-size: 15px; color: var(--ink); }
.input input::placeholder { color: #6a6364; }
.input input[type='email'], .input input[dir='ltr'] { text-align: right; }
.input:hover { border-color: rgba(217, 217, 217, .2); }
.input:focus-within { border-color: rgba(255, 43, 28, .7); box-shadow: 0 0 0 4px rgba(221, 1, 1, .14), 0 0 24px -6px rgba(221, 1, 1, .6); background: rgba(12, 4, 4, .7); }
.input:focus-within .ic { color: var(--red-hi); }
.input.has-error { border-color: var(--down); }
.input-action { color: var(--faint); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; }
.input-action:hover { color: var(--ink); background: rgba(217, 217, 217, .06); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--muted); font-size: 14px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid rgba(217, 217, 217, .28); display: grid; place-items: center; transition: all .2s var(--ease); }
.check .box .ic { opacity: 0; transform: scale(.4); transition: all .25s var(--ease); color: #fff; }
.check input:checked + .box { background: var(--red); border-color: var(--red); box-shadow: 0 0 14px -2px rgba(221, 1, 1, .8); }
.check input:checked + .box .ic { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { outline: 2px solid var(--red-hi); outline-offset: 2px; }

/* ── شارات ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: rgba(217, 217, 217, .06); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--up); background: var(--up-bg); border-color: rgba(43, 227, 160, .2); }
.chip.bad { color: var(--down); background: var(--down-bg); border-color: rgba(255, 77, 94, .22); }
.chip.red { color: #ff6b5c; background: rgba(221, 1, 1, .12); border-color: rgba(221, 1, 1, .3); }
.chip.amber { color: var(--amber); background: rgba(255, 181, 71, .1); border-color: rgba(255, 181, 71, .25); }
.chip.live .dot { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ── شعار ── */
.logo-tile { filter: drop-shadow(0 6px 18px rgba(221, 1, 1, .45)); }
.wordmark { display: inline-grid; line-height: 1; direction: ltr; }
.wordmark .wm-top { font-family: var(--f-brand); font-weight: 900; font-size: 22px; letter-spacing: .08em; color: var(--ink); }
.wordmark .wm-bottom { font-family: var(--f-brand); font-weight: 700; font-size: 8.5px; letter-spacing: .58em; color: var(--muted); margin-top: 5px; }

/* ── تنبيهات ── */
.toasts { position: fixed; z-index: 100; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: rgba(27, 16, 17, .92); border: 1px solid var(--line-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .8); font-size: 14px; color: var(--ink);
  animation: toastIn .45s var(--ease) both;
}
.toast .ic { flex: none; color: var(--red-hi); }
.toast-success .ic { color: var(--up); }
.toast-error .ic { color: var(--down); }
.toast.out { animation: toastOut .4s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ── شريط المعاينة ── */
.preview-flag {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--amber); background: rgba(255, 181, 71, .09); border: 1px dashed rgba(255, 181, 71, .45);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .backdrop .scar::after { display: none; }
}
.nw { white-space: nowrap; }

/* ════════ ترحيب شادي الصوتي ════════ */
.wv { --wv-red: var(--red-hi); }
/* شاشة كاملة بعد تسجيل الدخول */
.wv-full {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; overflow: hidden;
  padding: 24px 16px calc(96px + env(safe-area-inset-bottom));
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(221, 1, 1, .2), transparent 70%),
    radial-gradient(120% 80% at 50% 120%, rgba(125, 1, 1, .35), transparent 60%),
    rgba(2, 1, 1, .94);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  opacity: 0; transition: opacity .55s var(--ease);
}
.wv-full.on { opacity: 1; }
.wv-bg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.wv-ring { position: absolute; top: 42%; left: 50%; width: 220px; height: 220px; margin: -110px 0 0 -110px; border-radius: 50%; border: 1px solid rgba(221, 1, 1, .35); opacity: 0; }
.wv-full.is-playing .wv-ring { animation: wvRing 3.6s var(--ease) infinite; }
.wv-full.is-playing .r2 { animation-delay: 1.2s; }
.wv-full.is-playing .r3 { animation-delay: 2.4s; }
@keyframes wvRing { 0% { transform: scale(.55); opacity: 0; } 15% { opacity: .9; } 100% { transform: scale(3.4); opacity: 0; } }

.wv-in { position: relative; display: grid; justify-items: center; gap: 18px; width: min(640px, 100%); text-align: center; }
.wv-logo { position: relative; filter: drop-shadow(0 0 28px rgba(221, 1, 1, .55)); transform: scale(.82); opacity: 0; transition: transform .9s var(--ease) .1s, opacity .6s var(--ease) .1s; }
.wv-full.on .wv-logo { transform: none; opacity: 1; }

.wv-eq { display: inline-flex; align-items: center; gap: 4px; height: 26px; }
.wv-eq i { width: 3px; height: 4px; border-radius: 3px; background: linear-gradient(180deg, var(--red-hi), var(--blood)); transition: height .3s var(--ease); }
.is-playing .wv-eq i { animation: wvEq 1s ease-in-out infinite alternate; }
.wv-eq i:nth-child(2n) { animation-delay: -.35s !important; }
.wv-eq i:nth-child(3n) { animation-delay: -.7s !important; animation-duration: .8s !important; }
.wv-eq i:nth-child(4n+1) { animation-delay: -.15s !important; animation-duration: 1.2s !important; }
@keyframes wvEq { 0% { height: 4px; } 50% { height: 22px; } 100% { height: 9px; } }

.wv-lines { display: grid; gap: 10px; min-height: 2lh; }
.wv-line { margin: 0; opacity: 0; transform: translateY(14px); filter: blur(6px); transition: opacity .7s var(--ease), transform .8s var(--ease), filter .7s var(--ease); text-wrap: balance; }
.wv-line.in { opacity: 1; transform: none; filter: none; }
.wv-line.l0 { font: 800 clamp(24px, 5.4vw, 42px)/1.35 var(--f-display); color: var(--ink); }
.wv-line.l1 { font: 600 clamp(18px, 3.8vw, 28px)/1.5 var(--f-display); color: var(--bone); }
.wv-brand { font-family: var(--f-brand); font-weight: 900; letter-spacing: .02em; color: var(--red-hi); text-shadow: 0 0 24px rgba(221, 1, 1, .55); unicode-bidi: isolate; white-space: nowrap; }

.wv-sign { display: inline-flex; align-items: baseline; gap: 12px; margin-top: 6px; opacity: 0; transform: translateY(10px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.wv-sign.in { opacity: 1; transform: none; }
.wv-dash { width: 34px; height: 1px; align-self: center; background: linear-gradient(90deg, transparent, var(--red)); }
.wv-name { font: 700 clamp(30px, 6vw, 40px)/1 'Aref Ruqaa', var(--f-display); color: var(--red-hi); text-shadow: 0 0 22px rgba(221, 1, 1, .45); }
.wv-role { font-size: 14px; font-weight: 600; color: var(--muted); }

.wv-foot { position: absolute; inset-inline: 0; bottom: 0; display: grid; justify-items: center; gap: 16px; padding: 0 16px calc(26px + env(safe-area-inset-bottom)); }
.wv-full .wv-prog { width: min(320px, 70vw); height: 2px; border-radius: 2px; background: rgba(217, 217, 217, .1); overflow: hidden; }
.wv-prog > span { display: block; height: 100%; background: linear-gradient(270deg, var(--red-hi), var(--blood)); transform: scaleX(0); transform-origin: right; }
.wv-full .wv-skip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px 0 12px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line-2); background: rgba(19, 11, 11, .6);
  transition: color .2s, border-color .2s, background .2s;
}
.wv-full .wv-skip:hover, .wv-full .wv-skip:focus-visible { color: var(--ink); border-color: var(--red-line); background: rgba(221, 1, 1, .12); }
.wv-full.is-done .wv-skip { opacity: 0; pointer-events: none; transition: opacity .3s; }

/* شريط صغير جوّا اللوحة */
.wv-mini {
  position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); height: 52px; padding: 0 8px 0 10px; overflow: hidden;
  border-radius: 999px; background: rgba(19, 11, 11, .92); border: 1px solid var(--red-line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .9), 0 0 30px -10px rgba(221, 1, 1, .6);
  transition: opacity .4s var(--ease), transform .5s var(--ease);
}
.wv-mini.on { opacity: 1; transform: translate(-50%, 0); }
.wv-mlogo { display: grid; flex: none; }
.wv-mini .wv-eq { height: 18px; gap: 3px; flex: none; }
.wv-mini .wv-eq i { width: 2.5px; }
.wv-mtext { min-width: 0; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wv-mtext.swap { animation: wvSwap .5s var(--ease) both; }
@keyframes wvSwap { from { opacity: 0; transform: translateY(6px); } }
.wv-mini .wv-skip { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--muted); }
.wv-mini .wv-skip:hover, .wv-mini .wv-skip:focus-visible { color: var(--ink); background: rgba(217, 217, 217, .08); }
.wv-mini .wv-prog { position: absolute; inset-inline: 18px; bottom: 0; height: 2px; }
@media (max-width: 1023px) { .app-page .wv-mini { bottom: calc(92px + env(safe-area-inset-bottom)); } }
