/* The glass is one opaque camera frame. The foreground is sized by the actual
   space between the live text rows. The outer molecules may pass behind either row. */
.home-editorial .opening:has(.studio-aperture) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(280px, 1fr) auto;
  row-gap: clamp(12px, 1.45svh, 24px);
  background: #a6b69f;
  justify-content: stretch;
}
.opening:has(.studio-aperture) > .opening-top { grid-row: 1; }
.opening:has(.studio-aperture) > .opening-booking { grid-row: 3; }
.opening:has(.studio-aperture) > :is(.opening-top,.opening-booking) {
  grid-column: 1; position: relative; z-index: 1;
}
.studio-aperture {
  grid-column: 1; grid-row: 2; position: relative;
  min-width: 0; min-height: 0; container-type: size;
  pointer-events: none; z-index: 0;
  --plate-height: min(308cqh, 221cqw);
  --plate-width: calc(var(--plate-height) * 1.77777778);
  --focus-x: 54%;
  --focus-y: 52%;
}
.studio-frame {
  position: absolute; left: var(--focus-x); top: var(--focus-y);
  height: var(--plate-height); width: var(--plate-width);
  max-width: none; max-height: none;
  display: block; transform: translate(-50%,-50%); pointer-events: none;
}
.studio-aperture::before {
  content: ""; position: absolute; left: var(--focus-x); top: var(--focus-y);
  width: max(var(--plate-width), 220vw); height: 400svh;
  transform: translate(-50%,-50%);
  background: #b3bcae url('/assets/sage-studio-edge.png') center / var(--plate-width) 100% no-repeat;
}
@media(min-aspect-ratio: 22/10) {
  .home-editorial .opening:has(.studio-aperture) { min-height: max(34vw, 100svh, 680px); }
}
@media(max-width: 760px) {
  .studio-aperture { --focus-x: 50%; --focus-y: 51%; }
}

/* Keep the original source frame inside the live middle row. */
.opening:has(.studio-frame.gold-molecular-video) .studio-aperture::before { content: none; }
.home-editorial .opening .studio-frame.gold-molecular-video {
  inset: auto; left: 50%; top: 50%;
  width: min(147cqh, 100cqw);
  height: min(98cqh, 66.666667cqw);
  max-width: none; padding: 0;
  object-fit: contain;
  transform: translate(-50%, -50%);
  z-index: 0;
}

/* The overscanned Blender frame continues through the entire opening. */
.studio-aperture:has(.studio-expanded-still) {
  --plate-height: min(420cqh, 390cqw);
  --plate-width: calc(var(--plate-height) * 1.6);
  --focus-x: 54%;
  --focus-y: 50%;
}
.studio-aperture:has(.studio-expanded-still)::before { content: none; }

/* Extend the feathered header backdrop by one-third of its previous height. */
.opening:has(.studio-expanded-still) :is(.opening-top, .opening-booking) { z-index: 2; }
.opening-readability, .booking-readability {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  content: "";
  position: absolute;
  top: -120px;
  left: calc(-1 * var(--gutter));
  right: calc(-1 * var(--gutter));
  bottom: auto;
  height: calc((100% + 134px) * 4 / 3);
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 0%, #000 58%, transparent 100%);
  mask-image: linear-gradient(#000 0%, #000 58%, transparent 100%);
}
@media (max-width: 760px) {
  .studio-aperture:has(.studio-expanded-still) { --focus-x: 50%; }
}

/* Each feather paints into a fixed box. Overscan keeps the blur soft at the section edges. */
.opening-readability canvas, .booking-readability canvas {
  position: absolute;
  inset: -22px;
  width: calc(100% + 44px);
  height: calc(100% + 44px);
  max-width: none;
  filter: blur(10px);
  pointer-events: none;
}
.opening-readability::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #d4ded1c9 0%, #cad8c3a6 48%, #8fab9238 75%, #375f4712 100%);
}

.booking-readability {
  grid-row: 3 / 4;
  top: -50px;
  bottom: -60px;
  height: auto;
  -webkit-mask-image: linear-gradient(transparent 0%, #000 42%, #000 100%);
  mask-image: linear-gradient(transparent 0%, #000 42%, #000 100%);
}
.booking-readability::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #cfdbc6c4, #b9cbb09e 55%, #5d806448);
}

@media (max-width: 760px) and (max-height: 779px) and (orientation: portrait) {
  .home-editorial .opening:has(.studio-aperture) {
    min-height: 100svh;
    padding-top: 68px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    grid-template-rows: auto minmax(110px, 1fr) auto;
    row-gap: 8px;
  }
  .opening-top { gap: 10px; }
  .opening-heading .folio { margin-bottom: 5px; }
  .opening-booking { padding-top: 8px; }
  .home-editorial .visit-choices { margin-top: 8px; }
}
