/* ============================================================
   css/storefront.css (formerly style.css) — فروشگاه اخوان (ShopJS) | استایل صفحه فروشگاه
   Styles for the visitor-facing storefront (index.html only).
   ------------------------------------------------------------
   WHAT'S HERE:
     • Page header (title / subtitle) and the product grid layout.
     • Product cards: media area, name, description, price,
       stock badge, and the quantity stepper buttons.
     • Fixed cart button with a count badge (bump animation).
     • Cart modal (items, footer, total, Telegram CTA).
     • Product image gallery (horizontal swipe + dots) and the
       fullscreen lightbox (prev/next arrows + dots).
   ------------------------------------------------------------
   NOTE: Uses the CSS variables (--primary, --surface, ...) and
   shared classes (.modal, .btn, ...) defined in shared.css.
   Location: css/storefront.css (loaded only by index.html).
============================================================ */

.app-header {
  text-align: center;
  padding: 4rem 1.5rem 1.75rem;
}

.app-eyebrow {
  margin: 0 0 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--primary);
}

.app-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--heading-foreground);
}

.app-subtitle {
  margin: 0;
  font-size: 1.02rem;
  color: var(--muted-foreground);
}

#productGrid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  padding-bottom: 5rem;
}

/* ===== Sort bar (above the first product, right-aligned) =====
   Lets the visitor sort the grid by newest or by highest price.
   Both orders are descending ("bigger to smaller"), handled
   server-side via ?sort= on GET /api/products. */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  padding-top: 0.5rem;
  padding-bottom: 0.25rem;
}

.sort-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.sort-options {
  display: inline-flex;
  gap: 0.5rem;
}

.sort-btn {
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition:
    background-color var(--t-fast),
    color var(--t-fast),
    border-color var(--t-fast),
    transform 140ms ease;
}

.sort-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.sort-btn:active {
  transform: scale(0.97);
}

.sort-btn.active {
  color: var(--primary-contrast);
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 16px -10px color-mix(in srgb, var(--primary) 60%, transparent);
}

#productGrid > .state {
  grid-column: 1 / -1;
}

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(16px);
  transition:
    transform var(--t-base),
    box-shadow var(--t-base),
    border-color var(--t-base),
    opacity 300ms var(--ease);
}

.product-card.revealed {
  opacity: 1;
  transform: translateY(0);
  animation: card-reveal 500ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: var(--reveal-delay, 0ms);
}

.product-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}

@keyframes card-reveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-muted);
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.product-card:hover .product-image {
  transform: scale(1.06);
}

.product-media .stock-badge {
  position: absolute;
  top: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 3;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-ambient);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.product-media .stock-badge.stock-in {
  color: var(--success);
}

.product-media .stock-badge.stock-out {
  color: var(--danger);
}

.product-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem 1.15rem 1.15rem;
}

.product-name {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--heading-foreground);
}

.product-description {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--muted-foreground);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.7em * 2);
}

.product-price-row {
  margin-top: auto;
  padding-top: 0.35rem;
  display: flex;
  align-items: baseline;
}

.product-price {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--primary);
}

.product-price-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

/* ===== Quantity stepper on product cards ===== */
.qty-stepper {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.25rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--foreground);
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast), transform 140ms ease;
}

.qty-btn svg {
  width: 14px;
  height: 14px;
}

.qty-btn:hover {
  background: var(--primary);
  color: var(--primary-contrast);
}

.qty-btn:active {
  transform: scale(0.92);
}

.qty-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--surface-muted);
  color: var(--muted-foreground);
  transform: none;
}

.qty-btn:disabled:hover {
  background: var(--surface-muted);
  color: var(--muted-foreground);
}

.qty-value {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--foreground);
  transition: color var(--t-fast), opacity var(--t-fast);
}

.qty-value.qty-zero {
  color: var(--muted-foreground);
  opacity: 0.45;
}

.qty-input {
  width: 56px;
  height: 36px;
  padding: 0 0.5rem;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: var(--foreground);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
}

.qty-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-input.qty-zero {
  color: var(--muted-foreground);
  opacity: 0.45;
}

.qty-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--surface-muted);
  color: var(--muted-foreground);
}

.qty-btn.qty-confirm {
  width: 88px;
  height: 36px;
  padding: 0 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--success);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--t-fast), transform 140ms ease;
}

