/* WebGL is an optional visual layer. Every override requires a successful model
   render; losing the context removes that single gate and restores native DOM. */
.object-webgl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: block;
  visibility: hidden;
  pointer-events: none;
}
[data-webgl-active] .object-webgl-canvas { visibility: visible; }
[data-webgl-active] .scene-heading { z-index: 4; }

/* The final display is the same persistent video, never a texture clone. */
/* The original accessible film-poster links are exact projected hit areas on
   the paper. No duplicate links, replacement click handler or extra Tab stops. */
#gallery[data-webgl-active] .album-book {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  perspective: none;
  transform: none;
  pointer-events: none;
}
#gallery[data-webgl-active] .album-spread { position: static; display: contents; }
#gallery[data-webgl-active] .album-book::before,
#gallery[data-webgl-active] .album-book::after,
#gallery[data-webgl-active] .album-spread::before,
#gallery[data-webgl-active] .album-spread::after,
#gallery[data-webgl-active] .album-cover,
#gallery[data-webgl-active] .album-turn-leaf,
#gallery[data-webgl-active] .album-turn-underlay,
#gallery[data-webgl-active] .album-turn-shadow,
#gallery[data-webgl-active] .album-interleaf { display: none; }
#gallery[data-webgl-active] .album-page {
  position: absolute;
  left: var(--webgl-photo-left, 25%);
  top: var(--webgl-photo-top, 35%);
  width: var(--webgl-photo-width, 20%);
  height: var(--webgl-photo-height, 25%);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  opacity: 1;
}
#gallery[data-webgl-active] .album-page .still-frame {
  display: block;
  flex: none;
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  background: none;
  box-shadow: none;
  border-radius: 0;
  pointer-events: none;
}
#gallery[data-webgl-active][data-webgl-interactive] .album-page .still-frame { pointer-events: auto; }
#gallery[data-webgl-active] .album-page .still-frame img { opacity: 0; }
#gallery[data-webgl-active] .album-page .still-frame::after { display: none; }
#gallery[data-webgl-active] .album-page figcaption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#gallery[data-webgl-active] .still-expand { opacity: 0; }
#gallery[data-webgl-active][data-webgl-interactive] .still-expand { opacity: 1; }
#gallery[data-webgl-active] .still-frame:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 7px;
  box-shadow: 0 0 0 9px var(--ink);
}
#gallery[data-webgl-active] .album-edge {
  top: var(--webgl-book-top, 35%);
  bottom: auto;
  height: var(--webgl-book-height, 25%);
  opacity: 0;
  pointer-events: none;
}
#gallery[data-webgl-active] .album-edge-prev { left: var(--webgl-book-left, 10px); }
#gallery[data-webgl-active] .album-edge-next { right: auto; left: calc(var(--webgl-book-left, 10px) + var(--webgl-book-width, calc(100% - 20px)) - clamp(44px, 5vw, 76px)); }
#gallery[data-webgl-active][data-webgl-interactive] .album-edge,
#gallery[data-webgl-active] .album-edge:focus-visible { opacity: 1; pointer-events: auto; }

