/* product.css — City of Rugs Product Detail Page */
/* Imports base design tokens from base.css (loaded before this file) */

/* Global: ensure [hidden] always wins over display rules */
[hidden] {
  display: none !important;
}

/* =============================================
   BREADCRUMB
   ============================================= */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-4) 0 var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-interactive);
}
.breadcrumb a:hover {
  color: var(--color-primary);
}

.breadcrumb__sep {
  opacity: 0.4;
  font-size: 0.75em;
}

.breadcrumb__current {
  color: var(--color-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30ch;
}

/* =============================================
   PRODUCT LAYOUT
   ============================================= */
.product-page {
  padding-bottom: var(--space-24);
}

.product-container {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.product-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-16);
  align-items: start;
}

@media (max-width: 900px) {
  .product-layout {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
}

/* =============================================
   IMAGE GALLERY
   ============================================= */
.gallery {
  position: sticky;
  top: calc(var(--space-16) + var(--space-4));
}

.gallery__main {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  cursor: zoom-in;
}

.gallery__main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease-out), opacity 0.25s ease;
  display: block;
}

.gallery__main img.is-loading {
  opacity: 0;
}

.gallery__main:hover img {
  transform: scale(1.02);
}

.gallery__nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: var(--shadow-md);
  transition: background var(--transition-interactive), opacity var(--transition-interactive);
  opacity: 0.85;
}
.gallery__nav-btn:hover {
  background: var(--color-primary);
  color: white;
  opacity: 1;
}
.gallery__nav-btn--prev { left: var(--space-3); }
.gallery__nav-btn--next { right: var(--space-3); }
.gallery__nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.gallery__counter {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-4);
  background: rgba(0,0,0,0.5);
  color: white;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
}

.gallery__thumbs {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.gallery__thumbs::-webkit-scrollbar { height: 4px; }
.gallery__thumbs::-webkit-scrollbar-track { background: transparent; }
.gallery__thumbs::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.gallery__thumb {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition-interactive), opacity var(--transition-interactive);
  opacity: 0.6;
  scroll-snap-align: start;
}
.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery__thumb:hover {
  opacity: 0.85;
  border-color: var(--color-gold);
}
.gallery__thumb.is-active {
  opacity: 1;
  border-color: var(--color-primary);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}
.lightbox.is-open {
  display: flex;
}
.lightbox__img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}
.lightbox__close {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  color: white;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.1);
  transition: background var(--transition-interactive);
  cursor: pointer;
}
.lightbox__close:hover { background: rgba(255,255,255,0.2); }
.lightbox__close svg { width: 22px; height: 22px; }

/* =============================================
   PRODUCT INFO COLUMN
   ============================================= */
.product-info {
  padding-top: var(--space-2);
}

.product-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold);
  margin-bottom: var(--space-3);
}
.product-badge svg { width: 14px; height: 14px; }

.product-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-heading, var(--color-text));
  line-height: 1.1;
  margin-bottom: var(--space-4);
}

.product-sku {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-5);
}

.product-price {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--space-6);
  line-height: 1;
}

.product-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

/* =============================================
   SPECS TABLE
   ============================================= */
.product-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1) var(--space-4);
  margin-bottom: var(--space-6);
}

@media (max-width: 480px) {
  .product-specs {
    grid-template-columns: 1fr;
  }
}

.spec-item {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
}

.spec-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-1);
}

.spec-value {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 500;
}

/* =============================================
   DESCRIPTION
   ============================================= */
.product-description {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.75;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}
.product-description p {
  max-width: 100%;
}

/* =============================================
   COLOR SWATCHES
   ============================================= */
.product-colors {
  margin-bottom: var(--space-6);
}

.product-colors__label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-3);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.color-swatch {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.color-swatch__dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

/* =============================================
   TAG PILLS
   ============================================= */
.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.tag-pill {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-surface-offset, var(--color-surface));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  text-transform: capitalize;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}
.tag-pill:hover {
  background: var(--color-gold-highlight, #F5ECD5);
  border-color: var(--color-gold);
}

/* =============================================
   AR BUTTON
   ============================================= */
.ar-section {
  margin-bottom: var(--space-6);
}

.ar-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: linear-gradient(135deg, var(--color-primary) 0%, color-mix(in srgb, var(--color-primary) 80%, var(--color-gold)) 100%);
  color: white;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-primary) 40%, transparent);
  width: 100%;
  justify-content: center;
}

