/* ============================================================
   Sweet Gypsy Design — Product Detail Modal
   ============================================================ */

.product-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(44, 30, 20, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), backdrop-filter 0.4s ease;
}

.product-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Keep every part of the site navigation out of product detail view.
   On mobile, the menu button and menu panel are moved to <body> by nav.js. */
body.product-modal-open nav,
body.product-modal-open .nav-hamburger,
body.product-modal-open .nav-links,
body.product-modal-open .nav-overlay {
  visibility: hidden;
}

.product-modal {
  background: var(--white);
  border-radius: 4px;
  max-width: 900px;
  width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 28px 90px rgba(44, 30, 20, 0.35);
  transform: translateY(28px) scale(0.95);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  border-top: 3px solid var(--gold);
  will-change: transform, opacity;
}

.product-modal-overlay.active .product-modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: rgba(250, 246, 240, 0.9);
  border: 1px solid rgba(201, 169, 110, 0.25);
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 10;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  line-height: 1;
}

.modal-close:hover {
  color: var(--white);
  background: var(--brown);
  border-color: var(--brown);
  transform: rotate(90deg) scale(1.1);
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.modal-img-side {
  position: relative;
  overflow: hidden;
  border-radius: 4px 0 0 4px;
}

.modal-slider {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 400px;
  background: var(--cream-dark);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.modal-img-wrapper {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.modal-product-img {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  box-sizing: border-box;
  filter: sepia(5%);
}

.modal-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(201, 169, 110, 0.4);
  border-radius: 50%;
  color: var(--brown);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.modal-arrow:hover {
  background: var(--gold);
  color: white;
}

.modal-arrow-left {
  left: 10px;
}

.modal-arrow-right {
  right: 10px;
}

.modal-dots {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  display: none;
  justify-content: center;
  gap: 8px;
  z-index: 10;
}

.modal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.modal-dot.active {
  background: var(--gold);
  transform: scale(1.2);
}

.modal-product-img.image-error {
  object-fit: contain;
  padding: 2rem;
}

.modal-info-side {
  padding: 2.5rem 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modal-product-cat {
  font-size: .65rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .6rem;
  position: relative;
  display: inline-block;
}

.modal-product-cat::after {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--gold);
  margin-top: .4rem;
  opacity: .5;
}

.modal-product-name {
  font-family: var(--heading-font), serif;
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--brown);
  line-height: 1.25;
  margin-bottom: .6rem;
  text-rendering: optimizeLegibility;
}

.modal-product-story {
  font-family: var(--heading-font), serif;
  font-size: 1rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
  padding-left: .8rem;
  border-left: 2px solid rgba(201, 169, 110, 0.3);
}

.modal-divider {
  width: 40px;
  height: 1px;
  background: var(--gold);
  margin: .5rem 0 1rem;
}

.modal-product-price {
  font-family: var(--heading-font), serif;
  font-size: 1.5rem;
  color: var(--brown);
  font-weight: 400;
  margin-bottom: .8rem;
}

.modal-product-desc {
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 1.8rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.modal-order-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: .9rem 1.5rem;
  border-radius: 3px;
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: opacity .2s, transform .2s, box-shadow .2s;
  font-family: var(--body-font), sans-serif;
}

.modal-order-btn:hover {
  opacity: .88;
  transform: translateY(-1px);
}

.modal-wa {
  background: #25D366;
  color: white;
  box-shadow: 0 4px 14px rgba(37, 211, 102, .25);
}

.modal-wa:hover {
  box-shadow: 0 6px 20px rgba(37, 211, 102, .35);
}

.modal-line {
  background: #06C755;
  color: white;
  box-shadow: 0 4px 14px rgba(6, 199, 85, .25);
}

.modal-line:hover {
  box-shadow: 0 6px 20px rgba(6, 199, 85, .35);
}

/* ============================================================
   Sub-Products Mini Catalog (Variations from Sheet 2)
   ============================================================ */

.modal-sub-products {
  margin: 1.2rem 0 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(201, 169, 110, 0.15);
}

.modal-sub-title {
  font-family: var(--heading-font), serif;
  font-size: .75rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .8rem;
  position: relative;
  padding-left: 0;
}

.modal-sub-title::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--gold);
  vertical-align: middle;
  margin-left: .6rem;
  opacity: .5;
}

.modal-sub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom scrollbar for sub-grid */
.modal-sub-grid::-webkit-scrollbar {
  width: 4px;
}

.modal-sub-grid::-webkit-scrollbar-track {
  background: rgba(201, 169, 110, 0.08);
  border-radius: 2px;
}

.modal-sub-grid::-webkit-scrollbar-thumb {
  background: rgba(201, 169, 110, 0.3);
  border-radius: 2px;
}

.modal-sub-card {
  background: var(--cream);
  border: 1px solid rgba(201, 169, 110, 0.2);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease, box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  will-change: transform;
}

.modal-sub-card:hover {
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(201, 169, 110, 0.25);
  transform: translateY(-5px) scale(1.02);
}

.modal-sub-card.active-sub {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), 0 6px 20px rgba(201, 169, 110, 0.3);
}

.sub-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f5f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px 4px 0 0;
}

.sub-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  display: block;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
  filter: sepia(5%);
  will-change: transform;
}

.modal-sub-card:hover .sub-card-img {
  transform: scale(1.04);
  filter: sepia(0%);
}

.sub-card-img-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--heading-font), serif;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: var(--cream-dark);
}

.sub-card-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(61, 43, 31, 0.75);
  color: var(--cream);
  font-size: .55rem;
  font-weight: 500;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 2px;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
}

.sub-card-info {
  padding: 6px 8px 8px;
}

.sub-card-name {
  font-family: var(--body-font), sans-serif;
  font-size: .68rem;
  color: var(--brown);
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-card-price {
  font-family: var(--heading-font), serif;
  font-size: .72rem;
  color: var(--gold-dark);
  font-weight: 500;
}

/* ============================================================
   Sub-Product Switching — Smooth Crossfade Transitions
   ============================================================ */

/* GPU-accelerated transition base for modal content panels */
.modal-info-side,
.modal-img-side {
  will-change: opacity, transform;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Exit state: fade out + slight scale down */
.modal-content-exit {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s cubic-bezier(0.4, 0, 1, 1),
              transform 0.18s cubic-bezier(0.4, 0, 1, 1);
}

/* Enter state: fade in + slight scale up from below */
.modal-content-enter {
  animation: modalContentFadeIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalContentFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Active sub-card click pulse (tactile feedback) */
.modal-sub-card:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* Responsive: 2 columns on smaller screens */
@media (max-width: 600px) {
  .modal-sub-grid {
    grid-template-columns: repeat(2, 1fr);
    max-height: 300px;
  }
}