/* A separate mobile composition, including phones turned sideways. Native media
   is deliberately retained; WebGL never downloads or consumes a phone GPU. */

  .home-page #films, .home-page #gallery { height: auto !important; }
  .home-page #films .object-stage, .home-page #gallery .object-stage { position: relative; top: auto; display: block; height: auto; min-height: 0; padding: 48px 0 40px; }
  .home-page #films .scene-heading, .home-page #gallery .scene-heading { position: relative; inset: auto; opacity: 1; padding: 0 24px; margin-bottom: 28px; display: block; }
  .home-page .scene-heading .eyebrow { font-size: 10px; letter-spacing: .14em; margin-bottom: 14px; }
  .home-page #films .scene-heading h2, .home-page #gallery .scene-heading h2 { font-size: clamp(43px, 11.5vw, 64px); line-height: 1; }
  .home-page .scene-heading .section-note { max-width: 450px; margin-top: 20px; font-size: 13px; line-height: 1.8; }
  .home-page .scene-scroll-hint, .home-page .object-webgl-canvas { display: none; }
  .home-page #films .laptop-computer[data-scene-object] { position: relative; inset: auto; width: 100%; height: auto; min-height: 0; margin: 0; transform: none; perspective: none; opacity: 1; pointer-events: auto; }
  .home-page #films .device-assembly, .home-page #films .device-lid, .home-page #films .device-lid-front { position: relative; inset: auto; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; transform: none; transform-style: flat; }
  .home-page #films .device-base, .home-page #films .device-shadow, .home-page #films .device-camera, .home-page #films .device-lid-back, .home-page #films .device-lid-edge, .home-page #films .device-lid::before, .home-page #films .device-lid::after { display: none; }
  .home-page #films .laptop-screen { display: block; height: auto; border-radius: 0; background: var(--paper); color: var(--ink); }
  .home-page #films .screen-player-stage { width: 100%; height: auto; aspect-ratio: 16 / 9; background: var(--viewer); }
  .home-page #films .screen-player-stage:has([data-format="portrait"]) { aspect-ratio: 4 / 5; max-height: 70svh; }
  .home-page #films #screen-player { position: absolute; inset: 0; }
  .home-page .screen-start { color: var(--paper); font-size: 13px; }
  .home-page .screen-start > span { width: 58px; height: 58px; font-size: 30px; }
  .home-page .screen-film-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 18px 16px 0; border: 0; background: var(--paper); }
  .home-page .screen-film-choice { padding: 0 0 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; gap: 10px; min-height: 0; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; text-align: left; background: none; }
  .home-page .screen-film-choice[aria-current="true"] { border-bottom-color: var(--ink); }
  .home-page .screen-film-choice img { display: block; flex: none; width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 3px; object-fit: cover; }
  .home-page .screen-film-choice[data-screen-film="portrait"] img { object-position: center 32%; object-fit: cover; }
  .home-page .screen-film-choice strong { font-size: clamp(18px, 5vw, 25px); line-height: 1.05; min-height: 2.1em; }
  .home-page .screen-film-choice small { font-size: 9px; line-height: 1.5; color: var(--surface); }
  .home-page .screen-choice-number { display: none; }
  .home-page #gallery .object-stage { padding-bottom: 24px; }
  .home-page #gallery .album-book { position: relative; inset: auto; display: flex; gap: 12px; width: 100%; height: auto; min-height: 0; padding: 0 24px 12px; margin: 0; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding-inline: 24px; overscroll-behavior-x: contain; scrollbar-width: none; transform: none; perspective: none; touch-action: auto; pointer-events: auto; }
  .home-page #gallery .album-book::-webkit-scrollbar { display: none; }
  .home-page #gallery .album-book::before, .home-page #gallery .album-book::after, .home-page #gallery .album-spread::before, .home-page #gallery .album-spread::after, .home-page #gallery .album-cover { display: none; }
  .home-page #gallery .album-spread { display: contents; }
  .home-page #gallery .album-page { position: relative; inset: auto; display: block; flex: 0 0 calc(100% - 12px); width: auto; height: auto; min-width: 0; padding: 0; margin: 0; opacity: 1; background: none; box-shadow: none; color: var(--paper); scroll-snap-align: center; scroll-snap-stop: always; }
  .home-page #gallery .album-page .still-frame { display: block; position: relative; width: 100%; height: auto; max-height: none; aspect-ratio: 4 / 3; border-radius: 3px; background: #260000; box-shadow: none; pointer-events: auto; }
  .home-page #gallery .album-page .still-frame::after { display: none; }
  .home-page #gallery .album-page .still-frame img { opacity: 1; object-fit: contain; }
  .home-page #gallery .album-page figcaption { position: static; display: flex; align-items: baseline; justify-content: space-between; width: auto; height: auto; padding: 16px 0 4px; overflow: visible; clip-path: none; white-space: normal; gap: 12px; font-size: 13px; line-height: 1.6; color: var(--paper); }
  .home-page #gallery .album-page figcaption > span:last-child { font-size: 9px; color: var(--muted); }
  .home-page #gallery .still-expand { width: 36px; height: 36px; right: 10px; bottom: 10px; opacity: 1; }
  .home-page #gallery .album-navigation { position: relative; inset: auto; height: auto; margin: 10px 24px 0; display: flex; justify-content: space-between; gap: 16px; font-size: 12px; }
  /* Reset native button padding before its flex child can shrink the circle. */
  .home-page #gallery .album-edge { position: static; width: 48px; height: 48px; padding: 0; border-radius: 50%; color: var(--paper); line-height: 1; opacity: 1; pointer-events: auto; flex: 0 0 48px; }
  .home-page #gallery .album-edge > span { width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--paper); box-shadow: none; font-size: 22px; line-height: 1; transform: none; }

@media (max-width: 1000px) and (pointer: coarse) and (max-height: 550px) {
  .home-page #films .screen-player-stage { max-height: 78svh; }
  .home-page .screen-film-options { max-width: 640px; margin-inline: auto; }
  .home-page #gallery .album-page { flex-basis: min(72%, 560px); }
}

.home-page #gallery .album-page.album-end-page { display:none; }

.home-page #gallery .album-book[data-album-closed="true"] { overflow:visible; display:block; padding-inline:24px; }
.home-page #gallery .album-book[data-album-closed="true"] .album-spread { display:none; }
.home-page #gallery .album-back-cover { position:relative; left:auto; top:auto; width:100%; height:300px; transform:none; animation:mobile-album-close .5s ease-out both; }
.home-page #gallery .album-back-cover > span { transform:none; }
@keyframes mobile-album-close { from { opacity:.3; transform:perspective(900px) rotateY(45deg); } to { opacity:1; transform:perspective(900px) rotateY(0); } }
@media (prefers-reduced-motion:reduce) { .home-page #gallery .album-back-cover { animation:none; } }

.home-page #gallery .album-book[data-album-closed="true"][data-album-cover="front"] .album-back-cover { animation:mobile-album-flip .75s ease-in-out both; transform:none; }
@keyframes mobile-album-flip { from { transform:perspective(900px) rotateY(180deg); } to { transform:perspective(900px) rotateY(360deg); } }
@media(prefers-reduced-motion:reduce) { .home-page #gallery .album-book[data-album-closed="true"][data-album-cover="front"] .album-back-cover { animation:none; } }

.home-page #gallery .album-book[data-album-closing-side="front"] .album-back-cover { animation:mobile-album-close .5s ease-out both; transform:none; }
@media(prefers-reduced-motion:reduce) { .home-page #gallery .album-book[data-album-closing-side="front"] .album-back-cover { animation:none; } }
