/**
 * ثهلان – جماليات متقدمة وأنيميشنات تاريخية ثقافية
 * إبداعات بصرية فريدة بلمسات عربية أصيلة
 */

/* ========== متغيرات الأنيميشن ========== */
:root {
  --anim-fast: 0.2s;
  --anim-normal: 0.4s;
  --anim-slow: 0.8s;
  --anim-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --anim-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --gold-shimmer: linear-gradient(90deg, transparent 0%, rgba(201,162,39,0.3) 50%, transparent 100%);
  --heritage-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23C9A227' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ========== أنيميشنات الظهور المتسلسل ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

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

@keyframes shimmerGold {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.4); }
  50% { box-shadow: 0 0 20px 8px rgba(201, 162, 39, 0.2); }
}

@keyframes borderDraw {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes rotateIn {
  from { opacity: 0; transform: rotate(-10deg) scale(0.9); }
  to { opacity: 1; transform: rotate(0) scale(1); }
}

@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

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

/* ========== الظهور عند التمرير ========== */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--anim-smooth), transform 0.6s var(--anim-smooth);
}

.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll.delay-1 { transition-delay: 0.1s; }
.animate-on-scroll.delay-2 { transition-delay: 0.2s; }
.animate-on-scroll.delay-3 { transition-delay: 0.3s; }
.animate-on-scroll.delay-4 { transition-delay: 0.4s; }
.animate-on-scroll.delay-5 { transition-delay: 0.5s; }

.animate-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.5s var(--anim-smooth), transform 0.5s var(--anim-ease);
}

.animate-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* ========== تأثيرات البطاقات المتميزة ========== */
.card {
  position: relative;
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 70%
  );
  transform: rotate(45deg) translateY(-100%);
  transition: transform 0.8s var(--anim-smooth);
  pointer-events: none;
  z-index: 2;
}

.card:hover::after {
  transform: rotate(45deg) translateY(100%);
}

.card .thumb {
  position: relative;
  overflow: hidden;
}

.card .thumb::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4) 100%);
  opacity: 0;
  transition: opacity 0.4s var(--anim-smooth);
  z-index: 1;
}

.card:hover .thumb::before {
  opacity: 1;
}

/* ========== تأثير الذهب المتلألئ ========== */
.shimmer-gold {
  position: relative;
  overflow: hidden;
}

.shimmer-gold::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: var(--gold-shimmer);
  animation: shimmerGold 3s infinite;
  pointer-events: none;
}

/* ========== نمط تراثي للخلفية ========== */
.heritage-bg {
  position: relative;
}

.heritage-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--heritage-pattern);
  opacity: 0.5;
  pointer-events: none;
}

/* ========== أزرار متحركة ========== */
.btn {
  position: relative;
  overflow: hidden;
  transition: transform var(--anim-fast) var(--anim-ease), 
              box-shadow var(--anim-normal) var(--anim-smooth),
              background var(--anim-normal) var(--anim-smooth);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s var(--anim-smooth), height 0.6s var(--anim-smooth);
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

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

.btn-primary {
  background-size: 200% 200%;
  animation: btnGradient 3s ease infinite;
}

@keyframes btnGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ========== روابط التنقل المحسنة ========== */
nav a {
  position: relative;
  transition: color var(--anim-normal) var(--anim-smooth);
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent));
  transition: width var(--anim-normal) var(--anim-ease);
  border-radius: 2px;
}

nav a:hover::after {
  width: 100%;
}

/* ========== الهيرو المتحرك ========== */
.hero {
  position: relative;
}

.hero::before {
  animation: heroGlow 8s ease-in-out infinite alternate;
}

@keyframes heroGlow {
  0% { opacity: 0.5; }
  100% { opacity: 0.8; }
}

.hero-grid {
  animation: fadeInUp 0.8s var(--anim-smooth);
}

.cover {
  animation: slideInRight 0.6s var(--anim-smooth) 0.2s both;
}

.editor-picks .pick:nth-child(1) { animation: slideInLeft 0.5s var(--anim-smooth) 0.3s both; }
.editor-picks .pick:nth-child(2) { animation: slideInLeft 0.5s var(--anim-smooth) 0.4s both; }
.editor-picks .pick:nth-child(3) { animation: slideInLeft 0.5s var(--anim-smooth) 0.5s both; }

/* ========== تأثيرات التايملاين (الفعاليات) ========== */
.timeline .event {
  transition: transform var(--anim-normal) var(--anim-ease),
              box-shadow var(--anim-normal) var(--anim-smooth),
              border-color var(--anim-normal) var(--anim-smooth);
}

.timeline .event:hover {
  transform: translateY(-6px) scale(1.02);
}

.timeline .event::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 0;
  background: linear-gradient(180deg, var(--accent-gold), var(--accent));
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: height var(--anim-normal) var(--anim-ease);
}

.timeline .event:hover::before {
  height: 100%;
}

/* ========== الشعار المتحرك ========== */
.logo {
  transition: transform var(--anim-normal) var(--anim-ease);
}

.logo:hover {
  transform: scale(1.03);
}

.logo-icon {
  transition: transform var(--anim-slow) var(--anim-ease);
}

.logo:hover .logo-icon {
  transform: rotate(-3deg) scale(1.05);
}

/* ========== تأثير نبض الإشعارات ========== */
.pulse-notification {
  animation: pulseGlow 2s infinite;
}

