/* ==========================================================================
   BASE & RESET STYLES
   Reset, Fluid Typography, Accessibility & Reduced Motion
   ========================================================================== */

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

html {
  font-family: var(--font-family-cairo);
  background-color: var(--bg-page);
  color: var(--color-ivory);
  font-size: 16px;
  line-height: var(--line-height-normal);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Standard Lenis Smooth Scroll CSS (Required for Lenis performance)
   ========================================================================== */
html.lenis, html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: clip;
  background: var(--bg-page);
  background-image: var(--gradient-hero-bg);
  background-attachment: fixed;
  padding-bottom: 0;
}

/* Offset for mobile sticky bar on small screens */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(var(--mobile-bar-height) + env(safe-area-inset-bottom, 16px));
  }
}

/* ==========================================================================
   Typography Hierarchy (Fluid clamp() without awkward breaks)
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  color: var(--color-ivory);
  font-weight: 700;
  line-height: var(--line-height-tight);
  letter-spacing: -0.01em;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

h1 {
  font-size: clamp(2rem, 4.5vw + 1rem, 3.75rem);
  font-weight: 800;
  margin-bottom: var(--space-3);
}

h2 {
  font-size: clamp(1.65rem, 3.2vw + 0.8rem, 2.75rem);
  font-weight: 800;
  margin-bottom: var(--space-2);
}

h3 {
  font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem);
  font-weight: 700;
  margin-bottom: var(--space-1);
}

h4 {
  font-size: clamp(1.1rem, 1.2vw + 0.4rem, 1.35rem);
  font-weight: 600;
}

p {
  color: var(--color-ivory-muted);
  font-size: clamp(0.95rem, 0.4vw + 0.9rem, 1.125rem);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-2);
}

p.lead {
  font-size: clamp(1.05rem, 0.8vw + 0.95rem, 1.35rem);
  color: var(--color-ivory);
  line-height: 1.7;
}

small {
  font-size: 0.875rem;
  color: var(--color-ivory-dim);
}

strong {
  font-weight: 700;
  color: var(--color-ivory);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

ul, ol {
  list-style: none;
}

picture {
  display: block;
  width: 100%;
  height: 100%;
}

img, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

figure {
  margin: 0;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: none;
  border: none;
}

/* ==========================================================================
   Directional & LTR Helpers inside RTL Layouts
   ========================================================================== */

[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

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

.num, [dir="ltr"].phone-link, .phone-num {
  direction: ltr;
  display: inline-block;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ==========================================================================
   Accessibility & Focus States
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
  border-radius: var(--radius-xs);
}

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

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-2);
  background: var(--color-primary);
  color: var(--color-ink);
  padding: var(--space-1) var(--space-3);
  font-weight: 700;
  z-index: 10000;
  border-radius: var(--radius-sm);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-2);
}

/* ==========================================================================
   Selection & Custom Scrollbar
   ========================================================================== */

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

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-ink);
}

::-webkit-scrollbar-thumb {
  background: var(--color-surface);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-ink);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* ==========================================================================
   PREFERS-REDUCED-MOTION (User Rule & Accessibility Mandatory)
   ========================================================================== */

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

  .cursor-dot,
  .cursor-follower {
    display: none !important;
  }
}
