/**
 * Feed page styles — Simpsons Pop Art comic design.
 * Thick black borders, yellow accents, halftone dots, comic bursts.
 */

/* ─── Pop Art Background ─── */
.feed-page-wrap {
  background: #FFF8DC;
  min-height: 100vh;
  position: relative;
}

/* Halftone dot overlay */
.feed-page-wrap::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* ─── Shipping Banner ─── */
.shipping-banner {
  background: #111;
  color: #FFD90F;
  text-align: center;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 3px solid #FFD90F;
  position: relative;
  z-index: 2;
}
.shipping-banner svg { opacity: 0.9; stroke: #FFD90F; }

/* ─── Feed Header ─── */
.feed-header-comic {
  text-align: center;
  padding: 28px 16px 8px;
  position: relative;
  z-index: 1;
}
.feed-header-comic h1 {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 900;
  color: #111;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-shadow: 3px 3px 0 #FFD90F;
  margin: 0;
}
.feed-header-comic p {
  font-size: 0.85rem;
  color: #555;
  font-weight: 600;
  margin-top: 6px;
}

/* ─── Feed Search Bar ─── */
.feed-search-wrap {
  margin: 14px auto 0;
  max-width: 480px;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

.feed-search-input {
  border: 3px solid #111;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 4px 4px 0 #111;
  transition: box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.feed-search-input:focus {
  box-shadow: 6px 6px 0 #111;
  outline: none;
}
.feed-search-input::-webkit-search-cancel-button { display: none; }

.feed-search-empty {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #555;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Category Filter Bar ─── */
/* WHY: top: 64px accounts for the sticky pa-nav height so filters sit below it */
.feed-filters {
  background: transparent;
  border-bottom: none;
  padding: 14px 16px 0;
  position: sticky;
  top: 64px;
  z-index: 5;
}
.filter-row-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #555;
  margin-bottom: 6px;
  padding-left: 4px;
}
.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.filter-pill {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 6px;
  border: 2.5px solid #111;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: #111;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.filter-pill:hover {
  background: #FFF3B0;
  transform: translateY(-1px);
}
.filter-pill.active {
  background: #FFD90F;
  color: #111;
  border-color: #111;
  box-shadow: 3px 3px 0 #111;
}

/* ─── Shopping Mode Pills ─── */
/* WHY: top: 116px = 64px nav + ~52px category row */
.mode-filters {
  padding: 8px 16px 14px;
  position: sticky;
  top: 116px;
  z-index: 4;
}
.mode-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.mode-scroll::-webkit-scrollbar { display: none; }

.mode-pill {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 20px;
  border: 2px solid #111;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  color: #111;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.mode-pill:hover {
  background: #FFF3B0;
}
.mode-pill.active {
  background: #111;
  color: #FFD90F;
  border-color: #111;
}

/* ─── Feed Grid ─── */
/* WHY: max-width 1400px keeps cards from stretching too wide on large monitors.
   box-sizing + overflow-x hidden prevents any horizontal scroll from card overflow.
   !important on grid-template-columns prevents theme.css .product-grid from leaking.
   align-items:stretch ensures all cards in a row stretch to the same height. */
.feed-main {
  padding: 16px 16px 100px;
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
  width: 100% !important;
}
.feed-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 10px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  align-items: stretch !important;
  align-content: start !important;
}
@media (min-width: 768px) {
  .feed-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 20px !important; }
}
@media (min-width: 1024px) {
  .feed-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 24px !important; }
}

/* ─── Product Card — Comic Pop Art ─── */
/* WHY: display flex + column ensures card body fills remaining space evenly
   across all cards in a grid row. min-width 0 prevents grid blowout.
   box-sizing border-box includes border in width calculation.
   !important overrides theme.css .product-card competing styles.
   overflow:hidden + max-width:100% prevents cards from overflowing their grid cell
   even when box-shadow or border would otherwise push width past container. */
.product-card {
  background: #fff !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  border: 3px solid #111 !important;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  box-shadow: 4px 4px 0 #111;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  word-break: break-word;
  /* Prevent box-shadow from expanding the element's visual width */
  outline: none;
}
.product-card:hover {
  transform: rotate(-1deg) scale(1.02);
  box-shadow: 6px 6px 0 #111;
}

