/* Darkroom opening. The existing motif masks take their ink from the hall palette. */

#hub-root.is-opening-phase {
  --opening-ease: cubic-bezier(.22, .72, .2, 1);
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  color-scheme: dark;
  color: #f3f1f6;
  background: #030913;
}

#hub-root.is-opening-phase .hub-backdrop {
  background:
    radial-gradient(ellipse at 27% 95%, #781a3d36, transparent 54%),
    radial-gradient(ellipse at 51% 47%, #0e2350, #08162e 46%, #030913 84%);
}

#hub-root.is-opening-phase > #atmosphere {
  width: 100%;
  height: 100%;
  opacity: .85;
}

#opening {
  --opening-ease: cubic-bezier(.22, .72, .2, 1);
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100svh;
  min-height: 540px;
  padding: 0;
  overflow: hidden;
  overflow: clip;
  color: #f3f1f6;
  font-family: var(--font-body);
}

#opening::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(64% 56% at 51% 44%, #0645a25e, transparent 72%),
    radial-gradient(62% 43% at 24% 89%, #781a3d65, transparent 76%);
  opacity: 0;
  transition: opacity .62s ease-out;
}

#hub-root.is-opening-finale #opening::before { opacity: 1; }

#opening button {
  color: inherit;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#opening button:focus-visible {
  outline: 1px solid #a9b9d2;
  outline-offset: 8px;
}

#opening button:disabled { cursor: wait; }

#opening .opening-objects {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translate(var(--parallax-x, 0px), var(--parallax-y, 0px));
  transition: opacity .34s ease-out;
  will-change: transform;
}

#hub-root.is-ready #opening .opening-objects { opacity: 1; }

#opening .artifact {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: min(var(--size), 12vw, calc(19svh * var(--ratio)));
  height: auto;
  aspect-ratio: var(--ratio, 1);
  transform: translate(-50%, -50%);
}

#opening .artifact-button {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  outline-offset: 8px;
  transform-origin: 50% 50%;
  animation: mj-opening-drift var(--drift, 10s) ease-in-out infinite alternate;
  animation-delay: var(--phase, 0s);
}

#opening .artifact:nth-child(3n) .artifact-button { animation-name: mj-opening-float-turn; }
#opening .artifact:nth-child(3n + 1) .artifact-button { animation-name: mj-opening-float-sway; }
#opening .artifact-button:focus-visible { outline-style: dashed; border-radius: 40%; }

#opening .gesture {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  transform-origin: 50% 50%;
}

#opening .gesture::before {
  content: "";
  position: absolute;
  inset: -48%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--ink) 23%, transparent), transparent 64%);
  opacity: 0;
  transition: opacity .58s ease-out;
}

#opening .artifact .outline,
#opening .artifact .grain {
  position: absolute;
  inset: 0;
  background: var(--ink);
  -webkit-mask: var(--motif-mask) center / contain no-repeat;
  mask: var(--motif-mask) center / contain no-repeat;
}

#opening .artifact .outline {
  opacity: calc(var(--opacity, .6) * .42);
  transition: opacity .44s ease-out;
}

#opening .artifact .grain {
  opacity: calc(var(--exposure, 0) * .72);
  transition: opacity .58s ease-out;
}

#opening .artifact.is-revealed .outline { opacity: var(--opacity, .6); }
#opening .artifact.is-revealed .grain { opacity: max(.09, calc(var(--exposure, 0) * .72)); }
#opening .artifact:is(.is-cue-lit, .is-active) { z-index: 6; }
#opening .artifact:is(.is-cue-lit, .is-active) .outline {
  opacity: .86;
  transition-duration: .09s;
}
#opening .artifact:is(.is-cue-lit, .is-active) .grain {
  opacity: .94;
  transition-duration: .11s;
}
#opening .artifact:is(.is-cue-lit, .is-active) .gesture::before {
  opacity: 1;
  transition-duration: .15s;
}

#opening .artifact.is-active[data-id="top"] .gesture { animation: mj-opening-spin-top 2.9s var(--opening-ease); }
#opening .artifact.is-active[data-id="fish"] .gesture { animation: mj-opening-swim 3s var(--opening-ease); }
#opening .artifact.is-active[data-id="moon"] .gesture { animation: mj-opening-moon-nod 2.9s var(--opening-ease); }
#opening .artifact.is-active[data-id="hand"] .gesture { animation: mj-opening-catch-light 2.9s var(--opening-ease); }
#opening .artifact.is-active[data-id="glasses"] .gesture { animation: mj-opening-look-around 2.9s var(--opening-ease); }
#opening .artifact.is-active[data-id="boat"] .gesture { animation: mj-opening-boat-rock 2.9s var(--opening-ease); }
#opening .artifact.is-active[data-id="star"] .gesture { animation: mj-opening-star-turn 2.9s var(--opening-ease); }
#opening .artifact.is-active[data-id="shoe"] .gesture { animation: mj-opening-shoe-step 2.9s var(--opening-ease); }

#opening .title-block {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 46%;
  width: max-content;
  max-width: calc(100% - 64px);
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

#opening .main-title {
  display: flex;
  justify-content: center;
  gap: .26em;
  margin: 0;
  color: #f3f1f6;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(64px, 7.3vw, 116px);
  line-height: 1.3;
  letter-spacing: .02em;
  text-shadow: 0 0 30px #a9b9d221;
}

#opening .title-trigger {
  display: flex;
  justify-content: center;
  gap: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  cursor: pointer;
  pointer-events: auto;
}

