/* ============================================================
   ASK AUNTY MIMI — MOBILE-FIRST OVERRIDES
   Optimized for low-end smartphones | Youth in Zambia
   ============================================================ */

/* ── BASE MOBILE IMPROVEMENTS ──────────────────────────── */
@media (max-width: 768px) {
  /* Improve base font sizes for readability */
  body {
    font-size: 15px;
    /* Prevent iOS text size adjust */
    -webkit-text-size-adjust: 100%;
  }

  /* Larger tap targets everywhere */
  a, button, .nav-link, .nav-btn, .nav-btn-ghost,
  .fac-filter-btn, .lang-btn, .qr-chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Reduce heavy blur effects on mobile for performance */
  .nav.scrolled,
  .webchat-header,
  .wc-input-area,
  .fac-nav-bar,
  .hero-slider-dots {
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  /* Disable grain overlay on mobile (performance) */
  body::before {
    display: none !important;
  }

  /* Hero section mobile */
  .hero {
    padding-left: 20px !important;
    padding-right: 20px !important;
    min-height: 100svh; /* Use svh for mobile browsers */
  }

  .hero-title {
    font-size: clamp(28px, 8vw, 40px) !important;
    letter-spacing: -0.02em !important;
  }

  .hero-desc {
    font-size: 15px !important;
  }

  /* Hero slider overlay - stronger on mobile */
  .hero-slide-overlay {
    background: rgba(250, 250, 250, 0.93) !important;
  }

  /* Hero stats - scrollable row on mobile */
  .hero-stats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding: 16px 20px !important;
    max-width: 100%;
    width: auto !important;
    scrollbar-width: none;
  }
  .hero-stats::-webkit-scrollbar { display: none; }

  .stat-item {
    padding: 0 14px !important;
    flex-shrink: 0;
  }

  .stat-num { font-size: 20px !important; }

  /* Hero actions - stack vertically */
  .hero-actions {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    padding: 16px 24px !important;
    font-size: 15px !important;
  }
}

/* ── SMALL PHONE (360px - 414px) ───────────────────────── */
@media (max-width: 414px) {
  /* Section spacing reduction */
  .section { padding: 60px 0 !important; }

  .container { padding: 0 16px !important; }

  .section-title {
    font-size: clamp(24px, 7vw, 32px) !important;
  }

  .section-desc {
    font-size: 14px !important;
    margin-bottom: 32px !important;
  }

  /* Service cards - full width, no image overlay */
  .services-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .service-card { padding: 20px !important; }
  .service-card-img { display: none !important; }

  /* Step cards - 1 column */
  .steps-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .step-card { padding: 20px !important; }

  /* Language cards - 2 columns */
  .lang-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .lang-card { padding: 16px 12px !important; }
  .lang-flag { font-size: 28px !important; }
  .lang-name { font-size: 14px !important; }
  .lang-sample { font-size: 11px !important; padding: 8px !important; }

  /* Trust ribbon */
  .trust-inner { gap: 20px !important; }
  .trust-label { display: none !important; }
  .trust-logo { font-size: 10px !important; padding: 4px 10px !important; }

  /* Nav */
  .logo-sub { display: none !important; }
  .nav-inner { padding: 0 16px !important; gap: 12px !important; }

  /* Map CTA - single column */
  .map-cta-inner { grid-template-columns: 1fr !important; gap: 32px !important; }
  .map-preview { height: 200px !important; }

  /* Privacy split - single column */
  .privacy-split { grid-template-columns: 1fr !important; gap: 32px !important; }

  /* Footer */
  .footer-links { grid-template-columns: 1fr 1fr !important; gap: 24px !important; }
  .footer-bottom { flex-direction: column !important; text-align: center !important; }

  /* Crisis banner v2 */
  .cb-call-btns { flex-direction: column !important; gap: 8px !important; }
  .cb-call-btn { width: 100% !important; justify-content: center !important; }
}

