/* ==========================================================================
   AYAT QURAN ACADEMY - RESPONSIVE STYLESHEET
   Mobile-First & Fully Responsive across all Device Breakpoints:
   1200px (Desktop), 992px (Tablets / Mobile Drawer), 768px (Small Tablets),
   576px (Mobiles), 375px & 320px (Compact Mobiles)
   ========================================================================== */

/* Global horizontal overflow protection */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Prevent background scrolling when mobile menu drawer is open */
body.nav-open {
  overflow: hidden !important;
  touch-action: none !important;
}

/* Ensure all media adapts fluidly */
img, picture, video, iframe, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   Large Tablets & Small Laptops (<= 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: var(--space-2xl);
    text-align: center;
  }

  .hero-lead {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-visual {
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
  }

  .trust-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-features-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 2rem;
    padding: 1rem 1.25rem;
  }
}

/* --------------------------------------------------------------------------
   Intermediate Desktop / Laptops (993px - 1180px)
   -------------------------------------------------------------------------- */
@media (min-width: 993px) and (max-width: 1180px) {
  .main-nav {
    gap: 0.5rem;
  }

  .nav-list {
    gap: 0.05rem;
  }

  .nav-link {
    font-size: 0.82rem;
    padding: 0.35rem 0.45rem;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .brand-name {
    font-size: 1.15rem;
  }

  .brand-tagline {
    font-size: 0.65rem;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .header-actions .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }
}

/* --------------------------------------------------------------------------
   Tablets & Mobile Navigation Drawer (<= 992px)
   BULLETPROOF ARCHITECTURE: Fixed Header, Zero-Overflow Drawer, Root Z-Index
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  /* Hide top notification snippet on mobile to avoid stacking clutter */
  .top-bar {
    display: none !important;
  }

  /* Offset body for fixed header height */
  body {
    padding-top: 66px !important;
  }

  /* Header fixed at root viewport level with top z-index */
  .site-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 66px !important;
    z-index: 999999 !important;
    background-color: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
    display: flex !important;
    align-items: center !important;
  }

  .site-header .container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Brand element constrained so it never pushes the hamburger button off-screen */
  .brand {
    max-width: calc(100% - 54px) !important;
    flex-shrink: 1 !important;
    gap: 0.5rem !important;
  }

  .brand-logo {
    width: 40px !important;
    height: 40px !important;
    flex-shrink: 0 !important;
  }

  .brand-name {
    font-size: 1.1rem !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
  }

  .brand-tagline {
    font-size: 0.625rem !important;
    white-space: nowrap !important;
  }

  /* Hamburger toggle button firmly anchored at top-right */
  .nav-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    z-index: 1000001 !important;
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0 !important;
    font-size: 1.6rem !important;
    cursor: pointer !important;
    background: none !important;
    border: none !important;
    color: var(--color-primary-dark) !important;
    padding: 0 !important;
  }

  /* Mobile navigation drawer */
  .main-nav {
    position: fixed !important;
    top: 66px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: calc(100vh - 66px) !important;
    height: calc(100dvh - 66px) !important;
    background-color: #ffffff !important;
    z-index: 999998 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
    padding: 1.25rem 1.25rem 3rem !important;
  }

  /* Zero-overflow when closed: completely removed from layout */
  .main-nav:not(.active) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Display flex and visible when active */
  .main-nav.active {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
    animation: navDrawerFadeIn 0.2s ease-out forwards;
  }

  @keyframes navDrawerFadeIn {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .nav-list {
    flex-direction: column !important;
    width: 100% !important;
    align-items: stretch !important;
    gap: 0.35rem !important;
  }

  .nav-link {
    font-size: 1.05rem !important;
    padding: 0.75rem 1rem !important;
    width: 100% !important;
    white-space: normal !important;
    border-radius: var(--radius-sm) !important;
    display: block !important;
  }

  .nav-item-dropdown .dropdown-menu {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    box-shadow: none !important;
    border: 1px solid var(--color-border-subtle) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.5rem !important;
    width: 100% !important;
    background-color: var(--color-primary-soft) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
    margin-top: 0.25rem !important;
  }

  .dropdown-link {
    padding: 0.55rem 0.85rem !important;
    font-size: 0.9375rem !important;
  }

  .header-actions {
    width: 100% !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    margin-top: 1rem !important;
    padding-top: 1rem !important;
    border-top: 1px solid var(--color-border-subtle) !important;
  }

  .header-actions .btn {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
    justify-content: center !important;
    text-align: center !important;
  }

  /* Stacking context safety: prevent hero components from competing with header */
  .hero, .hero-content, .hero-visual, .hero-card-frame, .hero-image {
    z-index: 1 !important;
  }

  /* Inner Page Layout Grids Collapse */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
}

