/**
 * Responsive — Mobile & Tablet
 *
 * @package Developer_Starter
 */

/* ─── Tablet (≤ 1024px) ─── */
@media (max-width: 1024px) {
    .services-grid,
    .testimonials-grid,
    .blog-grid { grid-template-columns: repeat(2, 1fr); }

    .about-layout { grid-template-columns: 1fr; gap: 2.5rem; }
    .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 2rem; }
    .contact-layout { grid-template-columns: 1fr; gap: 2.5rem; }

    .hero { padding: 5rem 0 4rem; }
    .hero__stats { gap: 2rem; }
}

/* ─── Mobile Nav (≤ 768px) ─── */
@media (max-width: 768px) {
    html, body { overflow-x: hidden; }
    .menu-toggle { display: block; }

    .main-nav {
        position: fixed;
        top: 0;
        right: 0;
        width: 85%;
        max-width: 360px;
        height: 100vh;
        background: var(--color-secondary);
        flex-direction: column;
        align-items: stretch;
        padding: 5rem 2rem 2rem;
        gap: 0;
        transform: translateX(110%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        pointer-events: none;
        visibility: hidden;
        box-shadow: -8px 0 32px rgba(0,0,0,0.5);
        z-index: 999;
        overflow-y: auto;
    }
    .main-nav.open { transform: translateX(0); pointer-events: auto; visibility: visible; }

    .nav-list {
        flex-direction: column;
        gap: 0;
    }
    .nav-list li a {
        display: block;
        padding: 14px 16px;
        font-size: 17px;
        border-radius: var(--radius-sm);
    }
    .nav-cta {
        margin: 1rem 0 0;
        text-align: center;
        justify-content: center;
    }

    /* Overlay */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 998;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    .nav-overlay.active { opacity: 1; pointer-events: auto; }

    /* Hero mobile */
    .hero { padding: 4rem 0 3rem; }
    .hero__title { font-size: clamp(2rem, 8vw, 2.8rem); }
    .hero__actions { flex-direction: column; }
    .hero__actions .btn { width: 100%; justify-content: center; }
    .hero__stats { flex-direction: column; gap: 1.2rem; }
    .hero__stat { display: flex; align-items: center; gap: 12px; }
    .hero__stat-number { font-size: 1.5rem; }

    /* Grids → single column */
    .services-grid,
    .testimonials-grid,
    .blog-grid { grid-template-columns: 1fr; }

    .about-grid { grid-template-columns: 1fr; }

    /* Footer */
    .footer-grid { grid-template-columns: 1fr; gap: 2rem; }

    /* Forms */
    .form-row { grid-template-columns: 1fr; }

    .section { padding: 3.5rem 0; }

    /* Top bar */
    .top-bar__areas { display: none; }
    .top-bar__inner { justify-content: center; }

    /* Areas */
    .areas-grid { gap: 10px; }
    .area-badge { padding: 10px 18px; font-size: 14px; }
}

/* ─── Small mobile (≤ 480px) ─── */
@media (max-width: 480px) {
    .container { padding: 0 16px; }
    body { font-size: 16px; }
    .section { padding: 3rem 0; }
    .service-card { padding: 2rem 1.5rem; }
    .testimonial-card { padding: 2rem 1.5rem; }
    .contact-form-wrap { padding: 1.5rem; }
    .btn--lg { padding: 14px 24px; font-size: 15px; }
}

/* ─────────────────────────────────────────────────────────────
   Mobile Menu (redesign helpers)
   - Dedicated submenu toggle button on parent items
   - Larger tap targets + predictable layout
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Prevent any accidental horizontal scroll on mobile */
  html, body { overflow-x: hidden; }

  /* Parent row layout: link + toggle button */
  .nav-list li.menu-item-has-children {
    position: relative;
  }

  /* Make room for the right-side toggle button */
  .nav-list li.menu-item-has-children > a {
    padding-right: 60px;
  }

  /* Submenu toggle button (right side) */
  .submenu-toggle {
    position: absolute;
    right: 6px;
    top: 10px;
    transform: none;
    width: 48px;
    height: 48px;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 12px;
    z-index: 3;
    pointer-events: auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .submenu-toggle:hover,
  .submenu-toggle:focus-visible {
    background: rgba(255,255,255,0.06);
    outline: none;
  }

  /* Chevron */
  .submenu-toggle::before {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(255,255,255,0.75);
    border-bottom: 2px solid rgba(255,255,255,0.75);
    transform: rotate(45deg);
    transition: transform 0.18s ease;
  }

  .nav-list li.submenu-open > .submenu-toggle::before {
    transform: rotate(-135deg);
  }

  /* Hide the desktop arrow on mobile to avoid double indicators */
  .nav-list .menu-item-has-children > a::after {
    display: none;
  }
}

/* ============================================================
   Mobile Menu (from scratch) — mm-* classes
   ============================================================ */
@media (max-width: 920px) {
  /* Make sure parent row can host a button */
  .nav-list li.menu-item-has-children { position: relative; }

  /* Parent label: full width, keep room for arrow button */
  .nav-list li.menu-item-has-children > a {
    display: block;
    padding-right: 64px;
  }

  /* Kill any old mobile arrows from earlier CSS */
  .nav-list .menu-item-has-children > a::after { display: none !important; }

  /* New arrow button */
  .nav-list li.menu-item-has-children > button.mm-toggle {
    position: absolute;
    right: 10px;
    top: 8px;
    width: 44px;
    height: 44px;
    border: 0;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
  }

  .nav-list li.menu-item-has-children > button.mm-toggle::before {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(255,255,255,0.78);
    border-bottom: 2px solid rgba(255,255,255,0.78);
    transform: rotate(45deg);
    transition: transform 0.18s ease;
  }

  .nav-list li.mm-parent.mm-open > button.mm-toggle::before {
    transform: rotate(-135deg);
  }

  /* Submenu show/hide */
  .nav-list li.mm-parent > .sub-menu { display: none; }
  .nav-list li.mm-parent.mm-open > .sub-menu { display: block; }

  /* Extra spacing so submenu never overlaps the parent row */
  .nav-list li.mm-parent > .sub-menu { margin-top: 10px; }
}


/* Hide mm-toggle on desktop (prevents tiny default button "dots" in the header nav) */
@media (min-width: 921px) {
  .nav-list li.menu-item-has-children > button.mm-toggle {
    display: none !important;
  }
}

/* ─── Sitemap list padding (prevents bullets hugging the left edge on mobile) ─── */
@media (max-width: 768px) {
  .page-template-template-sitemap .sitemap-list,
  .page-template-template-sitemap .sitemap-list ul {
    padding-left: 1.25rem;
    margin-left: 0;
  }

  .page-template-template-sitemap .sitemap-list li {
    margin: 0.35rem 0;
  }
}
