/* Modern Product Cards - 2025 Design Trends Implementation */

/* Base Card Styles */
.modern-product-card,
.product-card.modern-enhanced {
  position: relative;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  /* limit transitions to transform and opacity only (avoid triggering layout/paint) */
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  /* backdrop-filter is expensive on many devices; only enable it via a utility class or on capable devices */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  contain: layout;
  transform: translateZ(0);
  transform-origin: center;
  box-sizing: border-box;
}

.modern-product-card:hover,
.product-card.modern-enhanced:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.08),
    0 10px 10px -5px rgba(0, 0, 0, 0.03);
  border-color: rgba(79, 70, 229, 0.22);
  /* hint to compositor only when hovered */
  will-change: transform, box-shadow;
}

/* Make only interactive controls show pointer -- avoid entire card being perceived as a button */
.btn-action,
.product-card .buy-now-btn,
.modern-product-card .buy-now-btn,
.product-payment-close,
.buy-now-btn a,
.wewonttip-support-copy,
.download-btn {
  cursor: pointer;
}

/* Dark Mode Styles */
.dark .modern-product-card,
.dark .product-card.modern-enhanced {
  /* Use deep, true black in dark mode for product cards to match design */
  background: #000;
  border-color: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.6),
    0 2px 4px -1px rgba(0, 0, 0, 0.5);
}



.modern-product-card::after,
.product-card.modern-enhanced::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* Limit transition to transform and opacity to avoid layout/paint on unrelated properties */
  transition:
    transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  opacity: 0;
}

.modern-product-card:hover::after,
.product-card.modern-enhanced:hover::after {
  width: 300px;
  height: 300px;
  opacity: 1;
}

.modern-product-card.loading,
.product-card.modern-enhanced.loading {
  overflow: hidden;
}

/* Card Overlay */
.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.06));
  opacity: 0;
  transform: translateY(8%);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
  pointer-events: none;
  border-radius: inherit;
}

.modern-product-card.hovered .card-overlay {
  opacity: 1;
  transform: translateY(0);
}

/* Card Shimmer Effect */
.card-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
  border-radius: inherit;
  /* reduce paint cost by using opacity animation only where possible */
  will-change: transform;
}

.modern-product-card.loaded .card-shimmer {
  display: none;
}

/* Product Image */
.modern-product-card .product-image,
.product-card.modern-enhanced .product-image {
  position: relative;
  height: 160px;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.modern-product-card .product-image img,
.product-card.modern-enhanced .product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: inherit;
}

.modern-product-card:hover .product-image img,
.product-card.modern-enhanced:hover .product-image img {
  transform: scale(1.05) rotate(1deg);
}

.modern-product-card .card-image,
.product-card.modern-enhanced .card-image {
  will-change: transform, opacity;
  backface-visibility: hidden;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.1);
}

/* Per-component focus/hover styles using canonical brand variables */
.product-image[data-focus-halo],
.product-title[data-focus-halo],
.product-description[data-focus-halo],
.buy-now-btn[data-focus-halo] {
  transition: box-shadow 160ms ease, transform 160ms ease, outline-color 160ms ease;
}

/* Always use the brand focus color/ring so visuals are consistent across components */
.product-image[data-focus-halo]:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px var(--brand-focus-color) !important;
}

.product-title[data-focus-halo]:focus-visible {
  outline: none;
  /* underline dotted with brand color for clear keyboard affordance */
  text-decoration: underline dotted var(--brand-focus-color) !important;
  text-decoration-thickness: 2px;
}

.product-description[data-focus-halo]:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--brand-focus-color) !important;
}

.buy-now-btn[data-focus-halo]:focus-visible,
.buy-now-btn[data-focus-halo]:hover {
  outline: none;
  box-shadow: var(--brand-focus-ring), 0 6px 16px rgba(0,0,0,0.08) !important;
  transform: translateY(-2px);
}

.product-image[data-focus-halo]:hover {
  transform: translateY(-4px) scale(1.02);
}

/* Product Content */
.modern-product-card .product-content,
.product-card.modern-enhanced .product-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* Defensive: allow shrinking in flex containers (fixes Safari's intrinsic min-width behavior) */
  min-width: 0;
  box-sizing: border-box;
  gap: 8px;
}

/* Retired product visual state */
.product-card.retired {
  opacity: 0.45;
  filter: grayscale(80%);
}

/* Ensure images remain visible but subdued */
.product-card.retired .product-image img {
  transform: none !important;
  opacity: 0.7;
}

/* Replace interactive buy button with a visible retired badge */
.retired-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 2px solid rgba(0,0,0,0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,250,250,0.95));
  color: #6b7280;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
}

html[data-theme="dark"] .retired-badge {
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(10,10,10,0.8));
  color: #9ca3af;
  border-color: rgba(255,255,255,0.04);
}

/* Keep layout consistent: ensure buy-now-btn space reserved */
.product-card .buy-now-btn,
.product-card .retired-badge {
  margin-top: auto;
}

