/* Layout System CSS */

/* Smooth Scroll */
html {
  scroll-behavior: smooth;
}

/* Smooth scroll for all browsers */
* {
  scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
html ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html ::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 0;
}

html ::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 0;
  transition: background 0.3s ease;
}

html ::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* Dark theme webkit scrollbar */
[data-theme="dark"] html ::-webkit-scrollbar-track {
  background: transparent !important;
}

[data-theme="dark"] html ::-webkit-scrollbar-thumb {
  background: var(--primary-color) !important;
}

[data-theme="dark"] html ::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark) !important;
}

/* Firefox scrollbar support */
html {
  scrollbar-width: thin;
  scrollbar-color: #911A1E transparent;
}

/* Dark theme scrollbar for Firefox */
[data-theme="dark"] html {
  scrollbar-color: #911A1E transparent;
}

/* iOS Safari scrollbar styling */
@supports (-webkit-touch-callout: none) {
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Force scrollbar visibility on iOS */
  body {
    -webkit-overflow-scrolling: touch;
  }
}

/* Mobile scrollbar fixes */
@media (max-width: 768px) {
  * {
    scrollbar-width: thin;
    scrollbar-color: #911A1E #f8f9fa;
  }
  
  [data-theme="dark"] * {
    scrollbar-color: #911A1E #2a2525;
  }
  
  /* Force scrollbar visibility on mobile */
  body {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Additional mobile webkit scrollbar */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  
  ::-webkit-scrollbar-thumb {
    background: #911A1E;
    border-radius: 0;
  }
  
  [data-theme="dark"] ::-webkit-scrollbar-track {
    background: transparent !important;
  }
  
  [data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #911A1E !important;
  }
}


/* Scroll progress indicator */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  z-index: 1001;
  transition: width 0.1s ease;
}

/* Scroll animation effects */
[data-scroll-effect] {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease-out;
}

[data-scroll-effect].scroll-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Fade in from left */
[data-scroll-effect="fade-left"] {
  transform: translateX(-30px);
}

[data-scroll-effect="fade-left"].scroll-visible {
  transform: translateX(0);
}

/* Fade in from right */
[data-scroll-effect="fade-right"] {
  transform: translateX(30px);
}

[data-scroll-effect="fade-right"].scroll-visible {
  transform: translateX(0);
}

/* Scale in effect */
[data-scroll-effect="scale"] {
  transform: scale(0.9);
}

[data-scroll-effect="scale"].scroll-visible {
  transform: scale(1);
}

/* Staggered animation delays */
[data-scroll-effect]:nth-child(1) { transition-delay: 0.1s; }
[data-scroll-effect]:nth-child(2) { transition-delay: 0.2s; }
[data-scroll-effect]:nth-child(3) { transition-delay: 0.3s; }
[data-scroll-effect]:nth-child(4) { transition-delay: 0.4s; }
[data-scroll-effect]:nth-child(5) { transition-delay: 0.5s; }

