/* =========================================================================
   AGAPE LIGHT NETWORK — NATIVE-GRADE MOBILE VIEWPORT DESIGN SYSTEM
   Strictly scoped to mobile viewports (<= 768px). Desktop is 100% untouched.
   Target Standards: 60fps Hardware Acceleration, Fluid Typography, 3D Soft Elevation
   ========================================================================= */

@media (max-width: 768px) {

  /* -----------------------------------------------------------------------
     1. GLOBAL VIEWPORT & HORIZONTAL OVERFLOW PREVENTION
     ----------------------------------------------------------------------- */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative !important;
    -webkit-overflow-scrolling: touch !important;
  }

  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  #mainContent,
  section,
  .section,
  .container,
  .container-narrow,
  .header-nav {
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* -----------------------------------------------------------------------
     2. FLUID TYPOGRAPHY & LAYOUT NORMALIZATION (CSS CLAMP)
     ----------------------------------------------------------------------- */
  h1, .h1, [style*="font-size: 2.75rem"], [style*="font-size: 2.5rem"], [style*="font-size: clamp(2"] {
    font-size: clamp(1.75rem, 5.8vw, 2.35rem) !important;
    line-height: 1.18 !important;
    letter-spacing: -0.02em !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
  }

  h2, .h2, [style*="font-size: 2rem"], [style*="font-size: 1.8rem"] {
    font-size: clamp(1.4rem, 4.8vw, 1.95rem) !important;
    line-height: 1.24 !important;
    letter-spacing: -0.015em !important;
    margin-bottom: 0.85rem !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
  }

  h3, .h3, [style*="font-size: 1.5rem"], [style*="font-size: 1.35rem"] {
    font-size: clamp(1.15rem, 3.8vw, 1.5rem) !important;
    line-height: 1.3 !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
  }

  h4, .h4, [style*="font-size: 1.25rem"] {
    font-size: clamp(1.025rem, 3.2vw, 1.2rem) !important;
    line-height: 1.35 !important;
  }

  p, .body-text, [style*="font-size: 1.25rem"], [style*="font-size: 1.1rem"], [style*="font-size: 1.05rem"] {
    font-size: clamp(0.95rem, 2.2vw + 0.45rem, 1.05rem) !important;
    line-height: 1.62 !important;
  }

  .eyebrow {
    font-size: 0.72rem !important;
    letter-spacing: 0.08em !important;
    margin-bottom: 0.5rem !important;
    display: inline-block !important;
  }

  .container,
  .container-narrow {
    padding-left: 1.15rem !important;
    padding-right: 1.15rem !important;
  }

  .section {
    padding-top: 3.5rem !important;
    padding-bottom: 3.5rem !important;
  }

  /* Form Elements: Strictly Enforce 16px to prevent iOS Safari auto-zoom */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 48px !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
  }

  /* Collapse two-column form grids on mobile */
  form div[style*="grid-template-columns: 1fr 1fr"],
  form div[style*="grid-template-columns:1fr 1fr"],
  form div[style*="grid-template-columns: repeat(2, 1fr)"],
  .form-row-2,
  .form-grid-2 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  /* Home Metrics Ribbon Grid: 2x2 Crisp Balanced Layout */
  .metrics-ribbon-grid,
  section[style*="background: var(--color-surface)"] > .container > div[style*="grid-template-columns"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
    text-align: center !important;
  }

  .metrics-ribbon-grid > div,
  section[style*="background: var(--color-surface)"] > .container > div[style*="grid-template-columns"] > div {
    background: #FFFFFF !important;
    border: 1px solid var(--color-border, #E2E8F0) !important;
    border-radius: 10px !important;
    padding: 1rem 0.65rem !important;
    box-shadow: 0 4px 14px rgba(15, 28, 54, 0.05) !important;
  }

  .metrics-ribbon-grid [data-counter],
  section[style*="background: var(--color-surface)"] [data-counter] {
    font-size: clamp(1.25rem, 4.5vw, 1.65rem) !important;
    line-height: 1.2 !important;
    margin: 0.25rem 0 !important;
  }

  /* -----------------------------------------------------------------------
     3. CRUCIAL MOBILE MAP USABILITY & VERTICAL PROPORTIONS
     ----------------------------------------------------------------------- */
  /* Force adequate vertical height on mobile so Pakistan grid is easily explored */
  .aln-vector-map-wrap {
    min-height: 65vh !important;
    height: 65vh !important;
    max-height: 720px !important;
    width: 100% !important;
    position: relative !important;
    border-radius: 12px 12px 0 0 !important;
    touch-action: pan-x pan-y pinch-zoom !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    transform: translate3d(0, 0, 0) !important;
  }

  .aln-map-frame {
    border-radius: 14px !important;
    overflow: hidden !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
    margin-bottom: 1.5rem !important;
    background: #071224 !important;
  }

  .aln-map-toolbar {
    padding: 0.65rem 0.95rem !important;
    font-size: 0.75rem !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    background: #0B1325 !important;
  }

  .aln-map-legend-hint {
    font-size: 0.72rem !important;
  }

  /* SVG Map Pin Touch Hitboxes: Make them generously tappable */
  .op-node {
    cursor: pointer !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .op-node .op-node-outer {
    r: 13px !important;
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.7)) !important;
  }

  .op-node .op-node-core {
    r: 5.5px !important;
  }

  .op-node .node-badge text {
    font-size: 11px !important;
    font-weight: 700 !important;
  }

  /* Province Header Cards: 2x2 Clean Compact Grid on Mobile */
  .province-cards-grid,
  .op-province-selector-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
    margin-bottom: 1rem !important;
  }

  .province-summary-card,
  .prov-card {
    padding: 0.85rem 0.75rem !important;
    min-height: 58px !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 12px rgba(10, 30, 60, 0.06) !important;
  }

  .prov-card-title,
  .province-summary-card strong {
    font-size: 0.875rem !important;
    margin-bottom: 2px !important;
  }

  .prov-card-hubs,
  .prov-card-status,
  .province-summary-card span {
    font-size: 0.72rem !important;
  }

  /* Sub-Filter Bar & Category Pills: Horizontal Smooth Touch Scroller */
  .op-sub-filter-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    margin-bottom: 1.25rem !important;
  }

  .op-category-filters {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    gap: 0.5rem !important;
    padding: 0.25rem 0.15rem 0.5rem 0.15rem !important;
  }

  .op-category-filters::-webkit-scrollbar {
    display: none !important;
  }

  .op-category-pill {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 0.45rem 0.95rem !important;
    font-size: 0.8125rem !important;
    min-height: 40px !important;
    border-radius: 9999px !important;
    touch-action: manipulation !important;
  }

  .op-sub-actions {
    display: flex !important;
    gap: 0.5rem !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .op-sub-actions .op-view-all-prov-btn {
    flex: 1 !important;
    padding: 0.55rem 0.85rem !important;
    font-size: 0.785rem !important;
    min-height: 40px !important;
  }

  .op-sub-actions a {
    flex: 1 !important;
    justify-content: center !important;
    min-height: 40px !important;
    font-size: 0.8125rem !important;
  }

  /* Rescue Map Telemetry Bar */
  .map-telemetry-grid,
  section[style*="background: #070d18"] > div[style*="grid-template-columns"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .map-telemetry-grid > div,
  section[style*="background: #070d18"] > div[style*="grid-template-columns"] > div {
    padding: 0.95rem 0.85rem !important;
    border-radius: 10px !important;
  }

  .map-telemetry-grid [style*="font-size: 2rem"],
  section[style*="background: #070d18"] [style*="font-size: 2rem"] {
    font-size: 1.35rem !important;
    line-height: 1.2 !important;
  }

  /* Sidebar Case Carousel on Mobile */
  .dispatch-card-container {
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(10, 30, 60, 0.08) !important;
    margin-top: 1rem !important;
    transform: translate3d(0, 0, 0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
  }

  .carousel-header-bar {
    padding: 0.85rem 1rem !important;
  }

  .carousel-city-name {
    font-size: 1.1rem !important;
  }

  .carousel-nav-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  .dispatch-media-wrap {
    height: clamp(210px, 34vh, 260px) !important;
  }

  .dispatch-body {
    padding: 1.25rem 1.15rem 1.5rem 1.15rem !important;
  }

  .dispatch-title {
    font-size: 1.35rem !important;
    margin-bottom: 0.35rem !important;
  }

  .sidebar-slide-sponsor-btn,
  #sidebarSlideSponsorBtn,
  .map-case-action-btn {
    width: 100% !important;
    min-height: 52px !important;
    font-size: 1.05rem !important;
    font-weight: 800 !important;
    border-radius: 8px !important;
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.45) !important;
    letter-spacing: 0.02em !important;
  }

  /* -----------------------------------------------------------------------
     4. HARDWARE ACCELERATION (60FPS), 3D TRANSITIONS & TACTILE TOUCH
     ----------------------------------------------------------------------- */
  /* Pure GPU Compositing on Interactive UI */
  .mobile-drawer,
  .modal-dialog,
  .map-case-card,
  .carousel-slide,
  .carousel-track,
  .btn,
  .card,
  .mobile-bottom-nav {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
  }

  /* GPU-Accelerated Mobile Drawer (Replaces clunky right property) */
  .mobile-drawer {
    right: 0 !important;
    -webkit-transform: translate3d(100%, 0, 0) !important;
    transform: translate3d(100%, 0, 0) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    will-change: transform !important;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4) !important;
  }

  .mobile-drawer.active {
    -webkit-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
  }

  /* Native iOS/Android Bottom Sheet Modals */
  .modal-overlay,
  .map-case-modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
    -webkit-backdrop-filter: blur(12px) !important;
    backdrop-filter: blur(12px) !important;
  }

  .modal-dialog,
  .map-case-card {
    border-radius: 20px 20px 0 0 !important;
    max-height: 88vh !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 2rem 1.25rem 2.5rem 1.25rem !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5) !important;
    -webkit-transform: translate3d(0, 100%, 0) !important;
    transform: translate3d(0, 100%, 0) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease !important;
    will-change: transform !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Native Bottom Sheet Drag Handle */
  .modal-dialog::before,
  .map-case-card::before {
    content: '' !important;
    display: block !important;
    width: 42px !important;
    height: 4px !important;
    border-radius: 9999px !important;
    background: rgba(148, 163, 184, 0.45) !important;
    margin: -1rem auto 1.25rem auto !important;
  }

  .modal-overlay.active .modal-dialog,
  .map-case-modal-overlay.is-open .map-case-card {
    -webkit-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
  }

  /* Tactile Touch Feedback: Native Mobile App Bounce */
  .btn,
  .mobile-nav-item,
  .carousel-nav-btn,
  .op-category-pill,
  .province-summary-card,
  .prov-card,
  .card,
  .hamburger-btn,
  .modal-close {
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s ease !important;
  }

  .btn:active,
  .mobile-nav-item:active,
  .carousel-nav-btn:active,
  .op-category-pill:active {
    -webkit-transform: scale(0.96) translate3d(0, 0, 0) !important;
    transform: scale(0.96) translate3d(0, 0, 0) !important;
    transition: transform 0.08s ease-out !important;
  }

  .card:active,
  .prov-card:active,
  .province-summary-card:active {
    -webkit-transform: scale(0.985) translate3d(0, 0, 0) !important;
    transform: scale(0.985) translate3d(0, 0, 0) !important;
    transition: transform 0.08s ease-out !important;
  }

  /* 3D Soft Ambient Shadows on Cards */
  .card {
    border-radius: 14px !important;
    box-shadow: 0 10px 25px -4px rgba(15, 28, 54, 0.08), 0 4px 10px -2px rgba(15, 28, 54, 0.04) !important;
    border: 1px solid var(--color-border, #E2E8F0) !important;
  }

  /* Fixed Mobile Bottom Nav Bar */
  .mobile-bottom-nav {
    -webkit-backdrop-filter: blur(18px) !important;
    backdrop-filter: blur(18px) !important;
    background: rgba(11, 19, 37, 0.94) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  }

  /* Button Groups on Mobile: Stack Vertically with Full Width */
  .btn-group {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.75rem !important;
  }

  .btn-group .btn {
    width: 100% !important;
    min-height: 48px !important;
    justify-content: center !important;
  }

  /* Safe Area Padding for Notch / Modern Phones */
  body {
    padding-bottom: calc(4.85rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  .site-footer {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* -----------------------------------------------------------------------
     5. SUCCESSFUL CASES 3D ARCHIVE MOBILE NORMALIZATION
     ----------------------------------------------------------------------- */
  .victory-hero {
    padding: 3.25rem 1rem 2.5rem !important;
  }

  .victory-title {
    font-size: clamp(1.75rem, 5.5vw, 2.35rem) !important;
  }

  .counters-row {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
    width: 100% !important;
    margin-top: 1.75rem !important;
  }

  .counter-box {
    padding: 0.85rem 0.65rem !important;
    border-radius: 10px !important;
  }

  .counter-num {
    font-size: clamp(1.35rem, 4.5vw, 1.85rem) !important;
  }

  .archive-section {
    padding: 3rem 1rem 4.5rem !important;
  }

  .filter-nav {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    justify-content: flex-start !important;
    gap: 0.5rem !important;
    padding: 0.25rem 0.25rem 0.75rem 0.25rem !important;
    margin-bottom: 2rem !important;
  }

  .filter-nav::-webkit-scrollbar {
    display: none !important;
  }

  .filter-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 0.5rem 1.05rem !important;
    font-size: 0.8125rem !important;
    min-height: 40px !important;
  }

  .cards-3d-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .card-3d-wrapper,
  .card-3d {
    width: 100% !important;
    max-width: 100% !important;
  }

  .card-banner {
    height: clamp(200px, 32vh, 250px) !important;
  }

  /* Card Highlight Pulse for Mobile Map Pin Taps */
  @keyframes cardHighlightGlow {
    0% {
      box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.7), 0 16px 36px rgba(0, 0, 0, 0.4);
    }
    50% {
      box-shadow: 0 0 0 8px rgba(217, 119, 6, 0.45), 0 16px 36px rgba(0, 0, 0, 0.55);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(217, 119, 6, 0), 0 16px 36px rgba(0, 0, 0, 0.4);
    }
  }

  .card-highlight-pulse {
    animation: cardHighlightGlow 0.85s ease-out !important;
  }
}

/* -------------------------------------------------------------------------
   NARROW MOBILE SCREENS (<= 480px)
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .aln-vector-map-wrap {
    min-height: 62vh !important;
    height: 62vh !important;
  }

  .container,
  .container-narrow {
    padding-left: 0.95rem !important;
    padding-right: 0.95rem !important;
  }

  .section {
    padding-top: 2.75rem !important;
    padding-bottom: 2.75rem !important;
  }

  .brand-logo img {
    height: 36px !important;
    max-width: 140px !important;
  }

  .metrics-ribbon-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .metrics-ribbon-grid > div {
    padding: 0.75rem 0.5rem !important;
  }

  .map-telemetry-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
}
