/* ==========================================
   MOBILE LAYOUT (phones, ≤ 768px)
   App-style layout layered on top of style.css: green header with search, bottom tab bar,
   two-column product grid, floating cart bar, sticky checkout bar. Desktop is untouched -
   every rule here is inside the media query except the hidden-by-default injected elements.
   Elements prefixed .m- are injected by js/mobile.js.
   ========================================== */

.m-search, .m-subtitle, .m-bottom-nav, .m-cart-bar, .m-checkout-bar { display: none; }

/* "Order again" card - shown on all screen sizes when the customer has a previous order */
.m-reorder {
  display: flex; align-items: center; gap: 12px;
  background: #fff7ef; border: 1.5px dashed var(--accent);
  border-radius: var(--radius); padding: 14px 16px;
  margin: 24px auto 0; max-width: 1200px;
}
.m-reorder-icon { font-size: 1.8rem; flex-shrink: 0; }
.m-reorder-text { flex: 1; min-width: 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.m-reorder-text strong { display: block; color: var(--text); font-size: 0.95rem; }
.m-reorder button {
  background: var(--primary); color: #fff; font-weight: 600; font-size: 0.85rem;
  padding: 10px 16px; border-radius: var(--radius-sm); white-space: nowrap;
}

/* Free-delivery progress bar (cart page, all sizes) */
.free-ship-bar { height: 6px; background: #fff; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.free-ship-bar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s ease; }

@media (max-width: 768px) {
  :root { --m-nav-h: 62px; }
  body { background: #fafcfa; padding-bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom)); }

  /* ---------- Header: green, brand + account, search underneath ---------- */
  .navbar { background: var(--primary-dark); padding: 10px 0 12px; border-bottom: none; }
  .navbar.scrolled { box-shadow: 0 4px 16px rgba(0,0,0,0.18); border-bottom: none; }
  .navbar .container { flex-wrap: wrap; padding: 0 14px; gap: 0; }
  .navbar .nav-logo { color: #fff; font-size: 1.08rem; gap: 7px; flex: 1 0 100%; min-width: 0; align-items: center; }
  .navbar .nav-actions { display: none; }
  .navbar .nav-logo .leaf { font-size: 1.2rem; }
  .m-subtitle { display: block; font-family: 'Poppins', sans-serif; font-weight: 400; font-size: 0.68rem; color: rgba(255,255,255,0.78); line-height: 1.2; }
  .m-brand-text { display: flex; flex-direction: column; min-width: 0; }
  .m-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-links, .menu-toggle, .navbar .cart-btn { display: none !important; }
  .m-search {
    display: flex; align-items: center; gap: 8px;
    width: 100%; margin-top: 10px;
    background: #fff; border-radius: 12px; padding: 0 12px;
  }
  .m-search svg { color: var(--text-muted); flex-shrink: 0; }
  .m-search input { flex: 1; border: none; background: transparent; padding: 11px 0; font-size: 0.92rem; color: var(--text); min-width: 0; }

  /* ---------- Bottom tab bar ---------- */
  .m-bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
    background: #fff; border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(0,0,0,0.05);
  }
  .m-bottom-nav a {
    flex: 1; text-align: center; font-size: 0.68rem; color: var(--text-muted);
    position: relative; line-height: 1.3; padding-top: 2px;
  }
  .m-bottom-nav a .m-ico { display: block; font-size: 1.3rem; line-height: 1.4; }
  .m-bottom-nav a.active { color: var(--primary); font-weight: 600; }
  .m-bottom-nav .cart-count { top: -2px; right: auto; left: calc(50% + 4px); width: 18px; height: 18px; font-size: 0.62rem; background: var(--accent-dark); }

  /* ---------- Floating cart bar (home, shop, product) ---------- */
  .m-cart-bar.show {
    display: flex; align-items: center; justify-content: space-between;
    position: fixed; left: 12px; right: 12px; z-index: 1000;
    bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom) + 10px);
    background: var(--primary-dark); color: #fff; border-radius: 14px; padding: 10px 12px 10px 16px;
    box-shadow: 0 8px 24px rgba(27,67,50,0.35); font-size: 0.85rem;
  }
  .m-cart-bar b { font-size: 1rem; }
  .m-cart-bar a { background: var(--accent); color: var(--primary-dark); font-weight: 700; padding: 8px 14px; border-radius: 10px; font-size: 0.82rem; }
  body.has-cart-bar { padding-bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom) + 72px); }

  /* ---------- Toasts sit above the bars ---------- */
  #toast { left: 16px; right: 16px; bottom: calc(var(--m-nav-h) + 84px); text-align: center; }
  #toast-warning { white-space: normal; width: calc(100% - 32px); font-size: 0.9rem; }

  /* ---------- Inner-page header: left-aligned serif title, not a big green block ---------- */
  .page-header { background: transparent; color: var(--text); text-align: left; padding: 16px 14px 6px; }
  .page-header h1 { color: var(--primary-dark); font-size: 1.4rem; margin: 0; }
  .page-header p { display: none; }

  /* ---------- Home ---------- */
  .hero { margin: 14px 14px 0; border-radius: 18px; padding: 26px 0 24px; min-height: 0; }
  .hero .container { padding: 0 20px; gap: 0; }
  .hero h1 { font-size: 1.55rem; line-height: 1.25; margin-bottom: 0.6rem; }
  .hero p { font-size: 0.85rem; margin-bottom: 1.1rem; line-height: 1.6; }
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { width: auto; padding: 10px 20px; font-size: 0.88rem; background: var(--accent); border-color: var(--accent); color: var(--primary-dark); }
  .hero-stats, .hero-bg-circles span:nth-child(3) { display: none; }

  .features-bar { padding: 12px 0 0; border-bottom: none; background: transparent; }
  .features-bar .container { padding: 0 14px; }
  .features-grid { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; grid-template-columns: none; }
  .features-grid::-webkit-scrollbar { display: none; }
  .feature-item { flex: 1 0 auto; background: var(--light); border-radius: 12px; padding: 8px 12px; gap: 8px; }
  .feature-icon { width: auto; height: auto; background: none; font-size: 1.1rem; }
  .feature-item h4 { font-size: 0.75rem; margin: 0; }
  .feature-item p { font-size: 0.66rem; }

  .m-reorder { margin: 14px 14px 0; padding: 12px; }
  .m-reorder-text { font-size: 0.78rem; }
  .m-reorder-text strong { font-size: 0.88rem; }
  .m-reorder button { padding: 9px 12px; font-size: 0.78rem; }

  .section { padding: 22px 0 4px; }
  .section[style] { padding-top: 22px !important; } /* the home categories section sets padding-top:0 inline */
  .section .container, .shop-section .container, .cart-page .container, .checkout-page .container { padding: 0 14px; }
  .section .text-center { text-align: left; display: flex; align-items: baseline; justify-content: space-between; }
  .section-label, .section-subtitle { display: none; }
  .section-title { font-size: 1.15rem; margin-bottom: 10px; }
  .mt-4 { display: none; }
  #featured-section .text-center::after { content: none; }

  /* Featured products scroll sideways instead of stacking */
  #featured-grid { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  #featured-grid::-webkit-scrollbar { display: none; }
  #featured-grid .product-card { flex: 0 0 150px; }

  .categories-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .category-card { padding: 0; background: none; box-shadow: none; border: none; }
  .category-card:hover { transform: none; box-shadow: none; }
  .category-icon {
    width: 100%; aspect-ratio: 1 / 1; max-height: 70px; margin: 0 0 5px;
    background: #fff; border: 1px solid var(--border); border-radius: 16px;
    display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
  }
  .category-card h3 { font-size: 0.68rem; font-weight: 500; line-height: 1.25; }
  .category-card p { display: none; }

  .why-section { background: transparent; }
  .why-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .why-card { padding: 14px 12px; text-align: left; }
  .why-icon { width: 40px; height: 40px; font-size: 1.2rem; margin: 0 0 8px; }
  .why-card h3 { font-size: 0.85rem; margin-bottom: 4px; }
  .why-card p { font-size: 0.72rem; line-height: 1.5; }

  /* ---------- Product cards: two per row, compact ---------- */
  .products-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .product-card { border: 1px solid var(--border); box-shadow: none; border-radius: 14px; }
  .product-card:hover { transform: none; box-shadow: none; }
  .product-card:hover .product-emoji { transform: none; }
  .product-image { aspect-ratio: 4 / 3; }
  .product-emoji { font-size: 3rem; }
  .product-info { padding: 8px 10px 0; }
  .product-category, .product-desc { display: none; }
  .product-name {
    font-size: 0.82rem; line-height: 1.3; margin: 0; min-height: 2.6em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .product-footer { padding: 6px 10px 10px; gap: 6px; flex-wrap: wrap; }
  .product-price { flex-direction: column; gap: 0; }
  .price { font-size: 0.98rem; }
  .unit { font-size: 0.66rem; }
  .btn-add-cart {
    background: #fff; color: var(--primary); border: 1.5px solid var(--primary);
    padding: 6px 14px; font-size: 0.78rem; font-weight: 700; gap: 0;
  }
  .btn-add-cart svg { display: none; }
  .btn-add-cart:hover { background: #fff; transform: none; }
  .card-qty-btn { width: 28px; height: 30px; }
  .card-qty-num { min-width: 20px; font-size: 0.82rem; }
  .btn-out-of-stock { font-size: 0.68rem; padding: 6px 8px; }

  /* ---------- Shop ---------- */
  /* Categories wrap onto as many lines as needed so every one is visible - a sideways-scrolling
     row hid most of them (no way to scroll it with a mouse, and nothing hinted it scrolled). Not
     sticky, since several wrapped lines would cover too much of the screen. */
  .shop-controls { position: static; padding: 10px 0 8px; box-shadow: none; border-bottom: 1px solid var(--border); }
  .shop-controls .container { padding: 0 14px; flex-direction: column; align-items: stretch; gap: 6px; }
  .shop-controls-left { width: 100%; }
  .shop-controls .search-box { display: none; }
  .filter-buttons { flex-wrap: wrap; overflow: visible; gap: 6px; padding-bottom: 0; }
  .filter-btn { flex-shrink: 0; padding: 6px 12px; font-size: 0.78rem; }
  .shop-controls .container > div:last-child { justify-content: flex-start; }
  .product-count { font-size: 0.72rem; }
  .shop-section { padding: 12px 0 20px; background: transparent; }

  /* ---------- Product page ---------- */
  .pdp-breadcrumb-bar { padding: 10px 0; }
  .pdp-breadcrumb-bar .container { padding: 0 14px; }
  .pdp-section { padding: 14px 0 24px; }
  .pdp-section .container { padding: 0 14px; }
  .pdp-image { aspect-ratio: 4 / 3; }
  .pdp-info, .pdp-info:hover { border: none; border-radius: 0; }
  .pdp-name { font-size: 1.35rem; }
  .pdp-price .price { font-size: 1.5rem; }
  .pdp-actions .card-qty-stepper { transform: none; }
  .pdp-actions .btn-add-cart { padding: 12px 28px; font-size: 0.9rem; }

  /* ---------- Cart ---------- */
  .cart-page { padding: 4px 0 20px; background: transparent; min-height: 0; }
  .cart-layout { gap: 12px; }
  .cart-panel { box-shadow: none; border: 1px solid var(--border); }
  .cart-panel-header { padding: 12px 14px; }
  .cart-panel-header h2 { font-family: 'Playfair Display', serif; font-size: 1.05rem; }
  .cart-panel-body { padding: 4px 14px; }
  .cart-item { grid-template-columns: 56px 1fr auto; gap: 4px 10px; padding: 12px 0; }
  .cart-item-image { width: 56px; height: 56px; font-size: 1.8rem; grid-row: 1 / 3; }
  .cart-item-details h4 { font-size: 0.85rem; }
  .cart-item-details p { font-size: 0.72rem; }
  .cart-item-qty { grid-row: 2; grid-column: 2; justify-self: start; }
  .cart-item-qty button { width: 30px; height: 30px; }
  .cart-item-qty span { width: 30px; }
  .cart-item-total { grid-row: 1; grid-column: 3; font-size: 0.9rem; }
  .cart-item-remove { grid-row: 2; grid-column: 3; justify-self: end; }
  .cart-summary { box-shadow: none; border: 1px solid var(--border); padding: 14px; }
  .cart-summary h3 { font-family: 'Playfair Display', serif; font-size: 1.05rem; padding-bottom: 8px; margin-bottom: 10px; }
  .cart-actions { display: none; }
  .m-checkout-bar.show {
    display: flex; align-items: center; gap: 12px;
    position: fixed; left: 0; right: 0; z-index: 1000;
    bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--border); padding: 10px 14px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  }
  .m-checkout-bar div { font-size: 0.7rem; color: var(--text-muted); line-height: 1.2; }
  .m-checkout-bar div b { display: block; color: var(--text); font-size: 1.1rem; }
  .m-checkout-bar a { flex: 1; text-align: center; background: var(--primary); color: #fff; font-weight: 700; padding: 13px; border-radius: 12px; font-size: 0.95rem; }
  body.has-checkout-bar { padding-bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom) + 76px); }
  .m-help { text-align: center; font-size: 0.78rem; color: var(--text-muted); margin-top: 12px; }
  .m-help a { color: var(--primary); font-weight: 600; }

  /* ---------- Checkout ---------- */
  .checkout-page { padding: 4px 0 20px; background: transparent; }
  .checkout-card { padding: 16px 14px; box-shadow: none; border: 1px solid var(--border); margin-bottom: 12px; }
  .checkout-card h2 { font-family: 'Playfair Display', serif; font-size: 1.05rem; margin-bottom: 12px; }
  .order-summary-card { box-shadow: none; border: 1px solid var(--border); padding: 14px; }
  .order-summary-card h3 { font-family: 'Playfair Display', serif; }
  .payment-method-tabs { gap: 8px; }
  .payment-tab { padding: 10px; gap: 8px; }
  .payment-tab-icon { font-size: 1.2rem; }
  .form-group input, .form-group select, .form-group textarea { font-size: 16px; } /* stops iOS zooming into fields */
  #order-success { padding: 2.5rem 1.25rem; }

  /* ---------- Other inner pages ---------- */
  .contact-section, .about-story, .about-values, .team-section { padding: 16px 0 24px; }
  .contact-section .container, .about-story .container, .about-values .container { padding: 0 14px; }
  .contact-info-card, .contact-form-card { padding: 1.25rem; }

  /* ---------- Footer: compact ---------- */
  footer { padding: 28px 0 0; }
  footer .container { padding: 0 14px; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
  .footer-brand .nav-logo { color: #fff; }
  .footer-brand p { margin-bottom: 0; }
  .footer-col h4 { margin-bottom: 0.6rem; }
  .footer-col ul { flex-direction: row; flex-wrap: wrap; gap: 0.4rem 1.1rem; }
}

@media (max-width: 480px) {
  /* style.css drops to one product per row here - keep two */
  .products-grid { grid-template-columns: 1fr 1fr; }
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .why-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 24px 0 22px; }
  .hero h1 { font-size: 1.45rem; }
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { width: auto; }
}