:root {
  /* Primary Colors */
  --primary-color: #911A1E;
  --primary-light: #b52a2e;
  --primary-dark: #7a1519;
  
  /* Light Theme */
  --bg-primary-light: #FAF7F4;
  --bg-secondary-light: #f8f9fa;
  --text-primary-light: #1a1a1a;
  --text-secondary-light: #6c757d;
  --border-light: #e9ecef;
  
  /* Dark Theme */
  --bg-primary-dark: #1f1f1f;
  --bg-secondary-dark: #2a2525;
  --text-primary-dark: #ffffff;
  --text-secondary-dark: #b0b0b0;
  --border-dark: #4a4444;
  
  /* Current Theme (defaults to light) */
  --bg-primary: var(--bg-primary-light);
  --bg-secondary: var(--bg-secondary-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --border-color: var(--border-light);

  /* Elevation — light mode uses deeper layered shadows to match dark depth */
  --shadow-xs: 0 2px 8px rgba(28, 14, 14, 0.1), 0 1px 3px rgba(28, 14, 14, 0.08);
  --shadow-sm: 0 8px 20px rgba(28, 14, 14, 0.14), 0 3px 8px rgba(28, 14, 14, 0.1);
  --shadow-md: 0 16px 36px rgba(28, 14, 14, 0.18), 0 8px 16px rgba(145, 26, 30, 0.12);
  --shadow-lg: 0 28px 64px rgba(28, 14, 14, 0.22), 0 12px 28px rgba(145, 26, 30, 0.14);
  --shadow-brand: 0 18px 40px rgba(145, 26, 30, 0.32), 0 8px 20px rgba(28, 14, 14, 0.14);
  --shadow-glass: 0 12px 40px rgba(28, 14, 14, 0.18), 0 4px 14px rgba(28, 14, 14, 0.1);
  
  /* Spacing */
  --header-height: 80px;
  --mobile-header-height: 60px;
  --footer-height: 60px;
  
  /* Transitions */
  --transition-speed: 0.3s;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: var(--bg-primary-dark);
  --bg-secondary: var(--bg-secondary-dark);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --border-color: var(--border-dark);

  --shadow-xs: 0 2px 6px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 14px 28px rgba(0, 0, 0, 0.4);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* RTL Support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

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

body {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition-speed), color var(--transition-speed);
  line-height: 1.6;
}

/* Layout Container */
.layout-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main Content */
.main-content {
  flex: 1;
  padding-top: var(--header-height);
  transition: padding-top var(--transition-speed);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity var(--transition-speed);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --header-height: var(--mobile-header-height);
  }
  
  .main-content {
    padding-top: var(--mobile-header-height);
  }
}

/* Utility Classes */
.text-primary {
  color: var(--primary-color);
}

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

.border-primary {
  border-color: var(--primary-color);
}

/* Theme Transition */
.theme-transition {
  transition: background-color var(--transition-speed), 
              color var(--transition-speed), 
              border-color var(--transition-speed);
}

/* Language morph — creative minimal blink (no text) */
html.lang-switching,
html.lang-switching body {
  cursor: wait;
}

html.lang-switching body {
  pointer-events: none;
}

.lang-morph {
  position: fixed;
  inset: 0;
  z-index: 12000;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
}

.lang-morph.is-active {
  opacity: 1;
  visibility: visible;
}

.lang-morph__shade {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.06);
  opacity: 0;
}

.lang-morph.is-active .lang-morph__shade {
  animation: langEyeShade 1.05s ease forwards;
}