/* Card image area */
.card-img-wrap {
  position: relative !important;
  overflow: hidden !important;
  border-bottom: 3px solid #111;
  width: 100% !important;
  box-sizing: border-box !important;
  /* WHY: aspect-ratio: 1/1 on the wrap forces all cards to have equal image areas.
     Negative margin-top removes the ::after placeholder from layout so it doesn't
     affect card height — it stays visual-only. */
  aspect-ratio: 1 / 1 !important;
  margin-top: 0 !important;
}
/* WHY: ::after provides a placeholder icon behind the img.
   When img loads it covers the placeholder. When img 404s and
   onerror hides it, the placeholder shows through. */
.card-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #F5F5DC;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' fill='none' stroke='%23ccc' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  z-index: 0;
  pointer-events: none;
}
/* WHY: !important on position overrides theme.css's position:absolute which
   removes the image from normal flow and breaks card height calculation.
   max-width prevents the image from blowing out the card on mobile. */
.card-img {
  width: 100% !important;
  max-width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  display: block !important;
  background: #F5F5DC;
  position: relative !important;
  z-index: 1;
  height: 100% !important;
  box-sizing: border-box !important;
}

/* Discount badge — comic starburst */
.card-discount {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #DC2626;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 10px;
  border: 2px solid #111;
  border-radius: 4px;
  transform: rotate(-3deg);
  z-index: 2;
  letter-spacing: 0.02em;
}
.card-discount::before {
  content: '%';
}

/* Trending badge — starburst shape via clip-path */
.card-trending-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: #FFD90F;
  color: #111;
  font-size: 10px;
  font-weight: 900;
  padding: 6px 10px;
  border: 2px solid #111;
  border-radius: 4px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.card-trending-badge svg {
  width: 12px;
  height: 12px;
}

/* Save button — comic heart */
.card-save-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
  border: 2.5px solid #111;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.15s, background 0.15s;
}
.card-save-btn:hover {
  transform: scale(1.12);
  background: #FFF3B0;
}
.card-save-btn svg { width: 18px; height: 18px; }
.card-save-btn.saved {
  background: #FEE2E2;
  border-color: #DC2626;
}
.card-save-btn.saved svg {
  fill: #DC2626;
  stroke: #DC2626;
}

/* Card body */
/* WHY: flex: 1 makes card body fill remaining height so all cards in a row
   align price/button at the same vertical position.
   min-width 0 prevents text content from blowing out the card width. */
