/* Animation for cart count update */
@keyframes cart-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.cart-updated {
  animation: cart-pop 0.5s ease-in-out;
  font-weight: bold !important; /* Make it bold instead of red */
}

/* Animation for cart item removal */
@keyframes fade-out {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.fade-out {
  animation: fade-out 0.5s ease-out forwards;
}

/* -------------------------------------------------------------------------
   Cart line thumbnails: soft shell while loading / after imgproxy 404/504
   ------------------------------------------------------------------------- */
.cart-line-thumb-shell {
  position: relative;
  width: 100%;
  max-width: 220px;
  margin-left: auto;
  aspect-ratio: 1 / 1;
  border-radius: 0.5rem;
  /* Warm paper tone — visible during load and if the image is slow (504 path) */
  background:
    linear-gradient(180deg, #f7f4f0 0%, #efeae4 100%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cart-line-thumb-shell::before {
  /* Faint picture glyph while the real image loads */
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../images/placeholder-thumb.aef458e9bad9.png");
  background-size: cover;
  background-position: center;
  opacity: 0.55;
  pointer-events: none;
}

.cart-line-thumb {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.5rem;
  /* Soft fade-in when the real image arrives */
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cart-line-thumb:not(.cart-line-thumb--fallback) {
  animation: cart-thumb-reveal 0.35s ease forwards;
  animation-delay: 0.05s;
}

@keyframes cart-thumb-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Loaded success: hide the underlay glyph so only the photo shows */
.cart-line-thumb-shell:has(.cart-line-thumb:not(.cart-line-thumb--fallback))::before {
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Failed load (404 missing file, 504 S3 timeout): calm de-emphasised tile */
.cart-line-thumb-shell--fallback,
.cart-line-thumb-shell--empty {
  background: linear-gradient(180deg, #f8f6f3 0%, #f0ebe5 100%);
  box-shadow: none;
  border-color: rgba(0, 0, 0, 0.05);
}

.cart-line-thumb-shell--fallback::before,
.cart-line-thumb-shell--empty::before {
  opacity: 0; /* img itself is the soft placeholder */
}

.cart-line-thumb--fallback {
  opacity: 1 !important;
  object-fit: cover;
  filter: none;
  animation: none;
}

/* Optional tiny caption under fallback (if we add it later) */
.cart-line-thumb-caption {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: #9a9086;
  text-align: center;
  max-width: 220px;
  margin-left: auto;
}

@media (max-width: 767.98px) {
  .cart-line-thumb-shell {
    max-width: 140px;
    margin-right: auto;
    margin-left: 0;
  }
  .cart-line-thumb-caption {
    margin-left: 0;
    text-align: left;
  }
}

