/* =====================================
   Product Card — Thunder Blue Glass (Professional)
   - Matches global thunder-blue glass theme
   - Keeps existing markup/class names intact
   - Includes compact variant + image skeleton
===================================== */

/* Grid Layout for the container */
#products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  padding: 20px 0;
}

@media (max-width: 520px){
  #products{ grid-template-columns: 1fr; gap: 16px; }
}

/* Card Container */
.product-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(148, 191, 255, 0.20);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, filter 0.22s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  height: 100%;

  backdrop-filter: saturate(140%) blur(14px);
  box-shadow: 0 18px 60px rgba(2, 6, 23, 0.55);
}

/* Glass highlight + inner stroke */
.product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 48%),
    radial-gradient(700px 260px at 20% 0%, rgba(30, 94, 255, 0.22), transparent 60%);
  opacity: 0.85;
  z-index: 0;
}

.product-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 0 1px rgba(148, 191, 255, 0.10);
  z-index: 0;
}

/* Ensure pseudo-elements can never sit above / steal interactions from content */
.product-card {
  isolation: isolate;
}

/* Ensure card content stays above highlight layers */
.product-card > * {
  position: relative;
  z-index: 1;
}

.product-card:hover {
  transform: translateY(-6px);
  border-color: rgba(148, 191, 255, 0.34);
  filter: saturate(1.06);
  box-shadow:
    0 26px 92px rgba(2, 6, 23, 0.65),
    0 0 0 1px rgba(0, 163, 255, 0.10);
}

/* Optional "open" affordance: doesn't block click, just hints it's clickable */
/* (hover handled above as well for a stronger cue) */
.product-card:hover .view-details {
  opacity: 1;
  transform: translateX(0);
}

.product-card:active {
  transform: translateY(-2px);
}

/* Image Area */
.product-image-wrapper {
  width: 100%;
  height: clamp(140px, 22vw, 180px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
  position: relative;

  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(30, 94, 255, 0.12));
  border-bottom: 1px solid rgba(148, 191, 255, 0.18);
}

/* Image loading skeleton */
.product-image-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(0, 163, 255, 0.12) 35%,
    rgba(255, 255, 255, 0.06) 70%
  );
  background-size: 240% 100%;
  animation: productImageSkeleton 1.1s ease-in-out infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.product-image-wrapper.is-loading::before {
  opacity: 1;
}

.product-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-width: 100%;
  transition: transform 0.25s ease, opacity 160ms ease;
  opacity: 1;
  display: block;

  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.30));
}

.product-image-wrapper.is-loading img {
  opacity: 0;
}

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

.product-card:hover .product-image-wrapper img {
  transform: scale(1.05);
}

/* Smaller variant (use for recommended/suggestion product cards) */
.product-card.is-compact {
  border-radius: 12px;
}

.product-card.is-compact .product-image-wrapper {
  height: 88px;
  padding: 8px;
}

.product-card.is-compact .product-content {
  padding: 10px;
  gap: 8px;
}

.product-card.is-compact .product-header h3 {
  font-size: 0.95rem;
  -webkit-line-clamp: 2;
}

.product-card.is-compact .part-number {
  font-size: 0.78rem;
  padding: 5px 8px;
  border-radius: 10px;
  line-height: 1.3;
}

.product-card.is-compact .stock-tag,
.product-card.is-compact .promo-tag,
.product-card.is-compact .brand-tag {
  font-size: 0.7rem;
}

.product-card.is-compact .price {
  font-size: 1.05rem;
}

/* Content Area */
.product-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
}

.product-header h3 {
  font-size: 1.05rem;
  font-weight: 850;
  color: rgba(236, 244, 255, 0.98);
  margin: 0 0 6px 0;
  line-height: 1.35;

  /* Truncate to 2 lines (webkit) */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;

  /* Fallback (non-webkit): keep layout stable */
  max-height: calc(1.35em * 2);
}

.part-number {
  font-size: 0.85rem;
  color: rgba(232, 240, 255, 0.92);
  background: rgba(2, 6, 23, 0.42);
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 191, 255, 0.18);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  display: block;              /* allow multi-line */
  line-height: 1.35;
  white-space: normal;         /* show full compatible text */
  word-break: break-word;
  overflow: visible;
  max-width: 100%;
}

/* Tags */
.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.stock-tag, .promo-tag, .brand-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stock-tag {
  background: rgba(0, 163, 255, 0.16);
  color: rgba(210, 241, 255, 0.98);
  border: 1px solid rgba(0, 163, 255, 0.18);
}

.promo-tag {
  background: rgba(244, 63, 94, 0.16);
  color: rgba(255, 225, 232, 0.98);
  border: 1px solid rgba(244, 63, 94, 0.18);
}

.brand-tag {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(220, 235, 255, 0.92);
  border: 1px solid rgba(148, 191, 255, 0.14);
}

/* Footer */
.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 191, 255, 0.18);
}

.price {
  font-size: 1.35rem;
  font-weight: 950;
  color: rgba(180, 230, 255, 0.98);
  margin: 0;
  letter-spacing: 0.02em;
  text-shadow: 0 10px 26px rgba(0, 163, 255, 0.18);
  transition: transform 0.18s ease, filter 0.18s ease, text-shadow 0.18s ease;
}

.view-details {
  font-size: 0.9rem;
  color: rgba(199, 231, 255, 0.92);
  font-weight: 850;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.25s ease;
  pointer-events: none; /* prevents it from stealing clicks on the card */
  user-select: none;

  /* Avoid text causing overflow on narrow cards */
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Accessibility/UX: hover-only cues don't exist on touch */
@media (hover: none) and (pointer: coarse) {
  .view-details {
    opacity: 0.95;
    transform: none;
  }
}

.product-card:hover .view-details {
  opacity: 1;
  transform: translateX(0);
}
