/*
 * The rotate screen: on a phone held upright, the film asks to be turned sideways, quietly, in the intro's
 * look: its night and glass over the page, a phone outline turning, one line in Instrument Serif and one in
 * Manrope. Shown and hidden by the media query alone (so it's there before any script runs); it leaves by
 * itself, fading, the moment the phone is sideways. rotate.js pauses the film under it and resumes it after.
 */

.turn {
  position: fixed;
  inset: 0;
  z-index: 40; /* over the film and its controls, under an error screen (notice.css) */
  display: grid;
  place-content: center;
  justify-items: center;
  padding: max(24px, env(safe-area-inset-top)) 32px max(24px, env(safe-area-inset-bottom));
  text-align: center;
  color: #f3efe6;
  background: radial-gradient(ellipse 90% 60% at 50% 45%, rgba(16, 20, 28, 0.78) 0%, rgba(6, 8, 12, 0.94) 75%);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.7s ease, visibility 0s 0.7s;
}

@media (orientation: portrait) and (max-width: 500px) and (hover: none) and (pointer: coarse) {
  .turn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.5s ease;
  }
}

.turn svg {
  width: 112px;
  height: 112px;
  margin-bottom: 26px;
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the phone: Begin's glass, a hairline edge of light */
.turn-body {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: turn 3.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.turn-body rect {
  fill: rgba(255, 255, 255, 0.07);
  stroke: rgba(243, 239, 230, 0.8);
  stroke-width: 1.6;
}

.turn-body path {
  stroke: rgba(243, 239, 230, 0.5);
  stroke-width: 1.6;
}

/* the way to turn it: a short arc of the orb's light, drawn as the phone turns */
.turn-arc {
  stroke: rgba(190, 215, 255, 0.8);
  stroke-width: 1.4;
  filter: drop-shadow(0 0 3px rgba(170, 200, 255, 0.7));
  animation: turn-arc 3.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.turn-arc .sweep {
  stroke-dasharray: 92;
  animation: turn-sweep 3.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes turn {
  0% {
    opacity: 0;
    transform: rotate(0deg);
  }
  10%,
  24% {
    opacity: 1;
    transform: rotate(0deg);
  }
  56%,
  80% {
    opacity: 1;
    transform: rotate(-90deg);
  }
  94%,
  100% {
    opacity: 0;
    transform: rotate(-90deg);
  }
}

@keyframes turn-arc {
  0%,
  22% {
    opacity: 0;
  }
  30%,
  60% {
    opacity: 1;
  }
  76%,
  100% {
    opacity: 0;
  }
}

@keyframes turn-sweep {
  0%,
  24% {
    stroke-dashoffset: 92;
  }
  56%,
  100% {
    stroke-dashoffset: 0;
  }
}

.turn h2 {
  margin: 0;
  font: italic 400 34px/1.1 'Instrument Serif', Georgia, serif;
  letter-spacing: -0.01em;
  text-shadow: 0 0 3px rgba(6, 8, 12, 0.5), 0 0 16px rgba(6, 8, 12, 0.55);
}

.turn p {
  max-width: 17em;
  margin: 12px 0 0;
  font: 500 14px/1.5 'Manrope', system-ui, sans-serif;
  color: rgba(243, 239, 230, 0.7);
  text-wrap: balance; /* no word alone on the last line */
}

@media (prefers-reduced-motion: reduce) {
  .turn-body,
  .turn-arc,
  .turn-arc .sweep {
    animation: none;
  }

  .turn-body {
    transform: rotate(-90deg);
  }
}
