/**
 * Phase 2 of the mobile app-feel upgrade: a shared, store-agnostic layer
 * added on top of the three existing templates (store-classic.php,
 * store-restaurant.php, store-energized.php) rather than merging them —
 * their product/menu grids differ enough structurally that a blind merge
 * was higher-risk than adding one consistent interaction layer all three
 * already qualify for: a live sticky cart bar, and (where the card markup
 * supports it) a quick-view bottom sheet instead of a full page navigation.
 *
 * Mobile-only (matches the 768px breakpoint header.php's bottom nav and
 * Phase 1's app-chrome-mobile.css already use). Desktop is untouched.
 */
@media (max-width: 768px) {
  .sas-cartbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 10px);
    z-index: 240;
    background: #111827;
    color: #fff;
    border-radius: 14px;
    padding: 10px 10px 10px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(17,24,39,.35);
    transform: translateY(120%);
    transition: transform .25s ease;
  }
  .sas-cartbar.sas-show { display: flex; transform: translateY(0); }
  .sas-cartbar .sas-cb-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
  .sas-cartbar .sas-cb-count { font-size: .68rem; color: #9ca3af; font-weight: 600; }
  .sas-cartbar .sas-cb-total { font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; }
  .sas-cartbar .sas-cb-btn {
    flex-shrink: 0;
    background: #667eea;
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 9px;
    font-weight: 700;
    font-size: .82rem;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  /* ── Quick-view bottom sheet ── */
  .sas-backdrop {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(15,23,42,.5);
    display: none;
    opacity: 0;
    transition: opacity .2s ease;
  }
  .sas-backdrop.sas-open { display: block; opacity: 1; }
  .sas-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 901;
    background: #fff;
    border-radius: 18px 18px 0 0;
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform .25s ease;
    max-height: 78vh;
    overflow-y: auto;
  }
  .sas-backdrop.sas-open .sas-sheet { transform: translateY(0); }
  .sas-sheet .sas-handle { width: 36px; height: 4px; border-radius: 4px; background: #e5e7eb; margin: 2px auto 14px; }
  .sas-sheet .sas-close {
    position: absolute; top: 12px; right: 14px;
    width: 30px; height: 30px; border-radius: 50%;
    background: #f3f4f6; border: none; color: #4b5563; font-size: 16px; line-height: 1;
  }
  .sas-sheet img { width: 100%; height: 170px; object-fit: cover; border-radius: 12px; margin-bottom: 12px; background: #f3f4f6; }
  .sas-sheet h3 { font-size: 1.05rem; font-weight: 800; color: #111827; margin: 0 0 4px; }
  .sas-sheet .sas-price { font-size: 1.15rem; font-weight: 800; color: #667eea; margin: 0 0 16px; font-variant-numeric: tabular-nums; }
  .sas-sheet .sas-qty-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
  .sas-sheet .sas-qty-row button {
    width: 38px; height: 38px; border-radius: 50%; border: 2px solid #667eea;
    background: #f3f4f6; color: #667eea; font-size: 20px; font-weight: 700; line-height: 1;
  }
  .sas-sheet .sas-qty-row span { font-weight: 800; font-size: 1.05rem; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
  .sas-sheet .sas-add-btn {
    width: 100%; padding: 13px; border-radius: 11px; border: none;
    background: linear-gradient(135deg,#667eea,#764ba2); color: #fff;
    font-weight: 800; font-size: .92rem; margin-bottom: 8px;
  }
  .sas-sheet .sas-full-link { display: block; text-align: center; color: #6b7280; font-size: .8rem; text-decoration: none; padding: 4px; }

  /* ── Cart drawer (Phase 3) ── */
  .sas-cart-sheet { max-height: 82vh; }
  .sas-cart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .sas-cart-head h3 { margin: 0; font-size: 1.05rem; }
  .sas-cart-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
  .sas-cart-row { display: flex; gap: 10px; align-items: center; }
  .sas-cart-row img { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; background: #f3f4f6; flex-shrink: 0; }
  .sas-cart-row .sas-ci-info { flex: 1; min-width: 0; }
  .sas-cart-row .sas-ci-name { font-size: .85rem; font-weight: 700; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sas-cart-row .sas-ci-store { font-size: .72rem; color: #9ca3af; }
  .sas-cart-row .sas-ci-qty { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .sas-cart-row .sas-ci-qty button { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #d1d5db; background: #f9fafb; color: #4b5563; font-size: 14px; line-height: 1; }
  .sas-cart-row .sas-ci-qty span { min-width: 22px; text-align: center; font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
  .sas-cart-row .sas-ci-price { flex-shrink: 0; font-weight: 800; font-size: .85rem; color: #111827; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
  .sas-cart-row .sas-ci-remove { flex-shrink: 0; background: none; border: none; color: #d1d5db; font-size: 15px; padding: 4px; }
  .sas-cart-empty { text-align: center; padding: 30px 10px; color: #9ca3af; font-size: .85rem; }
  .sas-cart-total-row { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 1px solid #e5e7eb; margin-bottom: 12px; }
  .sas-cart-total-row span:first-child { font-size: .85rem; color: #6b7280; font-weight: 600; }
  .sas-cart-total-row span:last-child { font-size: 1.15rem; font-weight: 800; color: #111827; font-variant-numeric: tabular-nums; }
  .sas-cart-full-link { display: block; text-align: center; color: #6b7280; font-size: .8rem; text-decoration: none; padding: 4px 0 2px; }

  body.sas-locked { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .sas-cartbar, .sas-backdrop, .sas-sheet { transition: none !important; }
}
