:root {
  /* === COLORS — REAL GOLD (shared across all themes) === */
  --gold: #D4AF37;
  --gold-light: #E8C84A;
  --gold-dim: #B8963A;
  --gold-muted: #8a7a52;
  --gold-glow: rgba(212, 175, 55, 0.15);
  --gold-glow-strong: rgba(212, 175, 55, 0.3);

  /* === DEFAULT THEME: COSMIC BLACK === */
  --black: #0a0a0a;
  --black-light: #0f0f0f;
  --surface: #111111;
  --surface-elevated: #161616;
  --border: rgba(212, 175, 55, 0.08);
  --border-hover: rgba(212, 175, 55, 0.25);
  --text-primary: #f0ede8;
  --text-secondary: #a8a4a0;
  --text-muted: #6a665e;
  --text-dim: #444444;

  /* === TYPOGRAPHY === */
  --font-heading: 'Tajawal', 'Amiri', 'Cairo', serif;
  --font-body: 'Cairo', 'Tajawal', 'Segoe UI', sans-serif;
  --font-en-heading: 'Playfair Display', 'Georgia', serif;
  --font-en-body: 'Inter', 'Segoe UI', sans-serif;

  /* === SPACING === */
  --space-unit: 8px;
  --space-xs: calc(var(--space-unit) * 0.5);
  --space-sm: var(--space-unit);
  --space-md: calc(var(--space-unit) * 2);
  --space-lg: calc(var(--space-unit) * 3);
  --space-xl: calc(var(--space-unit) * 4);
  --space-2xl: calc(var(--space-unit) * 6);
  --space-3xl: calc(var(--space-unit) * 8);

  /* === ANIMATION === */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === SHADOWS === */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 30px rgba(212, 175, 55, 0.1);
  --shadow-gold-lg: 0 0 60px rgba(212, 175, 55, 0.15);

  /* === Z-INDEX === */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-tooltip: 400;
  --z-toast: 500;
}

/* === THEME 2: CELESTIAL SKY BLUE (light) === */
:root.theme-celestial {
  --black: #cfe0ef;
  --black-light: #c1d6e9;
  --surface: #dfeaf6;
  --surface-elevated: #eef5fc;
  --border: rgba(43, 97, 148, 0.25);
  --border-hover: rgba(43, 97, 148, 0.50);
  --text-primary: #1e3348;
  --text-secondary: #3a5876;
  --text-muted: #5e7d9b;
  --text-dim: #86a0ba;
}

/* === THEME 3: EARTHLY GOLD-BROWN (light) === */
:root.theme-earthly {
  --black: #e5d7ba;
  --black-light: #dbcaa7;
  --surface: #efe4cc;
  --surface-elevated: #f8f0de;
  --border: rgba(125, 84, 23, 0.30);
  --border-hover: rgba(125, 84, 23, 0.55);
  --text-primary: #3b2d16;
  --text-secondary: #5c4826;
  --text-muted: #7d6a45;
  --text-dim: #9d8b66;
}

/* Smooth theme transition — targeted to avoid performance issues */
.section, .card, .pathway-card, .path-card, .stat-box, .level-card, .follow-card,
.btn, .btn-gold, .btn-outline,
input, textarea, select,
.faiq-nav, .top-bar, .nav-bar, .theme-menu, .lang-dropdown-menu {
  transition: background-color 0.5s ease, color 0.3s ease, border-color 0.3s ease;
}

/* === RESET === */
body, body * {
  transition: background-color 0.5s ease, color 0.3s ease, border-color 0.3s ease;
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-body); background: var(--black); color: var(--text-primary); line-height: 1.7; direction: rtl; overflow-x: hidden; }
img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; transition: var(--transition-base); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* === NOISE TEXTURE OVERLAY === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--gold-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* === SELECTION === */
::selection { background: rgba(212, 175, 55, 0.3); color: var(--text-primary); }

