.case-screen-gallery [hidden] { display: none !important; }

.case-phone {
  width: 100%;
  max-width: 390px;
  justify-self: start;
}
.case-phone-stage { grid-row: 2; }
.case-phone .case-phone-caption {
  margin: 0 0 12px;
  color: var(--color-text-secondary);
  font: 400 14px/20px var(--font-body);
  text-align: left;
  overflow-wrap: anywhere;
}
.case-phone .case-phone-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: auto;
  padding: clamp(5px, .7vw, 9px);
  overflow: visible;
  border: 2px solid #57585c;
  border-radius: 15% / 7%;
  background: #101113;
  box-shadow: inset 0 0 0 1px #2d2e31, 0 0 0 1px #202124;
}
.case-phone .case-phone-frame:focus-visible { border-radius: 15% / 7%; }
.case-phone .case-phone-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12% / 5.6%;
}
/* Small hardware details sit on the frame and leave the source image untouched. */
.case-phone-frame::before, .case-phone-frame::after {
  position: absolute;
  z-index: -1;
  width: 3px;
  border-radius: 2px;
  background: #4a4b50;
  content: '';
  pointer-events: none;
}
.case-phone-frame { isolation: isolate; }
.case-phone-frame::before { top: 18%; left: -4px; height: 7%; }
.case-phone-frame::after { top: 25%; right: -4px; height: 9%; }

@media (min-width: 1024px) {
  .case-phone { max-width: 300px; }
  .case-phone .case-phone-frame {
    max-width: min(100%, calc((100vh - var(--nav-height) - 200px) * var(--screen-ratio)));
    max-width: min(100%, calc((100svh - var(--nav-height) - 200px) * var(--screen-ratio)));
  }
}
@media (max-width: 767px) {
  /* Without JavaScript, show the full set as a vertical list. */
  .case-screen-gallery [data-case-screen-track] { grid-template-columns: minmax(0,1fr); }
  .case-screen-gallery .case-phone { max-width: none; }
  .case-screen-gallery .case-phone-frame {
    width: min(100%, 300px, max(100px, calc((100vh - var(--nav-height) - 175px) * var(--screen-ratio))));
    width: min(100%, 300px, max(100px, calc((100svh - var(--nav-height) - 175px) * var(--screen-ratio))));
    margin-inline: auto;
  }
  .case-screen-gallery[data-active] {
    display: grid;
    grid-template-rows: minmax(0,1fr) auto;
    height: min(650px, calc(100vh - var(--nav-height) - 24px));
    height: min(650px, calc(100svh - var(--nav-height) - 24px));
    margin-top: 24px;
  }
  .case-screen-gallery[data-active] [data-case-screen-track] {
    grid-template-rows: minmax(0,1fr);
    margin: 0;
    align-items: stretch;
    touch-action: pan-y pinch-zoom;
  }
  .case-screen-gallery[data-active] .case-phone {
    display: grid;
    grid-template: auto minmax(0,1fr) / minmax(0,1fr);
    min-height: 0;
  }
  .case-screen-gallery[data-active] .case-phone-stage { container-type: size; }
  .case-screen-gallery[data-active] .case-phone-frame {
    width: min(100%, 300px, calc(100cqh * var(--screen-ratio)));
  }
  .case-screen-pagination {
    justify-content: center;
    flex-wrap: nowrap;
    padding-top: 4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .case-screen-pagination .pagination-dot span { transition: none; }
}
