/* ===========================
   arab-qr.com — Design System
   Optimised for: Technical SEO · Core Web Vitals (LCP/CLS/INP) · Mobile-First
   =========================== */

/* Fonts loaded asynchronously in HTML head via preload + onload trick */

:root {
  --bg:            #fafaf9;
  --bg2:           #f3f2f0;
  --surface:       #ffffff;
  --border:        #e5e3df;
  --border-strong: #c9c5be;
  --text:          #18181b;
  --text-2:        #52525b;
  --muted:         #a1a1aa;
  --accent:        #1a6fe8;
  --brand:         #1a6fe8;
  --accent-dim:    rgba(26, 111, 232, 0.08);
  --accent-mid:    rgba(26, 111, 232, 0.18);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.05);
  --radius-sm:     6px;
  --radius:        12px;
  --radius-lg:     18px;
  --font-head:     'Instrument Serif', Georgia, serif;
  --font-body:     'Cairo', sans-serif;
  --ease:          cubic-bezier(.25, .46, .45, .94);
  --transition:    .22s var(--ease);
}

[data-theme="dark"] {
  --bg:            #0f0f0f;
  --bg2:           #161616;
  --surface:       #1c1c1c;
  --border:        #2a2a2a;
  --border-strong: #3f3f3f;
  --text:          #fafafa;
  --text-2:        #a8a8a8;
  --muted:         #5a5a5a;
  --accent:        #4a8ff5;
  --brand:         #4a8ff5;
  --accent-dim:    rgba(74, 143, 245, 0.1);
  --accent-mid:    rgba(74, 143, 245, 0.2);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.3);
  --shadow:        0 4px 20px rgba(0,0,0,.4);
  --shadow-lg:     0 12px 48px rgba(0,0,0,.5);
}

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

html { 
  scroll-behavior: smooth; 
  font-size: 16px; 
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Prevent horizontal scroll on mobile — avoids CLS from scrollbar appearing */
  overflow-x: hidden;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg); 
  color: var(--text);
  line-height: 1.65;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh; 
  direction: rtl;
  /* Prevent layout shifts from scrollbar appearing/disappearing */
  scrollbar-gutter: stable;
}

/* Focus-visible: keyboard-only focus rings (improves INP + accessibility) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Remove outline for mouse/touch users — cleaner UI without hurting a11y */
:focus:not(:focus-visible) {
  outline: none;
}

/* Touch targets: minimum 44×44px for all interactive elements (mobile INP) */
button, a, input, select, textarea, [role="button"] {
  touch-action: manipulation;
}

/* Optimized scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
  background: var(--border-strong); 
  border-radius: 3px; 
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* NAV — GPU-accelerated, sticky with explicit height to prevent CLS */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* Reserve space so sticky nav never causes layout shift */
  contain: layout style;
}

nav {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
  transition: background var(--transition);
  will-change: transform;
  transform: translateZ(0); /* Force GPU layer */
}

[data-theme="dark"] nav { background: rgba(15,15,15,0.85); }

.nav-inner {
  max-width: 1160px; 
  margin: 0 auto;
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 0 28px; 
  height: 64px;
  min-height: 64px; /* Explicit height prevents CLS on font load */
}

.logo {
  font-family: var(--font-body); 
  font-size: 1rem; 
  font-weight: 700;
  color: var(--text); 
  text-decoration: none;
  display: flex; 
  align-items: center; 
  gap: 10px;
}

.logo-icon {
  width: 34px; 
  height: 34px; 
  border-radius: 9px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  flex-shrink: 0; 
  overflow: hidden;
  background: none !important; 
  padding: 0 !important;
}

.logo-icon svg { display: block; }

.nav-links { 
  display: flex; 
  align-items: center; 
  gap: 24px; 
  list-style: none; 
}

.nav-links a { 
  font-size: .85rem; 
  font-weight: 500; 
  color: var(--text-2); 
  text-decoration: none; 
  transition: color var(--transition); 
}

.nav-links a:hover { color: var(--text); }

