/* ==========================================================
   mobile.css — Apple SF Pro system stack, iOS-style UI
   Loaded after style.css. All layout rules inside
   @media (max-width: 980px) except overflow-x (global).

   Architecture:
   - .site-header: position fixed (out of flow)
   - .nav-drawer:  position absolute inside fixed header
   - body:         padding-top: 72px compensates fixed header
   ========================================================== */

/* ── CSS variables ── */
:root {
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --px: 18px;
}

/* ── Global: prevent horizontal overflow ── */
html,
body {
  overflow-x: clip;
}

/* ── Nav overlay (mobile drawer backdrop) ── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.nav-overlay.is-visible {
  display: block;
}

body.nav-is-open {
  overflow: hidden;
}

/* ================================================================
   MOBILE ONLY  (≤980px)
   ================================================================ */
@media (max-width: 980px) {

  /* ── Typography — SF Pro system font ── */

  body {
    padding-top: 72px;
    font-family: var(--font-system);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
  }

  h1, h2, h3, h4, h5, h6,
  button, input, label,
  nav, .nav-drawer {
    font-family: var(--font-system);
  }

  h1 {
    font-size: clamp(1.75rem, 6vw, 2.25rem);
    letter-spacing: -0.03em;
    font-weight: 700;
  }

  h2 {
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    letter-spacing: -0.025em;
    font-weight: 600;
  }

  h3 {
    font-size: clamp(1.1rem, 4vw, 1.35rem);
    letter-spacing: -0.02em;
    font-weight: 600;
  }

  p {
    font-size: 1rem;
    line-height: 1.6;
  }

  /* ── Layout ── */

  .section {
    padding-block: 48px;
  }

  img {
    max-width: 100%;
    height: auto;
  }

  /* ── Navbar mobile ── */

  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 72px;
    overflow: visible;
    z-index: 10001;
  }

  .navbar {
    height: 72px;
  }

  .nav-inner {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    padding-inline: var(--px);
    box-sizing: border-box;
  }

  .brand {
    min-width: 0;
    max-width: 220px;
    overflow: hidden;
  }

  .brand-main {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
  }

  .brand-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
  }

  .nav-links,
  .nav-cta,
  .nav-separator {
    display: none;
  }

  /* Hamburger: 44×44 iOS tap target */
  .menu-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    margin-left: auto;
  }

  .menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease;
    transform-origin: center;
  }

  .menu-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* ── Nav drawer: slide-in da destra ── */

  .nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100dvh;
    background: #fff;
    transform: translateX(100%);
    transition: transform 260ms ease;
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 16px;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    display: flex;
    flex-direction: column;
  }

  .nav-drawer.is-open {
    transform: translateX(0);
  }

  .nav-drawer a:not(.btn) {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 14px 20px;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    text-decoration: none;
  }

  .nav-drawer a.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 16px;
    width: calc(100% - 32px);
    min-height: 50px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    padding: 0 20px;
    border-bottom: none;
  }

  /* ── Cards: iOS border-radius ── */

  .service-card,
  .approach-card,
  .sidebar-box,
  .sidebar-cta-box,
  .problem-panel,
  .solution-panel,
  .timeline-step,
  .risk-chart-card,
  .stats-strip {
    border-radius: 14px;
  }

  /* ── CTA buttons ── */

  /* Hero: stack vertically, full width */
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions .btn {
    min-height: 50px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    justify-content: center;
  }

  /* Standalone section CTAs */
  .sidebar-cta-box .btn-primary,
  .province-section-cta .btn-primary {
    display: flex;
    width: 100%;
    min-height: 50px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    justify-content: center;
  }

  /* ── Animation throttle ── */

  .reveal,
  .reveal-card {
    transition-duration: 0.4s !important;
  }

  /* Cap translateY at 15px (desktop uses 30px) */
  .gsap-reveal,
  .reveal[style*="translateY"],
  .reveal-card[style*="translateY"] {
    --gsap-y: 15px;
  }

  /* No parallax on mobile */
  [data-parallax] {
    transform: none !important;
  }

  /* ── Nav drawer close button ── */

  .drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 8px 12px 4px auto;
    background: var(--bg-soft);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
  }

  /* ── Mobile dropdown Territorio ── */

  .mobile-dropdown-menu {
    display: none;
    flex-direction: column;
    background: var(--bg-soft);
    border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  }

  .mobile-dropdown-menu.is-open {
    display: flex;
  }

  .mobile-dropdown-menu a {
    padding-left: 36px !important;
    font-size: 0.95rem !important;
    color: var(--text-gray) !important;
  }

  .mobile-dropdown-toggle {
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    min-height: 44px;
    cursor: pointer;
  }

  .mobile-dropdown-toggle svg {
    transition: transform 0.25s ease;
    flex-shrink: 0;
  }

  .mobile-dropdown-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  /* ── Container / layout ── */

  .container {
    width: calc(100% - 32px);
    padding-inline: 0;
  }

  /* ── Blog grid: single column ── */

  .blog-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .blog-card {
    width: 100%;
  }

  /* ── Footer ── */

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
  }

  .footer-bottom-right {
    justify-content: center;
  }

}
/* end @media (max-width: 980px) */

/* ── Small screens (≤400px) ── */
@media (max-width: 400px) {
  h1 {
    font-size: 1.6rem;
  }
  .hero-actions {
    gap: 10px;
  }
}
