/* What lies over the pages: the sheets, with their footer, the toasts,
   the overlays and the confetti. */

/* SHEETS: from the bottom on a phone, a panel on wider screens */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(29 16 41 / 45%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 0.2s ease;
}
.sheet {
  --pad-x: 18px;
  --pad-bottom: calc(22px + env(safe-area-inset-bottom));
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px var(--pad-x) var(--pad-bottom);
  border-radius: 28px 28px 0 0;
  background: var(--card);
  box-shadow: var(--shadow-l);
  animation: sheet-up 0.38s var(--ease-out);
}
.sheet::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 40px;
  height: 5px;
  margin-left: -20px;
  border-radius: 99px;
  background: var(--border);
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@media (min-width: 720px) {
  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }
  .sheet {
    --pad-x: 28px;
    --pad-bottom: 28px;
    border-radius: 28px;
    animation: pop-in 0.32s var(--spring);
  }
  .sheet::before {
    display: none;
  }
  /* The account opens under its button. */
  .sheet-backdrop:has(.account-sheet) {
    align-items: flex-start;
    justify-content: flex-end;
    padding: calc(var(--header-h) + 8px) 16px 16px;
    background: rgb(29 16 41 / 16%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .account-sheet {
    max-width: 380px;
    transform-origin: top right;
    animation: pop-in 0.28s var(--spring);
  }
}
.sheet h2 {
  padding-right: 44px;
  font-size: 22px;
  font-weight: 850;
  color: var(--text-strong);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card-alt);
  color: var(--text);
  transition: transform 0.2s var(--spring);
}
@media (hover: hover) {
  .sheet-close:hover {
    transform: rotate(90deg);
  }
}
.sheet-hint {
  margin: 6px 0 14px;
  font-size: 14px;
  color: var(--text-muted);
}
/* A footer that stays at the sheet's bottom edge while its list scrolls. */
.sheet-footer {
  position: sticky;
  z-index: 3;
  bottom: calc(-1 * var(--pad-bottom));
  margin: 10px calc(-1 * var(--pad-x)) calc(-1 * var(--pad-bottom));
  padding: 16px var(--pad-x) calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--card) 28%);
}
.sheet-footer .cta {
  width: 100%;
}
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.sheet-actions button {
  flex: 1;
  min-width: 120px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-weight: 750;
  font-size: 14px;
}
.sheet-actions button.primary {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--text-strong);
}
.sheet-actions button.danger {
  border-color: #f3c4c6;
  color: var(--danger);
}
.sheet-actions button:disabled {
  opacity: 0.5;
}
.sheet-notice {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-bg);
  font-size: 13px;
}

/* SCREENING: a video large over everything */
.screening {
  position: fixed;
  inset: 0;
  z-index: 9200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(12 6 18 / 88%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease;
}
.screening-stage {
  /* As wide as it may be while its 16:9 player and head fit the height. */
  width: min(100%, calc((100dvh - 150px) * 16 / 9));
  animation: pop-in 0.3s var(--spring);
}
.screening-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.screening-head h2 {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 850;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.screening-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(255 255 255 / 16%);
  color: #fff;
  transition: transform 0.2s var(--spring);
}
@media (hover: hover) {
  .screening-close:hover {
    transform: rotate(90deg);
    background: rgb(255 255 255 / 26%);
  }
}
.screening .video-frame,
.screening .video-file {
  margin-top: 0;
  border-radius: 14px;
}
.screening .video-file {
  max-height: calc(100dvh - 150px);
}
.screening .version-pill:not(.version-on) {
  border-color: rgb(255 255 255 / 30%);
  background: transparent;
  color: #fff;
}
.screening .video-link {
  margin-top: 0;
  color: var(--gold);
}

/* TOASTS */
.vote-toast-container {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 0;
  right: 0;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}
.vote-toast {
  max-width: 440px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text-strong);
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  box-shadow: var(--shadow);
  animation:
    toast-in 0.4s var(--spring),
    toast-out 0.4s ease 3.6s forwards;
}
.vote-toast strong {
  color: var(--gold);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.9);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* OVERLAYS: the welcome, a suspension, a link's offer */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(29 16 41 / 55%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease;
}
.overlay-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 24px 24px;
  border-radius: 30px;
  background: var(--card);
  text-align: center;
  box-shadow: var(--shadow-l);
  animation: pop-in 0.45s var(--spring);
}
.overlay-card .avatar {
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  font-size: 28px;
}
.overlay-emoji {
  margin-bottom: 10px;
  font-size: 58px;
  line-height: 1;
  animation: wiggle 2.6s ease-in-out infinite;
}
.overlay-card h2 {
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: 900;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.overlay-card p {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-muted);
}
.overlay-card .fine-print {
  font-size: 12.5px;
}
.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

/* CONFETTI */
.confetti {
  position: fixed;
  z-index: 10001;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  pointer-events: none;
  will-change: transform, opacity;
}
.confetti.burst {
  animation: confetti-burst var(--life) cubic-bezier(0.15, 0.75, 0.3, 1) forwards;
}
@keyframes confetti-burst {
  from {
    transform: translate(-50%, -50%) rotate(0);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  to {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + var(--fall))) rotate(var(--spin));
    opacity: 0;
  }
}
.confetti.shower {
  animation: confetti-fall var(--life) linear var(--delay, 0ms) both;
}
@keyframes confetti-fall {
  from {
    transform: translate(0, 0) rotate(0);
  }
  to {
    transform: translate(var(--dx), 110vh) rotate(var(--spin));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