.card-body {
  padding: 14px;
  background: #fff;
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* Category pill */
.card-cat {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #111;
  font-weight: 700;
  margin-bottom: 6px;
  background: #FFF3B0;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1.5px solid #111;
}

/* Product name — clamped to 2 lines so cards stay even height */
.card-name {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 800;
  color: #111;
  line-height: 1.3;
  text-decoration: none;
  margin-bottom: 8px;
  word-break: break-word;
  min-height: calc(14px * 1.3 * 2); /* reserve 2-line height for consistent cards */
}
.card-name:hover { color: #333; }

/* Price row */
.card-price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-price {
  font-size: 20px;
  font-weight: 900;
  color: #B8860B;
  letter-spacing: -0.01em;
}
.card-compare {
  font-size: 13px;
  color: #999;
  text-decoration: line-through;
  font-weight: 500;
}

/* Add to Cart button — yellow comic style */
/* WHY: margin-top auto pushes button to card bottom for uniform row alignment.
 * WHY: flex-wrap allows the low-stock badge to claim its own row above the button. */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto !important;
}
.card-add-btn {
  flex: 1;
  padding: 10px;
  background: #000;
  color: #FFD90F;
  border: 2.5px solid #111;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 3px 3px 0 #000;
}
.card-add-btn:hover {
  background: #FFD90F;
  color: #000;
  box-shadow: 2px 2px 0 #111;
  transform: translateY(-1px);
}
.card-add-btn:active {
  transform: translateY(0);
  box-shadow: none;
}
.card-add-btn:disabled {
  background: #E5E5E5;
  color: #999;
  cursor: not-allowed;
  border-color: #999;
  box-shadow: none;
  transform: none;
}
.card-add-btn.added {
  background: #16a34a;
  color: #fff;
  border-color: #111;
}

/* ─── Card entry animation ─── */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.product-card {
  animation: cardSlideIn 0.35s ease-out both;
}
.product-card:nth-child(2) { animation-delay: 0.05s; }
.product-card:nth-child(3) { animation-delay: 0.1s; }
.product-card:nth-child(4) { animation-delay: 0.15s; }
.product-card:nth-child(5) { animation-delay: 0.2s; }
.product-card:nth-child(6) { animation-delay: 0.25s; }

/* ─── Cart pop animation ─── */
@keyframes cartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.nav-cart-badge.pop {
  animation: cartPop 0.3s ease;
}

/* ─── Feed States ─── */
.feed-state {
  text-align: center;
  padding: 32px;
  position: relative;
  z-index: 1;
}
.feed-loading {
  color: #555;
  font-size: 14px;
  font-weight: 700;
}
.feed-end {
  color: #555;
  font-size: 14px;
  font-weight: 700;
  padding: 24px;
  background: #fff;
  border: 3px solid #111;
  border-radius: 8px;
  display: inline-block;
  box-shadow: 3px 3px 0 #111;
}
.feed-empty {
  text-align: center;
  padding: 60px 0;
  color: #555;
  font-weight: 700;
}

/* ─── Feed Nav overrides ─── */
body .feed-nav {
  background: #FFD90F;
  border-bottom: 3px solid #111;
}
body .feed-nav .feed-logo {
  font-weight: 900;
  color: #111;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}
body .feed-nav .nav-link {
  color: #111;
  font-weight: 700;
}
body .feed-nav .nav-icon-btn {
  color: #111;
}
body .feed-nav .nav-icon-btn:hover {
  background: rgba(0,0,0,0.1);
}
body .feed-nav .account-trigger {
  border-color: #111;
  background: #fff;
}
body .feed-nav .account-avatar {
  background: #111;
}
body .feed-nav .nav-cart-badge {
  background: #DC2626;
  color: #fff;
}

/* ─── Mobile Bottom Nav pop art ─── */
body .mobile-bottom-nav {
  background: #FFD90F;
  border-top: 3px solid #111;
}
body .mobile-nav-item {
  color: #111;
}
body .mobile-nav-item.active {
  color: #111;
  font-weight: 800;
}
body .mobile-cart-badge {
  background: #DC2626;
  color: #fff;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .feed-header-comic h1 {
    font-size: 1.5rem;
    text-shadow: 2px 2px 0 #FFD90F;
  }
  .feed-main {
    padding: 12px 8px 100px !important;
  }
  .feed-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .product-card {
    box-shadow: 3px 3px 0 #111;
  }
  .card-body {
    padding: 10px;
  }
  .card-name {
    font-size: 12px;
    -webkit-line-clamp: 2;
    min-height: calc(12px * 1.3 * 2);
  }
  .card-price {
    font-size: 15px;
  }
  .card-compare {
    font-size: 11px;
  }
  .card-add-btn {
    font-size: 12px;
    padding: 10px 6px;
    min-height: 44px;
  }
  .card-cat {
    font-size: 8px;
    padding: 2px 6px;
  }
  .card-price-row {
    margin-bottom: 8px;
  }
  .filter-pill {
    padding: 6px 12px;
    font-size: 12px;
  }
  .mode-pill {
    padding: 5px 10px;
    font-size: 10px;
  }
}

/* ─── Low-stock urgency badge ─── */
/* WHY: flex-basis 100% + parent flex-wrap: wrap forces badge onto its own row
 * above the Add to Cart button. */
.low-stock-badge {
  display: block;
  flex: 0 0 100%;
  background: #DC2626;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border: 2.5px solid #111;
  border-radius: 4px;
  box-shadow: 2px 2px 0 #111;
  margin: 0 0 8px 0;
  text-align: center;
}