/* Ensure JS-inserted wrapper participates as a flex child */
.card-perspective {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  -webkit-flex: 1 1 auto;
  -ms-flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
}

.modern-product-card .product-title,
.product-card.modern-enhanced .product-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 8px;
  line-height: 1.3;
  transition: color 0.3s ease;
}

.modern-product-card .product-description,
.product-card.modern-enhanced .product-description {
  font-size: 0.875rem;
  /* inherit color from the card so descriptions are pure black (light) or pure white (dark) */
  color: inherit;
  margin: 0 0 12px;
  line-height: 1.4;
}

.modern-product-card .product-price,
.product-card.modern-enhanced .product-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-color);
  margin: auto 0 16px;
}

/* Reinforce buy button layout and accessibility across bundled CSS */
.product-card .buy-now-btn,
.modern-product-card .buy-now-btn {
  justify-content: center; /* ensure centered even if utility classes interfere */
  gap: 0.5rem;
  text-decoration: none;
}

.product-card .buy-now-btn span,
.modern-product-card .buy-now-btn span {
  text-decoration: none;
}

/* Price appearance and separator fallback when JS/templating omits it */
.product-card .buy-now-btn > .text-2xl::before,
.modern-product-card .buy-now-btn > .text-2xl::before {
  /* Disabled: separator is provided centrally by unified-cta-buttons.css
     Keep the selector present for specificity parity, but do not generate content. */
  content: none;
  margin-right: 0;
  font-weight: 900;
  color: inherit;
}

/* Remove underline on focus but keep clear focus ring for keyboard users */
.buy-now-btn:focus {
  /* avoid stacking: defer visible focus to :focus-visible and brand ring */
  outline: none !important;
  box-shadow: none !important;
}

.product-card.modern-enhanced.loading .card-shimmer {
  display: block;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* Buttons */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  min-height: 44px;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(79, 70, 229, 0.4);
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.btn-action:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

/* Button focus states */
.btn-action:focus:not(:focus-visible) {
  outline: none !important;
  box-shadow: none !important;
}

.btn-action:focus-visible {
  outline: none !important;
  box-shadow: var(--brand-focus-ring) !important;
}

/* Dark Mode Button Styles */
.dark .btn-action {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.4);
}

.dark .btn-action:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.5);
}

.btn-action::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-action:hover::before {
  left: 100%;
}

/* Dark Mode Styles */
.dark .modern-product-card,
.dark .product-card.modern-enhanced {
  background: #000; /* deep black */
  border-color: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.6),
    0 2px 4px -1px rgba(0, 0, 0, 0.5);
}

.dark .modern-product-card .product-title,
.dark .product-card.modern-enhanced .product-title {
  color: #f9fafb;
}

.dark .modern-product-card .product-description,
.dark .product-card.modern-enhanced .product-description {
  /* Keep inheriting the card's color in dark mode */
  color: inherit;
} /* Improved Accessibility Styles */
@media (prefers-reduced-motion: reduce) {
  .modern-product-card,
  .product-card.modern-enhanced,
  .btn-action,
  .card-overlay,
  .modern-product-card .product-image img,
  .product-card.modern-enhanced .product-image img {
    transition: none;
    animation: none;
    transform: none !important;
  }

  .modern-product-card::after,
  .product-card.modern-enhanced::after {
    display: none;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  .modern-product-card:hover,
  .product-card.modern-enhanced:hover {
    transform: none;
    box-shadow:
      0 4px 6px -1px rgba(0, 0, 0, 0.1),
      0 2px 4px -1px rgba(0, 0, 0, 0.06);
  }

  .modern-product-card:hover .product-image img,
  .product-card.modern-enhanced:hover .product-image img {
    transform: none;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: more) {
  .modern-product-card,
  .product-card.modern-enhanced {
    border-width: 2px;
    border-color: #000;
  }

  .btn-action {
    border: 2px solid #000;
  }
}

/* Print Styles */
@media print {
  .modern-product-card,
  .product-card.modern-enhanced {
    background: white !important;
    box-shadow: none !important;
    border: 1px solid #000 !important;
    break-inside: avoid;
  }

  .btn-action {
    background: #000 !important;
    color: white !important;
    box-shadow: none !important;
  }
}

/* Responsive Design */
@media (max-width: 640px) {
  .modern-product-card,
  .product-card.modern-enhanced {
    padding: 16px;
    min-height: 280px;
  }

  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    height: 140px;
    margin-bottom: 12px;
  }

  .modern-product-card .product-title,
  .product-card.modern-enhanced .product-title {
    font-size: 1rem;
  }

  .btn-action {
    padding: 10px 20px;
    font-size: 0.8125rem;
    min-height: 40px;
  }
}

/* Layout: stack on small screens, side-by-side on larger screens */
@media (max-width: 720px) {
  /* Collapse image above content for narrow viewports */
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    flex-direction: column !important;
    align-items: stretch;
  }

  .product-card .product-image,
  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    width: 100% !important;
    height: auto !important;
    margin-bottom: 12px !important;
    border-right: none !important;
    border-bottom-width: 4px !important;
  }

  .product-card .product-content,
  .modern-product-card .product-content,
  .product-card.modern-enhanced .product-content {
    width: 100% !important;
    padding: 12px !important;
  }
}

