/* =========================================
    Emarat Isfahan Real Estate - MASTER CSS (FINAL)
   Features: RTL, 3D depth, shimmer, aurora, 
   conic rings, staggered grids, skeletons, 
   and ULTIMATE MOBILE RESPONSIVE FIXES.
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

/* ================= 1. VARIABLES & TOKENS ================= */
:root {
  --c-primary: #0f172a;
  --c-secondary: #1e3a8a;
  --c-accent: #d4af37;
  --c-accent-glow: rgba(212, 175, 55, 0.4);
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --border-light: #e2e8f0;
  --font-sans: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --ease-out-back: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= 2. BASE & RESET (RTL) ================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; transition: color 0.2s var(--ease-smooth); }
button, input, select, textarea { font-family: inherit; font-size: 100%; line-height: 1.15; margin: 0; }

/* ================= 3. LAYOUT UTILITIES ================= */
.container { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: 1.5rem; }
.grid { display: grid; gap: 2rem; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ================= 4. AURORA HERO ================= */
.hero-aurora { position: relative; background: linear-gradient(180deg, var(--bg-base) 0%, var(--bg-surface) 100%); overflow: hidden; isolation: isolate; padding: 6rem 0; }
.aurora-blob { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.5; mix-blend-mode: multiply; pointer-events: none; z-index: -1; animation: aurora-drift 20s ease-in-out infinite alternate; }
.aurora-blob-1 { width: 60vw; height: 60vw; background: radial-gradient(circle, rgba(30, 58, 138, 0.3), transparent 70%); top: -20%; right: -10%; }
.aurora-blob-2 { width: 50vw; height: 50vw; background: radial-gradient(circle, rgba(212, 175, 55, 0.2), transparent 70%); bottom: -20%; left: -10%; animation-delay: -7s; }
@keyframes aurora-drift { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(50px, -50px) scale(1.15); } }

/* ================= 5. 3D CARD DEPTH ================= */
.card-3d {
  background: var(--bg-elevated); border-radius: var(--radius-md); border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md); transform-style: preserve-3d;
  transition: transform 0.5s var(--ease-out-back), box-shadow 0.5s var(--ease-smooth);
  will-change: transform; position: relative; overflow: hidden; padding: 2rem;
}
.card-3d::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 50%);
  opacity: 0; transition: opacity 0.5s ease; pointer-events: none;
}
.card-3d:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(212, 175, 55, 0.1) inset;
}
.card-3d:hover::before { opacity: 1; }

/* ================= 6. GRADIENT TEXT SHIMMER ================= */
.text-shimmer {
  background: linear-gradient(90deg, var(--c-primary) 0%, var(--c-accent) 25%, var(--c-secondary) 50%, var(--c-accent) 75%, var(--c-primary) 100%);
  background-size: 200% auto; color: transparent; -webkit-background-clip: text; background-clip: text;
  animation: shimmer-text 4s linear infinite; font-weight: 800;
}
@keyframes shimmer-text { 0% { background-position: 0% center; } 100% { background-position: 200% center; } }

/* ================= 7. CONIC RING ================= */
.conic-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.conic-ring::before {
  content: ''; position: absolute; inset: -3px; border-radius: inherit;
  background: conic-gradient(from 0deg, transparent 0%, var(--c-accent) 25%, var(--c-secondary) 50%, transparent 100%);
  animation: spin-conic 3s linear infinite; z-index: -1;
}
.conic-ring::after { content: ''; position: absolute; inset: 0; background: var(--bg-surface); border-radius: inherit; z-index: -1; }
@keyframes spin-conic { 100% { transform: rotate(360deg); } }

/* ================= 8. STAGGERED REVEAL ================= */
.stagger-grid > * { opacity: 0; transform: translateY(40px); animation: reveal-up 0.8s var(--ease-out-back) forwards; }
.stagger-grid > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-grid > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-grid > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-grid > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-grid > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-grid > *:nth-child(6) { animation-delay: 0.6s; }
@keyframes reveal-up { to { opacity: 1; transform: translateY(0); } }

/* ================= 9. SKELETON ================= */
.skeleton { background: linear-gradient(90deg, var(--border-light) 25%, #f1f5f9 50%, var(--border-light) 75%); background-size: 200% 100%; animation: shimmer-skeleton 1.5s infinite; border-radius: var(--radius-sm); }
.skeleton-text { height: 1rem; margin-block-end: 0.5rem; width: 80%; }
.skeleton-title { height: 1.5rem; margin-block-end: 1rem; width: 50%; }
.skeleton-img { aspect-ratio: 16/9; width: 100%; }
@keyframes shimmer-skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ================= 10. BUTTONS & LINKS ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border-radius: var(--radius-full); font-weight: 600;
  transition: all 0.3s var(--ease-smooth); position: relative; overflow: hidden;
  isolation: isolate; border: none; cursor: pointer; white-space: nowrap;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.3) 50%, transparent 70%);
  transform: translateX(-100%); transition: transform 0.6s ease; z-index: -1;
}
.btn:hover::after { transform: translateX(100%); }
.btn-primary { background: var(--c-primary); color: var(--text-inverse); box-shadow: 0 4px 14px 0 rgba(15, 23, 42, 0.3); }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 8px 20px 0 rgba(15, 23, 42, 0.4); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-accent { background: var(--c-accent); color: var(--c-primary); box-shadow: 0 4px 14px 0 var(--c-accent-glow); }
.btn-accent:hover { transform: translateY(-3px); }

