.product-popup {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  min-height: 100dvh;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.2s cubic-bezier(0.2, 0, 0, 1),
    visibility 0.2s;
}

.product-popup--open {
  visibility: visible;
  opacity: 1;
}

.product-popup__backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  border: none;
  padding: 0;
  margin: 0;
  background-color: rgba(35, 25, 23, 0.48);
  cursor: pointer;
}

.product-popup__card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(100%, 560px);
  height: 85vh;
  max-height: 85vh;
  padding: 16px 0 16px 16px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-surface-container-lowest);
  box-shadow: var(--md-sys-elevation-2);
  overflow: hidden;
}

.product-popup__scroll {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding-inline-end: 8px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent)
    transparent;
}

.product-popup__scroll::-webkit-scrollbar {
  width: 8px;
}

.product-popup__scroll::-webkit-scrollbar-track {
  background: transparent;
}

.product-popup__scroll::-webkit-scrollbar-thumb {
  border-radius: var(--md-sys-shape-corner-full);
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
}

.product-popup__scroll::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 20%, transparent);
}

.product-popup__media {
  position: relative;
  flex-shrink: 0;
}

.product-popup__badge {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: var(--md-sys-shape-corner-small);
  color: var(--md-sys-color-on-error-container);
  background-color: var(--md-sys-color-error-container);
}

.product-popup__close {
  position: absolute;
  top: 20px;
  right: 16px;
  z-index: 3;
  color: var(--md-sys-color-on-surface);
  background-color: color-mix(
    in srgb,
    var(--md-sys-color-surface-container-highest) 50%,
    transparent
  );
}

.product-popup__main-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
  background-color: var(--md-sys-color-surface-container-high);
}

.product-popup__main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-popup__main-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 3rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}

.product-popup__thumbs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.product-popup__thumb {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: var(--md-sys-shape-corner-small);
  overflow: hidden;
  cursor: pointer;
  background-color: var(--md-sys-color-surface-container);
}

.product-popup__thumb--active {
  border-radius: var(--md-sys-shape-corner-xl);
}

.product-popup__thumb:disabled {
  cursor: default;
  opacity: 0.48;
}

.product-popup__thumb-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: rgba(0, 0, 0, 0.52);
}

.product-popup__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-popup__details {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.product-popup__headline {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.product-popup__name {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--md-sys-color-on-surface);
}

.product-popup__description {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
}

.product-popup__pricing {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  margin-inline-start: auto;
  text-align: right;
}

.product-popup__price-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  width: max-content;
  max-width: 100%;
}

.product-popup__price {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  margin: 0;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.13rem;
  color: var(--md-sys-color-on-surface);
}

.product-popup__price--compare {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  text-decoration: line-through;
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.72;
}

.product-popup__unit {
  flex-shrink: 0;
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.45;
}

.product-popup__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  padding-top: 16px;
  margin-right: 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.product-popup__qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.product-popup__qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  background-color: var(--md-sys-color-surface-container-high);
  transition: background-color 0.2s ease;
}

.product-popup__qty-btn--dec {
  border-radius: var(--md-sys-shape-corner-medium);
}

.product-popup__qty-btn:hover:not(:disabled) {
  background-color: var(--md-sys-color-surface-container-highest);
}

.product-popup__qty-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.product-popup__qty-value {
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
}

.product-popup__cart-btn {
  flex: 1;
  max-width: 240px;
}

@media (prefers-reduced-motion: reduce) {
  .product-popup {
    transition: none;
  }

  .product-popup__card {
    transition: none;
  }
}

@media (max-width: 960px) {
  .product-popup {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0;
  }

  .product-popup__card {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 92dvh;
    padding: 16px 0 16px 16px;
    border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.05, 0.7, 0.1, 1);
  }

  .product-popup--open .product-popup__card {
    transform: translateY(0);
  }

  .product-popup__scroll {
    scrollbar-gutter: auto;
    padding-inline-end: 16px;
  }

  .product-popup__thumb--active {
    border-radius: var(--md-sys-shape-corner-large);
  }
}
