/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero {
  padding: var(--space-xl) 0;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.hero-centered {
  text-align: center;
}

.hero-centered .search-form {
  margin: 0 auto;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 400;
  margin: 0 0 var(--space-sm);
  color: var(--color-text);
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-lg);
}

/* ==========================================================================
   Search Form (Hero)
   ========================================================================== */

.search-form {
  max-width: 600px;
}

.search-input-wrapper {
  display: flex;
  border: 1px solid var(--color-border-dark);
  border-radius: 3px;
  overflow: hidden;
}

.search-input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(99, 111, 233, 0.15);
}

.search-input {
  flex: 1;
  background: var(--color-bg);
  border: none;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--color-text);
  outline: none;
  min-width: 0;
}

.search-input::placeholder {
  color: var(--color-text-tertiary);
}

.search-button {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: none;
  border-left: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-sans);
  font-size: 1rem;
  cursor: pointer;
}

.search-button:hover {
  background: var(--color-border);
}

/* ==========================================================================
   Results Section
   ========================================================================== */

.results-section {
  padding: var(--space-lg) 0 var(--space-2xl);
}

.results-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 var(--space-lg);
  color: var(--color-text);
}

.results-count {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-left: var(--space-sm);
}

/* Products List View */
.products-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--color-border);
}

.product-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}