/* --------------------------------------------------------------------------
   Tablets & Medium Mobile Screens (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --space-3xl: 2.5rem;
    --space-4xl: 3.25rem;
  }

  /* Inner Page Hero Sections - Proportional & Compact */
  main > section:first-of-type.section-subtle {
    padding-top: 1.5rem !important;
    padding-bottom: 2rem !important;
  }

  main > section:first-of-type h1 {
    font-size: clamp(1.6rem, 5vw, 2.15rem) !important;
    line-height: 1.25 !important;
    margin-bottom: 0.75rem !important;
  }

  main > section:first-of-type .lead {
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
  }

  .breadcrumbs {
    font-size: 0.8125rem !important;
    margin-bottom: 0.75rem !important;
    flex-wrap: wrap !important;
    gap: 0.25rem 0.5rem !important;
  }

  /* Grids */
  .trust-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }

  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-xl) !important;
  }

  .footer-bottom {
    flex-direction: column !important;
    text-align: center !important;
    gap: 0.75rem !important;
  }

  .hero-features-bar {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.85rem 1.25rem !important;
    padding: 1.15rem !important;
  }

  .map-container {
    height: 300px !important;
  }
}

/* --------------------------------------------------------------------------
   Mobile Phones (<= 576px)
   Comprehensive Inner Page & UI/UX Optimizations
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  :root {
    --space-2xl: 1.5rem;
    --space-3xl: 2rem;
  }

  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Inner Page Hero Sections */
  main > section:first-of-type.section-subtle {
    padding-top: 1.25rem !important;
    padding-bottom: 1.5rem !important;
  }

  main > section:first-of-type h1 {
    font-size: 1.65rem !important;
    line-height: 1.25 !important;
    margin-bottom: 0.5rem !important;
  }

  main > section:first-of-type .lead {
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
  }

  /* Content Sections */
  .section {
    padding-top: 1.75rem !important;
    padding-bottom: 1.75rem !important;
  }

  .section-sm {
    padding-top: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }

  /* Typography Scale */
  h2 {
    font-size: 1.45rem !important;
    line-height: 1.25 !important;
  }

  h3 {
    font-size: 1.15rem !important;
  }

  /* Home Hero Section */
  .hero {
    padding: 1.5rem 0 2rem !important;
  }

  .hero-title {
    font-size: 1.85rem !important;
    line-height: 1.2 !important;
  }

  .hero-lead {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
  }

  .hero-actions {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.75rem !important;
  }

  .hero-actions .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .hero-features-bar {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
    padding: 0.85rem 1rem !important;
  }

  .hero-features-bar .hero-feature-item {
    white-space: normal !important;
    font-size: 0.85rem !important;
  }

  .hero-floating-badge {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    margin-top: 1rem !important;
    width: 100% !important;
  }

  /* Cards & Form Padding - Prevents Horizontal Squeezing */
  .card, .form-card {
    padding: 1.25rem !important;
    border-radius: var(--radius-md) !important;
  }

  .card-title {
    font-size: 1.3rem !important;
  }

  .card-text {
    font-size: 0.875rem !important;
  }

  .card .btn {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Trust & Gallery Grids */
  .trust-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .gallery-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Audio player responsiveness */
  audio {
    width: 100% !important;
    height: 40px !important;
  }

  /* Google Maps Iframe Container */
  .map-container {
    height: 280px !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
  }

  .map-container iframe {
    width: 100% !important;
    height: 100% !important;
  }

  /* Floating WhatsApp Widget */
  .floating-whatsapp {
    bottom: 16px !important;
    right: 16px !important;
    width: 52px !important;
    height: 52px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.45) !important;
    z-index: 9999 !important;
  }

  .floating-whatsapp .floating-label {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   Small Screens (320px - 375px)
   -------------------------------------------------------------------------- */
@media (max-width: 375px) {
  .brand-name {
    font-size: 1rem !important;
  }

  .brand-tagline {
    font-size: 0.58rem !important;
  }

  .hero-title {
    font-size: 1.65rem !important;
  }

  main > section:first-of-type h1 {
    font-size: 1.5rem !important;
  }

  .btn {
    font-size: 0.85rem !important;
    padding: 0.6rem 0.85rem !important;
  }

  .card, .form-card {
    padding: 1rem !important;
  }
}

/* --------------------------------------------------------------------------
   Print Stylesheet
   -------------------------------------------------------------------------- */
@media print {
  .site-header,
  .site-footer,
  .floating-whatsapp,
  .btn,
  .top-bar,
  .nav-toggle {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding-top: 0 !important;
  }
}
