/* ==========================================================================
   1. Filter System
   ========================================================================== */

.products-filter-btn {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.72);
  cursor: pointer;
  transition:
    background 160ms ease,
    transform 180ms ease;
}
.products-filter-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
}
.products-filter-btn:active {
  transform: scale(0.96);
}
[data-theme="dark"] .products-filter-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
}

.products-filter-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.72;
}
[data-theme="dark"] .products-filter-icon {
  filter: brightness(0) invert(1);
  opacity: 0.7;
}

.products-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1rem;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: transparent;
  color: rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.filter-pill:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.88);
  border-color: rgba(0, 0, 0, 0.24);
  transform: scale(1.04);
}
.filter-pill:active {
  transform: scale(0.95);
}
.filter-pill.is-active {
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  border-color: transparent;
}
.filter-pill:focus-visible {
  outline: 2px solid rgba(0, 100, 120, 0.6);
  outline-offset: 2px;
}
[data-theme="dark"] .filter-pill {
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.55);
}
[data-theme="dark"] .filter-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="dark"] .filter-pill.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: rgba(0, 0, 0, 0.88);
}

/* ==========================================================================
   2. Grid Layouts
   ========================================================================== */

.products-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
}

.related-grid {
  grid-template-columns: repeat(4, 1fr);
}

.no-products {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(0, 0, 0, 0.45);
  padding: 3rem 0;
  font-size: 1rem;
}

/* ==========================================================================
   3. Product Cards
   ========================================================================== */

.product-card {
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.025);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition:
    box-shadow 200ms ease,
    transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.product-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
  transform: translateY(-3px) scale(1.01);
}
.product-card:active {
  transform: scale(0.97);
}
.product-card:focus-visible {
  outline: 2px solid rgba(0, 100, 120, 0.6);
  outline-offset: 2px;
}
[data-theme="dark"] .product-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .product-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.product-card-img-wrap {
  aspect-ratio: 1;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.03);
}
.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 300ms ease;
}
.product-card:hover .product-card-img {
  transform: scale(1.06);
}

.product-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.product-card-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.82);
  line-height: 1.3;
  margin: 0;
}
[data-theme="dark"] .product-card-name {
  color: rgba(255, 255, 255, 0.88);
}

.product-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  flex-wrap: wrap;
  /*
    Pushes the footer to the bottom of the card body regardless of how
    many lines the product name takes, so prices align across all cards
    in the same row.
  */
  margin-top: auto;
}

.product-card-size {
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.42);
}
[data-theme="dark"] .product-card-size {
  color: rgba(255, 255, 255, 0.38);
}

.product-card-prices {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.price-regular {
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.35);
  text-decoration: line-through;
}

.price-special {
  font-size: 0.8125rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.88);
}
[data-theme="dark"] .price-special {
  color: rgba(255, 255, 255, 0.88);
}

/* ==========================================================================
   4. Product Detail View
   ========================================================================== */

.product-detail-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: stretch;
  margin-bottom: 2.5rem;
}

.detail-image-col {
  border-radius: 24px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.06);
  min-height: 400px;
}
[data-theme="dark"] .detail-image-col {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.09);
}

.detail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.detail-info-col {
  display: flex;
  flex-direction: column;
}

.detail-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.75rem;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.025);
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow-y: auto;
}
[data-theme="dark"] .detail-box {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.09);
}

.detail-name {
  font-family: "Satoshi", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.88);
  line-height: 1.2;
  margin: 0;
}
[data-theme="dark"] .detail-name {
  color: rgba(255, 255, 255, 0.92);
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  padding-top: 0.15rem;
  min-width: 68px;
}
[data-theme="dark"] .detail-label {
  color: rgba(255, 255, 255, 0.38);
}

.detail-value {
  font-size: 0.9375rem;
  color: rgba(0, 0, 0, 0.78);
}
[data-theme="dark"] .detail-value {
  color: rgba(255, 255, 255, 0.78);
}

.detail-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.category-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.62);
  text-decoration: none;
  transition:
    background 150ms ease,
    color 150ms ease;
}
.category-tag:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.88);
}
[data-theme="dark"] .category-tag {
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
}
[data-theme="dark"] .category-tag:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

