.product-modal {
  grid-template-areas: 'heading close' 'body body';
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: 12px;
  width: min(1240px, calc(100vw - 32px));
  max-height: min(840px, calc(100dvh - 32px));
  border: 1px solid #e8dcbf;
  background: radial-gradient(ellipse 430px 135px at 0 0, #ffe8ad, #fff5d8 48%, transparent), #fff;
  box-shadow: 0 25px 80px rgb(24 16 2 / .26), 24px 15px 65px -44px rgb(227 168 26 / .47);
  overflow: hidden;
  visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.product-modal.open {
  visibility: visible;
}

.product-modal-heading {
  grid-area: heading;
  align-self: center;
  min-width: 0;
  padding: 16px 0 16px 24px;
}

.product-modal-heading .eyebrow {
  margin-bottom: 4px;
  color: #656565;
}

.product-modal-heading h2 {
  margin: 0;
  font-family: var(--heading);
  font-size: clamp(21px, 3vw, 31px);
  line-height: 1.15;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}

.product-modal .product-close {
  grid-area: close;
  align-self: center;
  position: static;
  width: 44px;
  height: 44px;
  margin-inline-end: 16px;
}

.product-stock-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 7px 0 0;
  color: #a51824;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.product-stock-note::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d12435;
}

.product-modal-body {
  --product-body-top-padding: 22px;
  --product-body-bottom-padding: 22px;
  grid-area: body;
  min-width: 0;
  min-height: 0;
  padding: var(--product-body-top-padding) 24px var(--product-body-bottom-padding);
  border-top: 1px solid #ede3ca;
  overflow: hidden auto;
  overscroll-behavior: contain;
  background-color: #fff;
  background-image: radial-gradient(ellipse 100% 100% at 100% 100%, #ffe8ad, #fff4d7 44%, transparent 100%);
  background-position: right bottom;
  background-size: min(540px, 86%) min(290px, 75%);
  background-repeat: no-repeat;
  background-attachment: local;
}

.modal-product-gallery {
  grid-area: gallery;
  min-width: 0;
  align-self: stretch;
}

#product-photo-carousel {
  --gallery-photo-height: clamp(112px, calc(100dvh - 184px), min(74dvh, 680px));
  --gallery-thumbnail-size: 52px;
  --gallery-rail-width: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
}

.modal-product-gallery .modal-product-image {
  position: relative;
  grid-area: 1 / 2;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: 100%;
  min-height: 0;
  height: var(--gallery-photo-height);
  aspect-ratio: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafafa;
  touch-action: pan-y;
}

.gallery-photo-open {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.gallery-photo-open:focus-visible {
  outline-offset: -3px;
}

.gallery-photo-open img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-expand-icon {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
}

.gallery-photo-open:hover .gallery-expand-icon {
  border-color: var(--ink);
  background: #fff4d6;
}

.product-photo-viewer {
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #121212;
  color: #fff;
}

.product-photo-viewer[open] {
  display: grid;
  grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
}

.product-photo-viewer-toolbar,
.product-photo-viewer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-photo-viewer-toolbar {
  padding: 6px 12px;
}

.product-photo-viewer-toolbar button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid #5f5f5f;
  border-radius: 50%;
  background: #222;
  color: #fff;
  font-size: 22px;
}

.product-photo-viewer-toolbar button:hover {
  border-color: var(--yellow);
}

#photo-viewer-close {
  margin-inline-start: auto;
}

#photo-viewer-count {
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#full-product-photo {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 6px 6px;
  object-fit: contain;
  touch-action: pan-y pinch-zoom;
}

.gallery-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.gallery-controls button,
#gallery-count {
  position: absolute;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.gallery-controls button {
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  pointer-events: auto;
}

.gallery-controls button:hover {
  border-color: var(--ink);
}

#gallery-prev { left: 8px; }
#gallery-next { right: 8px; }

#gallery-count {
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.gallery-thumbnails {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: var(--gallery-rail-width);
  height: var(--gallery-photo-height);
  margin-inline-end: 8px;
  padding: 2px;
  overflow: hidden auto;
  scrollbar-width: thin;
}

.gallery-thumbnails button {
  flex: 0 0 var(--gallery-thumbnail-size);
  width: var(--gallery-thumbnail-size);
  max-width: 100%;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.gallery-thumbnails button[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--yellow);
}

.gallery-thumbnails img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-faq {
  --product-faq-gap: 24px;
  margin-top: var(--product-faq-gap);
  padding-block: 4px 8px;
  border-top: 2px solid #ead6a2;
}

.product-faq h3 {
  margin: 12px 0 8px;
  font-family: var(--heading);
  font-size: clamp(17px, 2vw, 21px);
}

