/* Keep the winter photograph opaque below the second plate. At the midpoint
   the two images still add to a fully opaque picture. */
#music .cinema {
  isolation: isolate;
  overflow: hidden;
}
#music .cinema .plate {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
#music .cinema .plate-snow { z-index: 0; opacity: 1; }
#music .cinema .plate-lion {
  z-index: 1;
  background: #47352b;
  opacity: 0;
  transition: opacity 1050ms cubic-bezier(.42,0,.28,1);
}
body[data-track="lion"] #music .cinema .plate-lion { opacity: 1; }
body[data-track="lion"] #music .cinema[data-lion-ready="waiting"] .plate-lion { opacity: 0; }
#music .cinema .plate > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
#music .cinema .plate-snow > img {
  transform-origin: 70% 37%;
  animation: winter-drift 31s ease-in-out infinite alternate both;
}
#music .cinema .plate-lion > img {
  transform-origin: 76% 55%;
  animation: window-drift 37s ease-in-out -9s infinite alternate both;
}
@keyframes winter-drift {
  from { transform: scale(1.010) translate3d(0,0,0); }
  to   { transform: scale(1.035) translate3d(-.20%,-.22%,0); }
}
@keyframes window-drift {
  from { transform: scale(1.010) translate3d(.02%,0,0); }
  to   { transform: scale(1.038) translate3d(-.25%,-.12%,0); }
}
#music .cinema .veil,
#music .cinema .weather,
#music .cinema .light-bridge {
  pointer-events: none;
  user-select: none;
}
/* The photographic grade travels with its own plate. A single shared
   gradient switching from pale to dark would flash during the dissolve. */
#music .cinema .veil { z-index: 2; background: transparent; }
#music .cinema .plate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#music .cinema .plate-snow::after { background: var(--snow-veil,transparent); }
#music .cinema .plate-lion::after { background: var(--lion-veil,transparent); }
#music .cinema .weather {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 3;
}
#music .cinema .weather-field {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transition: opacity 950ms ease-in-out;
}
#music .cinema .weather-field[data-kind="snow"] { opacity: 1; }
#music .cinema .weather-field[data-kind="dust"] { opacity: 0; }
body[data-track="lion"] #music .cinema .weather-field[data-kind="snow"] { opacity: 0; }
body[data-track="lion"] #music .cinema .weather-field[data-kind="dust"] { opacity: 1; }
#music .cinema .weather-grain {
  position: absolute;
  left: var(--grain-x);
  top: var(--grain-y);
  width: var(--grain-size);
  height: var(--grain-size);
  border-radius: 50%;
  opacity: 0;
  animation-duration: var(--grain-time);
  animation-delay: var(--grain-delay);
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
#music .cinema [data-kind="snow"] .weather-grain {
  background: #f8fbff;
  animation-name: snow-travel;
}
#music .cinema [data-kind="dust"] .weather-grain {
  background: #ffe6a4;
  animation-name: dust-travel;
}
@keyframes snow-travel {
  0%   { opacity: 0; transform: translate3d(0,0,0); }
  20%  { opacity: var(--grain-alpha); }
  52%  { transform: translate3d(var(--grain-bend),var(--grain-half),0); }
  77%  { opacity: var(--grain-alpha); }
  100% { opacity: 0; transform: translate3d(var(--grain-dx),var(--grain-dy),0); }
}
@keyframes dust-travel {
  0%   { opacity: 0; transform: translate3d(0,0,0); }
  24%  { opacity: var(--grain-alpha); }
  58%  { transform: translate3d(var(--grain-bend),var(--grain-half),0); }
  70%  { opacity: var(--grain-alpha); }
  100% { opacity: 0; transform: translate3d(var(--grain-dx),var(--grain-dy),0); }
}

/* A small highlight travels from the sun dog to the shop light. It never
   covers the full image, and it doesn't change the exposure of either scene. */
#music .cinema .light-bridge {
  position: absolute;
  z-index: 4;
  right: auto;
  bottom: auto;
  left: var(--snow-light-x,70%);
  top: var(--snow-light-y,37%);
  width: clamp(44px,9%,120px);
  height: auto;
  aspect-ratio: 1;
  transform: translate(-50%,-50%) scale(.87);
  transition:
    left 1050ms cubic-bezier(.42,0,.28,1),
    top 1050ms cubic-bezier(.42,0,.28,1),
    transform 1050ms cubic-bezier(.42,0,.28,1);
}
body[data-track="lion"] #music .cinema .light-bridge {
  left: var(--lion-light-x,76%);
  top: var(--lion-light-y,55%);
  transform: translate(-50%,-50%) scale(.76,1.03);
}
#music .cinema .light-bridge::before,
#music .cinema .light-glint {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 50%;
}
#music .cinema .light-bridge::before {
  content: "";
  background: radial-gradient(ellipse at center,
    rgba(255,240,206,.14),rgba(253,226,181,.06) 29%,rgba(253,226,181,0) 68%);
}
#music .cinema .light-glint {
  opacity: 0;
  background: radial-gradient(ellipse at center,
    rgba(255,241,205,.50),rgba(255,218,158,.27) 13%,rgba(246,178,116,.09) 40%,transparent 72%);
}
#music .cinema[data-ambient="paused"] .weather-grain,
#music .cinema[data-ambient="paused"] .plate > img { animation-play-state: paused; }

/* Visibility is opt-in. JS only prepares elements that begin below the fold. */
.reveal[data-reveal-state] {
  transition: opacity 650ms ease-out, translate 720ms cubic-bezier(.2,.7,.3,1);
}
.reveal[data-reveal-state="waiting"] { opacity: 0; translate: 0 12px; }
.reveal[data-reveal-state="visible"],
.reveal[data-reveal-state]:focus-within { opacity: 1; translate: none; }
.reveal[data-reveal-state]:focus-within { transition: none; }
img[data-parallax][data-depth-ready] {
  transform: translate3d(0,var(--depth-y,0px),0) scale(1.045);
  transform-origin: center;
}

.story-frame:has(> img[data-parallax]) { overflow: hidden; }

@media (max-width: 600px) {
  #music .cinema .weather-grain[data-fine] { display: none; }
  #music .cinema .plate-snow > img { animation-duration: 38s; }
  #music .cinema .plate-lion > img { animation-duration: 42s; }
  #music .cinema .light-bridge { width: clamp(42px,10%,70px); }
}
body[data-motion="off"] #music .cinema .plate,
body[data-motion="off"] #music .cinema .weather-field,
body[data-motion="off"] #music .cinema .light-bridge,
body[data-motion="off"] .reveal[data-reveal-state] { transition: none !important; }
body[data-motion="off"] #music .cinema .plate > img,
body[data-motion="off"] #music .cinema .weather-grain {
  animation: none !important;
  transform: none !important;
}
body[data-motion="off"] #music .cinema .weather,
body[data-motion="off"] #music .cinema .light-bridge { visibility: hidden; }
body[data-motion="off"] img[data-parallax][data-depth-ready] { transform: none; }
body[data-motion="off"] .reveal[data-reveal-state] { opacity: 1; translate: none; }
@media (prefers-reduced-motion: reduce) {
  #music .cinema .plate, #music .cinema .weather-field, #music .cinema .light-bridge,
  .reveal[data-reveal-state] { transition: none !important; }
  #music .cinema .plate > img, #music .cinema .weather-grain {
    animation: none !important;
    transform: none !important;
  }
  #music .cinema .weather, #music .cinema .light-bridge { visibility: hidden; }
  img[data-parallax][data-depth-ready] { transform: none; }
  .reveal[data-reveal-state] { opacity: 1; translate: none; }
}