/* === ANIMATION KEYFRAMES === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-40px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(60px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes goldPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.1); }
}
@keyframes goldGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(212,175,55,0.1); }
  50% { box-shadow: 0 0 40px rgba(212,175,55,0.2), 0 0 80px rgba(212,175,55,0.1); }
}
@keyframes textReveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes borderGlow {
  0%, 100% { border-color: rgba(212,175,55,0.1); }
  50% { border-color: rgba(212,175,55,0.3); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
}
@keyframes rotateSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === REVEAL ANIMATION SYSTEM === */
.reveal { opacity: 0; transform: translateY(40px); transition: opacity 0.8s var(--transition-slow), transform 0.8s var(--transition-slow); }
.reveal.active { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

/* === HEADING STYLES === */
.heading-xl {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  color: var(--gold);
  line-height: 1.2;
  letter-spacing: 1px;
  position: relative;
}
.heading-lg {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 700;
  color: var(--gold);
  line-height: 1.3;
  letter-spacing: 0.5px;
}
.heading-md {
  font-family: var(--font-heading);
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}
.heading-sm {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* === TEXT STYLES === */
.text-body {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  color: var(--text-secondary);
  line-height: 1.9;
}
.text-small {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }

/* === BUTTON STYLES === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 1px;
  border-radius: 4px;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
  min-height: 48px;
  touch-action: manipulation;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(212,175,55,0.1) 50%, transparent 60%);
  background-size: 200% 200%;
  opacity: 0;
  transition: var(--transition-base);
}
.btn:hover::before { opacity: 1; animation: shimmer 2s infinite; }
.btn-gold {
  background: var(--gold);
  color: var(--black);
  box-shadow: var(--shadow-gold);
}
.btn-gold:hover {
  background: var(--gold-light);
  box-shadow: var(--shadow-gold-lg);
  transform: translateY(-2px);
}
.btn-gold:active { transform: translateY(0) scale(0.98); }
.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--border-hover);
}
.btn-outline:hover {
  border-color: var(--gold);
  background: rgba(212,175,55,0.05);
  transform: translateY(-2px);
}
.btn-outline:active { transform: translateY(0) scale(0.98); }

/* === CARD STYLES === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-xl);
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-muted), transparent);
  opacity: 0;
  transition: var(--transition-base);
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md), var(--shadow-gold);
}
.card:hover::before { opacity: 1; }
.card-3d {
  transform-style: preserve-3d;
  perspective: 1000px;
  transition: transform 0.4s var(--transition-slow);
}
.card-3d:hover { transform: rotateX(2deg) rotateY(-2deg) translateY(-4px); }

/* === SECTION STYLES === */
.section {
  padding: var(--space-3xl) var(--space-md);
  position: relative;
}
.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--space-xl);
  position: relative;
  display: inline-block;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent);
  transition: width 0.6s var(--transition-slow);
}
.section-title:hover::after { width: 100%; }

/* === GRADIENT BORDER === */
.gradient-border {
  position: relative;
  background: var(--surface);
  border-radius: 8px;
}
.gradient-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--gold-muted), transparent, var(--gold-muted));
  z-index: -1;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}
.gradient-border:hover::before { opacity: 1; }

/* === GOLD GLOW EFFECT === */
.gold-glow { animation: goldGlow 3s ease-in-out infinite; }
.gold-pulse { animation: goldPulse 3s ease-in-out infinite; }
.float { animation: float 6s ease-in-out infinite; }
.breathe { animation: breathe 4s ease-in-out infinite; }

/* === SHIMMER EFFECT === */
.shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(212,175,55,0.1) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* === TEXT SCRAMBLE REVEAL === */
.text-scramble {
  display: inline-block;
  position: relative;
}
.text-scramble.revealed {
  animation: textReveal 0.8s var(--transition-slow) forwards;
}

/* === SACRED GEOMETRY OVERLAY === */
.sacred-geometry {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(212,175,55,0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(212,175,55,0.05) 0%, transparent 40%);
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 768px) {
  .section { padding: var(--space-2xl) var(--space-md); }
  .heading-xl { font-size: clamp(2rem, 6vw, 2.5rem); }
  .heading-lg { font-size: clamp(1.5rem, 4vw, 2rem); }
  .heading-md { font-size: clamp(1.1rem, 3vw, 1.4rem); }
  .btn { padding: var(--space-md) var(--space-lg); font-size: 0.85rem; }
  .card { padding: var(--space-lg); }
}
@media (max-width: 480px) {
  .section { padding: var(--space-xl) var(--space-sm); }
  .btn { width: 100%; justify-content: center; }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
