/* ===========================
   RESPONSIVE.CSS
   Mobile-first breakpoints:
   – xs  < 480px
   – sm  480 – 767px
   – md  768 – 1023px
   – lg  1024 – 1279px
   – xl  ≥ 1280px

   STRATEGY:
   • Mobile-first: defaults above target small screens.
   • Only layout/size properties are overridden here — colors, transitions,
     and animations live in style.css to avoid specificity fights.
   • All breakpoints use min-width so rules cascade up correctly.
   • Grid column counts use explicit repeat() for predictable rendering
     on older Android WebView versions.
=========================== */

/* ===========================
   GLOBAL MOBILE BASE
   Applies to ALL screens ≤ 767px (majority of traffic).
=========================== */
@media (max-width: 767px) {

  /* Prevent horizontal overflow from any stray wide element */
  html, body { overflow-x: hidden; }

  /* Note: no-scroll is handled entirely in JS (see script.js) to avoid
     position:fixed scroll-jump bugs on mobile. No CSS rule needed here. */

  /* Cart count offset fix for smaller navbar */
  .cart-count { top: -6px; right: -6px; }

  /* Hero: allow line break to flow naturally */
  .hero-title br { display: none; }
  .hero-title { word-break: break-word; hyphens: auto; }

  /* Hero actions: stack vertically, full-width feel */
  .hero-actions { flex-direction: column; align-items: flex-start; }
  .btn-primary,
  .btn-secondary { width: 100%; max-width: 280px; justify-content: center; }

  /* Search: stack search bar and select vertically */
  .search-filter-bar { flex-direction: column; gap: 10px; }
  .filter-select     { width: 100%; min-width: unset; }

  /* Pills: horizontally scrollable, hide scrollbar */
  .filter-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    /* Smooth momentum scroll on iOS */
    -webkit-overflow-scrolling: touch;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
  .pill { flex-shrink: 0; }

  /* Cart + Modal: full-width on mobile */
  .cart-sidebar { width: 100vw; }

  /*
    iOS INPUT ZOOM FIX:
    font-size ≥ 16px prevents Safari from zooming in on focus.
    !important overrides any inherited size from style.css on xs cards.
  */
  .search-input,
  .filter-select,
  .form-group input,
  .form-group select,
  .form-group textarea { font-size: 16px !important; }

  /* Floating buttons: slightly smaller label text */
  .fab { font-size: 11px; }
}