.lang-morph__lid {
  position: absolute;
  left: 0;
  right: 0;
  height: 51%;
  background: var(--bg-primary, #fff);
  z-index: 2;
}

.lang-morph__lid--top {
  top: 0;
  transform: translateY(-105%);
}

.lang-morph__lid--bottom {
  bottom: 0;
  transform: translateY(105%);
}

.lang-morph.is-active .lang-morph__lid--top {
  animation: langLidTop 1.05s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.lang-morph.is-active .lang-morph__lid--bottom {
  animation: langLidBottom 1.05s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

[data-theme="dark"] .lang-morph__lid {
  background: var(--bg-primary-dark, #1a1a1a);
}

/* Center mark: almond line + two brand dots */
.lang-morph__eye {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: min(168px, 46vw);
  height: min(84px, 23vw);
  transform: translate(-50%, -50%) scaleY(0.08);
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-morph.is-active .lang-morph__eye {
  animation: langEyeBlink 1.05s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.lang-morph__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.lang-morph__stroke {
  stroke: var(--primary-color, #911A1E);
  fill: none;
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
}

.lang-morph.is-active .lang-morph__stroke {
  animation: langEyeStroke 1.05s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.lang-morph__dot {
  fill: var(--primary-color, #911A1E);
  opacity: 0;
  transform-origin: center;
  transform-box: fill-box;
}

.lang-morph.is-active .lang-morph__dot {
  animation: langEyeDots 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.lang-morph.is-active .lang-morph__dot:last-child {
  animation-delay: 0.04s;
}

[data-theme="dark"] .lang-morph__stroke {
  stroke: #f0d2d2;
}

[data-theme="dark"] .lang-morph__dot {
  fill: #f0d2d2;
}

@keyframes langLidTop {
  0% { transform: translateY(-105%); }
  38% { transform: translateY(0); }
  58% { transform: translateY(0); }
  100% { transform: translateY(-105%); }
}

@keyframes langLidBottom {
  0% { transform: translateY(105%); }
  38% { transform: translateY(0); }
  58% { transform: translateY(0); }
  100% { transform: translateY(105%); }
}

@keyframes langEyeBlink {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleY(0.08) scaleX(0.9);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleY(0.45) scaleX(1);
  }
  38%, 58% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleY(1) scaleX(1);
  }
  78% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleY(0.4) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleY(0.08) scaleX(0.9);
  }
}

@keyframes langEyeStroke {
  0% { stroke-dashoffset: 260; }
  34% { stroke-dashoffset: 0; }
  62% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 260; }
}

@keyframes langEyeDots {
  0%, 28% {
    opacity: 0;
    transform: scale(0.2);
  }
  38%, 58% {
    opacity: 1;
    transform: scale(1);
  }
  78%, 100% {
    opacity: 0;
    transform: scale(0.35);
  }
}

@keyframes langEyeShade {
  0%, 100% { opacity: 0; }
  38%, 58% { opacity: 1; }
}

html.lang-switching .main-content {
  animation: langContentBlink 1.05s ease;
}

@keyframes langContentBlink {
  0%, 100% { opacity: 1; }
  38%, 58% { opacity: 0.72; }
}

.minimal-language-toggle.is-morphing {
  transform: scale(0.94);
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .lang-morph,
  html.lang-switching .main-content {
    animation: none !important;
    display: none !important;
  }

  .lang-morph__lid,
  .lang-morph__eye,
  .lang-morph__stroke,
  .lang-morph__dot,
  .lang-morph__shade {
    animation: none !important;
  }
}

/* Cursor Finder - Desktop Only */
@media (min-width: 769px) {
  .cursor-finder {
    position: fixed;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(145, 26, 30, 0.3);
  }

  /* Cursor finder animation */
  .cursor-finder::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
    animation: cursorPulse 2s infinite;
  }

  @keyframes cursorPulse {
    0% {
      transform: translate(-50%, -50%) scale(0.8);
      opacity: 0.3;
    }
    50% {
      transform: translate(-50%, -50%) scale(1.2);
      opacity: 0.1;
    }
    100% {
      transform: translate(-50%, -50%) scale(0.8);
      opacity: 0.3;
    }
  }

  /* Dark theme cursor finder */
  [data-theme="dark"] .cursor-finder {
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  }

  [data-theme="dark"] .cursor-finder::before {
    border-color: #ffffff;
  }
}

/* Glass Circle Cursor - Desktop Only */
@media (min-width: 769px) {
  .glass-cursor {
    position: fixed;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }

  /* Dark theme glass cursor */
  [data-theme="dark"] .glass-cursor {
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  }

  /* Glass cursor animation - very subtle */
  .glass-cursor::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(145, 26, 30, 0.03);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: glassPulse 6s infinite;
  }

  @keyframes glassPulse {
    0% {
      transform: translate(-50%, -50%) scale(0.98);
      opacity: 0.03;
    }
    50% {
      transform: translate(-50%, -50%) scale(1.01);
      opacity: 0.015;
    }
    100% {
      transform: translate(-50%, -50%) scale(0.98);
      opacity: 0.03;
    }
  }

  /* Dark theme glass cursor pulse */
  [data-theme="dark"] .glass-cursor::before {
    background: rgba(255, 255, 255, 0.02);
  }

  /* Enhanced readability on hover over interactive elements */
  .glass-cursor:hover {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(0.5px);
    -webkit-backdrop-filter: blur(0.5px);
  }

  [data-theme="dark"] .glass-cursor:hover {
    background: rgba(0, 0, 0, 0.12);
  }
}

/* Hide cursors on mobile */
@media (max-width: 768px) {
  .cursor-finder,
  .glass-cursor {
    display: none !important;
  }
}

/* Section Separators - Minimal */
.section-separator {
  width: 100%;
  height: 1px;
  background: var(--border-color);
  opacity: 0.2;
}

