.satella-effects { display: none; }

body[data-broken] {
  --satella-surge: 0;
  --satella-reach: calc(var(--satella-depth) + var(--satella-surge));
  --satella-clear: calc(72% - var(--satella-depth) * 46%);
}

body[data-timeline-rewinding] {
  --satella-surge: calc(var(--satella-depth) * .16);
}

body[data-broken] .satella-effects {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

body[data-broken] :is(.topbar, .page, .footer) {
  position: relative;
  z-index: 1;
}

.satella-mist {
  position: absolute;
  inset: -20% -14%;
  background: url("assets/satella-mist.png") repeat;
  pointer-events: none;
  transition: opacity .65s ease;
}

.satella-mist-back {
  opacity: calc(.08 + var(--satella-reach) * .67);
  background-size: max(640px, 66vw) max(310px, 44vh);
  mask-image: radial-gradient(ellipse at 50% 42%, transparent 8%, #0008 42%, #000 76%);
  animation: satella-drift 26s ease-in-out infinite alternate;
}

.satella-mist-front {
  inset: -10% -12%;
  opacity: calc(.035 + var(--satella-reach) * .62);
  background-size: max(720px, 76vw) max(200px, 38vh);
  mask-image: radial-gradient(ellipse at 50% 42%, transparent var(--satella-clear), #0008 68%, #000 97%);
  animation: satella-drift 19s -9s ease-in-out infinite alternate-reverse;
}

.satella-hand {
  position: absolute;
  width: var(--hand-width, clamp(230px, 34vw, 500px));
  aspect-ratio: 2 / 3;
  opacity: clamp(0, calc(var(--hint, 0) + (var(--satella-reach) - var(--gate, 0)) * 1.04), var(--hand-max, .85));
  transform: translate(var(--hand-x, 0), var(--hand-y, 0));
  transition: opacity .6s ease, transform .9s ease;
}

.satella-hand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/satella-hand.webp") center / contain no-repeat;
  filter: hue-rotate(287deg) saturate(1.12);
  transform-origin: 50% 85%;
  animation: satella-emerge var(--period, 9s) var(--delay, -4s) ease-in-out infinite;
}

.satella-hand:nth-of-type(1) {
  --hint: .075;
  --angle: -21deg;
  --hand-x: calc(var(--satella-reach) * 9vw);
  --hand-y: calc(var(--satella-reach) * -13vh);
  bottom: -34vh;
  left: -13vw;
}

.satella-hand:nth-of-type(2) {
  --gate: .16;
  --angle: 19deg;
  --mirror: -1;
  --period: 12s;
  --delay: -6s;
  --hand-x: calc(var(--satella-reach) * -8vw);
  --hand-y: calc(var(--satella-reach) * -11vh);
  bottom: -29vh;
  right: -14vw;
}

.satella-hand:nth-of-type(3) {
  --gate: .33;
  --angle: 150deg;
  --period: 10s;
  --delay: -2s;
  --hand-width: clamp(180px, 26vw, 420px);
  --hand-x: calc(var(--satella-reach) * -11vw);
  --hand-y: calc(var(--satella-reach) * 9vh);
  top: -28vh;
  right: -8vw;
}

.satella-hand:nth-of-type(4) {
  --gate: .52;
  --angle: 192deg;
  --mirror: -1;
  --period: 14s;
  --delay: -11s;
  --hand-width: clamp(150px, 24vw, 400px);
  --hand-x: calc(var(--satella-reach) * 9vw);
  --hand-y: calc(var(--satella-reach) * 11vh);
  top: -22vh;
  left: -10vw;
}

.satella-hand:nth-of-type(5) {
  --gate: .72;
  --angle: -7deg;
  --period: 8s;
  --delay: -6s;
  --hand-width: clamp(130px, 21vw, 300px);
  --hand-y: calc(var(--satella-reach) * -13vh);
  bottom: -31vh;
  left: 45%;
}

/* Mist can touch the playable board at the edges. Its center stays clear. */
body[data-broken] .board-shell::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  opacity: calc(.035 + var(--satella-reach) * .42);
  background: url("assets/satella-mist.png") center / 120% 88%;
  mask-image: radial-gradient(ellipse at 50% 44%, transparent calc(70% - var(--satella-depth) * 32%), #0005 76%, #000 100%);
  transition: opacity .65s ease;
}

body[data-broken] .rewind-effect.active::before,
body[data-broken] .rewind-effect.active::after {
  content: "";
  position: absolute;
  bottom: -28%;
  width: 52%;
  height: 100%;
  left: -12%;
  opacity: 0;
  background: url("assets/satella-hand.webp") center bottom / contain no-repeat;
  filter: hue-rotate(287deg) saturate(1.12);
  transform-origin: 50% 88%;
  --overlay-opacity: calc(.09 + var(--satella-depth) * .82);
  --sweep: -23deg;
  animation: satella-loom 1s ease-in-out both;
}

body[data-broken] .rewind-effect.active::after {
  left: auto;
  right: -12%;
  bottom: -21%;
  --mirror: -1;
  --sweep: 23deg;
  --overlay-opacity: calc(var(--satella-depth) * .76);
}

body[data-broken] .rewind-effect > :is(.icon, #rewind-label, .timeline-milestone) { z-index: 1; }

@keyframes satella-drift {
  from { transform: translate3d(-7%, 4%, 0) scale(1.02); }
  to { transform: translate3d(7%, -5%, 0) scale(1.13); }
}

@keyframes satella-emerge {
  0%, 100% { transform: rotate(calc(var(--angle) - 5deg)) scaleX(var(--mirror, 1)) translateY(13%) scaleY(.91); }
  38% { transform: rotate(var(--angle)) scaleX(var(--mirror, 1)) translateY(2%) scaleY(1.02); }
  62% { transform: rotate(calc(var(--angle) + 9deg)) scaleX(var(--mirror, 1)) translateY(-5%) scaleY(1.07); }
}

@keyframes satella-loom {
  0%, 100% { opacity: 0; transform: rotate(calc(var(--sweep) * 1.5)) scaleX(var(--mirror, 1)) translateY(31%); }
  43% { opacity: var(--overlay-opacity); transform: rotate(var(--sweep)) scaleX(var(--mirror, 1)) translateY(-9%); }
  66% { opacity: calc(var(--overlay-opacity) * .75); transform: rotate(calc(var(--sweep) * .72)) scaleX(var(--mirror, 1)) translateY(-3%); }
}

@media (max-width: 690px) {
  .satella-hand:nth-of-type(1) { bottom: -20vh; left: -32vw; }
  .satella-hand:nth-of-type(2) { bottom: -14vh; right: -32vw; }
  .satella-hand:nth-of-type(3) { top: -21vh; right: -22vw; }
  .satella-hand:nth-of-type(4) { top: -15vh; left: -19vw; }
  .satella-hand:nth-of-type(5) { bottom: -22vh; }
  body[data-broken] .rewind-effect.active::before,
  body[data-broken] .rewind-effect.active::after { width: 62%; }
}

@media (prefers-reduced-motion: reduce) {
  .satella-mist, .satella-hand::after { animation: none; }
  .satella-hand::after { transform: rotate(var(--angle)) scaleX(var(--mirror, 1)); }
  body[data-broken] .rewind-effect.active::before,
  body[data-broken] .rewind-effect.active::after { content: none; }
}