.nav-right { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  width: 72px; 
  height: 34px; 
  background: var(--bg2);
  border: 1.5px solid var(--border-strong); 
  border-radius: 34px;
  cursor: pointer; 
  position: relative;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0; 
  display: flex; 
  align-items: center; 
  padding: 0 6px; 
  justify-content: space-between;
}

.theme-toggle::after {
  content: ''; 
  position: absolute; 
  top: 4px; 
  left: 4px;
  width: 24px; 
  height: 24px; 
  background: var(--surface);
  border-radius: 50%; 
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.18); 
  z-index: 1;
  will-change: transform;
}

[data-theme="dark"] .theme-toggle { background: #1e2a3a; border-color: #2d3f55; }
[data-theme="dark"] .theme-toggle::after { transform: translateX(36px); background: #2a3f5a; }

.theme-icon { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  width: 20px; 
  height: 20px; 
  position: relative; 
  z-index: 0; 
  pointer-events: none; 
  color: var(--muted); 
  flex-shrink: 0; 
}

.theme-icon svg { width: 13px; height: 13px; }

[data-theme="dark"] .theme-icon.moon { color: #7ab3e8; }
[data-theme="light"] .theme-icon.sun  { color: #e8a020; }

.nav-hamburger { 
  display: none; 
  background: none; 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  padding: 6px 10px; 
  cursor: pointer; 
  color: var(--text); 
  font-size: 1.1rem; 
  line-height: 1;
  /* Minimum 44×44px touch target */
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.nav-mobile-menu { 
  display: none; 
  position: fixed; 
  top: 64px; 
  left: 0; 
  right: 0; 
  background: var(--surface); 
  border-bottom: 1px solid var(--border); 
  box-shadow: var(--shadow); 
  z-index: 99; 
  padding: 12px 0 16px; 
}

.nav-mobile-menu.open { display: block; }

.nav-mobile-menu ul { 
  list-style: none; 
  padding: 0 16px; 
  display: flex; 
  flex-direction: column; 
  gap: 2px; 
}

.nav-mobile-menu ul li a { 
  display: block; 
  padding: 12px 8px; 
  font-size: .9rem; 
  font-weight: 500; 
  color: var(--text-2); 
  text-decoration: none; 
  border-radius: var(--radius-sm); 
  transition: background var(--transition), color var(--transition); 
}

.nav-mobile-menu ul li a:hover { background: var(--bg2); color: var(--text); }

/* HERO — LCP element: reserve space so font-swap doesn't cause CLS */
.hero { 
  max-width: 1160px; 
  margin: 0 auto; 
  padding: 64px 28px 48px; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 16px; 
  text-align: center;
  /* Reserve minimum height so below-fold content doesn't jump on font load */
  min-height: 240px;
}

.hero-badge { 
  display: inline-flex; 
  align-items: center; 
  gap: 7px; 
  background: var(--accent-dim); 
  color: var(--accent); 
  border: 1px solid var(--accent-mid); 
  padding: 4px 14px; 
  border-radius: 100px; 
  font-size: .75rem; 
  font-weight: 600; 
}

.hero-badge::before { 
  content: ''; 
  width: 5px; 
  height: 5px; 
  background: var(--accent); 
  border-radius: 50%; 
}

h1 { 
  font-family: var(--font-head); 
  font-size: clamp(2rem, 4vw, 3rem); 
  font-weight: 400; 
  color: var(--text); 
  margin-bottom: 8px; 
  line-height: 1.25; 
}

.hero p { 
  color: var(--text-2); 
  font-size: .9rem; 
  line-height: 1.7; 
}

/* Sections */
.section { padding: 64px 28px; }
.section-inner { max-width: 1160px; margin: 0 auto; }
.section-head { text-align: center; margin-bottom: 40px; }
.section-head h2 { 
  font-family: var(--font-head); 
  font-size: clamp(1.8rem, 3vw, 2.5rem); 
  font-weight: 400; 
  color: var(--text); 
  margin-bottom: 10px; 
}
.section-head p { 
  color: var(--text-2); 
  font-size: .9rem; 
  max-width: 440px; 
  margin: 0 auto; 
}

/* Forms */
.form-label { 
  display: block; 
  font-size: .8rem; 
  font-weight: 600; 
  margin-bottom: 6px; 
  color: var(--text); 
}

.input-field { 
  width: 100%; 
  background: var(--bg); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  padding: 10px 14px; 
  font-family: var(--font-body); 
  font-size: .9rem; 
  color: var(--text); 
  transition: border-color var(--transition), box-shadow var(--transition); 
  outline: none; 
}

.input-field:focus { 
  border-color: var(--accent); 
  box-shadow: 0 0 0 3px var(--accent-dim); 
}

.input-field::placeholder { color: var(--muted); }

textarea.input-field { 
  resize: vertical; 
  min-height: 80px; 
}

.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1aa' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

/* Buttons */
.btn-primary { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 8px; 
  background: var(--accent); 
  color: white; 
  border: none; 
  border-radius: var(--radius-sm); 
  font-family: var(--font-body); 
  font-weight: 700; 
  font-size: .95rem; 
  padding: 12px 24px; 
  cursor: pointer; 
  width: 100%; 
  transition: opacity var(--transition), transform var(--transition); 
}

.btn-primary:hover { 
  opacity: .88; 
  transform: translateY(-1px); 
}

.btn-secondary { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 6px; 
  background: var(--surface); 
  color: var(--text); 
  border: 1.5px solid var(--border); 
  border-radius: var(--radius-sm); 
  font-family: var(--font-body); 
  font-weight: 600; 
  font-size: .85rem; 
  padding: 9px 16px; 
  cursor: pointer; 
  flex: 1; 
  transition: border-color var(--transition), color var(--transition); 
}

.btn-secondary:hover { 
  border-color: var(--accent); 
  color: var(--accent); 
}

/* Features Grid — contain prevents paint outside card boundary */
.features-grid { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: 16px; 
}

.feature-card { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-lg); 
  padding: 24px 20px; 
  box-shadow: var(--shadow-sm); 
  transition: box-shadow var(--transition), transform var(--transition); 
  contain: layout style paint;
  /* Explicit min-height prevents CLS when grid reflows */
  min-height: 140px;
}

.feature-card:hover { 
  box-shadow: var(--shadow); 
  transform: translateY(-2px); 
}

.feature-icon { 
  font-size: 1.6rem; 
  margin-bottom: 10px; 
}

.feature-card h3 { 
  font-size: .93rem; 
  font-weight: 600; 
  margin-bottom: 6px; 
}

.feature-card p { 
  font-size: .82rem; 
  color: var(--text-2); 
  line-height: 1.7; 
}

/* Steps */
.steps-section { 
  background: var(--bg2); 
  border-top: 1px solid var(--border); 
  border-bottom: 1px solid var(--border); 
}

.steps { 
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  max-width: 1160px; 
  margin: 0 auto; 
}

.step { 
  padding: 28px 24px; 
  border-right: 1px solid var(--border); 
}

.step:first-child { border-right: none; }

.step-num { 
  font-size: .7rem; 
  font-weight: 700; 
  color: var(--accent); 
  letter-spacing: .08em; 
  margin-bottom: 8px; 
  text-transform: uppercase; 
}

.step h3 { 
  font-size: .93rem; 
  font-weight: 600; 
  margin-bottom: 6px; 
}

.step p { 
  font-size: .82rem; 
  color: var(--text-2); 
  line-height: 1.6; 
}

/* FAQ */
.faq-list { 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
  max-width: 720px; 
  margin: 0 auto; 
}

.faq-item { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  overflow: hidden; 
}

/* faq-q is a <button> — reset browser defaults then apply design */
.faq-q { 
  width: 100%;
  background: none;
  border: none;
  text-align: right;  /* RTL */
  font-family: var(--font-body);
  color: var(--text);
  padding: 16px 20px; 
  font-size: .88rem; 
  font-weight: 600; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px; 
  user-select: none;
  /* Minimum touch target 44px for mobile INP */
  min-height: 44px;
  transition: background var(--transition);
}

.faq-q:hover {
  background: var(--bg2);
}

.faq-q::after { 
  content: '+'; 
  font-size: 1.2rem; 
  color: var(--muted); 
  flex-shrink: 0; 
  transition: transform var(--transition); 
}

.faq-item.open .faq-q::after { 
  transform: rotate(45deg); 
}

.faq-a { 
  padding: 0 20px; 
  max-height: 0; 
  overflow: hidden; 
  transition: max-height .3s var(--ease), padding .3s var(--ease); 
}

.faq-item.open .faq-a { 
  padding: 0 20px 16px; 
  max-height: 300px; 
}

.faq-a p { 
  font-size: .84rem; 
  color: var(--text-2); 
  line-height: 1.75; 
}

/* CTA */
.cta-banner { 
  background: linear-gradient(135deg, #1a6fe8 0%, #0d4db5 100%); 
  padding: 64px 28px; 
  text-align: center; 
}

.cta-banner h2 { 
  font-family: var(--font-head); 
  font-size: clamp(1.8rem, 3vw, 2.5rem); 
  font-weight: 400; 
  color: white; 
  margin-bottom: 10px; 
}

.cta-banner p { 
  color: rgba(255,255,255,.8); 
  font-size: .9rem; 
  margin-bottom: 24px; 
}

.cta-btn-white { 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  background: white; 
  color: var(--brand); 
  padding: 12px 28px; 
  border-radius: var(--radius-sm); 
  font-family: var(--font-body); 
  font-weight: 700; 
  font-size: .95rem; 
  cursor: pointer; 
  text-decoration: none; 
  border: none; 
  transition: opacity var(--transition), transform var(--transition); 
}

.cta-btn-white:hover { 
  opacity: .9; 
  transform: translateY(-1px); 
}

/* Footer */
footer { 
  background: var(--bg2); 
  border-top: 1px solid var(--border); 
  padding: 56px 28px 32px; 
}

.footer-inner { 
  max-width: 1160px; 
  margin: 0 auto; 
  display: grid; 
  grid-template-columns: 2fr 1fr 1fr 1fr; 
  gap: 40px; 
  margin-bottom: 40px; 
}

.footer-brand .logo { margin-bottom: 14px; }

.footer-brand p { 
  font-size: .825rem; 
  color: var(--text-2); 
  line-height: 1.7; 
  max-width: 280px; 
}

.footer-col h4 { 
  font-weight: 700; 
  font-size: .78rem; 
  text-transform: uppercase; 
  letter-spacing: .06em; 
  color: var(--muted); 
  margin-bottom: 14px; 
}

.footer-col ul { 
  list-style: none; 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
}

.footer-col a { 
  font-size: .825rem; 
  color: var(--text-2); 
  text-decoration: none; 
  transition: color var(--transition); 
}

.footer-col a:hover { color: var(--text); }

.footer-bottom { 
  max-width: 1160px; 
  margin: 0 auto; 
  padding-top: 24px; 
  border-top: 1px solid var(--border); 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  font-size: .775rem; 
  color: var(--muted); 
  flex-wrap: wrap; 
  gap: 10px; 
}

/* Inner Pages */
.page-hero { 
  border-bottom: 1px solid var(--border); 
  padding: 64px 28px; 
  text-align: center; 
}

.page-hero h1 { 
  font-size: clamp(2rem, 4vw, 3rem); 
  margin-bottom: 10px; 
}

.page-hero p { 
  color: var(--text-2); 
  font-size: .9rem; 
}

.page-content { 
  max-width: 720px; 
  margin: 60px auto; 
  padding: 0 28px; 
}

.page-content h2 { 
  font-family: var(--font-head); 
  font-size: 1.45rem; 
  font-weight: 400; 
  margin: 38px 0 12px; 
  color: var(--text); 
}

.page-content h2:first-child { margin-top: 0; }

.page-content p { 
  color: var(--text-2); 
  font-size: .875rem; 
  line-height: 1.8; 
  margin-bottom: 14px; 
}

.page-content ul { 
  color: var(--text-2); 
  font-size: .875rem; 
  line-height: 1.8; 
  margin-bottom: 14px; 
  padding-right: 18px; 
}

.page-content ul li { margin-bottom: 6px; }

/* Contact */
.contact-grid { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 48px; 
  align-items: start; 
}

.contact-info { 
  display: flex; 
  flex-direction: column; 
  gap: 18px; 
}

.contact-item { 
  display: flex; 
  gap: 14px; 
  align-items: flex-start; 
}

.contact-icon { 
  width: 40px; 
  height: 40px; 
  flex-shrink: 0; 
  background: var(--bg2); 
  border-radius: var(--radius-sm); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 1rem; 
  border: 1px solid var(--border); 
}

.contact-item h4 { 
  font-weight: 600; 
  margin-bottom: 2px; 
  font-size: .9rem; 
}

.contact-item p { 
  font-size: .825rem; 
  color: var(--text-2); 
}

.contact-form { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-lg); 
  padding: 32px; 
  box-shadow: var(--shadow-sm); 
}

.form-submit { 
  width: 100%; 
  padding: 12px; 
  background: var(--accent); 
  color: white; 
  border: none; 
  border-radius: var(--radius-sm); 
  font-family: var(--font-body); 
  font-weight: 600; 
  font-size: .9rem; 
  cursor: pointer; 
  transition: opacity var(--transition), transform var(--transition); 
}

.form-submit:hover { 
  opacity: .85; 
  transform: translateY(-1px); 
}

.success-msg { 
  background: #f0fdf4; 
  color: #15803d; 
  border: 1px solid #bbf7d0; 
  border-radius: var(--radius-sm); 
  padding: 11px 14px; 
  font-size: .825rem; 
  margin-top: 12px; 
}

/* Images — prevent CLS: always include width/height in HTML */
img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Canvas elements: do NOT override width/height — breaks QR rendering */
canvas:not(#display-canvas) {
  max-width: 100%;
}

/* Lazy-loaded images below fold */
img[loading="lazy"] {
  background: var(--bg2);
}

/* Animations - with will-change for performance */
@keyframes fadeUp { 
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  } 
  to { 
    opacity: 1; 
    transform: translateY(0); 
  } 
}

.fade-up { 
  animation: fadeUp .5s var(--ease) both; 
  will-change: opacity, transform;
}

.fade-up-1 { animation-delay: .06s; }
.fade-up-2 { animation-delay: .14s; }
.fade-up-3 { animation-delay: .22s; }

/* Remove will-change after animation completes */
.fade-up.animated {
  will-change: auto;
}

/* ═══ RESPONSIVE — Mobile-First ═══ */
@media (max-width: 900px) {
  .features-grid { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .step { border-right: none; border-bottom: 1px solid var(--border); }
  .step:nth-child(3), .step:nth-child(4) { border-bottom: none; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .nav-inner { padding: 0 16px; height: 56px; min-height: 56px; }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; align-items: center; }
  .hero { padding: 40px 16px 32px; min-height: 200px; }
  h1 { font-size: clamp(1.9rem, 8vw, 2.4rem); }
  .section { padding: 44px 16px; }
  .steps { grid-template-columns: 1fr; }
  .step { border-right: none; border-bottom: 1px solid var(--border); }
  .step:last-child { border-bottom: none; }
  .features-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
  footer { padding: 40px 16px 56px; }
  .footer-bottom { flex-direction: column; text-align: center; gap: 6px; }
  .page-hero { padding: 40px 16px; }
  .page-content { margin: 40px auto; padding: 0 16px; }
  .contact-form { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .cta-banner { padding: 44px 16px; }

  /* Larger tap targets on small screens */
  .nav-links a,
  .footer-col a { 
    padding: 8px 0;
    display: inline-block;
  }

  /* Prevent font scaling from causing CLS on mobile */
  .section-head h2 {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }
}

/* Print styles */
@media print {
  nav, footer, .cta-banner { display: none; }
  body { background: white; color: black; }
}

/* Reduced motion support */
@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;
  }
}
