/* Device side of the spotlight draw: the lights go out and a circular beam
   sweeps across the phone, uncovering the poly field as it passes. */

/* The draw replaces the phone UI, so nothing shows through the black. */
body.spotlight-reveal .container,
body.spotlight-reveal .emoji-container {
  visibility: hidden;
}

.spotlight {
  position: fixed;
  inset: 0;
  z-index: 2100;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

.spotlight.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0s;
}

.spotlight.ask {
  pointer-events: auto;
}

.spotlight-ask {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6vw;
  padding: 8vw;
  box-sizing: border-box;
}

.spotlight.ask .spotlight-ask {
  display: flex;
}

.spotlight.ask .spotlight-beam {
  opacity: 0;
}

.spotlight-ask-text {
  margin: 0;
  text-align: center;
  font-family: var(--display-font);
  font-size: 7.4vw;
  font-weight: 800;
  line-height: 1.25;
  color: var(--turn-primary);
}

.spotlight-ask-shape {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
}

html.team-square .spotlight-ask-shape {
  transform: rotate(-9deg);
}

html.team-circle .spotlight-ask-shape {
  transform: rotate(7deg);
}

html.team-triangle .spotlight-ask-shape {
  transform: rotate(-11deg);
}

.spotlight-ask-actions {
  display: flex;
  flex-direction: column;
  width: min(100%, 22rem);
  gap: 3vw;
}

.spotlight-ask-actions button {
  padding: 4vw 5vw;
  border: none;
  border-radius: 999px;
  font-family: var(--display-font);
  font-size: 6vw;
  font-weight: 700;
  cursor: pointer;
}

.spotlight-ask-yes {
  background: var(--turn-primary);
  color: var(--spot-ink, #ffffff);
}

.spotlight-ask-no {
  background: transparent;
  color: var(--turn-primary);
  box-shadow: inset 0 0 0 0.25em var(--turn-primary);
}

.spotlight-ask-actions button.chosen {
  outline: 0.35em solid var(--turn-accent);
  outline-offset: 0.15em;
  background-image: repeating-linear-gradient(
    -45deg,
    color-mix(in srgb, var(--turn-accent) 42%, transparent) 0 0.42em,
    transparent 0.42em 0.84em
  );
}

.spotlight-ask-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7vw;
  margin: 0;
  padding: 0 8vw;
  text-align: center;
  font-family: var(--display-font);
  font-size: 4.2vw;
  font-weight: 600;
  line-height: 1.35;
  color: var(--turn-primary-deep);
  opacity: 0;
  visibility: hidden;
}

.spotlight-ask.decided .spotlight-ask-note {
  opacity: 1;
  visibility: visible;
}

/* vw sizing is for a phone. Breakpoints are in px because the page root is 10px,
   so a rem query would trip on a large phone and the type would stay tiny. */
@media (min-width: 768px) {
  .spotlight-ask {
    gap: 40px;
    padding: 48px 32px 96px;
  }

  .spotlight-ask-text {
    max-width: 640px;
    font-size: 42px;
  }

  .spotlight-ask-actions {
    width: min(100%, 420px);
    gap: 16px;
  }

  .spotlight-ask-actions button {
    padding: 18px 28px;
    font-size: 28px;
  }

  .spotlight-ask-note {
    bottom: 40px;
    padding: 0 32px;
    font-size: 22px;
  }

  .spotlight-message {
    width: min(84vw, 640px);
    font-size: 76px;
  }

  .spotlight.lost .spotlight-message {
    font-size: 52px;
  }
}

@media (min-width: 1280px) {
  .spotlight-ask-text {
    max-width: 760px;
    font-size: 52px;
  }

  .spotlight-ask-actions {
    width: min(100%, 480px);
  }

  .spotlight-ask-actions button {
    padding: 22px 32px;
    font-size: 32px;
  }

  .spotlight-ask-note {
    bottom: 48px;
    font-size: 26px;
  }

  .spotlight-message {
    width: min(70vw, 820px);
    font-size: 96px;
  }

  .spotlight.lost .spotlight-message {
    font-size: 64px;
  }
}

/* Flat team colour, faded in only after this phone has been picked. */
.spotlight-wash {
  position: absolute;
  inset: 0;
  background: var(--spot-wash, #327c47);
  opacity: 0;
  transition: opacity 1.1s ease;
}

.spotlight.won .spotlight-wash {
  opacity: 1;
}

/* Sits behind the beam: only what the beam uncovers is readable. Stays hidden
   while the beam searches, so nobody reads it before being picked. */
.spotlight-message {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 84vw;
  margin: 0;
  transform: translate(-50%, -50%) scale(0.88);
  text-align: center;
  font-family: var(--display-font);
  font-size: 11vw;
  font-weight: 800;
  line-height: 1.1;
  color: var(--spot-ink, #ffffff);
  opacity: 0;
  transition: opacity 0.7s ease 0.35s, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.35) 0.35s;
}

.spotlight.won .spotlight-message {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Lost: the text sits on the black, not inside the beam. */
.spotlight.lost .spotlight-message {
  z-index: 3;
  color: #ffffff;
  font-size: 8vw;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/*
 * The beam is a hole rather than a lamp: the black layer covers the phone and
 * the gradient punches a soft-edged circle out of it. Position and radius come
 * from device-spotlight.js, which animates them frame by frame.
 */
.spotlight-beam {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(
      circle var(--beam-r, 0px) at var(--beam-x, 50%) var(--beam-y, 50%),
      rgba(0, 0, 0, 0) 0 62%,
      rgba(0, 0, 0, 0.8) 86%,
      #000 100%
    ),
    radial-gradient(
      circle calc(var(--beam-r, 0px) * 0.66) at var(--beam-x, 50%) var(--beam-y, 50%),
      rgba(255, 244, 214, 0.16),
      rgba(255, 244, 214, 0) 100%
    );
}

@media (prefers-reduced-motion: reduce) {
  .spotlight-wash,
  .spotlight-message {
    transition: none;
  }
}