/* ========== تأثير الكتابة ========== */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-left: 3px solid var(--accent);
  animation: typewriter 3s steps(40) 1s both, blink 0.7s infinite step-end 4s;
}

/* ========== تأثيرات الصور ========== */
.image-hover-zoom {
  overflow: hidden;
}

.image-hover-zoom img {
  transition: transform 0.6s var(--anim-smooth), filter 0.4s var(--anim-smooth);
}

.image-hover-zoom:hover img {
  transform: scale(1.1);
}

/* ========== تأثير التدرج المتحرك للنصوص ========== */
.gradient-text-animate {
  background: linear-gradient(90deg, var(--accent-gold), var(--accent), var(--accent-gold));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientText 3s linear infinite;
}

@keyframes gradientText {
  to { background-position: 200% center; }
}

/* ========== تأثير الظل المتحرك ========== */
.shadow-hover {
  transition: box-shadow var(--anim-normal) var(--anim-smooth);
}

.shadow-hover:hover {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
              0 0 40px rgba(201, 162, 39, 0.1);
}

/* ========== النشرة البريدية المتميزة ========== */
.newsletter {
  position: relative;
  overflow: hidden;
}

.newsletter::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 200%;
  background: radial-gradient(circle, rgba(201,162,39,0.1) 0%, transparent 70%);
  animation: floatSoft 6s ease-in-out infinite;
  pointer-events: none;
}

.newsletter::after {
  content: '';
  position: absolute;
  bottom: -50%;
  left: -50%;
  width: 100%;
  height: 200%;
  background: radial-gradient(circle, rgba(160,82,45,0.08) 0%, transparent 70%);
  animation: floatSoft 8s ease-in-out infinite reverse;
  pointer-events: none;
}

.newsletter input[type="email"] {
  transition: box-shadow var(--anim-normal) var(--anim-smooth),
              transform var(--anim-fast) var(--anim-ease);
}

.newsletter input[type="email"]:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 0 0 3px var(--accent-gold);
}

/* ========== الفوتر ========== */
footer {
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  opacity: 0.5;
}

footer .footer-links a {
  transition: color var(--anim-normal) var(--anim-smooth),
              transform var(--anim-fast) var(--anim-ease);
}

footer .footer-links a:hover {
  transform: translateX(-4px);
}

/* ========== سايد بار محسن ========== */
.side-block {
  transition: transform var(--anim-normal) var(--anim-ease),
              box-shadow var(--anim-normal) var(--anim-smooth);
}

.side-block:hover {
  transform: translateY(-4px);
}

.side-block li {
  transition: padding-right var(--anim-normal) var(--anim-ease),
              background var(--anim-normal) var(--anim-smooth);
}

.side-block li:hover {
  padding-right: 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

/* ========== عناوين الأقسام المتحركة ========== */
.lane h3 {
  position: relative;
}

.lane h3::after {
  content: '';
  position: absolute;
  bottom: -4px;
  right: 0;
  width: 0;
  height: 2px;
  background: var(--accent-gold);
  transition: width 0.6s var(--anim-ease);
}

.lane:hover h3::after {
  width: 60px;
}

/* ========== تعطيل الحركات لمن يفضلون ذلك ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .animate-on-scroll {
    opacity: 1;
    transform: none;
  }
}

/* ========== تأثيرات للجوال ========== */
@media (max-width: 640px) {
  .cover { animation-delay: 0.1s; }
  .editor-picks .pick:nth-child(1) { animation-delay: 0.15s; }
  .editor-picks .pick:nth-child(2) { animation-delay: 0.2s; }
  .editor-picks .pick:nth-child(3) { animation-delay: 0.25s; }
  
  .card::after {
    display: none;
  }
}

/* ========== تأثير الخط العربي التراثي ========== */
.arabic-calligraphy {
  font-family: 'Amiri', 'Tajawal', serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* ========== زخرفة إسلامية هندسية ========== */
.islamic-pattern {
  position: relative;
}

.islamic-pattern::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23C9A227' fill-opacity='0.04'%3E%3Cpath d='M40 0L80 40L40 80L0 40z M40 10L70 40L40 70L10 40z' fill-rule='evenodd'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.7;
}

/* ========== تأثير النجوم العربية ========== */
.star-decoration::before {
  content: '✦';
  margin-left: 8px;
  color: var(--accent-gold);
  font-size: 0.8em;
  animation: floatSoft 3s ease-in-out infinite;
}

.star-decoration::after {
  content: '✦';
  margin-right: 8px;
  color: var(--accent-gold);
  font-size: 0.8em;
  animation: floatSoft 3s ease-in-out infinite reverse;
}

/* ========== تأثير التمرير السلس ========== */
html {
  scroll-behavior: smooth;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-gold), var(--accent));
  border-radius: 5px;
  border: 2px solid var(--bg-soft);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent), var(--accent-gold));
}

/* ========== التحديد والنص المظلل ========== */
::selection {
  background: rgba(201, 162, 39, 0.3);
  color: var(--text);
}

::-moz-selection {
  background: rgba(201, 162, 39, 0.3);
  color: var(--text);
}

/* ========== تأثير البطاقة الزجاجية ========== */
.glass-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .glass-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========== مؤشر التحميل ========== */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== تأثير النقر على الأزرار ========== */
.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}