/* ===========================
   XS – Extra Small (< 480px)
   Low-end Android / older iPhones.
   Priority: reduce GPU overdraw, keep grid tight.
=========================== */
@media (max-width: 479px) {

  :root { --nav-h: 60px; }

  /* Floating buttons */
  .floating-buttons { bottom: 16px; right: 12px; gap: 10px; }
  .fab { padding: 11px 15px 11px 12px; }

  /* Navbar: tighter */
  .brand-name    { font-size: 15px; }
  .brand-tagline { display: none; }
  .cart-btn      { width: 40px; height: 40px; }

  /* Hero */
  .hero          { min-height: 100svh; }
  .hero-content  { padding: 90px 14px 56px; }
  .hero-badge    { font-size: 11px; padding: 5px 12px; }
  .hero-sub      { font-size: 14px; }
  .hero-stats    { gap: 12px; }
  .stat-num      { font-size: 20px; min-width: 2ch; }
  .stat-label    { font-size: 11px; }
  .stat-divider  { display: none; }
  .stat          { align-items: center; }

  /* Search */
  .search-section { padding: 28px 0 14px; }
  .section-title  { font-size: 24px; }
  .filter-pills   { gap: 6px; }
  .pill           { padding: 6px 14px; font-size: 12px; }

  /*
    Food grid on XS: 2-column grid.
    auto-fill with 140px minimum keeps items readable even on 360px screens.
    Images shrunk to 120px height to cut GPU memory usage.
  */
  .food-section { padding: 16px 0 40px; }
  .food-grid    {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  .food-img-wrap  { height: 120px; }
  .food-name      { font-size: 13px; margin-bottom: 4px; }
  .food-price     { font-size: 15px; }
  .food-card-body { padding: 10px; }
  .add-to-cart-btn {
    font-size: 11px;
    padding: 7px 10px;
    gap: 4px;
  }
  .add-to-cart-btn svg { width: 13px; height: 13px; }

  /* Cart */
  .cart-header { padding: 14px 14px 10px; }
  .cart-body   { padding: 10px; }
  .cart-footer { padding: 10px 14px; }

  /* Modal */
  .modal         { border-radius: 18px 18px 0 0; max-height: 95dvh; }
  .modal-header  { padding: 14px 14px 10px; }
  .modal-body    { padding: 12px; }
  .modal-footer  { padding: 10px 14px; }
  .btn-confirm   { font-size: 15px; padding: 14px; }
}

/* ===========================
   SM – Small (480px – 767px)
   Most mid-range Android phones.
=========================== */
@media (min-width: 480px) and (max-width: 767px) {

  :root { --nav-h: 64px; }

  /* Hero */
  .hero         { min-height: 90svh; }
  .hero-content { padding: 100px 16px 64px; }
  .hero-stats   { gap: 20px; }

  /* Search */
  .search-section { padding: 36px 0 16px; }

  /*
    Food grid on SM: 2-3 columns depending on available width.
    160px minimum hits 3 columns at 480-540px, 2 cols at narrower SM.
  */
  .food-grid    {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
  }
  .food-img-wrap  { height: 140px; }
  .food-name      { font-size: 13px; }
  .food-price     { font-size: 16px; }
  .food-card-body { padding: 12px; }
  .add-to-cart-btn { font-size: 12px; padding: 8px 12px; }

  /* Modal */
  .modal { border-radius: 22px 22px 0 0; }
}

/* ===========================
   MD – Medium (768px – 1023px)
   Tablets, large phones landscape.
=========================== */
@media (min-width: 768px) and (max-width: 1023px) {

  /* Hero */
  .hero-content { padding: 120px 20px 80px; max-width: 680px; }

  /* Search */
  .search-filter-bar { gap: 14px; }

  /*
    4-column grid on tablets.
    Fixed columns (not auto-fill) for visual consistency.
  */
  .food-grid    { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .food-img-wrap { height: 148px; }

  /* Cart sidebar: narrower than full-width */
  .cart-sidebar { width: 380px; }

  /* Modal: center on tablet (not bottom sheet) */
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--radius-xl); max-height: 88vh; }
}

/* ===========================
   LG – Large (1024px – 1279px)
   Small laptops, landscape tablets.
=========================== */
@media (min-width: 1024px) and (max-width: 1279px) {

  /* 5-column grid */
  .food-grid    { grid-template-columns: repeat(5, 1fr); gap: 16px; }
  .food-img-wrap { height: 155px; }

  .cart-sidebar { width: 400px; }

  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-xl); max-height: 86vh; }
}

/* ===========================
   XL – Extra Large (≥ 1280px)
   Desktops, wide screens.
=========================== */
@media (min-width: 1280px) {

  /* 5-column grid with larger images */
  .food-grid    { grid-template-columns: repeat(5, 1fr); gap: 20px; }
  .food-img-wrap { height: 175px; }

  /* Hero: full-width padding removed (max-width container handles it) */
  .hero-content { padding: 140px 0 100px; }

  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-xl); max-height: 85vh; }

  .cart-sidebar { width: 420px; }
}

/* ===========================
   HOVER/POINTER ENHANCEMENTS
   Only apply rich hover effects on true pointer devices.
   On mobile (touch), these are skipped → no accidental sticky hover states.
=========================== */
@media (hover: hover) and (pointer: fine) {
  .food-card:hover .food-category-badge {
    background: var(--primary);
    color: #fff;
    /* transition inherited from badge's computed style */
  }

  /* Fab expand: only on hover-capable devices */
  .fab:hover,
  .fab:focus-visible {
    max-width: 160px;
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,.2);
  }

  .fab:hover span,
  .fab:focus-visible span { opacity: 1; }
}

/* ===========================
   SAFE AREA INSETS (iPhone notch/home bar)
   max() ensures at least the original padding, plus the safe area.
=========================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .cart-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .modal-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .floating-buttons {
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  }
}

/* ===========================
   PRINT
=========================== */
@media print {
  .floating-buttons,
  .navbar,
  .cart-sidebar,
  .cart-overlay,
  .modal-overlay,
  .hero-actions,
  .toast { display: none !important; }

  .hero { min-height: auto; }
  body  { background: #fff; color: #000; }
}