/* ============================================================
   SHORTLONG HUB — DESIGN SYSTEM OVERLAY v1.0
   Load order: LAST (after main.css, ui-refine.css, tw.css)
   Strategy: additive only — no structure/markup changes.
   Phases: tokens · display font · elevation/depth · 3D · perf
   ============================================================ */

/* ── فاز ۰: فونت نمایشی برند (متصل به فایل‌های موجود Yekan Bakh Fanum برای حذف خطای 404) ── */
@font-face {
  font-family: 'Farhang Display';
  src: url('/fonts/Yekan_Bakh_Fanum_Regular.TTF') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Farhang Display';
  src: url('/fonts/Yekan_Bakh_Fanum_Medium.TTF') format('truetype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Farhang Display';
  src: url('/fonts/Yekan_Bakh_Fanum_Bold.TTF') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Farhang Display';
  src: url('/fonts/Yekan_Bakh_Fanum_Extra_Bold.TTF') format('truetype');
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: 'Farhang Display';
  src: url('/fonts/Yekan_Bakh_Fanum_Fat.TTF') format('truetype');
  font-weight: 900;
  font-display: swap;
}

/* ── فاز ۱: یکسان‌سازی توکن‌های رنگ (پالت Obsidian Fintech) ── */
:root {
  /* برند: آبی-نیلی فین‌تک + بنفش مخصوص هوش مصنوعی */
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --color-accent: #3b82f6;
  --color-ai: #8b5cf6;

  /* سیستم عمق سه‌سطحی (Elevation) */
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 10px rgba(2, 6, 23, 0.35);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.42), 0 12px 32px rgba(2, 6, 23, 0.48),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --elev-3: 0 12px 28px rgba(0, 0, 0, 0.55), 0 32px 80px rgba(2, 6, 23, 0.65),
            inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
html.light-theme {
  --elev-2: 0 1px 3px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --elev-3: 0 8px 20px rgba(15, 23, 42, 0.10), 0 28px 64px rgba(15, 23, 42, 0.14),
            inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* ── فاز ۱: تیترها و اعداد مالی تراز ستونی (Tabular Numerals) ── */
h1, h2, h3 {
  font-family: 'Farhang Display', 'YekanBakh', system-ui, sans-serif !important;
  letter-spacing: -0.01em !important;
}
td, th, .stat-value, .kpi-value, [class*="font-mono"], input[type="number"], input[type="tel"] {
  font-variant-numeric: tabular-nums;
}

/* ── فاز ۴ (عمق): کارت شیشه‌ای با لبه‌ی نور بالایی و سایه‌ی سطح‌بندی‌شده ── */
.glass-card {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.72), rgba(10, 16, 28, 0.80)) !important;
  backdrop-filter: blur(10px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(10px) saturate(140%) !important;
  box-shadow: var(--elev-2) !important;
  transition: box-shadow 0.25s ease, transform 0.18s cubic-bezier(0.2, 0.7, 0.3, 1) !important;
}
.glass-card:hover {
  box-shadow: var(--elev-2), 0 0 0 1px rgba(59, 130, 246, 0.18) !important;
}

/* مودال‌ها و دیالوگ‌ها: بالاترین سطح عمق */
[role="dialog"] .glass-card,
.modal-content {
  box-shadow: var(--elev-3) !important;
}

/* دکمه‌های با اهمیت بالا (CTA) */
.btn-primary, button.btn-brand {
  box-shadow: var(--elev-1) !important;
}
.btn-primary:hover, button.btn-brand:hover {
  box-shadow: var(--elev-2) !important;
}

/* ── فاز ۵ (سه‌بعدی): صحنه‌ی کندل‌استیک پرسپکتیو‌دار صفحه‌ی ورود ── */
.sl-candles {
  position: absolute;
  right: 0; left: 0; bottom: 0;
  height: 46%;
  pointer-events: none;
  z-index: 0;
}
/* کف مشبک پرسپکتیو — حس فضای سه‌بعدی */
.sl-candles::before {
  content: '';
  position: absolute;
  right: -12%; left: -12%; bottom: 0; top: 0;
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.10) 1px, transparent 1px);
  background-size: 30px 20px;
  transform: perspective(300px) rotateX(55deg);
  transform-origin: bottom center;
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent 85%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent 85%);
}
.sl-candle {
  position: absolute;
  bottom: 12%;
  width: 9px;
  height: var(--h, 40px);
  border-radius: 2px;
  transform-origin: bottom center;
  animation: sl-rise 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}
/* فتیله‌ی کندل */
.sl-candle::after {
  content: '';
  position: absolute;
  top: -9px; bottom: -9px;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: inherit;
  opacity: 0.5;
  border-radius: 1px;
}
.sl-candle.up {
  background: linear-gradient(180deg, #34d399, #059669);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.30);
}
.sl-candle.down {
  background: linear-gradient(180deg, #fb7185, #e11d48);
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.28);
}
@keyframes sl-rise {
  from { transform: scaleY(0); }
}
/* تنفس ملایم کندل‌ها بعد از رشد */
.sl-candle { animation: sl-rise 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) backwards, sl-breathe 6s ease-in-out 1s infinite; }
@keyframes sl-breathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.06); }
}

/* ── فاز ۵: تیلت سه‌بعدی کارت‌ها (کلاس‌ها از design3d.js تزریق می‌شوند) ── */
.sl-tilt, .sl-tilt-soft {
  transform-style: preserve-3d;
  will-change: transform;
}
.sl-tilt { transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.3, 1); }
.sl-tilt-soft { transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1); }

/* ── فاز ۶ (پرفورمنس): احترام به تنظیمات کاربر ── */
@media (prefers-reduced-motion: reduce) {
  .sl-candle { animation: none !important; }
  .sl-tilt, .sl-tilt-soft { transform: none !important; transition: none !important; }
}
/* موبایل: بلور سبک‌تر — GPU ضعیف‌تر */
@media (max-width: 768px) {
  .glass-card {
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
  }
  .sl-candles { opacity: 0.55; }
}
