/* STEP 19B — Premium homepage and catalog, scoped away from product detail. */

body[data-page="home"],
body[data-page="products"] {
  --catalog-ink: #142033;
  --catalog-muted: #647083;
  --catalog-line: #dde2e8;
  --catalog-surface: #ffffff;
  --catalog-soft: #f4f5f3;
  --catalog-accent: #a97822;
}

body[data-page="home"] .section-new,
body[data-page="home"] .section-featured,
body[data-page="products"] .section-products {
  width: min(100% - 2rem, 92rem);
  max-width: 92rem;
  margin-inline: auto;
}

body[data-page="home"] .product-grid,
body[data-page="products"] .product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.6rem, 2vw, 1.25rem);
  align-items: stretch;
  overflow: visible;
}

body[data-page="home"] .product-card,
body[data-page="products"] .product-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--catalog-line);
  border-radius: 0.9rem;
  background: var(--catalog-surface);
  color: var(--catalog-ink);
  box-shadow: 0 0.45rem 1.4rem rgba(16, 29, 48, 0.055);
  opacity: 1;
  transform: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

body[data-page="home"] .product-card:hover,
body[data-page="home"] .product-card:focus-within,
body[data-page="products"] .product-card:hover,
body[data-page="products"] .product-card:focus-within {
  border-color: #c9d0d9;
  box-shadow: 0 0.9rem 2.2rem rgba(16, 29, 48, 0.09);
  transform: translateY(-2px);
}

body[data-page="home"] .product-card-media-link,
body[data-page="products"] .product-card-media-link {
  display: block;
  min-width: 0;
  color: inherit;
}

body[data-page="home"] .product-media,
body[data-page="products"] .product-media {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  padding: 0;
  background: var(--catalog-soft);
}

body[data-page="home"] .product-image,
body[data-page="products"] .product-image {
  width: 100%;
  height: 100%;
  padding: clamp(0.35rem, 1.4vw, 0.8rem);
  object-fit: contain;
  object-position: center;
  background: var(--catalog-soft);
  transition: transform 260ms ease;
}

body[data-page="home"] .product-card:hover .product-image,
body[data-page="products"] .product-card:hover .product-image {
  transform: scale(1.025);
}

body[data-page="home"] .product-card-image-fallback,
body[data-page="products"] .product-card-image-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
  color: var(--catalog-muted);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
  background: var(--catalog-soft);
}

body[data-page="home"] .product-card-image-fallback[hidden],
body[data-page="products"] .product-card-image-fallback[hidden] {
  display: none !important;
}

body[data-page="home"] .brand-logo-card,
body[data-page="products"] .brand-logo-card {
  position: absolute;
  inset: 0.55rem auto auto 0.55rem;
  width: clamp(2rem, 6vw, 3rem);
  max-height: 1.25rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid rgba(20, 32, 51, 0.08);
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.88);
  object-fit: contain;
}

body[data-page="home"] .product-body,
body[data-page="products"] .product-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.42rem;
  padding: clamp(0.65rem, 1.6vw, 1rem);
}

