/* ==========================================================================
   تجربة: «الشكل الجديد» (new-look.js) — صور من Higgsfield + قوائم تفاعلية + خلفيات.
   كل القواعد تحت html.nl-on، والصفة تنحط للمدير بس (وبصفحة الدخول بجهازه بس).
   للإزالة الكاملة: احذف سطري new-look.css و new-look.js من index.html، ومجلد static/nl
   ========================================================================== */

/* ---------------- الخلفية: صورة الثيم تتحرك ببطء ---------------- */
.nl-backdrop { position: fixed; inset: 0; z-index: -2; pointer-events: none; overflow: hidden; background: var(--bg); }
.nl-bd-img {
  position: absolute; inset: -6%; background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.2s ease;
  animation: nlDrift 48s ease-in-out infinite alternate;
  will-change: transform;
}
.nl-bd-img.ready { opacity: var(--nl-bd-op, .85); }
.nl-bd-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 100% 90% at 50% 40%, transparent 45%, color-mix(in srgb, var(--bg) 70%, transparent) 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 10%, transparent), color-mix(in srgb, var(--bg) 45%, transparent));
}
/* حبيبات فلم خفيفة فوق الصورة */
.nl-bd-grain {
  position: absolute; inset: -50%; opacity: .07; mix-blend-mode: overlay;
  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='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: nlGrain 1.2s steps(6) infinite;
}
@keyframes nlDrift { from { transform: scale(1.04) translate3d(-1.2%, -1%, 0); } to { transform: scale(1.12) translate3d(1.4%, 1.2%, 0); } }
@keyframes nlGrain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-4%, 3%); } 40% { transform: translate(3%, -5%); }
  60% { transform: translate(-6%, -2%); } 80% { transform: translate(5%, 4%); } 100% { transform: translate(0, 0); }
}
/* الثيمات الفاتحة: الصورة أوضح والظل أفتح */
:root[data-theme="sakura"] .nl-bd-img.ready, :root[data-theme="support-desk"] .nl-bd-img.ready { --nl-bd-op: .6; }
:root[data-theme="zero-day"] .nl-bd-img.ready { --nl-bd-op: .6; }
/* ظل أطراف ثيم Cyber الأصلي أخف حتى تبين الصورة */
html.nl-on[data-theme="cyber-eng"] body::after { opacity: .55; }

/* ---------------- سطوح زجاجية (تبين الخلفية من وراها) ---------------- */
html.nl-on :is(.card, .tile) {
  background: color-mix(in srgb, var(--surface) 78%, transparent) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.25); backdrop-filter: blur(14px) saturate(1.25);
  border: 1px solid color-mix(in srgb, var(--text) 9%, transparent);
}
@media (hover: none), (max-width: 760px) {
  /* الموبايل: بدون blur حتى يبقى خفيف */
  html.nl-on :is(.card, .tile) { -webkit-backdrop-filter: none; backdrop-filter: none; background: color-mix(in srgb, var(--surface) 92%, transparent) !important; }
}

/* ضوء يلحق الماوس على الكروت */
html.nl-on :is(.card, .tile) { position: relative; }
html.nl-on :is(.card, .tile)::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  transition: opacity .35s ease;
  background: radial-gradient(380px circle at var(--nl-x, 50%) var(--nl-y, 50%), color-mix(in srgb, var(--primary) 16%, transparent), transparent 62%);
}
html.nl-on :is(.card, .tile):hover::after { opacity: 1; }
/* الحافة تضوي بنفس مكان الماوس */
html.nl-on :is(.card, .tile)::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; opacity: 0; padding: 1px;
  background: radial-gradient(240px circle at var(--nl-x, 50%) var(--nl-y, 50%), color-mix(in srgb, var(--primary) 85%, transparent), transparent 70%);
  -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);
  transition: opacity .35s ease;
}
html.nl-on :is(.card, .tile):hover::before { opacity: 1; }

/* أقسام الرئيسية تميل ثلاثي الأبعاد ويه الماوس */
html.nl-on .tile { transform-style: preserve-3d; transition: transform .5s cubic-bezier(.22, 1, .36, 1), box-shadow .3s; }
html.nl-on .tile.nl-tilting { transition: transform .08s linear, box-shadow .3s; box-shadow: 0 24px 50px -24px color-mix(in srgb, var(--primary) 55%, transparent); }