.detail-description {
  font-size: 0.9rem;
  line-height: 1.65;
  color: rgba(0, 0, 0, 0.62);
  margin: 0;
  flex: 1;
}
[data-theme="dark"] .detail-description {
  color: rgba(255, 255, 255, 0.6);
}

.detail-pricing {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .detail-pricing {
  border-color: rgba(255, 255, 255, 0.1);
}

.price-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price-line-label {
  font-size: 0.8125rem;
  color: rgba(0, 0, 0, 0.48);
}
[data-theme="dark"] .price-line-label {
  color: rgba(255, 255, 255, 0.42);
}

.price-line-value {
  font-size: 0.9375rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.88);
}
[data-theme="dark"] .price-line-value {
  color: rgba(255, 255, 255, 0.88);
}

.price-line-regular {
  font-weight: 400;
  color: rgba(0, 0, 0, 0.35);
  text-decoration: line-through;
}
[data-theme="dark"] .price-line-regular {
  color: rgba(255, 255, 255, 0.3);
}

.detail-section {
  margin-bottom: 2.5rem;
}

.detail-section-title {
  font-family: "Satoshi", sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.82);
  margin: 0 0 1rem;
}
[data-theme="dark"] .detail-section-title {
  color: rgba(255, 255, 255, 0.85);
}

.ingredients-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}
.ingredients-list li {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  color: rgba(0, 0, 0, 0.65);
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .ingredients-list li {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
}

/* ==========================================================================
   5. Buttons & CTA
   ========================================================================== */

.more-info-btn {
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 1.5rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.88);
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition:
    background 160ms ease,
    transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.more-info-btn:hover {
  background: rgba(0, 0, 0, 1);
  transform: scale(1.02);
}
.more-info-btn:active {
  transform: scale(0.97);
}
.more-info-btn:focus-visible {
  outline: 2px solid rgba(0, 100, 120, 0.6);
  outline-offset: 2px;
}
[data-theme="dark"] .more-info-btn {
  background: rgba(255, 255, 255, 0.92);
  color: rgba(0, 0, 0, 0.88);
}
[data-theme="dark"] .more-info-btn:hover {
  background: #fff;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  background: rgba(0, 0, 0, 0.88);
  color: rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition:
    background 160ms ease,
    transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cta-btn:hover {
  background: rgba(0, 0, 0, 1);
  transform: scale(1.03);
}
.cta-btn:active {
  transform: scale(0.97);
}
[data-theme="dark"] .cta-btn {
  background: rgba(255, 255, 255, 0.92);
  color: rgba(0, 0, 0, 0.88);
}
[data-theme="dark"] .cta-btn:hover {
  background: #fff;
}

/* ==========================================================================
   6. Modals (Local Overrides)
   ========================================================================== */

[data-theme="dark"] .modal-box {
  background: rgba(22, 22, 26, 0.88);
  border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .modal-close-btn img {
  filter: brightness(0) invert(1);
}
[data-theme="dark"] .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ==========================================================================
   7. Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1200px) {
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 960px) {
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .related-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .product-detail-container {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .products-filter-btn {
    display: inline-flex;
  }
  .products-filter {
    display: none;
  }
  .products-filter.is-open {
    display: flex;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  /*
    Related products switch from a 2×2 grid to a horizontal scroll strip.
    scroll-snap-type gives native swipe-and-snap behaviour; scrollbar is
    hidden visually but remains fully functional for pointer users.
    Each card is sized so ~2 cards are visible, with the third peeking
    in to signal there is more content to swipe.
  */
  .related-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.75rem;
    /* Prevent cards from being clipped at the container edge */
    padding-bottom: 0.25rem;
  }
  .related-grid::-webkit-scrollbar {
    display: none;
  }
  .related-grid .product-card {
    flex: 0 0 calc(50% - 0.375rem);
    scroll-snap-align: start;
  }

  .product-detail-container {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .detail-image-col {
    min-height: 300px;
  }

  .modal-overlay {
    padding: calc(70px + 1.25rem) 0.75rem 0.75rem;
  }
  .modal-box {
    border-radius: 20px;
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: 1fr;
  }
  /*
    On small phones, widen each related card so ~1.5 are visible —
    the half-card peek is a strong affordance for horizontal swiping.
  */
  .related-grid .product-card {
    flex: 0 0 65%;
  }
}

/* ==========================================================================
   8. Accessibility
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
