/* ============================================================
   3D TACT - catalogue components
   Added for the database-driven homepage, category pages and
   product detail pages. Uses the same colours, radii and fonts
   as the rest of the site. Nothing here should feel like a new
   design - it only fills the gaps the old static grid did not need.
   ============================================================ */

/* ------------------------------------------------------------
   1. SLIDESHOWS (category cards + product cards)
   ------------------------------------------------------------
   .slide-stack is a box that fills its parent. Each .slide is
   stacked on top of the others; only .is-active is visible.
   ============================================================ */
.slide-stack {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.slide-stack .slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.7s ease;
  display: block;
}

.slide-stack .slide.is-active {
  opacity: 1;
}

/* If JavaScript is off, the first slide stays visible. */
.no-js .slide-stack .slide {
  opacity: 1;
}

/* The existing product-card styles put the image above the card's
   stretched link (for the old lightbox). We want the whole card to
   open the product page, so put the link back on top. */
.product-card .product-card-img {
  z-index: 1;
  cursor: pointer;
}

.product-card .product-card-link::after {
  z-index: 2;
}

.product-card .slide-stack .slide {
  object-fit: contain;
  object-position: center;
}

/* ------------------------------------------------------------
   2. HOMEPAGE CATEGORY CARDS
   ------------------------------------------------------------ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition:
    border-color var(--t),
    transform var(--t),
    box-shadow var(--t);
}

.category-card:hover {
  border-color: var(--yellow);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.category-card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-4);
  overflow: hidden;
}

.category-card-media .slide-stack .slide {
  object-fit: cover;
  object-position: center;
}

.category-card:hover .category-card-media .slide.is-active {
  transform: scale(1.035);
}

.category-card-media .slide {
  transition:
    opacity 0.7s ease,
    transform 0.6s ease;
}

.category-card-count {
  position: absolute;
  left: 0.875rem;
  top: 0.875rem;
  z-index: 2;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(10, 10, 11, 0.78);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.category-card-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-4);
}

.category-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.category-card-body h3 {
  font-size: 1.375rem;
  letter-spacing: -0.02em;
  margin: 0;
}

.category-card-body p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin: 0 0 0.5rem;
}

.category-card-cta {
  margin-top: auto;
  color: var(--yellow);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------
   3. CATEGORY PAGE INTRO + BREADCRUMB
   ------------------------------------------------------------ */
.catalog-navigation-bar {
  position: relative;
  z-index: 10;
  padding: calc(var(--nav-h) + 1.5rem) 0 0.75rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(245, 184, 0, 0.09), transparent 55%),
    var(--bg);
}

.catalog-hero {
  padding: 0 0 1.75rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(245, 184, 0, 0.09), transparent 55%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}

.catalog-hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0.25rem 0 0.5rem;
}

.catalog-hero .label {
  margin-bottom: 0.5rem;
}

.catalog-hero-blurb {
  color: var(--text-muted);
  font-size: 1.0625rem;
  max-width: 680px;
}

.catalog-hero-count {
  margin-top: 0.75rem;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-faint);
  font-size: 0.8125rem;
  margin-bottom: 1.25rem;
}

.catalog-navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 0;
}

.catalog-navigation .breadcrumb {
  margin-bottom: 0;
}

.catalog-navigation-divider {
  align-self: stretch;
  width: 1px;
  min-height: 1.25rem;
  background: var(--border-2);
}

.catalog-products {
  padding: 2rem 0 3rem;
}

.catalog-back {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--t);
}

.catalog-back::after {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 6.25rem;
  height: 2px;
  background: var(--yellow);
  content: "";
}

.catalog-back-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--yellow);
  transition: transform var(--t);
}

.catalog-back-arrow svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.catalog-back-label-mobile {
  display: none;
}

.catalog-back:hover {
  color: var(--yellow);
}

.catalog-back:hover .catalog-back-arrow {
  transform: translateX(-3px);
}

.catalog-back:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

.breadcrumb a {
  color: var(--text-muted);
  transition: color var(--t);
}

.breadcrumb a:hover {
  color: var(--yellow);
}

.breadcrumb span[aria-current="page"] {
  color: var(--text-2);
}

/* Empty state + 404 */
.catalog-empty {
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-md);
}

.catalog-empty a {
  color: var(--yellow);
  text-decoration: underline;
}

.catalog-404 {
  min-height: 60vh;
  padding-top: calc(var(--nav-h) + 5rem);
}

.catalog-404 h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  margin: 0.25rem 0 0.75rem;
}

.catalog-404 p {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

/* Bottom enquiry band on category pages */
.catalog-cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.catalog-cta-inner h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0.25rem 0 0.5rem;
}

.catalog-cta-inner p {
  color: var(--text-muted);
}

.catalog-cta-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------
   4. PRODUCT DETAIL PAGE
   ------------------------------------------------------------ */
.product-detail {
  padding-top: 2rem;
}