/* ── WEBCHAT MOBILE ─────────────────────────────────────── */
@media (max-width: 768px) {
  .webchat-page { height: 100svh !important; }

  .webchat-header { padding: 12px 16px !important; }

  /* Lang switcher - scrollable */
  .lang-switcher {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 8px 12px !important;
    scrollbar-width: none;
  }
  .lang-switcher::-webkit-scrollbar { display: none; }
  .lang-btn { flex-shrink: 0; font-size: 12px !important; padding: 6px 12px !important; }

  /* Input area */
  .wc-input-area { padding: 10px 12px !important; }
  .wc-input { font-size: 16px !important; } /* Prevent iOS zoom on focus */
  .wc-send { width: 40px !important; height: 40px !important; min-height: auto !important; }

  /* Message bubbles */
  .msg-text { font-size: 13px !important; padding: 9px 12px !important; }

  /* Quick replies */
  .wc-quick-replies { padding: 8px 12px !important; gap: 6px !important; flex-wrap: nowrap !important; overflow-x: auto !important; }
  .qr-chip { flex-shrink: 0 !important; font-size: 12px !important; min-height: auto !important; }
}

/* ── FACILITIES MAP MOBILE ──────────────────────────────── */
@media (max-width: 900px) {
  /* Ensure sidebar visible below map */
  .fac-sidebar {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Smaller search input */
  .fac-search input { font-size: 16px !important; } /* Prevent iOS zoom */

  /* Filter chips - horizontal scroll */
  .fac-filters {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 8px 12px !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none !important;
  }
  .fac-filters::-webkit-scrollbar { display: none !important; }
  .fac-filter-btn { flex-shrink: 0 !important; font-size: 11px !important; padding: 6px 12px !important; min-height: auto !important; white-space: nowrap !important; }

  /* Hide trust image on mobile to save space */
  .fac-trust-image-wrap { display: none !important; }
}

/* ── PERFORMANCE: Disable heavy animations on slow devices ─ */
@media (max-width: 480px) {
  /* Disable card parallax transforms */
  .service-card:hover,
  .step-card:hover,
  .lang-card:hover {
    transform: none !important;
  }

  /* Simplify transitions */
  * {
    transition-duration: 0.15s !important;
  }
}

/* ── SAFE AREA INSETS (notched phones) ─────────────────── */
@supports (padding: max(0px)) {
  .webchat-page .wc-input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .crisis-banner-v2 {
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
  }

  .nav {
    padding-top: env(safe-area-inset-top);
  }
}

/* ── TOUCH FEEDBACK ────────────────────────────────────── */
@media (hover: none) {
  /* Active state feedback for touch devices */
  .btn-primary:active,
  .btn-secondary:active,
  .nav-btn:active {
    transform: scale(0.97) !important;
    opacity: 0.9;
  }

  .service-card:active,
  .step-card:active,
  .lang-card:active {
    transform: scale(0.99) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
  }

  .cb-call-btn:active {
    transform: scale(0.97) !important;
    opacity: 0.85;
  }
}

/* ── IMAGE LOADING (lazy load shimmer) ─────────────────── */
img[loading="lazy"] {
  background: linear-gradient(90deg, #F0F4F8 25%, #E8EDF2 50%, #F0F4F8 75%);
  background-size: 200% 100%;
  animation: imgShimmer 1.5s ease infinite;
}

img[loading="lazy"].loaded {
  background: none;
  animation: none;
}

@keyframes imgShimmer {
  from { background-position: 200% center; }
  to   { background-position: -200% center; }
}

/* ── CRISIS BANNER MOBILE ───────────────────────────────── */
@media (max-width: 414px) {
  .crisis-banner {
    padding: 12px 16px !important;
    text-align: center !important;
  }
  .crisis-inner {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .crisis-text { font-size: 12px !important; }
  .crisis-btn {
    width: 100% !important;
    text-align: center !important;
    padding: 12px !important;
    font-size: 14px !important;
  }
}