.product-row:hover {
  text-decoration: none;
  background: var(--color-bg-secondary);
  margin: 0 calc(-1 * var(--space-md));
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

.product-row-image {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-row-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.product-row-info {
  flex: 1;
  min-width: 0;
}

.product-row-title {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
  margin: 0 0 var(--space-xs);
  color: var(--color-link);
}

.product-row:hover .product-row-title {
  color: var(--color-link-hover);
}

.product-row-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.product-rating {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.review-count {
  color: var(--color-text-tertiary);
}

.product-row-price {
  font-size: 1.25rem;
  color: var(--color-price);
  flex-shrink: 0;
  text-align: right;
  min-width: 100px;
}

.price-unavailable {
  color: var(--color-text-tertiary);
  font-size: 0.9rem;
}

/* No Results */
.no-results {
  padding: var(--space-2xl) 0;
  text-align: center;
}

.no-results h2 {
  margin: 0 0 var(--space-sm);
  font-size: 1.25rem;
  font-weight: 400;
}

.no-results p {
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm);
}

.no-results-cta {
  margin-top: var(--space-lg) !important;
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-left: 3px solid var(--color-link);
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.5;
}

.no-results-link {
  color: var(--color-link);
  font-weight: 500;
  text-decoration: underline;
}

.no-results-link:hover {
  color: var(--color-link-hover);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.pagination-link {
  color: var(--color-link);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: 3px;
}

.pagination-link:hover {
  background: var(--color-bg-secondary);
  text-decoration: none;
}

.pagination-current {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   Product Detail Page
   ========================================================================== */

.product-detail {
  padding: var(--space-lg) 0 var(--space-2xl);
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
  color: var(--color-text-secondary);
}

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

.breadcrumb-separator {
  margin: 0 var(--space-xs);
  color: var(--color-text-tertiary);
}

.breadcrumb-current {
  color: var(--color-text-secondary);
}

/* Product Layout */
.product-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

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

/* ==========================================================================
   CSS-Only Product Gallery (Spectre.css-inspired tricks)
   Uses radio buttons + :checked selectors for zero-JS image switching
   ========================================================================== */

/* Product Gallery Container */
.product-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.image-placeholder {
  color: var(--color-text-tertiary);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
}

/* Hide radio buttons visually but keep them functional */
.gallery-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* Main gallery viewport */
.gallery-main {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  overflow: hidden;
}

.gallery-viewport {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Individual image figures - all stacked, only active one visible */
.gallery-figure {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

/* Zoom container magic */
.zoom-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gallery-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: center center;
}

/* Zoom lens effect (visible on hover) */
.zoom-lens {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 120px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    transparent 0%,
    rgba(0, 0, 0, 0.02) 100%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* Hover zoom effect - pure CSS magnification */
.zoom-container:hover .gallery-image {
  transform: scale(1.8);
}

.zoom-container:hover .zoom-lens {
  opacity: 1;
}

/* Make image follow mouse on hover using CSS custom properties */
.zoom-container:hover {
  --zoom-active: 1;
}


/* Thumbnail strip */
.gallery-thumbnails {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-xs) 0;
  /* Hide scrollbar but keep functionality */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.gallery-thumbnails::-webkit-scrollbar {
  height: 4px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
  background: transparent;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.thumbnail-label {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border: 2px solid var(--color-border);
  padding: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  background: var(--color-bg);
}

.thumbnail-label:hover {
  border-color: var(--color-text-tertiary);
  transform: translateY(-2px);
}

.thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   THE CSS MAGIC: Radio button state management
   When a radio is checked, we target its corresponding elements using
   sibling selectors - this is the core Spectre.css trick!
   ========================================================================== */

/* Image 0 (first image) */
.gallery-radio#gallery-img-0:checked ~ .gallery-main .gallery-figure[data-index="0"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.gallery-radio#gallery-img-0:checked ~ .gallery-thumbnails .thumbnail-label[data-index="0"] {
  border-color: var(--color-link);
  box-shadow: 0 0 0 1px var(--color-link);
}

/* Image 1 */
.gallery-radio#gallery-img-1:checked ~ .gallery-main .gallery-figure[data-index="1"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.gallery-radio#gallery-img-1:checked ~ .gallery-thumbnails .thumbnail-label[data-index="1"] {
  border-color: var(--color-link);
  box-shadow: 0 0 0 1px var(--color-link);
}

/* Image 2 */
.gallery-radio#gallery-img-2:checked ~ .gallery-main .gallery-figure[data-index="2"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.gallery-radio#gallery-img-2:checked ~ .gallery-thumbnails .thumbnail-label[data-index="2"] {
  border-color: var(--color-link);
  box-shadow: 0 0 0 1px var(--color-link);
}

/* Image 3 */
.gallery-radio#gallery-img-3:checked ~ .gallery-main .gallery-figure[data-index="3"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.gallery-radio#gallery-img-3:checked ~ .gallery-thumbnails .thumbnail-label[data-index="3"] {
  border-color: var(--color-link);
  box-shadow: 0 0 0 1px var(--color-link);
}

/* Image 4 */
.gallery-radio#gallery-img-4:checked ~ .gallery-main .gallery-figure[data-index="4"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.gallery-radio#gallery-img-4:checked ~ .gallery-thumbnails .thumbnail-label[data-index="4"] {
  border-color: var(--color-link);
  box-shadow: 0 0 0 1px var(--color-link);
}

/* Image 5 */
.gallery-radio#gallery-img-5:checked ~ .gallery-main .gallery-figure[data-index="5"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}
.gallery-radio#gallery-img-5:checked ~ .gallery-thumbnails .thumbnail-label[data-index="5"] {
  border-color: var(--color-link);
  box-shadow: 0 0 0 1px var(--color-link);
}

/* ==========================================================================
   Advanced CSS trick: Keyboard navigation support via :focus-visible
   ========================================================================== */
.gallery-radio:focus-visible ~ .gallery-main {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

/* ==========================================================================
   Responsive gallery adjustments
   ========================================================================== */
@media (max-width: 768px) {
  .gallery-main {
    aspect-ratio: 4/3;
  }

  .thumbnail-label {
    width: 48px;
    height: 48px;
  }

  /* Disable zoom on touch devices - it's not useful */
  .zoom-container:hover .gallery-image {
    transform: none;
  }
}

/* ==========================================================================
   Legacy fallback styles (keep for non-gallery pages)
   ========================================================================== */
.main-image-wrapper {
  aspect-ratio: 1;
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.main-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.thumbnail-gallery {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
}

.thumbnail-wrapper {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 1px solid var(--color-border);
  padding: 2px;
  cursor: pointer;
}

.thumbnail-wrapper.active,
.thumbnail-wrapper:hover {
  border-color: var(--color-link);
}

.thumbnail-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Product Details */
.product-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.product-brand {
  font-size: 0.9rem;
  color: var(--color-link);
  margin: 0;
}

.product-detail .product-title {
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.3;
  margin: 0;
  color: var(--color-text);
}

.product-rating-detail {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.rating-number {
  color: var(--color-link);
}

.review-count-detail {
  color: var(--color-link);
}

/* Price Section */
.price-section {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.current-price {
  font-size: 1.75rem;
  color: var(--color-price);
}

.original-price {
  font-size: 0.9rem;
  color: var(--color-text-tertiary);
  text-decoration: line-through;
}

/* Buy Section */
.buy-section {
  padding-top: var(--space-sm);
}

.buy-button {
  display: inline-block;
  background: var(--color-link);
  border: 1px solid var(--color-link);
  color: white;
  text-decoration: none;
  padding: var(--space-sm) var(--space-xl);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 3px;
}

.buy-button:hover {
  background: #005f73;
  border-color: #005f73;
  text-decoration: none;
  color: white;
}

.buy-icon {
  display: none;
}

.unavailable-section {
  padding: var(--space-md);
  background: #fff5f5;
  border: 1px solid #feb2b2;
}

.unavailable-message {
  margin: 0;
  color: var(--color-error);
}

/* Amazon Link */
.amazon-link-section {
  padding-top: var(--space-sm);
}

.amazon-link {
  color: var(--color-link);
}

.external-icon {
  font-size: 0.75rem;
}

/* Seller Info */
.seller-info {
  color: var(--color-text-secondary);
}

.seller-label {
  color: var(--color-text-secondary);
}

/* Feature Section */
.feature-section {
  padding-top: var(--space-md);
}

.feature-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 var(--space-sm);
}

.feature-list {
  margin: 0;
  padding-left: var(--space-lg);
}

.feature-list li {
  margin-bottom: var(--space-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* Categories */
.categories-section {
  padding-top: var(--space-md);
}

.categories-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 var(--space-xs);
  color: var(--color-text-secondary);
}

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.category-tag {
  font-size: 0.85rem;
  padding: 2px var(--space-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

/* Product Description Section */
.product-description-section,
.product-specs-section {
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-md);
}

.product-description-section h2,
.product-specs-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--space-md);
}

.description-content {
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.description-content p {
  margin: 0 0 var(--space-sm);
}

/* Description formatted as list (for products with bullet points) */
.description-list {
  margin: 0;
  padding-left: var(--space-lg);
  list-style-type: disc;
}

.description-list li {
  margin-bottom: var(--space-sm);
  line-height: 1.6;
}

.specs-list {
  margin: 0;
  padding-left: var(--space-lg);
}

.specs-list li {
  margin-bottom: var(--space-xs);
  color: var(--color-text-secondary);
}

/* Offers Section */
.offers-section {
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
}

.offers-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--space-md);
}

.offers-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.offer-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.offer-card.best-offer {
  border-color: var(--color-link);
  background: #f7fffe;
}

.offer-price {
  font-size: 1.1rem;
  color: var(--color-price);
  min-width: 80px;
}

.offer-seller {
  flex: 1;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.offer-badges {
  display: flex;
  gap: var(--space-xs);
}

.badge {
  font-size: 0.8rem;
  padding: 2px var(--space-sm);
}

.badge-fba {
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  color: var(--color-success);
}

.badge-condition {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}