@media (min-width: 721px) {
  /* Desktop: allow side-by-side layout for richer use of horizontal space */
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    flex-direction: row !important;
    gap: 20px;
    align-items: stretch;
  }

  .product-card .product-image,
  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    width: 40%;
    min-width: 220px;
    height: auto;
    margin: 0;
    border-bottom-width: 0;
    border-right: 4px solid currentColor;
    box-sizing: border-box;
  }

  .product-card .product-content,
  .modern-product-card .product-content,
  .product-card.modern-enhanced .product-content {
    width: 60%;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
  }

  /* Ensure title and price don't get vertically centered awkwardly */
  .product-card .product-price,
  .modern-product-card .product-price,
  .product-card.modern-enhanced .product-price {
    margin-top: auto;
  }
}

/* Stronger cross-breakpoint rules for predictable behavior */
/* Ensure dark-mode cards are deep black with higher specificity to avoid gradient overrides */
.dark .product-card,
.dark .modern-product-card,
.dark .product-card.modern-enhanced {
  background: #000 !important;
  color: #f8fafc;
}

/* Detailed breakpoint grid for product cards
   - mobile (<=480): single-column stacked, compact spacing
   - small tablet (481-720): stacked but more padding
   - medium (721-1024): side-by-side with 40/60 split
   - large (>=1025): side-by-side with generous spacing and min-heights
*/

/* Mobile: <=480px */
@media (max-width: 480px) {
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    flex-direction: column !important;
    gap: 8px;
    padding: 12px !important;
  }

  .product-card .product-image,
  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1/1;
    margin-bottom: 10px !important;
    border-radius: 10px;
  }

  .product-card .product-content,
  .modern-product-card .product-content,
  .product-card.modern-enhanced .product-content {
    padding: 8px !important;
  }
}

/* Small tablets: 481px - 720px */
@media (min-width: 481px) and (max-width: 720px) {
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    flex-direction: column !important;
    gap: 12px;
    padding: 14px !important;
  }

  .product-card .product-image,
  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4/3;
    margin-bottom: 12px !important;
  }

  .product-card .product-content,
  .modern-product-card .product-content,
  .product-card.modern-enhanced .product-content {
    padding: 12px 14px !important;
  }
}

/* Medium: 721px - 1024px (side-by-side) */
@media (min-width: 721px) and (max-width: 1024px) {
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    flex-direction: row !important;
    gap: 18px;
    align-items: stretch;
  }

  .product-card .product-image,
  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    flex: 0 0 42%;
    max-width: 46%;
    aspect-ratio: 4/3;
    height: auto;
    margin: 0;
    border-bottom-width: 0;
    border-right: 4px solid currentColor;
    box-sizing: border-box;
  }

  .product-card .product-content,
  .modern-product-card .product-content,
  .product-card.modern-enhanced .product-content {
    flex: 1 1 58%;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
  }
}

/* Large: >=1025px */
@media (min-width: 1025px) {
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    flex-direction: row !important;
    gap: 24px;
    align-items: stretch;
    padding: 20px;
  }

  .product-card .product-image,
  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    flex: 0 0 40%;
    max-width: 45%;
    aspect-ratio: 4/3;
    height: auto;
    margin: 0;
    border-bottom-width: 0;
    border-right: 4px solid currentColor;
    box-sizing: border-box;
  }

  .product-card .product-content,
  .modern-product-card .product-content,
  .product-card.modern-enhanced .product-content {
    flex: 1 1 60%;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
  }

  /* Gentle min-height so cards align nicely in grids without forcing huge whitespace on small screens */
  .product-card,
  .modern-product-card,
  .product-card.modern-enhanced {
    min-height: 380px;
  }
}

@media (max-width: 480px) {
  .modern-product-card,
  .product-card.modern-enhanced {
    padding: 12px;
    min-height: 260px;
  }

  .modern-product-card .product-image,
  .product-card.modern-enhanced .product-image {
    height: 120px;
    margin-bottom: 10px;
  }

  .btn-action {
    padding: 8px 16px;
    font-size: 0.75rem;
    min-height: 36px;
  }
}

/* Grid Layout Support */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 24px 0;
}

@media (max-width: 640px) {
  .products-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px 0;
  }
}

/* Filter Animation */
.filter-section {
  margin-bottom: 32px;
}

.filter-section select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  color: #374151;
  font-size: 0.875rem;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.filter-section select:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.dark .filter-section select {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

.dark .filter-section select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