#opening .main-title span {
  display: inline-block;
  opacity: 0;
  filter: blur(4px);
  transform: translateY(7px);
  transition: opacity .8s ease, filter .8s ease, transform .8s var(--opening-ease);
}

#opening .main-title span:nth-child(2) { transition-delay: .10s; }
#opening .main-title span:nth-child(3) { transition-delay: .20s; }
#opening .main-title span:nth-child(4) { transition-delay: .30s; }
#hub-root.is-title-visible #opening .main-title span,
#opening .title-trigger:focus-visible span { opacity: 1; filter: none; transform: none; }

#opening .skip {
  position: absolute;
  z-index: 12;
  right: max(24px, calc(env(safe-area-inset-right) + 16px));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  min-width: 48px;
  min-height: 44px;
  padding: 12px 8px;
  border: 0;
  background: none;
  color: #a9b9d2;
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: .16em;
  cursor: pointer;
}

#opening .skip:hover,
#opening .skip:focus-visible { color: #fff; }
/* These panels survive the opening stage so they can open onto the hall. */
#hub-root > .opening-curtain {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  width: 50.5%;
  pointer-events: none;
  background: #030913;
  transform: scaleX(0);
  transition: transform var(--curtain-reveal, 350ms) cubic-bezier(.65, .05, .3, 1);
}

#hub-root > .opening-curtain-left { left: 0; transform-origin: left; }
#hub-root > .opening-curtain-right { right: 0; transform-origin: right; }
#hub-root.is-transitioning > .opening-curtain {
  transform: scaleX(1);
  transition-duration: var(--curtain-close, 380ms);
}

#hub-root.is-background #opening *,
#hub-root.is-background #opening *::before,
#hub-root.is-background #opening *::after { animation-play-state: paused !important; }

#hub-root.is-reduced #opening .opening-objects { transform: none; transition: none; }
#hub-root.is-reduced #opening .artifact .outline,
#hub-root.is-reduced #opening .artifact .grain,
#hub-root.is-reduced #opening .gesture::before { transition: none; }
#hub-root.is-reduced #opening .artifact .outline { opacity: .56; }
#hub-root.is-reduced #opening .artifact-button,
#hub-root.is-reduced #opening .artifact.is-active .gesture { animation: none !important; }
#hub-root.is-reduced #opening .main-title span {
  opacity: 1;
  filter: none;
  transform: none;
  transition: none;
}
#hub-root.is-reduced > .opening-curtain { transition: none; }

@media (max-width: 700px) {
  #hub-root.is-opening-phase,
  #opening { min-height: 480px; }
  #opening .opening-objects { bottom: 70px; }
  #opening .artifact {
    left: var(--mx);
    top: clamp(42px, var(--my), calc(100% - 50px));
    width: min(var(--ms), 18vw, calc(9svh * var(--ratio)));
  }
  #opening .artifact-button { min-width: 40px; min-height: 40px; }
  #opening .title-block { top: 43%; max-width: calc(100% - 40px); }
  #opening .main-title { font-size: clamp(45px, 11.8vw, 76px); gap: .12em; letter-spacing: 0; }
}

@media (max-height: 600px) and (min-width: 701px) {
  #hub-root.is-opening-phase,
  #opening { min-height: 360px; }
  #opening .artifact { width: min(var(--size), 10vw, calc(18svh * var(--ratio))); }
  #opening .title-block { top: 45%; }
  #opening .main-title { font-size: 64px; }
}

@media (max-height: 650px) and (max-width: 700px) {
  #opening .main-title { font-size: 44px; }
}

@keyframes mj-opening-drift { from { transform: translate3d(0, -5px, 0) rotate(-2deg); } to { transform: translate3d(2px, 7px, 0) rotate(2deg); } }
@keyframes mj-opening-float-turn { from { transform: translate(-3px, -5px) rotate(-9deg); } to { transform: translate(4px, 5px) rotate(9deg); } }
@keyframes mj-opening-float-sway { from { transform: translate(-6px, 2px) rotate(3deg); } to { transform: translate(6px, -4px) rotate(-4deg); } }
@keyframes mj-opening-spin-top { 0% { transform: rotateY(0) rotate(0); } 40% { transform: rotateY(720deg) rotate(8deg); } 70% { transform: rotateY(1080deg) rotate(-7deg); } 100% { transform: rotateY(1440deg) rotate(0); } }
@keyframes mj-opening-swim { 0%, 100% { transform: translate(0, 0) rotate(0); } 30% { transform: translate(-24px, -16px) rotate(-8deg); } 65% { transform: translate(25px, 4px) rotate(6deg); } }
@keyframes mj-opening-moon-nod { 0%, 100% { transform: rotate(0) scale(1); } 40% { transform: rotate(-13deg) scale(1.06); } 70% { transform: rotate(5deg); } }
@keyframes mj-opening-catch-light { 0%, 100% { transform: rotate(0); } 35% { transform: translateY(-14px) rotate(-7deg); } 65% { transform: rotate(3deg); } }
@keyframes mj-opening-look-around { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-14deg) translateX(-8px); } 65% { transform: rotate(12deg) translateX(6px); } }
@keyframes mj-opening-boat-rock { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-10deg) translateY(-7px); } 65% { transform: rotate(9deg) translateY(4px); } }
@keyframes mj-opening-star-turn { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(110deg) scale(1.15); } }
@keyframes mj-opening-shoe-step { 0%, 100% { transform: rotate(0) translateY(0); } 35% { transform: rotate(-18deg) translateY(-16px); } 65% { transform: rotate(6deg) translateY(3px); } }
