/*
 * وشّى — Core Design System
 * Creative Director + UX Architect + AI Product Engineer
 */

/* ═══════════════════════════════════════════════════════════
   BRAND COLORS — Strict Palette (DO NOT ADD MORE)
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Primary Palette */
  --sand-paper: #EBE5D9;
  --espresso-ink: #2C241B;
  --desert-olive: #4B5842;
  --cocoa-brown: #5A3E2B;
  --lavender-mist: #9D8BB1;

  /* Functional Variables */
  --color-bg: var(--sand-paper);
  --color-text: var(--espresso-ink);
  --color-interactive: var(--desert-olive);
  --color-accent: var(--cocoa-brown);
  --color-ai: var(--lavender-mist);

  /* Typography */
  --font-primary: 'Suisse Intl', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;

  /* Spacing System */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-cinematic: 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-arabic);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  direction: rtl;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
}

h2 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h3 {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
}

p {
  font-size: 1rem;
  line-height: 1.8;
  max-width: 65ch;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT PRIMITIVES
   ═══════════════════════════════════════════════════════════ */

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-lg) var(--space-md);
  position: relative;
}

.centered {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2.5rem;
  font-family: var(--font-arabic);
  font-size: 1rem;
  font-weight: 500;
  border: 2px solid var(--color-text);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: var(--color-text);
  transition: width var(--transition-smooth);
  z-index: -1;
}

.btn:hover::before {
  width: 100%;
}

.btn:hover {
  color: var(--color-bg);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--color-text);
  color: var(--color-bg);
}

.btn-primary:hover {
  background: var(--desert-olive);
  border-color: var(--desert-olive);
  color: var(--color-bg);
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══ جنون حقيقي - حركات متقدمة ═══ */

@keyframes glitch {
  0% {
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
  20% {
    transform: translate(-3px, 3px);
    filter: hue-rotate(90deg);
  }
  40% {
    transform: translate(-3px, -3px);
    filter: hue-rotate(180deg);
  }
  60% {
    transform: translate(3px, 3px);
    filter: hue-rotate(270deg);
  }
  80% {
    transform: translate(3px, -3px);
    filter: hue-rotate(360deg);
  }
  100% {
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-15px) rotate(2deg);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.85;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100px) rotate(-5deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px) rotate(5deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
  }
}

@keyframes rotate360 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-8px) rotate(-2deg); }
  75% { transform: translateX(8px) rotate(2deg); }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(157, 139, 177, 0.3);
  }
  50% {
    box-shadow: 0 0 25px rgba(157, 139, 177, 0.8),
                0 0 40px rgba(157, 139, 177, 0.5);
  }
}

@keyframes morphBorder {
  0%, 100% {
    border-radius: 0%;
  }
  25% {
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  }
  50% {
    border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%;
  }
  75% {
    border-radius: 30% 70% 70% 30% / 70% 30% 30% 70%;
  }
}

@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.03);
    opacity: 0.9;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(100px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

.fade-in {
  animation: fadeIn var(--transition-cinematic) ease-out forwards;
}

.slide-up {
  animation: slideUp var(--transition-cinematic) ease-out forwards;
}

.float {
  animation: float 4s ease-in-out infinite;
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

.glitch-effect:hover {
  animation: glitch 0.4s ease-in-out;
}

.rotate {
  animation: rotate360 20s linear infinite;
}

.breathe {
  animation: breathe 3s ease-in-out infinite;
}

.bounce {
  animation: bounce 1.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ═══════════════════════════════════════════════════════════ */

/* Extra Small Devices (Phones, 320px and up) */
@media (max-width: 480px) {
  :root {
    --space-sm: 0.75rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
  }

  html {
    font-size: 14px;
  }

  .screen {
    padding: var(--space-md) var(--space-sm);
    min-height: 100svh; /* استخدام svh للموبايل */
  }

  .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    width: 100%;
    max-width: 100%;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .container {
    padding: 0 var(--space-sm);
  }

  /* تحسينات اللمس للموبايل */
  .btn,
  a,
  button,
  [role="button"] {
    min-height: 44px; /* iOS touch target */
    min-width: 44px;
  }
}

/* Small Devices (Tablets, 481px and up) */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --space-lg: 3rem;
    --space-xl: 5rem;
  }

  .screen {
    padding: var(--space-lg) var(--space-md);
  }

  .btn {
    padding: 0.875rem 2rem;
    font-size: 0.95rem;
  }
}

/* Medium Devices (Small Laptops, 769px and up) */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 900px;
  }
}

/* Large Devices (Desktops, 1025px and up) */
@media (min-width: 1025px) {
  .screen {
    padding: var(--space-xl) var(--space-lg);
  }

  /* تفعيل الحركات المتقدمة فقط على الشاشات الكبيرة */
  .hover-float:hover {
    animation: float 2s ease-in-out infinite;
  }

  .hover-glow:hover {
    animation: glow 1.5s ease-in-out infinite;
  }
}

/* Landscape Orientation (للموبايل الأفقي) */
@media (max-height: 500px) and (orientation: landscape) {
  .screen {
    min-height: auto;
    padding: var(--space-md) var(--space-sm);
  }

  h1 {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --sand-paper: #2C241B;
    --espresso-ink: #EBE5D9;
  }

  body {
    background-color: var(--sand-paper);
    color: var(--espresso-ink);
  }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* إزالة hover effects على الأجهزة اللمسية */
  .btn:hover::before {
    width: 0;
  }

  .btn:active {
    transform: scale(0.95);
  }

  /* زيادة مساحة اللمس */
  a, button {
    padding: 0.5rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════ */

.hidden {
  display: none !important;
}

.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;
}
