/*
 * ╔═══════════════════════════════════════════════════════════════╗
 * ║                       BASE STYLES                             ║
 * ║             Reset + Typography + Body Defaults                ║
 * ╚═══════════════════════════════════════════════════════════════╝
 */

/* ═════════════════════════════════════════════════════════════
 * 1. CSS RESET & NORMALIZE
 * ═════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  /* scroll-behavior: smooth;  <-- MOVED TO JS CONTROL for Performance */
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-main);
  background-color: var(--bg-color);
  direction: rtl;
  text-align: right;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Smooth theme transitions */
  transition: background-color 0.5s ease,
    color 0.5s ease;
}

/* Theme transitioning state - applies smooth transitions to all elements */
body.theme-transitioning,
body.theme-transitioning * {
  transition: background-color 0.4s ease,
    border-color 0.4s ease,
    color 0.4s ease,
    opacity 0.4s ease,
    transform 0.4s ease,
    box-shadow 0.4s ease !important;
}

body.theme-transitioning :is(#activities, #home-activities-grid) .activity-card,
body.theme-transitioning :is(#activities, #home-activities-grid) .activity-card * {
  transition: var(--activities-transition) !important;
}

body.theme-transitioning .action-btn i,
.no-theme-transition {
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) !important;
}

/* Completely exclude elements from theme transition */
body.theme-transitioning .no-theme-transition,
body.theme-transitioning .no-theme-transition * {
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) !important;
}

/* ═════════════════════════════════════════════════════════════
 * 2. TYPOGRAPHY SYSTEM
 * ═════════════════════════════════════════════════════════════ */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-4) 0;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--text-strong);
}

h1 {
  font-size: var(--font-size-5xl);
}

h2 {
  font-size: var(--font-size-4xl);
}

h3 {
  font-size: var(--font-size-3xl);
}

h4 {
  font-size: var(--font-size-2xl);
}

h5 {
  font-size: var(--font-size-xl);
}

h6 {
  font-size: var(--font-size-lg);
}

p {
  margin: 0 0 var(--space-4) 0;
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast) ease;
}

a:hover {
  color: var(--primary-dark);
}

a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ═════════════════════════════════════════════════════════════
 * 3. LISTS
 * ═════════════════════════════════════════════════════════════ */

ul,
ol {
  margin: 0 0 var(--space-4) 0;
  padding-right: var(--space-6);
  padding-left: 0;
}

li {
  margin-bottom: var(--space-2);
}

/* ═════════════════════════════════════════════════════════════
 * 4. IMAGES & MEDIA
 * ═════════════════════════════════════════════════════════════ */

img {
  max-width: 100%;
  height: auto;
  display: block;
  vertical-align: middle;
}

svg {
  max-width: 100%;
  height: auto;
  fill: currentColor;
}

/* ═════════════════════════════════════════════════════════════
 * 5. BUTTONS & FORM ELEMENTS RESET
 * ═════════════════════════════════════════════════════════════ */

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  direction: rtl;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

button:focus,
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ═════════════════════════════════════════════════════════════
 * 6. UTILITY CLASSES (Base Level)
 * ═════════════════════════════════════════════════════════════ */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.font-bold {
  font-weight: var(--font-weight-bold);
}

.font-semibold {
  font-weight: var(--font-weight-semibold);
}

.font-normal {
  font-weight: var(--font-weight-normal);
}

/* ═════════════════════════════════════════════════════════════
 * 7. ANIMATION UTILITIES
 * ═════════════════════════════════════════════════════════════ */

/* Fade In */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s var(--ease-in-out);
}

.fade-in.animate {
  opacity: 1;
  transform: translateY(0);
}

/* Scale In */
.scale-in {
  opacity: 0;
  transform: translateY(50px) scale(0.8);
  transition: all 0.8s var(--ease-in-out);
}

.scale-in.animate {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Slide In Left */
.slide-in-left {
  opacity: 0;
  transform: translateX(-50px);
  transition: all 0.7s var(--ease-in-out);
}

.slide-in-left.animate {
  opacity: 1;
  transform: translateX(0);
}

/* Slide In Right */
.slide-in-right {
  opacity: 0;
  transform: translateX(50px);
  transition: all 0.7s var(--ease-in-out);
}

.slide-in-right.animate {
  opacity: 1;
  transform: translateX(0);
}

/* Stagger Delays */
.stagger-1 {
  transition-delay: 0.1s;
}

.stagger-2 {
  transition-delay: 0.2s;
}

.stagger-3 {
  transition-delay: 0.3s;
}

.stagger-4 {
  transition-delay: 0.4s;
}

.stagger-5 {
  transition-delay: 0.5s;
}

/* Performance Optimization */
.fade-in,
.scale-in,
.slide-in-left,
.slide-in-right {
  /* will-change removed to prevent persistent memory usage. 
     Handled dynamically by bootstrap.js during animation only. */
  backface-visibility: hidden;
}

/* ═════════════════════════════════════════════════════════════
 * 8. ACCESSIBILITY
 * ═════════════════════════════════════════════════════════════ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip to main content */
.skip-to-main {
  position: absolute;
  top: -100px;
  right: 0;
  background: var(--primary-color);
  color: var(--text-white);
  padding: var(--space-4);
  z-index: var(--z-tooltip);
  transition: top var(--transition-fast) ease;
}

.skip-to-main:focus {
  top: 0;
}

/* ═════════════════════════════════════════════════════════════
 * 9. SELECTION & SCROLLBAR
 * ═════════════════════════════════════════════════════════════ */

::selection {
  background-color: var(--primary-color);
  color: var(--text-white);
}

::-moz-selection {
  background-color: var(--primary-color);
  color: var(--text-white);
}

/* Custom Scrollbar */
/* 
 * 🗑️ SCROLLBAR REMOVED
 * Reason: Moved to utilities-responsive.css with desktop-only media query
 * to prevent scrollbars on mobile devices (Native Feel).
 */

/* ═════════════════════════════════════════════════════════════
 * 10. انكسار السطر: الجزء بين أقواس في النهاية (مثل (1-4)) ككتلة واحدة
 * ═════════════════════════════════════════════════════════════ */

/* مقاطع أرقام/أقواس داخل عنوان عربي: عزل اتجاه LTR + منع الانكسار داخل الكتلة */
.text-trailing-paren-nowrap,
.hero-title-nowrap {
  white-space: nowrap;
  unicode-bidi: isolate;
  direction: ltr;
  display: inline-block;
}

/* حماية عامة لأي نص داخل الأقواس بدون فرض اتجاه LTR */
.text-paren-group-nowrap {
  white-space: nowrap;
  unicode-bidi: isolate;
  direction: inherit;
  display: inline;
}