/* shop.css -- the listing grid shared by the homepage shop section and
   browse.html: the filter sidebar beside it, the grid columns, and the
   product card from js/shop-card.js. Linked by index.html (after home.css)
   and browse.html (after main.compiled.css), so both pages get exactly the
   same card. Plain CSS so it reads the same under either stylesheet; the
   card sets every property it depends on rather than inheriting them. */

/* ---------- Layout: sidebar + results ---------- */

.shop.shop-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.shop.shop-page .shop-sidebar {
  display: none;
}

/* 1024px and wider: filters in a sidebar. Below that they're in the
   floating search panel (js/masthead.js). */
@media (min-width: 1024px) {
  .shop.shop-page {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .shop.shop-page .shop-sidebar {
    display: block;
    position: sticky;
    top: 68px;
    align-self: start;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 0.5rem;
    color: var(--t1);
  }
}

.shop-sidebar h2 {
  margin: 0 0 0.75rem;
  color: inherit;
  font-family: var(--font-heading);
  font-size: 1.17em;
  font-weight: 700;
  line-height: 1.3;
}

/* ---------- Grid columns ---------- */

/* Two across on every phone and tablet width, four from 1024px. */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 1rem;
}

@media (max-width: 639px) {
  .shop-grid {
    gap: 12px;
  }
}

@media (min-width: 1024px) {
  .shop-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Past 1366px the page widens (--container-max): add columns at about the
   1366px card width instead of stretching four cards. */
@media (min-width: 1367px) {
  .shop-grid {
    grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  }
}

/* ---------- The card ----------
   Light in dark mode too, as the homepage has always had it. */

.shop-grid > .product {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 16px;
  background: var(--surface);
  color: var(--t1);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  transition: transform var(--hover-slow) var(--hover-ease), border-color var(--hover-fast) var(--hover-ease);
}

/* The deeper hover shadow is .product::before (_product-card.scss), faded in. */
.shop-grid > .product:hover {
  transform: translateY(-5px);
  border-color: var(--line-strong);
}

/* The gap under the photo is on its wrapper, which clips the hover zoom. */
.shop-grid > .product .product-media {
  margin-bottom: 12px;
}

.shop-grid > .product img,
.shop-grid > .product .product-image-placeholder {
  display: block;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  margin: 0;
  border-radius: 8px;
}

.shop-grid > .product img {
  object-fit: cover;
}

.shop-grid > .product .product-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--raised);
  color: var(--t3);
  font-size: 2rem;
}

.shop-grid > .product h3 {
  flex-shrink: 0;
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  color: var(--t1);
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: normal;
  text-align: left;
}

.shop-grid > .product .meta {
  flex-shrink: 0;
  width: 100%;
  margin: 0 0 16px;
  padding: 0;
  color: var(--t3);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.9rem;
  line-height: normal;
  text-align: left;
}

.shop-grid > .product .btn {
  display: block;
  flex-shrink: 0;
  align-self: stretch;
  box-sizing: border-box;
  width: 100%;
  margin-top: auto;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 0.5rem;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: normal;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--hover-fast) var(--hover-ease), transform var(--hover-fast) var(--hover-ease), box-shadow var(--hover-fast) var(--hover-ease);
}

.shop-grid > .product .btn:hover,
.shop-grid > .product:hover .btn {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Phones and small tablets: one-line titles ending in "...", like a
   fashion retailer's grid. Phones: tighter padding and type so two cards
   fit side by side at 360px with photo, title and price still readable. */
@media (max-width: 767px) {
  .shop-grid > .product h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 639px) {
  .shop-grid > .product {
    padding: 10px;
  }

  .shop-grid > .product .product-media {
    margin-bottom: 10px;
  }

  .shop-grid > .product h3 {
    margin-bottom: 4px;
    font-size: 0.92rem;
  }

  .shop-grid > .product .meta {
    margin-bottom: 10px;
    font-size: 0.85rem;
  }

  .shop-grid > .product .btn {
    padding: 0.55rem 0.5rem;
    font-size: 0.85rem;
  }
}

/* ---------- Loading / empty messages ---------- */

.shop-grid > .results-empty,
.shop-grid > .results-loading,
.shop-grid > .carousel-loading {
  grid-column: 1 / -1;
  margin: 0;
  padding: 3rem 1rem;
  color: var(--t3);
  font-size: 1rem;
  text-align: center;
}

/* Text links in those messages ("Browse all listings", "Browse All"):
   the site's rust, dark enough to read on the light page and lighter on
   the dark one. */
.shop-grid > .results-empty a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}

.shop-grid > .results-empty a:hover {
  color: var(--accent-hover);
}

.shop-grid > .results-empty a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Loading skeletons ----------
   Placeholder cards while listings load (.product-skeleton: the card's own
   box, so it sizes like a real card) and, on the homepage, blank Top
   Sellers pills (.slide-skeleton). A gentle opacity pulse -- compositor
   only, no repaints. .skeleton-label is the "Loading..." text for screen
   readers. Same rules in Styles/shop.css and home.css. */
.skeleton-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.product-skeleton {
  pointer-events: none;
}

.product-skeleton .sk,
.slide-skeleton {
  display: block;
  border-radius: 6px;
  background: var(--raised);
  animation: skeleton-pulse 1.1s ease-in-out infinite alternate;
}

.product-skeleton .sk-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 12px;
  border-radius: 8px;
}

.product-skeleton .sk-line {
  width: 80%;
  height: 14px;
  margin-bottom: 8px;
}

.product-skeleton .sk-short {
  width: 40%;
  margin-bottom: 16px;
}

.product-skeleton .sk-btn {
  width: 100%;
  height: 40px;
  margin-top: auto;
  border-radius: 0.5rem;
}

@keyframes skeleton-pulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-skeleton .sk,
  .slide-skeleton {
    animation: none;
  }
  .shop-grid > .product,
  .shop-grid > .product .btn {
    transition: none;
  }
}

/* "Show more" under the browse grid (js/browse.js), only when there are
   more results than shown. */
.results-more {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0 0.5rem;
}

.results-more[hidden] {
  display: none;
}

/* Heading for the results (the cards are h3s), visible to screen readers only. */
.results-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
