.ow-gallery { isolation: isolate; min-block-size: 100svh; background: #fff; }
.ow-gallery__frame { box-sizing: border-box; margin: 0; display: grid; place-items: center; overflow: hidden; background: #fff; }
.ow-gallery__frame > img, .ow-gallery__image-wrap { display: block; width: var(--site-content-width); height: auto; }
.ow-gallery__image-wrap { position: relative; line-height: 0; }
.ow-gallery__image-wrap img { display: block; width: 100%; height: auto; }
.ow-gallery__hit { position: absolute; top: 22.9%; height: 54.3%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.ow-gallery__hit--1 { left: 16.1%; width: 22%; }
.ow-gallery__hit--2 { left: 39.1%; width: 21.8%; }
.ow-gallery__hit--3 { left: 62%; width: 22%; }
.ow-gallery__hit:focus-visible, .ow-gallery__dialog button:focus-visible { outline: 2px solid white; outline-offset: 3px; }
@media (hover: hover) { .ow-gallery__hit:hover { background: rgba(255,255,255,.1); } }
.ow-gallery__dialog { box-sizing: border-box; position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: auto; padding: 4rem 5vw; border: 0; background: #202020; color: white; overflow: hidden; overscroll-behavior: contain; }
.ow-gallery__dialog[open] { display: grid; place-items: center; }
.ow-gallery__dialog::backdrop { background: rgba(0,0,0,.8); }
.ow-gallery__detail { display: block; max-width: 100%; max-height: calc(100svh - 9rem); width: auto; height: auto; object-fit: contain; }
.ow-gallery__dialog button { color: inherit; border: 0; background: transparent; cursor: pointer; font: inherit; }
.ow-gallery__close { position: absolute; right: 1.5rem; top: 1rem; font-size: 2rem !important; line-height: 1; }
.ow-gallery__controls { position: absolute; bottom: 1rem; display: flex; gap: 2rem; font-size: 1.5rem; }
.ow-gallery__controls button, .ow-gallery__close { min-width: 44px; min-height: 44px; }

.ow-gallery__dialog[open] { animation: dialog-appear 250ms ease-out both; }
@keyframes dialog-appear { from { opacity: 0; } to { opacity: 1; } }
.ow-gallery__detail { animation: poster-appear 450ms cubic-bezier(.24, .77, .26, 1) both; }
@keyframes poster-appear {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ow-gallery__dialog[open], .ow-gallery__detail { animation: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .ow-gallery.has-card-motion {
    display: grid;
    margin-block-start: -100svh;
    background: transparent;
    pointer-events: none;
  }
  .ow-gallery.has-card-motion .ow-gallery__stage,
  .ow-gallery.has-card-motion .ow-gallery__stops { grid-area: 1 / 1; }
  .ow-gallery.has-card-motion .ow-gallery__stage {
    position: sticky;
    inset-block-start: 0;
    block-size: 100svh;
    align-self: start;
    display: grid;
    place-items: center;
    z-index: 1;
    pointer-events: none;
  }
  .ow-gallery.has-card-motion .ow-gallery__stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background: white;
    opacity: var(--gallery-backing, 0);
    pointer-events: none;
  }
  .ow-gallery.has-card-motion .ow-gallery__viewport {
    position: relative;
    width: var(--site-content-width);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    pointer-events: none;
  }
  .ow-gallery.has-card-motion .ow-gallery__frame {
    position: absolute;
    inset: 0;
    transform: translateY(var(--card-lift, 100%));
    pointer-events: auto;
  }
  .ow-gallery.has-card-motion .ow-gallery__frame > img,
  .ow-gallery.has-card-motion .ow-gallery__image-wrap { width: 100%; }
  .ow-gallery.has-card-motion .ow-gallery__stops { padding-block-start: 100svh; }
  .ow-gallery.has-card-motion .ow-gallery__stop { block-size: 100svh; }
  .ow-gallery.has-card-motion[data-gallery-active] .ow-gallery__stage { pointer-events: auto; }
  .ow-gallery.has-card-motion.is-interactive[data-gallery-active] .ow-gallery__stage,
  .ow-gallery.has-card-motion.is-interactive .ow-gallery__frame { touch-action: pan-x pinch-zoom; }
  .ow-gallery.has-card-motion .ow-gallery__dialog { pointer-events: auto; }
}

@media (prefers-reduced-motion: no-preference) and (max-aspect-ratio: 4/5) {
  .ow-gallery.has-card-motion .ow-gallery__viewport { aspect-ratio: 4 / 5; }
  .ow-gallery.has-card-motion .ow-gallery__frame {
    --portrait-band: 60%;
    --portrait-photo-width: 133.333333%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .ow-gallery.has-card-motion .ow-gallery__frame > img,
  .ow-gallery.has-card-motion .ow-gallery__image-wrap { height: var(--portrait-band); z-index: 1; }
  .ow-gallery.has-card-motion .ow-gallery__frame > img { object-fit: cover; }
  .ow-gallery.has-card-motion .ow-gallery__image-wrap { width: 133.333333%; }
  .ow-gallery.has-card-motion .ow-gallery__image-wrap img { height: 100%; }

  /* Only the photographed surface above and below the central crop extends. */
  .ow-gallery__wall { --card-image: url("assets/gallery/poster-wall.webp"); }
  .ow-gallery__frame--wide { --card-image: url("assets/gallery/full.webp"); }
  .ow-gallery__frame--fold { --card-image: url("assets/gallery/detail-landscape.webp"); }
  .ow-gallery.has-card-motion .ow-gallery__frame--diary {
    --card-image: url("assets/gallery/diary-inserts.webp");
    --portrait-band: 55%;
    --portrait-photo-width: 122.222222%;
  }
  .ow-gallery.has-card-motion .ow-gallery__frame::before,
  .ow-gallery.has-card-motion .ow-gallery__frame::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    block-size: calc((100% - var(--portrait-band)) / 2 + 1px);
    background-image: var(--card-image);
    background-repeat: no-repeat;
    background-size: var(--portrait-photo-width) 1200%;
    transform: scaleY(-1);
    pointer-events: none;
  }
  .ow-gallery.has-card-motion .ow-gallery__frame::before {
    inset-block-start: 0;
    background-position: center top;
  }
  .ow-gallery.has-card-motion .ow-gallery__frame::after {
    inset-block-end: 0;
    background-position: center bottom;
  }
}
