/* =============================================
   performance.css — Abouelezz Agency
   Performance, Accessibility & UX Enhancements
   LiteSpeed / Apache optimised output
   ============================================= */

/* =============================================
   1. CRITICAL FONT DISPLAY & LOADING
   ============================================= */
@font-face {
  font-family: 'Noto Kufi Arabic';
  font-display: swap; /* Prevent FOIT — show fallback text immediately */
}
@font-face {
  font-family: 'Almarai';
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-display: swap;
}

/* =============================================
   2. SKIP TO CONTENT — Accessibility A11Y
   ============================================= */
.skip-to-content {
  position: absolute;
  top: -999px;
  left: -999px;
  background: var(--brand);
  color: var(--dark-deep);
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 0 0 8px 0;
  z-index: 9999;
  text-decoration: none;
  transition: top 0.2s, left 0.2s;
}
.skip-to-content:focus {
  top: 0;
  left: 0;
  outline: 3px solid var(--dark-deep);
  outline-offset: 2px;
}

/* =============================================
   3. FOCUS-VISIBLE — Keyboard Navigation
   ============================================= */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}
/* Remove default outline only when not keyboard navigating */
:focus:not(:focus-visible) {
  outline: none;
}
/* Ensure interactive elements have visible focus rings */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

/* =============================================
   4. REDUCED MOTION — Accessibility
   ============================================= */
@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;
  }
  /* Keep opacity transitions but disable movement */
  .trust-ticker-track {
    animation: none;
  }
  .hero-bg-glow {
    animation: none;
  }
}

/* =============================================
   5. LAZY-LOAD IMAGE STATES
   ============================================= */
img[loading="lazy"] {
  /* Reserve space to prevent layout shift (CLS) */
  content-visibility: auto;
}

/* Blur-up / skeleton effect while image loads */
.img-lazy {
  background: linear-gradient(135deg, var(--dark-mid) 0%, var(--dark-card) 50%, var(--dark-mid) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  transition: filter 0.4s ease, opacity 0.4s ease;
  filter: blur(8px);
  opacity: 0.6;
}
.img-lazy.loaded {
  animation: none;
  background: none;
  filter: none;
  opacity: 1;
}

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

/* Portfolio card images — lazy loaded background images */
.portfolio-card-img {
  background-color: var(--dark-mid); /* placeholder color before BG image loads */
}
.portfolio-card-img.bg-loaded {
  animation: fadeIn 0.5s ease;
}

/* =============================================
   6. CONTENT-VISIBILITY — Deferred off-screen rendering
   ============================================= */
/* Defer below-fold sections to speed up initial render */
.section:not(.hero-section):not(.trust-ticker-section) {
  content-visibility: auto;
  contain-intrinsic-size: 0 600px; /* reserve estimated height to prevent jump */
}

/* =============================================
   7. WILL-CHANGE — GPU Compositing Hints
   ============================================= */
#navbar {
  will-change: transform, background-color;
}
#sticky-conversion-bar {
  will-change: transform;
}
.audit-modal-overlay {
  will-change: opacity;
}
.audit-modal-box {
  will-change: transform;
}
.trust-ticker-track {
  will-change: transform;
}
/* Remove will-change after animations are done via JS to free GPU memory */

/* =============================================
   8. PAINT & LAYOUT CONTAINMENT
   ============================================= */
.service-card,
.portfolio-card,
.testimonial-card,
.why-card,
.pricing-card {
  contain: layout style; /* prevent children from affecting parent layout */
}

/* =============================================
   9. MODAL CSS — Rebuild with correct IDs
   (footer.php uses #audit-modal not .audit-modal-backdrop)
   ============================================= */
#audit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
#audit-modal.active {
  opacity: 1;
  pointer-events: auto;
}
#audit-modal .audit-modal-box {
  background: #181818;
  border: 1px solid rgba(201, 168, 76, 0.4);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(201,168,76,0.1);
  border-radius: var(--radius-xl);
  max-width: 560px;
  width: 100%;
  padding: 3rem 2.5rem;
  position: relative;
  transform: translateY(24px) scale(0.98);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
#audit-modal.active .audit-modal-box {
  transform: translateY(0) scale(1);
}
.audit-modal-close {
  position: absolute;
  top: 1.1rem;
  inset-inline-end: 1.1rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--mid);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.audit-modal-close:hover { background: rgba(239,68,68,0.18); color: #ef4444; }
.audit-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  color: #4ade80;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.audit-modal-title {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 900;
  color: var(--light);
  margin-bottom: 0.85rem;
  line-height: 1.3;
}
.audit-modal-desc {
  color: var(--mid);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 1.5rem;
}
.audit-modal-proof {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1.1rem 1.25rem;
  background: rgba(201,168,76,0.06);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--light-dim);
}
.audit-modal-proof span { display: flex; align-items: center; gap: 0.5rem; }
.audit-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* =============================================
   10. STICKY BAR CSS — correct IDs
   ============================================= */