/* ---------------- القائمة الجانبية: مؤشر ينزلق ---------------- */
html.nl-on .side-nav { position: relative; }
html.nl-on .side-nav .side-link { z-index: 1; background: transparent !important; box-shadow: none !important; }
html.nl-on .side-nav .side-link.active { color: #fff; }
html.nl-on .side-link .icon { transition: transform .5s cubic-bezier(.34, 1.56, .64, 1); }
html.nl-on .side-link:hover .icon { transform: scale(1.15) rotate(-6deg); }
.nl-ind, .nl-hov {
  position: absolute; top: 0; inset-inline: 0; z-index: 0; border-radius: 15px; pointer-events: none;
  transition: transform .55s cubic-bezier(.34, 1.4, .64, 1), height .4s ease, opacity .25s ease;
}
.nl-ind {
  background: var(--grad);
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--grad-a, var(--primary)) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, .25);
}
[data-mode="dark"] .nl-ind { background: var(--grad-dark, var(--grad)); }
.nl-hov { background: var(--surface-2); opacity: 0; transition-duration: .35s; }
.nl-ind.nl-snap, .nl-hov.nl-snap { transition: none; }

/* ---------------- شريط الموبايل السفلي: فقاعة تنزلق ---------------- */
html.nl-on .bottomnav { isolation: isolate; }
.nl-bind {
  position: absolute; z-index: -1; top: 6px; bottom: 6px; left: 0; width: 60px; border-radius: 18px; pointer-events: none;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
  transition: transform .55s cubic-bezier(.34, 1.4, .64, 1), width .4s ease, opacity .25s;
}
.nl-bind.nl-snap { transition: none; }
html.nl-on .bottomnav :is(a, .bn-account).active { color: var(--primary); }

/* ---------------- قائمة «حسابي»: تنفتح بنابض وعناصرها تطلع ورا بعض ---------------- */
html.nl-on .account-menu {
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  animation: nlMenu .42s cubic-bezier(.34, 1.56, .64, 1) both;
}
html.nl-on .account-menu > * { animation: nlItem .45s cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(var(--i, 0) * 28ms + 60ms); }
html.nl-on .menu-item { transition: background .2s, color .2s, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
html.nl-on .menu-item:hover { transform: translateX(-4px); }
html.nl-on[dir="ltr"] .menu-item:hover { transform: translateX(4px); }
html.nl-on .menu-item:hover .icon { color: var(--primary); }
@keyframes nlMenu { from { opacity: 0; transform: scale(.86) translateY(14px); filter: blur(6px); } }
@keyframes nlItem { from { opacity: 0; transform: translateY(10px); } }

/* ---------------- الرئيسية: صورة الثيم بالهيرو ---------------- */
.nl-hero-img {
  position: absolute; inset: -18px; z-index: -1; pointer-events: none; background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1s ease, transform .9s cubic-bezier(.22, 1, .36, 1);
  transform: translate3d(var(--nl-px, 0px), var(--nl-py, 0px), 0) scale(1.06);
}
.nl-hero-img.ready { opacity: 1; }
.nl-hero-img::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(270deg, color-mix(in srgb, var(--bg) 88%, transparent) 0%, color-mix(in srgb, var(--bg) 55%, transparent) 50%, color-mix(in srgb, var(--bg) 20%, transparent) 100%);
}
html[dir="ltr"] .nl-hero-img::after { transform: scaleX(-1); }
html.nl-on .hero { min-height: 240px; }
html.nl-on .hero .hero-orb { opacity: .18; }

/* ---------------- صفحة الدخول: لوحة سينمائية ---------------- */
.nl-art-img {
  position: absolute; inset: 0; z-index: -2; pointer-events: none; background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.4s ease; animation: nlDrift 30s ease-in-out infinite alternate;
}
.nl-art-img.ready { opacity: 1; }
html.nl-on .auth-art { position: relative; overflow: hidden; isolation: isolate; }
html.nl-on .auth-art::after {
  content: "" !important; position: absolute !important; inset: 0 !important; z-index: -1 !important; height: auto !important;
  background: linear-gradient(200deg, rgba(4, 4, 6, .15), rgba(4, 4, 6, .82) 75%) !important; opacity: 1 !important;
}
html.nl-on .auth-card {
  background: color-mix(in srgb, var(--surface) 80%, transparent) !important;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}