.qty-btn.qty-confirm:hover {
  background: var(--success-soft);
  color: var(--success);
}

.qty-btn.qty-confirm:active {
  transform: scale(0.95);
}

/* ===== Cart button (fixed top corner) ===== */
.cart-btn {
  position: fixed;
  top: 1.15rem;
  right: 1.15rem;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  color: var(--foreground);
  transition: background-color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform 160ms ease;
}

.cart-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-float);
}

.cart-btn svg {
  width: 21px;
  height: 21px;
}

.cart-badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow-ambient);
}

.cart-badge[hidden] {
  display: none;
}

.cart-badge.bump {
  animation: badge-bump 300ms var(--ease);
}

@keyframes badge-bump {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.35);
  }

  100% {
    transform: scale(1);
  }
}

/* ===== Cart panel/modal ===== */
.cart-modal {
  max-width: 460px;
  max-height: 86vh;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.cart-modal-header .modal-title {
  margin: 0;
}

.cart-items {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: var(--space-4) 0;
  padding-inline-end: 0.2rem;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.cart-item-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--heading-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item-price {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.cart-item-controls .qty-btn {
  width: 28px;
  height: 28px;
}

.cart-item-controls .qty-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cart-item-controls .qty-btn:disabled:hover {
  background: var(--surface-elevated);
  color: var(--muted-foreground);
}

.cart-item-controls .qty-value {
  min-width: 20px;
}

.cart-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-inline-start: 0.4rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast), transform 140ms ease;
}

.cart-del:hover {
  background: var(--danger-soft);
  color: var(--danger-hover);
}

.cart-del:active {
  transform: scale(0.92);
}

.cart-empty {
  flex: 1 1 auto;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--muted-foreground);
  font-size: 0.95rem;
  text-align: center;
}

.cart-empty svg {
  width: 42px;
  height: 42px;
  color: var(--primary);
  opacity: 0.8;
}

.cart-empty p {
  margin: 0;
}

.cart-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.cart-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}

.cart-total-label {
  font-weight: 600;
  color: var(--muted-foreground);
}

#cartTotal {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
}

.cart-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.cart-empty[hidden],
.cart-footer[hidden] {
  display: none;
}

/* ============================================================
   Page loading bar (top of the storefront while products load)
   A thin animated bar that slides across the top of the viewport
   during the initial fetch, so the user sees progress instead of
   a blank page. Hidden (faded out) once products arrive.
   ============================================================ */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2000;
  background: transparent;
  opacity: 1;
  transition: opacity var(--t-base);
  pointer-events: none;
}

.page-loader.hidden {
  opacity: 0;
}

.page-loader-bar {
  height: 100%;
  width: 35%;
  border-radius: 0 999px 999px 0;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
  animation: page-loader-slide 1s var(--ease) infinite;
}

@keyframes page-loader-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(290%); }
}

/* ===== Infinite-scroll sentinel + spinner =====
    #gridSentinel sits right after the product grid. While the next
    page is being fetched it shows a centred spinner + Persian label so
    the user never sees a blank gap before the new cards appear. */
.grid-sentinel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.6rem 1rem 2.4rem;
  color: var(--muted-foreground);
}

.grid-sentinel[hidden] {
  display: none;
}

.grid-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: grid-spin 0.8s linear infinite;
}

@keyframes grid-spin {
  to { transform: rotate(360deg); }
}

.grid-sentinel-text {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ===== Product image loading placeholder (logo + bar) =====
   While a product image is still downloading (e.g. while scrolling
   and lazy-loaded images have not arrived yet), an overlay covers
   the media area showing the shop monogram + an animated loading
   bar. It fades out the moment the image(s) finish loading. */
.product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-muted);
}

.img-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  background: var(--surface-muted);
  transition: opacity var(--t-base), visibility var(--t-base);
}

.img-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.img-loader-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-contrast);
  background: var(--primary);
  box-shadow: var(--shadow-float);
  animation: logo-pulse 1.4s ease-in-out infinite;
}

@keyframes logo-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.08); opacity: 0.85; }
}

.img-loader-bar {
  width: 60%;
  max-width: 160px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  overflow: hidden;
}

.img-loader-bar span {
  display: block;
  height: 100%;
  width: 42%;
  border-radius: 999px;
  background: var(--primary);
  animation: loader-slide 1.1s ease-in-out infinite;
}