#sticky-conversion-bar {
  position: fixed;
  bottom: -120px;
  left: 0; right: 0;
  z-index: 990;
  background: rgba(12, 12, 12, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(201, 168, 76, 0.4);
  box-shadow: 0 -12px 50px rgba(0, 0, 0, 0.65);
  padding: 0.9rem 1.5rem;
  transition: bottom 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
#sticky-conversion-bar.visible {
  bottom: 0;
}
.sticky-bar-content {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: 1;
  flex-wrap: wrap;
}
.sticky-bar-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--light);
  flex: 1;
  min-width: 0;
}
.sticky-bar-pulse {
  width: 9px; height: 9px;
  background: #ef4444;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.6);
  animation: pulse-ring 1.6s infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.sticky-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.sticky-bar-btn-primary {
  background: var(--brand);
  color: var(--dark-deep);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  font-size: 0.85rem;
  font-weight: 800;
  font-family: var(--font-ar);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(201,168,76,0.35);
  white-space: nowrap;
}
.sticky-bar-btn-primary:hover {
  background: var(--brand-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(201,168,76,0.55);
}
.sticky-bar-btn-wa {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #25D366;
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
  white-space: nowrap;
}
.sticky-bar-btn-wa:hover { background: #22c55e; transform: translateY(-1px); }
#close-sticky-bar {
  background: none;
  border: none;
  color: var(--mid);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
#close-sticky-bar:hover { color: var(--light); background: rgba(255,255,255,0.07); }

/* =============================================
   11. TRUST TICKER — Smooth Infinite Scroll
   ============================================= */
.trust-ticker-section {
  background: rgba(201,168,76,0.04);
  border-top: 1px solid rgba(201,168,76,0.12);
  border-bottom: 1px solid rgba(201,168,76,0.12);
  overflow: hidden;
  padding: 0.85rem 0;
  position: relative;
}
.trust-ticker-inner {
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}
.trust-ticker-track {
  display: flex;
  align-items: center;
  gap: 0;
  width: max-content;
  animation: ticker-scroll 38s linear infinite;
}
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.trust-ticker-track:hover { animation-play-state: paused; }
.trust-item {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--light-dim);
  white-space: nowrap;
  padding: 0 2rem;
}
.trust-divider {
  color: var(--brand);
  font-size: 0.65rem;
  opacity: 0.6;
  flex-shrink: 0;
}

/* =============================================
   12. IMPROVED ARIA / HIGH-CONTRAST SUPPORT
   ============================================= */
@media (prefers-contrast: high) {
  :root {
    --brand: #FFD700;
    --glass-border: rgba(255,255,255,0.3);
    --mid: #cccccc;
  }
  .service-card, .portfolio-card, .testimonial-card, .why-card {
    border-width: 2px;
  }
  .btn-primary, .btn-ghost {
    border: 2px solid currentColor;
  }
}

/* =============================================
   13. PRINT STYLES
   ============================================= */
@media print {
  #navbar, #wa-float, #sticky-conversion-bar, #audit-modal,
  .trust-ticker-section, .hero-bg-glow, .hero-grid-pattern { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  a { text-decoration: underline; }
  .container { max-width: 100%; }
  .section { padding: 2rem 0; }
}

/* =============================================
   14. ASPECT-RATIO PLACEHOLDERS (CLS prevention)
   ============================================= */
.portfolio-card-img {
  aspect-ratio: 16/9;
  overflow: hidden;
}
.author-avatar {
  flex-shrink: 0;
  aspect-ratio: 1/1;
}

/* =============================================
   15. SCROLL-PADDING (Anchor nav offset fix)
   ============================================= */
html {
  scroll-padding-top: 90px; /* height of fixed navbar */
}

/* =============================================
   16. INTERACTIVE STATE ENHANCEMENTS
   ============================================= */
/* Larger touch targets on mobile */
@media (max-width: 768px) {
  .nav-links a, .footer-links a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .sticky-bar-btn-primary,
  .sticky-bar-btn-wa {
    min-height: 44px;
    padding: 0.6rem 1.1rem;
  }
  #sticky-conversion-bar {
    padding-bottom: max(0.9rem, env(safe-area-inset-bottom));
  }
  /* Audit modal fullscreen on mobile */
  #audit-modal .audit-modal-box {
    padding: 2rem 1.5rem;
    border-radius: var(--radius-lg);
    max-height: 95dvh;
  }
  .sticky-bar-text { font-size: 0.78rem; }
  .sticky-bar-actions { gap: 0.5rem; }
}

/* =============================================
   17. CUMULATIVE LAYOUT SHIFT (CLS) GUARDS
   ============================================= */
/* Reserve space for lazy-loaded images */
img { height: auto; }

/* Hero section min-height prevents reflow */
.hero-section {
  min-height: 100svh; /* svh = small viewport height — safer on mobile */
}

/* Prevent navbar height flash */
#navbar { min-height: 60px; }

/* =============================================
   18. LOADING SKELETON STATES
   ============================================= */
.skeleton {
  background: linear-gradient(90deg, var(--dark-mid) 25%, var(--dark-card) 50%, var(--dark-mid) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}

/* =============================================
   19. ICON-ONLY BUTTON ARIA LABEL STYLE
   ============================================= */
[aria-label]:not([aria-label=""]) {
  position: relative;
}

/* =============================================
   20. SELECTION HIGHLIGHT (Brand Colors)
   ============================================= */
::selection {
  background: rgba(201,168,76,0.35);
  color: var(--light);
}
::-moz-selection {
  background: rgba(201,168,76,0.35);
  color: var(--light);
}