/* ---------------- صفحة التحديات ---------------- */
html.nl-on .ctf-hero { position: relative; overflow: hidden; isolation: isolate; }
.nl-ctf-img {
  position: absolute; inset: 0; z-index: -1; pointer-events: none; background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1s ease;
}
.nl-ctf-img.ready { opacity: .55; }
.nl-ctf-img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--surface) 92%, transparent) 35%, color-mix(in srgb, var(--surface) 30%, transparent)); }

/* ---------------- الصفحات الفاضية: رسمة بدل الأيقونة ---------------- */
html.nl-on .empty .empty-art {
  width: 168px; height: 168px; border-radius: 28px; overflow: hidden;
  background: url("/static/nl/empty.jpg") center / cover no-repeat;
  box-shadow: 0 20px 44px -22px color-mix(in srgb, var(--primary) 60%, transparent);
  animation: nlFloat 6s ease-in-out infinite;
}
html.nl-on .empty .empty-art > * { display: none; }
@keyframes nlFloat { 50% { transform: translateY(-8px) rotate(-1deg); } }

/* ---------------- صفحة المساعدة: بانر ترحيبي ---------------- */
.nl-guide-banner {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px;
  padding: 18px 22px; border-radius: var(--r-lg, 22px); margin-bottom: 4px; isolation: isolate; color: #fff;
  background:
    radial-gradient(420px 220px at 12% 50%, rgba(255, 60, 70, .35), transparent 70%),
    linear-gradient(135deg, #15151b, #0b0b0f);
  box-shadow: 0 24px 50px -30px color-mix(in srgb, var(--primary) 70%, transparent), inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.nl-gb-text strong { display: block; font-size: 1.35rem; margin-bottom: 4px; }
.nl-gb-text p { margin: 0; color: rgba(255, 255, 255, .82); line-height: 1.7; }
.nl-gb-img {
  width: 150px; height: 150px; border-radius: 22px; object-fit: cover; display: block;
  box-shadow: 0 16px 34px -14px rgba(255, 60, 70, .6); animation: nlFloat 6s ease-in-out infinite;
}
@media (max-width: 560px) { .nl-guide-banner { grid-template-columns: 1fr; justify-items: center; text-align: center; } .nl-gb-img { width: 120px; height: 120px; grid-row: 1; } }

/* ---------------- ظهور الصفحة: الكروت تطلع ورا بعض ---------------- */
html.nl-on #view.nl-enter :is(.card, .tile, .hero) { animation: nlRise .7s cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(var(--nl-k, 0) * 45ms); }
@keyframes nlRise { from { opacity: 0; transform: translateY(18px) scale(.985); } }

/* ---------------- بطاقة المختبر: صور Higgsfield ---------------- */
.nl-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.nl-thumb { margin: 0; display: grid; gap: 4px; }
.nl-thumb img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; display: block;
  box-shadow: 0 0 0 1px var(--border); transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
}
.nl-thumb:hover img { transform: scale(1.04); }
.nl-thumb figcaption { font-size: .8rem; color: var(--muted); text-align: center; }

/* بعض الثيمات (مثل الدعم) تخلي كل أولاد الهيرو position: relative — طبقات الصور لازم تبقى مطلقة وورا المحتوى */
html.nl-on :is(.hero, .ctf-hero) > :is(.nl-hero-img, .nl-ctf-img) { position: absolute !important; z-index: -1 !important; }
html.nl-on .hero > .nl-hero-img { inset: -18px !important; }
html.nl-on .ctf-hero > .nl-ctf-img, html.nl-on .auth-art > .nl-art-img { inset: 0 !important; }
html.nl-on .auth-art > .nl-art-img { position: absolute !important; z-index: -2 !important; }

/* ---------------- الحركة المخففة ---------------- */
@media (prefers-reduced-motion: reduce) {
  .nl-bd-img, .nl-art-img, .nl-bd-grain, .nl-gb-img, html.nl-on .empty .empty-art { animation: none !important; }
  html.nl-on #view.nl-enter :is(.card, .tile, .hero), html.nl-on .account-menu, html.nl-on .account-menu > * { animation: none !important; }
  .nl-ind, .nl-hov, .nl-bind { transition: none; }
}
