/* Small or short viewports use one vertical scroller, rather than squeezing
   the viewer, thumbnails and footer into the dialog's remaining height. */
@media (max-width: 620px), (max-height: 600px) {
  .v2-product:not(.is-viewer-expanded) {
    --v3-stage-height: clamp(260px, 48svh, 420px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 64px 20px;
    scrollbar-width: thin;
    scrollbar-color: #7b8585 transparent;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100%;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-content {
    flex: 0 0 auto;
    min-height: 0;
  }

  .v2-product:not(.is-viewer-expanded) .v2-sidebar {
    overflow: visible;
    min-width: 0;
  }

  .v2-product:not(.is-viewer-expanded) .v2-model-area {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    align-self: start;
    width: 100%;
    min-height: 0;
    gap: 10px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-model-area > .v2-info {
    position: relative;
    inset: auto;
    flex: none;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    overflow: visible;
  }

  .v2-product:not(.is-viewer-expanded) .v2-stage {
    flex: 0 0 var(--v3-stage-height);
    height: var(--v3-stage-height);
    min-height: 260px;
  }

  .v2-product:not(.is-viewer-expanded) #v2-sections {
    flex: none;
    min-height: 44px;
    overflow-y: hidden;
  }

  .v2-product:not(.is-viewer-expanded) .v2-thumbnails {
    flex: 0 0 76px;
    height: 76px;
    overflow-y: hidden;
  }

  .v2-product:not(.is-viewer-expanded) .v2-thumb {
    height: 68px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-footer {
    flex: none;
    flex-wrap: wrap;
    margin-top: 14px;
  }

  /* Keep a reachable close control even after scrolling past the heading. */
  .v2-product:not(.is-viewer-expanded) .v2-close {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
    z-index: 4;
    width: 40px;
    height: 40px;
    background: #1a2427;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-heading {
    padding-right: 44px;
  }
}

@media (max-width: 620px) {
  .v2-product[data-product=mamparas]:not(.is-viewer-expanded) .v2-product-heading {
    padding-right: 0;
  }

  .v2-product[data-product=mamparas]:not(.is-viewer-expanded) .v2-product-heading > div:first-child {
    flex-basis: 100%;
    padding-right: 44px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-shell {
    padding: calc(18px + env(safe-area-inset-top, 0px))
      calc(14px + env(safe-area-inset-right, 0px))
      calc(16px + env(safe-area-inset-bottom, 0px))
      calc(14px + env(safe-area-inset-left, 0px));
  }

  .v2-product:not(.is-viewer-expanded) .v2-close {
    right: calc(14px + env(safe-area-inset-right, 0px));
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-configuration {
    flex-wrap: wrap;
    overflow: visible;
    gap: 10px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-configuration > label {
    flex: 1 1 130px;
    min-width: 0;
    font-size: 10px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-configuration select {
    min-height: 40px;
    font-size: 11px;
  }

  .v2-product:not(.is-viewer-expanded) #v2-opening {
    flex: 1 1 130px;
    min-height: 40px;
  }

  .v2-product:not(.is-viewer-expanded) #v2-sections .v2-section {
    min-height: 40px;
    flex-shrink: 0;
    font-size: 10px;
  }

  .v2-product:not(.is-viewer-expanded) #v2-shower-system .v2-choice-body {
    min-height: 40px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-thumb {
    height: 68px;
    flex-basis: 90px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-thumb.has-preview span {
    font-size: 9px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-facts {
    flex: 1 1 130px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-advice {
    margin-left: auto;
  }
}

@media (min-width: 621px) and (max-height: 600px) {
  .v2-product:not(.is-viewer-expanded) {
    --v3-stage-height: clamp(240px, 62svh, 360px);
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-shell {
    padding: 16px 20px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-heading {
    gap: 12px;
    align-items: start;
  }

  .v2-product:not(.is-viewer-expanded) h2 {
    font-size: 26px;
    margin: 6px 0;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-heading p {
    font-size: 11px;
    line-height: 1.5;
  }

  .v2-product:not(.is-viewer-expanded) .v2-product-content {
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 14px;
  }

  .v2-product:not(.is-viewer-expanded) .v2-stage {
    min-height: 240px;
  }

  .v2-product:not(.is-viewer-expanded) #v2-shower-system {
    flex-basis: 300px;
    min-width: 260px;
  }
}

@media (min-width: 901px) and (max-height: 600px) {
  .v2-product:not(.is-viewer-expanded) .v2-close {
    top: calc(30px + env(safe-area-inset-top, 0px));
    right: max(30px, calc((100vw - 1320px) / 2 + 12px));
  }
}

/* Expanded view remains independent from the scrolled product controls. */
.v2-product.is-viewer-expanded {
  overflow: hidden;
}

.v2-product.is-viewer-expanded #v2-sections {
  visibility: hidden;
}