.ar-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
}

.ar-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--color-primary) 50%, transparent);
  color: white;
}

.ar-btn:active {
  transform: translateY(0);
}

.ar-btn__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  animation: ar-float 3s ease-in-out infinite;
}

@keyframes ar-float {
  0%, 100% { transform: translateY(0) rotateY(0deg); }
  33%       { transform: translateY(-3px) rotateY(12deg); }
  66%       { transform: translateY(-1px) rotateY(-6deg); }
}

.ar-btn__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.ar-btn__label {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
}

.ar-btn__sub {
  font-size: var(--text-xs);
  opacity: 0.78;
  font-weight: 400;
}

/* AR fallback message for non-iOS */
.ar-fallback {
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.5;
}
.ar-fallback svg {
  display: inline-block;
  margin: 0 auto var(--space-2);
  color: var(--color-gold);
}
.ar-fallback strong {
  display: block;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

/* =============================================
   CTA BUTTONS
   ============================================= */
.product-cta {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.btn-contact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive), border-color var(--transition-interactive), transform 0.2s var(--ease-out);
  text-align: center;
}
.btn-contact:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}

.btn-call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--transition-interactive), color var(--transition-interactive);
  text-align: center;
}
.btn-call:hover {
  border-color: var(--color-gold);
  color: var(--color-gold);
}

/* =============================================
   TRUST BADGES
   ============================================= */
.trust-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
}

.trust-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.trust-badge svg {
  width: 16px;
  height: 16px;
  color: var(--color-gold);
  flex-shrink: 0;
}

/* =============================================
   RELATED RUGS
   ============================================= */
.related-section {
  padding-top: var(--space-20);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-16);
}

.related-header {
  margin-bottom: var(--space-10);
  text-align: center;
}

.related-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-gold);
  margin-bottom: var(--space-2);
}

.related-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-heading, var(--color-text));
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

@media (max-width: 1024px) {
  .related-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .related-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .related-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
}

.related-card {
  text-decoration: none;
  color: inherit;
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.25s var(--ease-out);
}
.related-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-gold);
}

.related-card__img-wrap {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--color-surface-offset, var(--color-surface));
}
.related-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease-out);
}
.related-card:hover .related-card__img-wrap img {
  transform: scale(1.05);
}

.related-card__body {
  padding: var(--space-4);
}

.related-card__name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.25;
  margin-bottom: var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-card__meta {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.related-card__price {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-primary);
}

/* =============================================
   LOADING / ERROR STATES
   ============================================= */
.product-loading {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  color: var(--color-text-muted);
  font-family: var(--font-body);
}


.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.product-error {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  padding: var(--space-8);
}


.product-error__icon {
  font-size: 3rem;
  opacity: 0.5;
}

.product-error h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text);
}

.product-error p {
  font-family: var(--font-body);
  color: var(--color-text-muted);
  max-width: 40ch;
  margin: 0 auto;
}

.product-error a {
  color: var(--color-primary);
  text-decoration: underline;
}

/* =============================================
   SWIPE SUPPORT (touch devices)
   ============================================= */
.gallery__main {
  touch-action: pan-y;
  user-select: none;
}

/* =============================================
   SKELETON LOADER
   ============================================= */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-offset, var(--color-divider)) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-gallery {
  aspect-ratio: 1/1;
  border-radius: var(--radius-lg);
  width: 100%;
}
.skeleton-text {
  height: 1.2em;
  margin-bottom: 0.75em;
  border-radius: var(--radius-sm);
}
.skeleton-text--lg { height: 2em; }
.skeleton-text--sm { height: 0.9em; width: 60%; }

/* =============================================
   MOBILE ADJUSTMENTS
   ============================================= */
@media (max-width: 600px) {
  .product-container {
    padding: 0 var(--space-4);
  }
  .gallery {
    position: static;
  }
  .product-name {
    font-size: var(--text-xl);
  }
  .product-price {
    font-size: var(--text-lg);
  }
}