.link-hover { position: relative; }
.link-hover::before { content: ''; position: absolute; bottom: -2px; right: 0; width: 0; height: 2px; background: var(--c-accent); transition: width 0.3s var(--ease-smooth); }
.link-hover:hover::before { width: 100%; }

.input-field {
  width: 100%; padding: 0.85rem 1.2rem; background: var(--bg-surface);
  border: 2px solid var(--border-light); border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease-smooth);
}
.input-field:hover { border-color: #cbd5e1; }
.input-field:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 4px var(--c-accent-glow); }

/* ================= 11. ACCESSIBILITY ================= */
:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 3px; border-radius: 4px; transition: outline-offset 0.2s ease; }
.skip-link { position: absolute; top: -100%; left: 50%; transform: translateX(-50%); background: var(--c-primary); color: white; padding: 1rem 2rem; border-radius: 0 0 8px 8px; z-index: 9999; transition: top 0.2s ease; }
.skip-link:focus { top: 0; }

/* ================= 12. VIEW TRANSITIONS ================= */
::view-transition-old(root) { animation: 150ms cubic-bezier(0.4, 0, 1, 1) both fade-out; filter: blur(2px); }
::view-transition-new(root) { animation: 250ms cubic-bezier(0, 0, 0.2, 1) 150ms both fade-in; }
@keyframes fade-out { to { opacity: 0; transform: scale(0.98); } }
@keyframes fade-in { from { opacity: 0; transform: scale(1.02); } }

/* =========================================
   ️ ULTIMATE MOBILE FIXES (NO HORIZONTAL SCROLL)
   ========================================= */
html, body, main, header, footer {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

@media (max-width: 900px) {
  
  /* --- HEADER: STACK VERTICALLY --- */
  .site-header .container, header .container {
    flex-direction: column !important;
    gap: 1rem !important;
    align-items: center !important;
    text-align: center;
    padding-inline: 1rem !important;
  }

  /* Mobile Nav Box */
  .main-nav, nav {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0.5rem 0 !important;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
  }

  /* Show Menu Links on Mobile */
  .main-nav a:not(.btn), nav a:not(.btn) {
    display: block !important;
    width: 100%;
    text-align: center;
    padding: 0.85rem 1rem !important;
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
    color: var(--text-main);
  }
  
  .main-nav a:not(.btn):last-of-type, nav a:not(.btn):last-of-type {
    border-bottom: none;
  }

  /* Contact Button on Mobile */
  .main-nav .btn, nav .btn {
    width: 90% !important;
    max-width: 300px !important;
    margin-top: 1rem !important;
    margin-bottom: 0.5rem !important;
    padding: 0.9rem 1.5rem !important;
    font-size: 1rem !important;
  }

  /* Logo */
  .logo {
    font-size: 1.3rem !important;
    margin: 0 !important;
  }

  /* --- GRID & LAYOUT FIXES --- */
  .grid, .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Force single column for inline-style grids (Property page) */
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:2fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* --- TYPOGRAPHY FIXES --- */
  h1, .text-shimmer { font-size: 2rem !important; line-height: 1.4 !important; }
  h2 { font-size: 1.6rem !important; }
  h3 { font-size: 1.25rem !important; }

  /* Word Wrap for Persian */
  h1, h2, h3, h4, p, span, a, div, .card-3d, .guide-content {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  /* Spacing */
  .container { padding-inline: 1rem !important; }
  .card-3d { padding: 1.5rem !important; }
  section { padding-block: 3rem !important; }
  
  .hero-aurora { padding: 4rem 0 !important; }
}

/* ================= 13. REDUCED MOTION ================= */
@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;
  }
  .aurora-blob { opacity: 0.2; animation: none; }
  .text-shimmer { background: var(--c-primary); -webkit-background-clip: unset; background-clip: unset; color: var(--c-primary); }
  .stagger-grid > * { opacity: 1; transform: none; }
}

/* ================= 14. RTL UTILITIES ================= */
.ms-2 { margin-inline-start: 0.5rem; }
.me-2 { margin-inline-end: 0.5rem; }
.ps-4 { padding-inline-start: 1rem; }
.pe-4 { padding-inline-end: 1rem; }