/* ============================================================================
   product-grid.css — Diamonds Outta Dirt (Purpley Shop Product Grid)
   Path: /home2/asqrtyte/public_html/css/product-grid.css
   Purpose: product grid cards + images + badges + reveal items
   
   UPDATES (2026-02-16) — MOBILE CRASH & VRAM FIX:
   - ✅ CRASH FIX: Removed all global `will-change` declarations. 
   - iOS Safari crashes (WebKit Jetsam events) when `will-change` is applied to 
     multiple grid items combining `filter` and `transform`. 
   - ✅ VISIBILITY HARDENING: Ensured images remain fully opaque and don't collapse.
   ============================================================================ */

:root{
  --pg-neon: #b84dff;
  --pg-cyan: #00f3ff;
  --pg-pink: #ff4bd6;
  --pg-text: #fff;
  --pg-dim: #a3a3b5;
  --pg-border: rgba(184,77,255,.22);
  --pg-border-strong: rgba(184,77,255,.55);
  --pg-panel: rgba(10,10,16,.45);
  --pg-shadow: 0 18px 40px rgba(0,0,0,.55);
  --pg-radius: 14px;

  /* a11y + polish */
  --pg-focus: rgba(0,243,255,.85);
  --pg-focus-shadow: 0 0 0 3px rgba(0,243,255,.25), 0 0 18px rgba(184,77,255,.18);
  
  /* New variables for enhancements */
  --pg-sold-out: rgba(255, 62, 62, 0.9);
  --pg-sale: rgba(255, 75, 214, 0.9);
  --pg-wishlist: rgba(255, 0, 128, 0.9);
  --pg-cart: rgba(0, 255, 157, 0.9);
}

/* SECTION WRAP (works with your .lookbook-section) */
.lookbook-section{
  position: relative;
}

/* PRODUCT GRID */
.product-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 36px 26px;
  margin-bottom: 70px;
}

