/* CTFNG Stage Animations, Podium Reveal, Drag-and-Drop Rows & Menu Motion */

.round-step-item.is-solve-strike {
  animation: solveStrikePulse 850ms var(--ease-out-expo) both;
}

.round-step-item.is-solve-pop {
  animation: solvePopSpring 650ms var(--ease-out-expo) both;
}

@keyframes solveStrikePulse {
  0% {
    transform: translateX(-18px) scale(0.95);
    border-color: var(--accent);
    background-color: var(--surface-muted);
  }
  50% {
    transform: translateX(4px) scale(1.03);
    border-color: var(--accent);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

@keyframes solvePopSpring {
  0% {
    transform: scale(0.86);
    border-color: var(--accent);
  }
  60% {
    transform: scale(1.04);
    border-color: var(--accent);
  }
  100% {
    transform: scale(1);
  }
}

/* Flying Solve Badge & Preview Dock (Hook: solve_feed) */
.solve-preview-dock {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 640;
  width: min(360px, 92vw);
  pointer-events: none;
}

.solve-preview-dock .panel-box {
  border: 2px solid var(--accent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.solve-flyer-chip {
  position: fixed;
  z-index: 650;
  pointer-events: none;
  padding: 0.55rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 900;
  background-color: var(--accent);
  color: var(--accent-contrast);
  border: 2px solid var(--text-primary);
  border-radius: var(--radius-sm);
  transform: translate(-50%, -50%);
}

.solve-flyer-chip.is-flying {
  animation: solveFlyArc var(--fly-dur, 900ms) var(--ease-out-expo) forwards;
}

@keyframes solveFlyArc {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.75);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -65%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--fly-dx, 240px)), calc(-50% + var(--fly-dy, -120px))) scale(0.85);
  }
}

/* Stage Transition Overlay (ENERGY 3 / MOTION 3) */
.stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 4px solid var(--accent);
}

.stage-overlay-shutter {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  background-color: var(--surface);
  z-index: 1;
}

.stage-shutter-top {
  top: 0;
  border-bottom: 2px solid var(--accent);
}

.stage-shutter-bottom {
  bottom: 0;
  border-top: 2px solid var(--accent);
}

.stage-overlay-core {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
  max-width: 90vw;
}

.stage-overlay-kicker {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stage-overlay-headline {
  font-size: clamp(2rem, 1.4rem + 3vw, 4rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-primary);
}

.stage-overlay.is-shutter-slam {
  animation: stageOverlayFade var(--anim-duration, 1100ms) var(--ease-out-expo) forwards;
}

.stage-overlay.is-shutter-slam .stage-overlay-core {
  animation: stageHeadlineSlam var(--anim-duration, 1100ms) var(--ease-out-expo) forwards;
}

.stage-overlay.is-countdown-burst,
.stage-overlay.is-time-up-curtain,
.stage-overlay.is-slide-sweep,
.stage-overlay.is-flash-cut {
  animation: stageOverlayFade var(--anim-duration, 1100ms) var(--ease-out-expo) forwards;
}

.stage-overlay.is-slide-sweep .stage-overlay-core {
  animation: stageSweepAcross var(--anim-duration, 1100ms) var(--ease-out-expo) forwards;
}

@keyframes stageOverlayFade {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes stageHeadlineSlam {
  0% {
    transform: scale(1.25);
    opacity: 0;
  }
  25% {
    transform: scale(1);
    opacity: 1;
  }
  80% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.94);
    opacity: 0;
  }
}

@keyframes stageSweepAcross {
  0% {
    transform: translateX(-80px);
    opacity: 0;
  }
  25% {
    transform: translateX(0);
    opacity: 1;
  }
  80% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(80px);
    opacity: 0;
  }
}