@media (prefers-reduced-motion: no-preference) {
  .product-faq-enter {
    animation: reveal-product-questions .38s cubic-bezier(.2, .65, .3, 1) both;
  }

  @keyframes reveal-product-questions {
    from { opacity: .7; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

.product-faq details {
  border-bottom: 1px solid var(--line);
}

.product-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  font-size: 1rem;
  line-height: 1.45;
  padding-block: 8px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.product-faq summary::-webkit-details-marker { display: none; }
.product-faq summary::after { content: '+' / ''; }
.product-faq details[open] summary::after { content: '−' / ''; }

.product-faq summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.product-faq p {
  margin: 0 0 12px;
  color: #454545;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.product-faq-answer {
  display: flow-root;
}

.modal-product-content {
  grid-area: details;
  display: block;
  min-width: 0;
  padding: 0;
  overflow-wrap: anywhere;
}

.product-modal-body .modal-subtitle {
  grid-area: subtitle;
  margin: 0;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.modal-product-content .modal-description {
  color: #454545;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-line;
}

.modal-description p {
  margin: 0;
}

.modal-description p + p {
  margin-top: 10px;
}

.modal-detail-section {
  padding-block: 14px;
  border-top: 1px solid var(--line);
}

.modal-product-content h3 {
  margin: 0 0 8px;
  font-family: var(--heading);
  font-size: 1.125rem;
}

.modal-product-content ul {
  margin: 0;
  color: #454545;
  font-size: 1rem;
  line-height: 1.5;
}

.modal-product-content li + li {
  margin-top: 6px;
}

.product-purchase-info {
  margin-top: 6px;
  padding: 15px clamp(12px, 2vw, 18px);
  border: 1px solid #ead6a2;
  border-left: 3px solid #e0ad36;
  border-radius: 8px;
  background: radial-gradient(ellipse 74% 95% at 100% 100%, #ffedb8, transparent), #fffaf0;
}

.product-purchase-info dl { margin: 0; }
.product-purchase-info dl > div { padding: 8px 0; }
.product-purchase-info dl > div + div { border-top: 1px solid #ebdfc2; }

.product-purchase-info dt {
  margin-bottom: 2px;
  font-size: 1rem;
  font-weight: 700;
}

.product-purchase-info dd,
.product-purchase-info .product-rights-note {
  margin: 0;
  color: #454545;
  font-size: 1rem;
  line-height: 1.55;
}

#modal-product-guarantee { white-space: pre-line; }

.product-purchase-info .product-rights-note {
  padding-top: 8px;
  border-top: 1px solid #ebdfc2;
}

.product-buy-dock {
  grid-area: purchase;
  min-width: 0;
}

.product-buy-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
  padding: 7px 10px 7px 12px;
  border: 1px solid #ead6a2;
  border-radius: 8px;
  background: #fffaf0;
}

.product-buy-prices {
  flex: 1 1 84px;
  min-width: 0;
}

.product-buy-box .modal-price,
.product-buy-box .modal-small-print {
  margin: 0;
}

.product-buy-box .modal-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  font-size: 1.375rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.product-buy-box .modal-small-print {
  margin-top: 3px;
  color: #656565;
  font-size: .75rem;
}

.product-card .product-image-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (min-width: 721px) {
  .product-modal-body {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(270px, 3fr);
    grid-template-rows: max-content max-content auto auto;
    grid-template-areas: 'gallery subtitle' 'gallery purchase' 'gallery details' 'questions .';
    align-content: start;
    align-items: start;
    column-gap: 28px;
  }

  .product-modal-overview {
    display: contents;
  }

  .product-buy-dock {
    position: sticky;
    top: calc(-1 * var(--product-body-top-padding));
    z-index: 2;
    padding: 10px 0 14px;
    background: #fff;
  }

  .product-faq {
    grid-area: questions;
  }

  #product-photo-carousel {
    position: sticky;
    top: 0;
  }
}

@media (max-width: 980px) {
  #product-photo-carousel {
    --gallery-thumbnail-size: 44px;
    --gallery-rail-width: 54px;
  }
}

@media (max-width: 720px) {
  .product-modal {
    --mobile-product-photo-height: clamp(72px, calc(100dvh - 240px), min(37dvh, 310px));
    grid-template-areas: 'heading close' 'body body' 'purchase purchase';
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 20px);
    background: radial-gradient(ellipse 245px 115px at 0 0, #ffecb9, #fff6df 48%, transparent), #fff;
  }

  .product-modal-heading {
    padding: 11px 0 11px 14px;
  }

  .product-modal .product-close {
    margin-inline-end: 14px;
  }

  .product-modal-body {
    --product-body-bottom-padding: 12px;
    padding: 0 10px var(--product-body-bottom-padding);
    scrollbar-width: thin;
    background-image: radial-gradient(ellipse 100% 100% at 100% 100%, #ffedbc, #fff7e3 47%, transparent 100%);
    background-size: min(360px, 94%) min(230px, 70%);
  }

  .product-modal-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'subtitle' 'gallery' 'details';
    gap: 14px;
    grid-template-rows: auto auto 1fr;
    align-items: start;
    padding-top: 12px;
  }

  .modal-product-gallery {
    position: sticky;
    z-index: 1;
    top: 0;
    padding: 6px 0 4px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  #product-photo-carousel {
    --gallery-photo-height: var(--mobile-product-photo-height);
  }

  .gallery-thumbnails {
    margin-inline-end: 6px;
  }

  .product-buy-box {
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid #ead6a2;
    border-radius: 0;
    background: #fff;
  }

  .product-buy-box [data-modal-add] {
    min-height: 46px;
  }
}