@keyframes loader-slide {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.product-media .product-gallery {
  position: relative;
}

.product-gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  height: 100%;
}

.product-gallery::-webkit-scrollbar {
  display: none;
}

.product-gallery .product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
  scroll-snap-align: start;
  display: block;
  cursor: zoom-in;
  transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.product-card:hover .product-gallery .product-image {
  transform: scale(1.06);
}

.gallery-dots {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: var(--radius-full);
}

.gallery-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-foreground);
  opacity: 0.4;
  transition: opacity var(--t-fast), background-color var(--t-fast);
}

.gallery-dot.active {
  opacity: 1;
  background: var(--primary);
}

/* ===== Site stats chart (bottom of storefront) ===== */
.stats-section {
  margin-top: 2.5rem;
  padding-bottom: 3rem;
}

.stats-title {
  margin: 0 0 0.85rem;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--heading-foreground);
  text-align: center;
}

.stats-legend {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.stats-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.stats-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

/* The visits line is brown (the site's primary). */
.stats-swatch-visits {
  background: var(--primary);
}

.stats-chart {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.stats-svg {
  width: 100%;
  height: auto;
  display: block;
}

.stats-thanks {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted-foreground);
}

.stats-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.stats-axis-label {
  fill: var(--muted-foreground);
  font-size: 10px;
  font-family: var(--font-sans);
}

.stats-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.stats-line-visits {
  stroke: var(--primary);
}

.stats-empty {
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 3rem;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background-color var(--t-fast);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background-color var(--t-fast);
}

.lightbox-arrow:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-dots {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.45rem;
}

.lightbox-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: background-color var(--t-fast), transform var(--t-fast);
}

.lightbox-dot.active {
  background: #fff;
  transform: scale(1.3);
}

@media (max-width: 620px) {
  .app-header {
    padding-top: 3.5rem;
  }

  .app-title {
    font-size: 1.7rem;
  }

  .app-subtitle {
    font-size: 0.92rem;
  }

  #productGrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
  }

  /* Tighter card padding on phones so two columns stay compact. */
  .product-body {
    padding: 0.7rem 0.8rem 0.85rem;
  }

  .product-name {
    font-size: 0.95rem;
  }

  .product-description {
    min-height: calc(1.7em * 2);
  }

  .product-price {
    font-size: 0.95rem;
  }

  .product-price-label {
    font-size: 0.74rem;
  }

  /* Product-card stepper: keep it centered and compact so it fits
     the narrower half-width card. Allow wrapping so the confirm
     button drops to its own line instead of overflowing/overlapping
     when it appears. */
  .qty-stepper {
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.25rem;
  }

  .qty-btn {
    width: 32px;
    height: 34px;
  }

  .qty-input {
    width: 42px;
    height: 34px;
  }

  .qty-btn.qty-confirm {
    width: 100%;
    height: 34px;
    margin-top: 0.1rem;
  }

  /* ===== Cart modal: keep items tidy on small screens =====
     The stepper (+/-/number) plus the trash button is too wide
     for a phone in one row, which mixes up the numbers. Stack
     the item info on top and the controls below, and shrink
     the buttons. */
  .cart-modal {
    max-width: 100%;
  }

  .cart-item {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .cart-item-info {
    min-width: 0;
  }

  .cart-item-price {
    white-space: normal;
    line-height: 1.6;
  }

  .cart-item-controls.qty-stepper {
    grid-template-columns: 36px 1fr 36px auto;
    width: 100%;
    gap: 0.35rem;
  }

  .cart-item-controls .qty-btn {
    width: 36px;
    height: 32px;
  }

  .cart-item-controls .qty-input {
    width: 48px;
    height: 32px;
  }

  .cart-item-controls .cart-del {
    width: 36px;
    height: 32px;
    margin-inline-start: 0;
  }
}

/* Very narrow phones: a single full-width column gives each card
   enough room so the price, text and stepper never get squeezed or
   overlap. */
@media (max-width: 420px) {
  #productGrid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .product-name {
    font-size: 1rem;
  }

  .product-description {
    font-size: 0.82rem;
  }

  .product-price {
    font-size: 1rem;
  }

  .qty-btn {
    width: 40px;
    height: 38px;
  }

  .qty-input {
    width: 54px;
    height: 38px;
  }

  .qty-btn.qty-confirm {
    height: 38px;
  }
}