body[data-page="home"] .product-brand,
body[data-page="products"] .product-brand {
  min-width: 0;
  overflow: hidden;
  margin: 0;
  color: var(--catalog-accent);
  font-family: "Oswald", sans-serif;
  font-size: clamp(0.64rem, 1.9vw, 0.74rem);
  font-weight: 600;
  letter-spacing: 0.11em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

body[data-page="home"] .product-name,
body[data-page="products"] .product-name {
  display: -webkit-box;
  min-height: 2.65em;
  overflow: hidden;
  margin: 0;
  color: var(--catalog-ink) !important;
  font-size: clamp(0.86rem, 2.8vw, 1.05rem) !important;
  font-weight: 600 !important;
  line-height: 1.32 !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body[data-page="home"] .product-card-title-link,
body[data-page="products"] .product-card-title-link {
  color: inherit;
}

body[data-page="home"] .product-card-model,
body[data-page="products"] .product-card-model {
  overflow: hidden;
  margin: -0.12rem 0 0;
  color: var(--catalog-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-page="home"] .product-meta,
body[data-page="products"] .product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
}

body[data-page="home"] .product-meta span,
body[data-page="products"] .product-meta span {
  min-height: 1.45rem;
  padding: 0.15rem 0.42rem;
  border: 1px solid #e2e5e9;
  border-radius: 999px;
  background: #f8f9fa;
  color: #4d596b;
  font-size: clamp(0.63rem, 1.9vw, 0.75rem);
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
}

body[data-page="home"] .product-price,
body[data-page="products"] .product-price {
  margin: auto 0 0;
  padding-top: 0.2rem;
  color: var(--catalog-ink) !important;
  font-family: "Oswald", sans-serif;
  font-size: clamp(1.12rem, 4vw, 1.45rem) !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

body[data-page="home"] .product-status-badge,
body[data-page="products"] .product-status-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 1.4rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #17734b;
  font-size: clamp(0.63rem, 1.9vw, 0.74rem);
  font-weight: 600;
}

body[data-page="home"] .product-status-badge::before,
body[data-page="products"] .product-status-badge::before {
  width: 0.42rem;
  height: 0.42rem;
}

body[data-page="home"] .product-card-actions,
body[data-page="products"] .product-card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

body[data-page="home"] .product-card-cta,
body[data-page="home"] .product-card-cart-btn,
body[data-page="products"] .product-card-cta,
body[data-page="products"] .product-card-cart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 2.25rem;
  margin: 0;
  padding: 0.4rem 0.45rem;
  border: 1px solid #ccd2d9;
  border-radius: 0.45rem;
  background: #fff;
  color: var(--catalog-ink) !important;
  font-family: "Kanit", sans-serif;
  font-size: clamp(0.66rem, 2vw, 0.78rem);
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}

body[data-page="home"] .product-card-cart-btn,
body[data-page="products"] .product-card-cart-btn {
  border-color: var(--catalog-ink);
  background: var(--catalog-ink);
  color: #fff !important;
}

body[data-page="home"] .product-card-cart-btn:disabled,
body[data-page="products"] .product-card-cart-btn:disabled {
  border-color: #d9dde2;
  background: #e9ebee;
  color: #747e8c !important;
  cursor: not-allowed;
}

body[data-page="home"] .product-card a:focus-visible,
body[data-page="home"] .product-card button:focus-visible,
body[data-page="products"] .product-card a:focus-visible,
body[data-page="products"] .product-card button:focus-visible {
  outline: 3px solid rgba(169, 120, 34, 0.42);
  outline-offset: 2px;
}

body[data-page="home"] .product-card.is-sold .product-media::after,
body[data-page="home"] .product-card.is-reserved .product-media::after,
body[data-page="products"] .product-card.is-sold .product-media::after,
body[data-page="products"] .product-card.is-reserved .product-media::after {
  position: absolute;
  inset: auto 0.55rem 0.55rem auto;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(20, 32, 51, 0.9);
  color: #fff;
  font: 600 0.66rem/1 "Oswald", sans-serif;
  letter-spacing: 0.08em;
}

body[data-page="home"] .product-card.is-sold .product-media::after,
body[data-page="products"] .product-card.is-sold .product-media::after {
  content: "SOLD";
}

body[data-page="home"] .product-card.is-reserved .product-media::after,
body[data-page="products"] .product-card.is-reserved .product-media::after {
  content: "RESERVED";
}

body[data-page="home"] .catalog-state,
body[data-page="products"] .catalog-state {
  grid-column: 1 / -1;
}

body[data-page="products"] .section-products {
  padding-inline: 0;
}

body[data-page="products"] .catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--catalog-line);
  border-radius: 0.8rem;
  background: #fff;
}

body[data-page="products"] .search-field,
body[data-page="products"] .sort-field {
  display: grid;
  gap: 0.38rem;
}

body[data-page="products"] .search-field input,
body[data-page="products"] .sort-field select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #cfd5dc;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--catalog-ink);
  font: 400 0.92rem/1.3 "Kanit", sans-serif;
}

body[data-page="products"] .catalog-layout {
  gap: 1rem;
}

body[data-page="products"] .filter-panel {
  border: 1px solid var(--catalog-line);
  border-radius: 0.8rem;
  box-shadow: none;
}

body[data-page="products"] .products-empty {
  border: 1px solid var(--catalog-line);
  background: #fff;
}

@media (min-width: 540px) {
  body[data-page="home"] .product-card-actions,
  body[data-page="products"] .product-card-actions {
    grid-template-columns: 0.85fr 1.15fr;
  }
}

@media (min-width: 768px) {
  body[data-page="home"] .product-grid,
  body[data-page="products"] .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body[data-page="products"] .catalog-toolbar {
    grid-template-columns: minmax(18rem, 1fr) minmax(11rem, 14rem) auto;
    align-items: end;
  }
}

@media (min-width: 960px) {
  body[data-page="products"] .catalog-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
    gap: 1.25rem;
  }

  body[data-page="products"] .catalog-toolbar {
    grid-template-columns: minmax(18rem, 1fr) minmax(11rem, 14rem);
  }
}

@media (min-width: 1200px) {
  body[data-page="home"] .product-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  body[data-page="products"] .product-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 539px) {
  body[data-page="home"] .product-card-cta,
  body[data-page="home"] .product-card-cart-btn,
  body[data-page="products"] .product-card-cta,
  body[data-page="products"] .product-card-cart-btn {
    min-height: 2.1rem;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="home"] .product-card,
  body[data-page="home"] .product-image,
  body[data-page="products"] .product-card,
  body[data-page="products"] .product-image {
    transition: none;
  }
}
