/* ============================================================
   Lumen / لایتنر — Design tokens, fonts, RTL base
   Static prototype: Tailwind (CDN) handles utilities; this file
   owns fonts, CSS variables (design tokens), and a few RTL +
   component tweaks Tailwind can't express cleanly.
   ============================================================ */

/* ---------- Vazirmatn (self-described via Google Fonts <link>) ---------- */

:root {
  /* Brand */
  --color-primary: #5b4bdb;       /* indigo / violet — learning, focus */
  --color-primary-600: #4f3fd0;
  --color-primary-700: #4233b8;
  --color-primary-soft: #ece9fb;  /* tint surface */

  --color-accent: #f59e0b;        /* warm amber — streaks, CTAs */
  --color-accent-soft: #fef3e2;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger:  #ef4444;

  /* Leitner 5-box ramp (cool -> warm), each with a soft tint */
  --box-1: #6366f1; --box-1-soft: #eaeafc;
  --box-2: #0ea5e9; --box-2-soft: #e3f4fd;
  --box-3: #10b981; --box-3-soft: #e1f6ef;
  --box-4: #f59e0b; --box-4-soft: #fdf1de;
  --box-5: #f43f5e; --box-5-soft: #fde7eb;

  /* ---- Light theme surfaces / text (warm neutral grays) ---- */
  --bg:          #f7f7fb;   /* page background */
  --surface:     #ffffff;   /* cards */
  --surface-2:   #f2f2f7;   /* subtle inset */
  --border:      #e8e8ef;   /* light hairline borders */
  --text:        #1c1b22;   /* near-black, not pure black */
  --text-muted:  #6b6a78;
  --text-faint:  #9b9aa8;

  /* Effects */
  --radius: 1rem;
  --shadow-sm: 0 1px 2px rgba(28, 27, 34, 0.04), 0 1px 3px rgba(28, 27, 34, 0.04);
  --shadow:    0 4px 16px -4px rgba(28, 27, 34, 0.08), 0 2px 6px -2px rgba(28, 27, 34, 0.05);
  --shadow-lg: 0 18px 40px -12px rgba(28, 27, 34, 0.16), 0 8px 16px -8px rgba(28, 27, 34, 0.08);
  --ring: 0 0 0 4px rgba(91, 75, 219, 0.16);
}

html.dark {
  --color-primary-soft: #241f47;
  --color-accent-soft: #3a2c12;

  --box-1-soft: #1e1f3a;
  --box-2-soft: #102a3a;
  --box-3-soft: #0f2c25;
  --box-4-soft: #352713;
  --box-5-soft: #371720;

  --bg:         #0e0d14;
  --surface:    #17161f;
  --surface-2:  #1f1e29;
  --border:     #2a2935;
  --text:       #f1f0f6;
  --text-muted: #a6a4b4;
  --text-faint: #747283;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 8px 24px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, 0.65);
  --ring: 0 0 0 4px rgba(124, 110, 240, 0.28);
}

/* ---------- Base ---------- */
* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;            /* comfortable for Farsi */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
}

/* Persian numerals look better with these features off */
body { font-feature-settings: "ss01" off; }

/* Headings: slightly tighter line-height than body */
h1, h2, h3, h4 { line-height: 1.4; }

/* ---------- Mobile bottom-nav spacing (mobile-first) ---------- */
/* Reserve space so the fixed bottom tab bar never covers content/footer. */
@media (max-width: 1023px) {
  body.has-bottom-nav { padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
}

/* Bigger, comfortable touch targets on coarse pointers (phones/tablets) */
@media (pointer: coarse) {
  .btn { padding-top: .75rem; padding-bottom: .75rem; }
  .chip { padding-top: .5rem; padding-bottom: .5rem; }
}

/* ---------- RTL helpers / mirroring ---------- */
/* Mirror inline directional icons (chevrons/arrows that point "forward") */
[dir="rtl"] .mirror-x { transform: scaleX(-1); }

/* ---------- Reusable token-driven classes ---------- */
.surface     { background-color: var(--surface); }
.surface-2   { background-color: var(--surface-2); }
.app-border  { border-color: var(--border); }
.text-main   { color: var(--text); }
.text-muted  { color: var(--text-muted); }
.text-faint  { color: var(--text-faint); }

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.card-hover:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--color-primary) 30%, var(--border));
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  font-weight: 600;
  border-radius: .9rem;
  padding: .65rem 1.25rem;
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
  cursor: pointer;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(91,75,219,.5);
}
.btn-primary:hover { box-shadow: 0 10px 24px -6px rgba(91,75,219,.6); transform: translateY(-1px); }

.btn-accent {
  background: linear-gradient(135deg, var(--color-accent) 0%, #e2820a 100%);
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(245,158,11,.5);
}
.btn-accent:hover { box-shadow: 0 10px 24px -6px rgba(245,158,11,.6); transform: translateY(-1px); }

.btn-ghost {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background-color: var(--surface-2); border-color: color-mix(in srgb, var(--color-primary) 30%, var(--border)); }

.btn-soft {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
}
.btn-soft:hover { background-color: color-mix(in srgb, var(--color-primary) 16%, var(--color-primary-soft)); }

/* Chips / pills */
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .85rem;
  border-radius: 999px;
  font-size: .8rem; font-weight: 600;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s ease;
}
.chip:hover { border-color: color-mix(in srgb, var(--color-primary) 40%, var(--border)); color: var(--text); }
.chip.is-active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* Inputs */
.input {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: .85rem;
  padding: .7rem 1rem;
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--ring); }

/* ---------- Progress bar (fills from the RIGHT in RTL) ---------- */
.progress-track {
  background-color: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  height: .5rem;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary-700), var(--color-primary));
  transition: width .6s cubic-bezier(.22,1,.36,1);
}

/* ---------- Navbar glass ---------- */
.glass {
  background-color: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

/* ---------- Flashcard flip ---------- */
.flashcard { perspective: 1600px; }
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .6s cubic-bezier(.22,1,.36,1);
  transform-style: preserve-3d;
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex; flex-direction: column;
}
.flashcard-back { transform: rotateY(180deg); }

/* slide-to-next */
@keyframes cardOut { to { opacity: 0; transform: translateX(-40px) scale(.96); } }
@keyframes cardIn  { from { opacity: 0; transform: translateX(40px) scale(.96); } }
.card-leaving { animation: cardOut .28s ease forwards; }
.card-entering { animation: cardIn .32s ease forwards; }

/* ---------- Leitner box card stacking ---------- */
.box-stack { position: relative; }
.box-card-mini {
  border-radius: .6rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

@keyframes promote {
  0%   { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-18px) scale(1.05) rotate(-2deg); }
  100% { transform: translateY(0) scale(1); }
}
.is-promoting { animation: promote .7s cubic-bezier(.22,1,.36,1); }

/* ---------- Reveal-on-load helpers ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.reveal { opacity: 0; animation: fadeUp .6s cubic-bezier(.22,1,.36,1) forwards; }

/* ---------- Misc ---------- */
.divide-app > * + * { border-top: 1px solid var(--border); }

::selection { background: color-mix(in srgb, var(--color-primary) 30%, transparent); }

/* Custom scrollbar (subtle) */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* Focus visibility default for keyboard users */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: .5rem;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
