/* ╔══════════════════════════════════════════════════╗
   ║                    Base CSS                      ║
   ║       استایل‌های عمومی و مشترک کل سایت           ║
   ╚══════════════════════════════════════════════════╝ */

:root {
  --bg: #f4f6f9;
  --bg-white: #ffffff;

  --text: #1a1a2e;
  --text-secondary: #5a6178;
  --text-muted: #9ca3b8;

  --border: #e4e8ef;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);

  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.main {
  padding: 40px 0 80px;
}

/* ── Selection ── */
::selection {
  background: rgba(26, 26, 46, 0.15);
  color: var(--text);
}

/* ════════════════════════════════════════
   نوار بالای صفحات داخلی
   ════════════════════════════════════════ */

.top-nav {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-nav-inner {
  display: flex;
  align-items: center;
}

.nav-back {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.nav-back:hover {
  color: var(--text);
}

.nav-back:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
  border-radius: 6px;
}

.nav-back svg {
  transition: var(--transition);
}

.nav-back:hover svg {
  transform: translateX(4px);
}

/* ════════════════════════════════════════
   Footer
   ════════════════════════════════════════ */

.footer {
  background: #1a1a2e;
  color: white;
  padding: 28px 0;
  text-align: center;
}

.footer-copy {
  font-size: 0.8em;
  opacity: 0.35;
}

/* ════════════════════════════════════════
   Scroll to Top
   ════════════════════════════════════════ */

.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: var(--transition);
  z-index: 90;
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  background: #2d3a5c;
  transform: translateY(-3px);
}

.scroll-top-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 3px;
}

/* ════════════════════════════════════════
   Loading
   ════════════════════════════════════════ */

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 20px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.95em;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════
   انیمیشن‌ها
   ════════════════════════════════════════ */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.7s ease backwards;
}

/* ════════════════════════════════════════
   Focus Styles (دسترسی‌پذیری)
   ════════════════════════════════════════ */

*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid #4a90e2;
  outline-offset: 3px;
  border-radius: 6px;
}

/* ════════════════════════════════════════
   Print
   ════════════════════════════════════════ */

@media print {
  .top-nav,
  .scroll-top-btn,
  .tag-filter,
  .topics-search,
  .term-nav,
  .footer {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .session-item,
  .topic-session-item {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .term-hero,
  .topics-hero,
  .course-hero,
  .chess-hero,
  .home-hero {
    background: #333 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* ════════════════════════════════════════
   Responsive
   ════════════════════════════════════════ */

@media (max-width: 768px) {
  .container {
    padding: 0 18px;
  }

  .main {
    padding: 32px 0 64px;
  }

  .scroll-top-btn {
    bottom: 20px;
    left: 20px;
    width: 42px;
    height: 42px;
  }
}