/* ==========================================================================
   SWAG shared layer — loaded LAST on every page (English and Arabic).
   1. Base safety (no sideways scroll, no "desktop zoom-out" on phones)
   2. Header + mobile menu (one implementation for all 16 pages)
   3. Page fixes for phones/tablets
   4. RTL (Arabic) adjustments
   ========================================================================== */

/* ---------- 1. Base safety ---------- */
html {
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  overflow-x: visible;
  overflow-x: clip;
  height: auto;
  min-height: 100%;
}
img, video, iframe { max-width: 100%; }
a, button { -webkit-tap-highlight-color: transparent; }

/* ---------- 2. Header ---------- */
.sw-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 10px 30px;
  pointer-events: none;
}
.sw-bar {
  pointer-events: auto;
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 20px;
  background: rgba(17, 17, 17, 0.92);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.sw-nav { display: contents; }
.sw-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 22px);
  grid-row: 1;
}
.sw-left { grid-column: 1; }
.sw-right { grid-column: 3; justify-content: flex-end; }
.sw-logo {
  grid-column: 2;
  grid-row: 1;
  display: block;
  line-height: 0;
}
.sw-logo img {
  display: block;
  height: 46px;
  width: auto;
  max-width: none;
}
.sw-links a {
  display: block;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.sw-links a:hover,
.sw-links a[aria-current="page"] { color: #ffc107; }
.sw-links a.sw-lang {
  padding: 9px 16px;
  border-radius: 999px;
  background: #ffc107;
  color: #111;
  font-weight: 700;
}
.sw-links a.sw-lang:hover { background: #fff; color: #111; }

.sw-burger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.sw-burger:hover { background: rgba(255, 255, 255, 0.08); }
.sw-burger span {
  display: block;
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.sw-header.is-open .sw-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sw-header.is-open .sw-burger span:nth-child(2) { opacity: 0; }
.sw-header.is-open .sw-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Phone + tablet: logo and menu button in the bar, links in a drop-down panel */
@media (max-width: 992px) {
  .sw-header { padding: 8px 10px; }
  .sw-bar {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px 6px 14px;
  }
  [dir="rtl"] .sw-bar { padding: 6px 14px 6px 8px; }
  .sw-logo img { height: 38px; }
  .sw-burger { display: flex; }

  .sw-nav {
    display: block;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    padding: 6px 16px 16px;
    max-height: calc(100vh - 80px);
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #151515;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .sw-header.is-open .sw-nav {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  /* dim the page behind the open menu; tapping it closes the menu */
  .sw-header.is-open::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
  }
  .sw-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .sw-links a {
    padding: 13px 4px;
    font-size: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: normal;
  }
  .sw-links a.sw-lang {
    margin-top: 14px;
    padding: 12px 16px;
    text-align: center;
    border-bottom: 0;
  }
}

/* ---------- 3. Page fixes ---------- */

/* grids that forced a minimum width wider than a phone */
.contact-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.training-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

/* Home: "Our Works" — native swipeable row instead of a JS-moved strip */
.page-index .cards-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.page-index .cards-wrapper::-webkit-scrollbar { display: none; }
.page-index .cards {
  gap: 16px;
  padding: 14px 2px;
  transform: none;
}
.page-index .card {
  flex: 0 0 calc((100% - 48px) / 4);
  width: auto;
  max-width: none;
  margin: 0;
  scroll-snap-align: start;
}
.page-index .arrows { direction: ltr; }
.page-index .map iframe { width: 100%; height: 320px; }

@media (max-width: 992px) {
  /* hero banners */
  .hero,
  .training-hero,
  .page-about .about-hero {
    height: auto;
    min-height: 70vh;
    padding: 120px 6% 60px;
  }
  .hero-content h1,
  .training-hero-content h1,
  .page-about .about-hero-content h1 { font-size: clamp(1.7rem, 7vw, 2.6rem); line-height: 1.25; }
  .hero-content p,
  .training-hero-content p,
  .page-about .about-hero-content p { font-size: 1rem; }

  .page-index .card { flex-basis: calc((100% - 16px) / 2); height: 240px; }

  /* About: three hover panels become three readable stacked panels */
  .page-about .about-text { padding: 30px 6%; }
  .page-about .steps-container {
    flex-direction: column;
    height: auto;
    padding-bottom: 0;
  }
  .page-about .steps-container .step,
  .page-about .steps-container:hover .step,
  .page-about .steps-container .step:hover {
    flex: none;
    padding: 44px 0;
  }
  .page-about .step::before,
  .page-about .step:hover::before { background: rgba(0, 0, 0, 0.84); }
  .page-about .step-content { opacity: 1; max-width: 88%; }
  .page-about .step h3 { color: #ffc107; font-size: 1.4rem; margin-bottom: 10px; }
  .page-about .step p { font-size: 1rem; }

  /* Contact */
  .page-contact .containers {
    width: auto;
    margin: 60px 4% 40px;
    padding: 28px 18px;
  }
  .page-contact .contact-headers { margin-bottom: 30px; }
  .page-contact .contact-headers h1 { font-size: 2rem; }
  .page-contact .info-item span { overflow-wrap: anywhere; }

  /* Projects: captions always visible (no hover on touch screens) */
  .page-projects .project-card { height: 62vh; min-height: 380px; }
  .page-projects .project-card:hover img { transform: none; }
  .page-projects .project-overlay,
  .page-projects .project-card:hover .project-overlay {
    top: auto;
    bottom: 0;
    height: auto;
    padding: 70px 18px 20px;
    transform: none;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0));
  }

  .services { padding: 50px 5%; }
  .trainings-section { padding: 50px 5%; }
  .why-us { padding: 50px 5%; }
  .how-we-work { padding: 50px 5%; }
  .footer { padding: 50px 6% 24px; }
  .footer-col p,
  .footer-col ul { text-align: start; }
}

@media (max-width: 768px) {
  .page-how .numbers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .page-how .number-card { max-width: none; padding: 22px 12px; }
  .page-how .number-section { padding: 40px 5%; }
  .services p { font-size: 16px; margin-bottom: 30px; }
  .services h2 { font-size: 28px; }
  .trainings-section h2 { margin-bottom: 30px; }
}

@media (max-width: 600px) {
  .page-index .card { flex-basis: 78%; height: 260px; }
  .page-projects .project-card { height: 56vh; }
}

/* Touch screens: home service cards show their caption without needing hover */
@media (hover: none) {
  .page-index .service-card .overlay {
    top: auto;
    bottom: 0;
    height: auto;
    padding: 50px 16px 14px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0));
  }
  .page-index .service-card .overlay p { margin-bottom: 0; font-size: 0.9rem; }
  .page-index .service-card:hover img { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 4. RTL (Arabic) ---------- */
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}
html[dir="rtl"] input,
html[dir="rtl"] textarea { text-align: right; }
html[dir="rtl"] .info-item i {
  margin-right: 0;
  margin-left: 12px;
}
html[dir="rtl"] .footer-socials a,
html[dir="rtl"] .socials a {
  margin-right: 0;
  margin-left: 15px;
}
html[dir="rtl"] .footer-col p,
html[dir="rtl"] .footer-col ul { text-align: right; }
html[dir="rtl"] .card-content,
html[dir="rtl"] .how-we-work .step,
html[dir="rtl"] .section-header { text-align: right; }
html[dir="rtl"] .quote { left: auto; right: 20px; }
/* phone numbers and e-mail stay left-to-right inside Arabic text */
html[dir="rtl"] .footer-col a[href^="https://wa.me"],
html[dir="rtl"] .footer-col a[href^="mailto:"] { direction: ltr; unicode-bidi: isolate; display: inline-block; }