.product-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 3.5rem;
  align-items: start;
}

.product-gallery {
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
}

.product-gallery-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  outline: none;
}

.product-gallery-stage.is-clickable {
  cursor: zoom-in;
}

.product-gallery-stage:focus-visible {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px var(--yellow-bg);
}

.product-gallery-stage .slide {
  object-fit: contain;
  object-position: center;
  background: var(--bg-3);
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(10, 10, 11, 0.72);
  border: 1px solid var(--border-2);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--t),
    border-color var(--t),
    color var(--t);
}

.gallery-arrow:hover {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #0a0a0b;
}

.gallery-prev {
  left: 0.75rem;
}

.gallery-next {
  right: 0.75rem;
}

.gallery-counter {
  position: absolute;
  left: 0.875rem;
  bottom: 0.875rem;
  z-index: 3;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(10, 10, 11, 0.78);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.product-gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 0.875rem;
}

.gallery-thumb {
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-3);
  overflow: hidden;
  opacity: 0.65;
  transition:
    opacity var(--t),
    border-color var(--t);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb:hover,
.gallery-thumb.is-active {
  opacity: 1;
  border-color: var(--yellow);
}

.product-detail-category {
  display: inline-block;
  color: var(--yellow);
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.product-detail-body h1 {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
}

.product-detail-short {
  color: var(--text-2);
  font-size: 1.125rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.product-detail-desc {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.75;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.product-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.product-detail-note {
  color: var(--text-faint);
  font-size: 0.8125rem;
  margin-top: 1.25rem;
}

/* ------------------------------------------------------------
   5. RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-detail-grid {
    gap: 2.5rem;
  }
}

@media (max-width: 900px) {
  .product-detail-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .product-gallery {
    position: static;
  }

  .catalog-cta-inner {
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  #cookies {
    scroll-margin-top: calc(var(--nav-h) + 6rem);
  }

  .category-grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .catalog-page {
    padding-top: var(--nav-h);
  }

  .catalog-navigation-bar {
    position: sticky;
    top: var(--nav-h);
    z-index: 98;
    padding: 1.5rem 0 0.375rem;
    background: rgba(10, 10, 11, 0.94);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .catalog-navigation-bar.is-footer-visible {
    visibility: hidden;
    pointer-events: none;
  }

  .catalog-navigation {
    flex-wrap: nowrap;
    gap: 0.625rem;
    min-height: 2.75rem;
  }

  .catalog-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--yellow);
    color: var(--bg);
    box-shadow: 0 3px 12px rgba(245, 184, 0, 0.24);
  }

  .catalog-back::after {
    display: none;
  }

  .catalog-back-arrow {
    display: grid;
    width: 1.5rem;
    height: 1.5rem;
    place-items: center;
    color: var(--bg);
  }

  .catalog-back-label {
    display: none;
  }

  .catalog-back-label-mobile {
    display: none;
  }

  .catalog-navigation .breadcrumb {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 0.35rem;
    min-width: 0;
    overflow: hidden;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .catalog-navigation .breadcrumb > * {
    flex: 0 0 auto;
  }

  .catalog-navigation .breadcrumb [aria-current="page"] {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .catalog-hero {
    padding-top: 1.25rem;
  }

  .category-card-body {
    padding: 0.875rem;
  }

  .category-card-body h3 {
    font-size: 1rem;
    line-height: 1.25;
  }

  .category-card-body p {
    font-size: 0.75rem;
    line-height: 1.45;
  }

  .category-card-count {
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.25rem 0.45rem;
    font-size: 0.5625rem;
  }

  .category-card-cta {
    font-size: 0.6875rem;
  }

  .product-card-body {
    padding: 0.875rem;
  }

  .product-card-body h3 {
    font-size: 0.875rem;
    line-height: 1.3;
  }

  .product-card-body p {
    font-size: 0.75rem;
    line-height: 1.45;
  }

  .product-card-actions {
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  .product-card-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 0.5rem 0.4rem;
    font-size: 0.75rem;
  }

  .product-detail {
    padding-top: 1.5rem;
  }
}

@media (max-width: 640px) {
  .catalog-navigation-divider {
    display: none;
  }

  .catalog-navigation .breadcrumb {
    min-width: 0;
  }

  .catalog-hero {
    padding-bottom: 1.25rem;
  }

  .catalog-products {
    padding-top: 1.25rem;
  }

  .gallery-arrow {
    width: 36px;
    height: 36px;
  }

  .gallery-thumb {
    width: 60px;
    height: 60px;
  }

  .product-detail-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ------------------------------------------------------------
   6. ACCESSIBILITY: reduce motion effects
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .category-card,
  .gallery-arrow,
  .gallery-thumb {
    transition: none !important;
  }

  .slide-stack .slide,
  .category-card-media .slide {
    transition: opacity 0.8s ease-in-out !important;
  }

  .category-card:hover,
  .category-card:hover .category-card-media .slide.is-active {
    transform: none;
  }
}
