/* Circus curtain loading screen.
   Markup: .curtain > .curtain-side.curtain-l > i, .curtain-side.curtain-r > i, .curtain-top > i
   curtain.js adds .open once the page has loaded, then removes the whole thing. */
.curtain { position: fixed; inset: 0; z-index: 1000; overflow: hidden; }
.curtain.open { pointer-events: none; }
.curtain-seen .curtain { display: none; }
.curtain i { display: block; width: 100%; height: 100%; }

/* The two drapes: two different pieces of cloth, rendered in Blender (tools/curtain). Each picture
   fills its half of the screen from the bottom up, so the fringe always sits on the bottom edge.
   The dark red behind is what shows for the moment before the picture arrives. */
.curtain-side { position: absolute; top: 0; width: 50.5%; height: 100%; filter: drop-shadow(0 0 2vw #000c); }
.curtain-l { left: 0; transform-origin: 0 50%; --d: -1; }
.curtain-r { right: 0; transform-origin: 100% 50%; --d: 1; }
.curtain-side i { background: #5e0a10 right bottom / cover; }
.curtain-l i { background-image: linear-gradient(#0009, #0000 30%), url(/img/curtain/left.webp); }
.curtain-r i { background-image: linear-gradient(#0009, #0000 30%), url(/img/curtain/right.webp); background-position: left bottom; }

/* The valance: a gathered strip with an uneven scalloped hem, hanging across the top. */
.curtain-top { position: absolute; inset: 0 0 auto; height: clamp(80px, 17vh, 160px); filter: drop-shadow(0 .8vh 1vh #000b); }
.curtain-top i { background: url(/img/curtain/valance.webp) center top / cover; }

@media (prefers-reduced-motion: no-preference) {
  /* Gather to the side first, then the bundle slides off. */
  .curtain.open .curtain-side { animation: curtain-part 2s forwards; }
  .curtain.open .curtain-top { animation: curtain-lift .8s 1.2s cubic-bezier(.6, 0, .8, .3) forwards; }
  @keyframes curtain-part {
    0% { transform: translateX(0) scaleX(1); animation-timing-function: cubic-bezier(.7, 0, .25, 1); }
    68% { transform: translateX(0) scaleX(.2); animation-timing-function: ease-in; }
    100% { transform: translateX(calc(var(--d) * 30%)) scaleX(.2); }
  }
  @keyframes curtain-lift { to { transform: translateY(-115%); } }
}
@media (prefers-reduced-motion: reduce) {
  .curtain.open { animation: curtain-fade .4s forwards; }
  @keyframes curtain-fade { to { opacity: 0; } }
}