/* REVEAL ITEM (matches your JS intersection logic) */
.reveal-item{
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .55s ease, transform .55s ease;
  /* CRITICAL FIX: will-change removed to prevent iOS memory crash */
}
.reveal-item.revealed{
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================================
   PATCH: VISIBILITY HARDENING (targets only grid cards)
   - If master.css/styles.css set .product-card {opacity:0} by default, this overrides it
     ONLY when the card is inside your product grid wrapper.
   - Prevents invisible cards/images even if reveal JS is working.
   ============================================================================ */
.product-grid .product-card{
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
}

.product-grid .card-image,
.product-grid .card-image *{
  visibility: visible !important;
}

.product-grid .card-image img,
.product-grid .card-image video{
  display: block !important;
  opacity: 1 !important;
}

/* If some other CSS applies opacity:0 unless .loaded, ensure default visible.
   Your JS can still add .loaded for fade-in; this just prevents “never shows”. */
.product-grid .card-image img:not(.loaded),
.product-grid .card-image video:not(.loaded){
  opacity: 1 !important;
}

/* PRODUCT CARD */
.product-card{
  display:block;
  text-decoration:none;
  height:100%;
  border-radius: var(--pg-radius);
  transition: transform .25s ease, filter .25s ease;
  outline: none;
  color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.product-card:hover{
  transform: translateY(-10px);
  filter: drop-shadow(0 18px 35px rgba(184,77,255,.08));
}

/* Keyboard accessibility */
.product-card:focus-visible{
  outline: 2px solid var(--pg-focus);
  outline-offset: 6px;
  filter: drop-shadow(0 18px 35px rgba(0,243,255,.06));
}

/* IMAGE WRAP */
.card-image{
  position:relative;
  overflow:hidden;
  height: 350px;
  border-radius: var(--pg-radius);
  border: 1px solid var(--pg-border);
  background:
    radial-gradient(circle at 30% 20%, rgba(184,77,255,.15), transparent 55%),
    radial-gradient(circle at 70% 60%, rgba(0,243,255,.10), transparent 60%),
    rgba(0,0,0,.75);
  box-shadow: 0 10px 26px rgba(0,0,0,.4);
  transition: border-color .25s ease, box-shadow .25s ease;
}

/* Loading state for images */
.card-image.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(10,10,16,0.8) 25%, 
    rgba(184,77,255,0.2) 50%, 
    rgba(10,10,16,0.8) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  z-index: 1;
  border-radius: var(--pg-radius);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.card-image img.loaded {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.card-image img:not(.loaded) {
  opacity: 0;
}

.product-card:hover .card-image{
  border-color: var(--pg-border-strong);
  box-shadow: var(--pg-shadow), 0 0 18px rgba(184,77,255,.12);
}

/* If a card is focused, reinforce the image boundary */
.product-card:focus-visible .card-image{
  border-color: rgba(0,243,255,.55);
  box-shadow: var(--pg-shadow), var(--pg-focus-shadow);
}

.card-image img,
.card-image video{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block; /* remove baseline gaps */
  transform: scale(1.02);
  transition: transform .55s ease, filter .55s ease;
  filter: grayscale(55%) contrast(110%) brightness(.92);
}

.product-card:hover .card-image img,
.product-card:hover .card-image video{
  transform: scale(1.08);
  filter: grayscale(0%) contrast(105%) brightness(1.05);
}

/* BADGES */
.stock-low{
  position:absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 10px;
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .58rem;
  letter-spacing: 2px;
  font-weight: 900;
  color:#000;
  background: linear-gradient(135deg, #ffcc00, #ff7a00);
  box-shadow: 0 10px 22px rgba(0,0,0,.35);
}

.featured-badge{
  position:absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 10px;
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .58rem;
  letter-spacing: 2px;
  font-weight: 900;
  color:#000;
  background: linear-gradient(135deg, rgba(184,77,255,.95), rgba(255,75,214,.75));
  box-shadow: 0 10px 22px rgba(0,0,0,.35), 0 0 16px rgba(184,77,255,.18);
}

/* SALE BADGE */
.sale-badge {
  position:absolute;
  top: 14px;
  right: 60px; /* Position next to stock-low badge */
  z-index: 2;
  padding: 6px 10px;
  border-radius: 10px;
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .55rem;
  letter-spacing: 2px;
  font-weight: 900;
  color:#000;
  background: linear-gradient(135deg, #ff4bd6, #ff00aa);
  box-shadow: 0 10px 22px rgba(0,0,0,.35), 0 0 16px rgba(255,75,214,.25);
}

/* SOLD OUT STATE */
.product-card.sold-out .card-image {
  filter: grayscale(100%) brightness(0.5);
  opacity: 0.7;
}

.product-card.sold-out .card-image::after {
  content: 'SOLD OUT';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 20px;
  border: 2px solid var(--pg-sold-out);
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  z-index: 3;
  border-radius: 8px;
  text-shadow: 0 0 10px rgba(255,62,62,0.5);
}

/* Disable hover effects for sold out items */
.product-card.sold-out:hover {
  transform: none;
  cursor: not-allowed;
}

.product-card.sold-out:hover .card-image img {
  transform: scale(1.02);
  filter: grayscale(100%) brightness(0.5);
}

/* QUICK ACTION OVERLAY */
.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, 
    rgba(0,0,0,0.95) 0%, 
    rgba(0,0,0,0.8) 50%, 
    transparent 100%);
  padding: 20px 15px 15px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  border-radius: 0 0 var(--pg-radius) var(--pg-radius);
  backdrop-filter: blur(5px);
}

.product-card:hover .card-overlay {
  opacity: 1;
  transform: translateY(0);
}

.product-card:focus-visible .card-overlay {
  opacity: 1;
  transform: translateY(0);
}

.quick-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.quick-btn {
  background: rgba(184,77,255,0.2);
  border: 1px solid rgba(184,77,255,0.4);
  color: #fff;
  padding: 10px 16px;
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  min-width: 100px;
  position: relative;
  overflow: hidden;
}

.quick-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.6s;
}

.quick-btn:hover::before {
  left: 100%;
}

.quick-btn:hover {
  background: rgba(184,77,255,0.4);
  border-color: var(--pg-neon);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(184,77,255,0.3);
}

.quick-btn:active {
  transform: translateY(0);
}

.quick-btn.wishlist-btn:hover {
  background: rgba(255,0,128,0.4);
  border-color: var(--pg-wishlist);
}

.quick-btn.cart-btn:hover {
  background: rgba(0,255,157,0.4);
  border-color: var(--pg-cart);
}

/* INFO */
.card-info{
  padding: 16px 6px 0;
  position: relative;
  z-index: 1;
}

.card-title{
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: rgba(255,255,255,.92);
  letter-spacing: 2px;
  font-size: .84rem;
  font-weight: 900;
  line-height: 1.35;
  margin-bottom: 8px;
  transition: color .25s ease, text-shadow .25s ease;
  text-transform: uppercase;
}

.product-card:hover .card-title,
.product-card:focus-visible .card-title{
  color: var(--pg-neon);
  text-shadow: 0 0 12px rgba(184,77,255,.18);
}

.card-price{
  font-family: "Syncopate", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 900;
  color: rgba(255,255,255,.92);
  letter-spacing: 2px;
  font-size: .95rem;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sale price styling */
.card-price.sale .original-price {
  text-decoration: line-through;
  color: var(--pg-dim);
  font-size: 0.8rem;
  opacity: 0.7;
  order: 1;
}

.card-price.sale .sale-price {
  color: var(--pg-sale);
  font-weight: 900;
  order: 2;
  text-shadow: 0 0 10px rgba(255,75,214,0.3);
}

.card-price::after{
  content:"";
  display:block;
  margin-top: 10px;
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, rgba(184,77,255,.6), rgba(0,243,255,.35), transparent);
  opacity:.55;
}

/* EMPTY STATE / LOADING */
.loading-spinner{
  grid-column: 1 / -1;
  text-align:center;
  padding: 70px 20px;
  border-radius: 16px;
  border: 1px solid rgba(184,77,255,.15);
  background: rgba(10,10,16,.35);
  color: rgba(184,77,255,.92);
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 3px;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
}

.loading-spinner::after{
  content:"";
  display:block;
  width: 42px;
  height: 42px;
  margin: 18px auto 0;
  border-radius: 999px;
  border: 3px solid rgba(184,77,255,.18);
  border-top-color: rgba(184,77,255,.85);
  animation: pgspin 1s linear infinite;
}
@keyframes pgspin{
  to { transform: rotate(360deg); }
}

/* RESPONSIVE */
@media (max-width: 992px){
  .product-grid{ grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .card-image{ height: 320px; }
}

@media (max-width: 768px){
  .product-grid{ gap: 28px 18px; }
  .card-image{ height: 300px; }
  
  /* Better touch targets on mobile */
  .quick-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px;
    font-size: 0.65rem;
  }
  
  /* Prevent iOS zoom */
  .product-card {
    font-size: 16px;
  }
}

@media (max-width: 576px){
  .product-grid{ grid-template-columns: 1fr; }
  .card-image{ height: 320px; }
  
  .quick-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .quick-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Hover/No-hover device detection */
@media (hover: hover) and (pointer: fine) {
  /* Only show hover effects on devices that support hover */
  .product-card:hover .card-overlay {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (hover: none) and (pointer: coarse) {
  /* Touch devices - show overlay on tap */
  .product-card:active .card-overlay,
  .product-card:focus-within .card-overlay {
    opacity: 1;
    transform: translateY(0);
  }
  
  .product-card:active {
    transform: scale(0.98);
  }
  
  .quick-btn:active {
    transform: scale(0.95);
  }
}

/* Reduced Motion (keeps layout but removes "floaty" animation) */
@media (prefers-reduced-motion: reduce){
  .reveal-item,
  .product-card,
  .card-image,
  .card-image img,
  .card-image video,
  .loading-spinner::after,
  .quick-btn,
  .card-overlay {
    transition: none !important;
    animation: none !important;
  }
  
  .reveal-item{
    opacity: 1;
    transform: none;
  }
  
  .product-card:hover {
    transform: none;
  }
  
  .card-image.loading::before {
    animation: none;
    background: rgba(10,10,16,0.8);
  }
  
  .quick-btn::before {
    display: none;
  }
}

/* High Contrast */
@media (prefers-contrast: high){
  :root{
    --pg-border: rgba(255,255,255,.25);
    --pg-border-strong: rgba(255,255,255,.55);
    --pg-neon: #fff;
    --pg-cyan: #0ff;
    --pg-pink: #f0f;
  }
  
  .card-title{ 
    color: #fff;
    font-weight: 900;
  }
  
  .card-price{ 
    color: #fff;
    font-weight: 900;
  }
  
  .card-image {
    border-width: 2px;
  }
  
  .product-card:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
  }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
  .product-card {
    background: rgba(5,5,10,0.3);
  }
  
  .card-info {
    background: rgba(5,5,10,0.5);
    border-radius: 0 0 var(--pg-radius) var(--pg-radius);
    backdrop-filter: blur(10px);
    padding: 16px 10px 10px;
    margin-top: -5px;
  }
}

/* Print styles */
@media print {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
  
  .product-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #000;
    box-shadow: none;
    transform: none !important;
  }
  
  .card-image {
    height: 250px;
    border: 1px solid #000;
    background: #fff;
  }
  
  .card-image img,
  .card-image video {
    filter: none !important;
    transform: none !important;
  }
  
  /* Hide decorative elements */
  .stock-low,
  .featured-badge,
  .sale-badge,
  .card-image::before,
  .card-overlay,
  .quick-actions,
  .card-price::after {
    display: none;
  }
  
  .card-title {
    color: #000;
    font-weight: bold;
  }
  
  .card-price {
    color: #000;
  }
  
  /* Show URLs for links */
  .product-card::after {
    content: " (" attr(href) ")";
    font-size: 0.7rem;
    color: #666;
    display: block;
    margin-top: 5px;
  }
}

/* Aspect ratio fallback for older browsers */
@supports not (aspect-ratio: 3/4) {
  .card-image {
    height: 350px;
  }
  
  @media (max-width: 992px) {
    .card-image {
      height: 320px;
    }
  }
  
  @media (max-width: 768px) {
    .card-image {
      height: 300px;
    }
  }
  
  @media (max-width: 576px) {
    .card-image {
      height: 320px;
    }
  }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
  .card-image {
    clip-path: inset(0 round var(--pg-radius));
  }
  
  .quick-btn {
    backdrop-filter: blur(5px);
  }
}