/* Kahoot-Style Horizontal Podium Stage (Hook: podium_reveal) */
.podium-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.16fr) minmax(0, 1fr);
  gap: clamp(0.45rem, 1.8vw, 1.1rem);
  align-items: end;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  margin-bottom: 1.35rem;
  padding: clamp(0.65rem, 2vw, 1.25rem);
  background-color: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.podium-column {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
  overflow: hidden;
  background-color: var(--surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: clamp(0.6rem, 1.5vw, 1rem);
  position: relative;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.podium-column > * {
  min-width: 0;
  max-width: 100%;
}

.podium-column h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  max-height: 2.5em;
  margin-bottom: 0.35rem;
}

.podium-column .readout-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-column.podium-rank-2 {
  grid-column: 1;
  order: 1;
  min-height: 190px;
}

.podium-column.podium-rank-1 {
  grid-column: 2;
  order: 2;
  min-height: 245px;
  border-color: var(--accent);
  border-width: 3px;
}

.podium-column.podium-rank-3 {
  grid-column: 3;
  order: 3;
  min-height: 160px;
}

.podium-rank-pill {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2rem 0.6rem;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.88rem;
  background-color: var(--surface-muted);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.podium-column.podium-rank-1 .podium-rank-pill {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.podium-pedestal-bar {
  margin-top: 0.75rem;
  height: 24px;
  background-color: var(--border-color);
  border-radius: 2px;
}

.podium-column.podium-rank-1 .podium-pedestal-bar {
  height: 76px;
  background-color: var(--accent);
}

.podium-column.podium-rank-2 .podium-pedestal-bar {
  height: 44px;
}

.podium-column.podium-rank-3 .podium-pedestal-bar {
  height: 24px;
}

@media (max-width: 639px) {
  .podium-stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1fr);
    gap: 0.35rem;
    padding: 0.5rem;
  }

  .podium-column {
    padding: 0.45rem;
  }

  .podium-column h3 {
    font-size: 0.85rem;
  }

  .podium-column .timer-value {
    font-size: 0.92rem;
  }

  .podium-rank-pill {
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
  }

  .podium-column .readout-label {
    font-size: 0.75rem;
  }

  .podium-column.podium-rank-2 {
    min-height: 165px;
  }

  .podium-column.podium-rank-1 {
    min-height: 215px;
  }

  .podium-column.podium-rank-3 {
    min-height: 135px;
  }

  .podium-column.podium-rank-1 .podium-pedestal-bar {
    height: 72px;
  }

  .podium-column.podium-rank-2 .podium-pedestal-bar {
    height: 38px;
  }

  .podium-column.podium-rank-3 .podium-pedestal-bar {
    height: 18px;
  }
}

/* Sequential 3rd -> 2nd -> 1st Suspenseful Podium Reveal */
.podium-stage.podium-mode-kahoot.is-revealed .podium-rank-3 {
  animation: podiumRiseUp 700ms var(--ease-out-expo) 350ms both;
}

.podium-stage.podium-mode-kahoot.is-revealed .podium-rank-2 {
  animation: podiumRiseUp 750ms var(--ease-out-expo) 1250ms both;
}

.podium-stage.podium-mode-kahoot.is-revealed .podium-rank-1 {
  animation: podiumWinnerRise 950ms var(--ease-out-expo) 2350ms both;
}

.podium-stage.podium-mode-spotlight.is-revealed .podium-rank-3 {
  animation: podiumDropDown 650ms var(--ease-out-expo) 200ms both;
}

.podium-stage.podium-mode-spotlight.is-revealed .podium-rank-2 {
  animation: podiumDropDown 700ms var(--ease-out-expo) 900ms both;
}

.podium-stage.podium-mode-spotlight.is-revealed .podium-rank-1 {
  animation: podiumDropDown 850ms var(--ease-out-expo) 1750ms both;
}

@keyframes podiumRiseUp {
  0% {
    opacity: 0;
    transform: translateY(36px) scaleY(0.88);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

@keyframes podiumWinnerRise {
  0% {
    opacity: 0;
    transform: translateY(48px) scale(0.9);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.03);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes podiumDropDown {
  0% {
    opacity: 0;
    transform: translateY(-28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Drag and Drop Challenge Reordering Rows */
#admin-rounds-table-container,
#admin-rounds-table-container .data-table,
tr.is-draggable-row,
tr.is-locked-round {
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--surface-muted);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

tr.is-draggable-row {
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

tr.is-dragging {
  opacity: 0.55;
  background-color: var(--surface-muted);
}

tr.is-drop-target td {
  border-top: 3px solid var(--accent) !important;
  background-color: var(--surface-muted);
}

tr.is-locked-round {
  background-color: var(--surface-muted);
}

.drag-ghost-pill {
  position: fixed;
  top: -9999px;
  left: -9999px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.88rem;
  background-color: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
}

/* Gamified Menu Hover & Click Micro-Animations (<= 140ms per R-23) */
/* Stationary hit-area buffer prevents edge-hover double-pulse when buttons translate */
body[data-menu-anim="kinetic_lift"] .nav-btn,
body[data-menu-anim="kinetic_lift"] .btn,
body[data-menu-anim="kinetic_lift"] .util-btn,
body[data-menu-anim="tetrio_snap"] .nav-btn,
body[data-menu-anim="tetrio_snap"] .btn,
body[data-menu-anim="tetrio_snap"] .util-btn,
body[data-menu-anim="pixel_step"] .nav-btn,
body[data-menu-anim="pixel_step"] .btn,
body[data-menu-anim="pixel_step"] .util-btn {
  position: relative;
}

body[data-menu-anim="kinetic_lift"] .nav-btn:hover::after,
body[data-menu-anim="kinetic_lift"] .btn:hover::after,
body[data-menu-anim="kinetic_lift"] .util-btn:hover::after,
body[data-menu-anim="tetrio_snap"] .nav-btn:hover::after,
body[data-menu-anim="tetrio_snap"] .btn:hover::after,
body[data-menu-anim="tetrio_snap"] .util-btn:hover::after,
body[data-menu-anim="pixel_step"] .nav-btn:hover::after,
body[data-menu-anim="pixel_step"] .btn:hover::after,
body[data-menu-anim="pixel_step"] .util-btn:hover::after {
  content: "";
  position: absolute;
  inset: -6px;
  background: transparent;
}

body[data-menu-anim="kinetic_lift"] .nav-btn,
body[data-menu-anim="kinetic_lift"] .btn,
body[data-menu-anim="kinetic_lift"] .util-btn {
  transition: transform 110ms var(--ease-out-expo), background-color 120ms ease, border-color 120ms ease, box-shadow 110ms var(--ease-out-expo);
}

body[data-menu-anim="kinetic_lift"] .nav-btn:hover:not(:disabled),
body[data-menu-anim="kinetic_lift"] .btn:hover:not(:disabled),
body[data-menu-anim="kinetic_lift"] .util-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

body[data-menu-anim="kinetic_lift"] .nav-btn:active:not(:disabled),
body[data-menu-anim="kinetic_lift"] .btn:active:not(:disabled),
body[data-menu-anim="kinetic_lift"] .util-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

body[data-menu-anim="tetrio_snap"] .nav-btn,
body[data-menu-anim="tetrio_snap"] .btn,
body[data-menu-anim="tetrio_snap"] .util-btn {
  transition: transform 90ms cubic-bezier(0.16, 1, 0.3, 1), background-color 100ms ease, border-color 100ms ease, box-shadow 90ms ease;
}

body[data-menu-anim="tetrio_snap"] .nav-btn:hover:not(:disabled),
body[data-menu-anim="tetrio_snap"] .btn:hover:not(:disabled),
body[data-menu-anim="tetrio_snap"] .util-btn:hover:not(:disabled) {
  transform: translate(3px, -2px);
  box-shadow: -3px 3px 0 var(--accent);
}

body[data-menu-anim="tetrio_snap"] .nav-btn:active:not(:disabled),
body[data-menu-anim="tetrio_snap"] .btn:active:not(:disabled),
body[data-menu-anim="tetrio_snap"] .util-btn:active:not(:disabled) {
  transform: translate(0, 1px);
  box-shadow: none;
}

body[data-menu-anim="pixel_step"] .nav-btn,
body[data-menu-anim="pixel_step"] .btn,
body[data-menu-anim="pixel_step"] .util-btn {
  transition: transform 80ms steps(2, end), background-color 80ms steps(2, end), border-color 80ms steps(2, end);
}

body[data-menu-anim="pixel_step"] .nav-btn:hover:not(:disabled),
body[data-menu-anim="pixel_step"] .btn:hover:not(:disabled),
body[data-menu-anim="pixel_step"] .util-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
}

body[data-menu-anim="pixel_step"] .nav-btn:active:not(:disabled),
body[data-menu-anim="pixel_step"] .btn:active:not(:disabled),
body[data-menu-anim="pixel_step"] .util-btn:active:not(:disabled) {
  transform: translate(1px, 1px);
}

/* Void Spiral Transition Stage (Hook: intermission_to_round -> void_spiral) */
body.is-void-animating {
  overflow: hidden !important;
}

.is-void-concealed {
  opacity: 0 !important;
  visibility: hidden !important;
}

.void-spiral-stage {
  position: fixed;
  inset: 0;
  z-index: 610;
  pointer-events: none;
  overflow: hidden;
}

.void-spiral-snapshot {
  position: fixed;
  margin: 0;
  pointer-events: none;
  transform-origin: center center;
}

.void-singularity {
  position: fixed;
  left: 50%;
  top: 50%;
  width: clamp(180px, 34vw, 310px);
  height: clamp(180px, 34vw, 310px);
  transform: translate(-50%, -50%) scale(0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: transform 220ms var(--ease-out-expo), opacity 180ms ease;
}

.void-singularity.is-active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.void-singularity.is-erupting {
  transform: translate(-50%, -50%) scale(1.18);
  opacity: 0.95;
}

.void-singularity.is-collapsing {
  transform: translate(-50%, -50%) scale(0.05);
  opacity: 0;
}

.void-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: voidSpinCW 1100ms linear infinite;
}

.void-ring-outer {
  inset: 0;
  border-style: dashed;
  border-width: 3px;
  border-color: var(--accent);
}

.void-ring-mid {
  inset: 16%;
  border-style: solid;
  border-width: 2px;
  border-color: var(--text-primary);
  border-top-color: transparent;
  border-bottom-color: transparent;
  animation: voidSpinCCW 720ms linear infinite;
}

.void-ring-inner {
  inset: 31%;
  border-style: solid;
  border-width: 3px;
  border-color: var(--accent);
  border-left-color: transparent;
  animation: voidSpinCW 480ms linear infinite;
}

.void-core {
  position: relative;
  z-index: 2;
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background-color: #090A0D;
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.35rem;
}

.void-core-label {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 0.55rem + 0.35vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #F7F7F5;
  text-transform: uppercase;
  line-height: 1.15;
}

.void-preview-card {
  position: fixed;
  width: min(520px, 86vw);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  pointer-events: none;
}

.void-preview-timer {
  top: 12vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-color: var(--accent);
}

.void-preview-outgoing {
  top: 32vh;
}

.void-preview-chat {
  bottom: 10vh;
}

@keyframes voidSpinCW {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes voidSpinCCW {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}
