/* Retro CRT corner cameo — non-blocking celebration overlay. */

.celebration-cameo,
.celebration-cameo *,
.celebration-cameo *::before,
.celebration-cameo *::after {
  box-sizing: border-box;
}


/* Design system preview harness */
.celebration-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  align-items: end;
}

.celebration-preview-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.celebration-preview-field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.celebration-preview-field--action {
  align-self: end;
}



.celebration-cameo {
  position: fixed;
  right: var(--space-14, 3.5rem);
  bottom: var(--space-14, 3.5rem);
  z-index: 9000;
  pointer-events: none;
  width: 320px;
  animation: celebration-poweron 280ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.celebration-cameo.celebration-exiting {
  animation: celebration-poweroff 400ms cubic-bezier(0.7, 0, 0.8, 0.3) forwards;
}

/* Panel: mounted NASA-style instrument console */
.celebration-bezel {
  --crt-panel: #9a9388;
  --crt-panel-dark: #6a6458;
  --crt-panel-hi: #b8b0a2;
  --crt-inner-bezel: #c2b9a6;
  --crt-screw: #4a463e;

  position: relative;
  width: 100%;
  padding: 22px 20px 8px;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  background:
    radial-gradient(circle at 10px 10px, var(--crt-screw) 1.5px, rgba(0, 0, 0, 0.25) 2.2px, transparent 3px),
    radial-gradient(circle at calc(100% - 10px) 10px, var(--crt-screw) 1.5px, rgba(0, 0, 0, 0.25) 2.2px, transparent 3px),
    radial-gradient(circle at 10px calc(100% - 10px), var(--crt-screw) 1.5px, rgba(0, 0, 0, 0.25) 2.2px, transparent 3px),
    radial-gradient(circle at calc(100% - 10px) calc(100% - 10px), var(--crt-screw) 1.5px, rgba(0, 0, 0, 0.25) 2.2px, transparent 3px),
    linear-gradient(155deg, var(--crt-panel-hi) 0%, var(--crt-panel) 45%, var(--crt-panel-dark) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 -1px 0 rgba(0, 0, 0, 0.35) inset,
    0 20px 40px -12px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.35);
  animation: celebration-flicker 1.8s steps(1, end) 1;
}

/* Sheen: subtle diagonal light catch across the matte panel */
.celebration-bezel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0) 35%,
    rgba(255, 255, 255, 0) 65%,
    rgba(255, 255, 255, 0.06) 100%
  );
  mix-blend-mode: overlay;
}

/* Stenciled corner callsign (top-left) */
.celebration-bezel__stencil {
  position: absolute;
  top: 5px;
  left: 20px;
  font-family: var(--font-family-mono, ui-monospace, monospace);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(40, 35, 25, 0.55);
  text-transform: uppercase;
  pointer-events: none;
}

.celebration-bezel__label {
  flex: 0 0 22px;
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-mono, ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(40, 35, 25, 0.75);
  text-transform: uppercase;
}

.celebration-rec {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 6px rgba(255, 59, 48, 0.8);
  animation: celebration-rec-blink 1s steps(2, end) infinite;
}

/* Screen: recessed into the panel cutout */
.celebration-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.85) inset,
    0 -1px 0 rgba(255, 255, 255, 0.1) inset,
    0 0 0 1.5px rgba(30, 25, 18, 0.85),
    0 0 0 3px rgba(122, 114, 102, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.35);
}


.celebration-screen__gif {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.85) contrast(1.05) brightness(0.95);
  display: block;
}

.celebration-screen__scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 2px,
    rgba(0, 0, 0, 0.22) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.7;
}

.celebration-screen__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(transparent 50%, rgba(255, 255, 255, 0.03) 50%);
  background-size: 100% 100%, 100% 2px;
}

/* One-shot scanline sweep during power-on */
.celebration-screen__sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 30%;
  top: -30%;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: celebration-sweep 700ms ease-out 1 forwards;
}

.celebration-screen__caption {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  font-family: var(--font-family-mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #c6ffb8;
  text-shadow: 0 0 6px rgba(120, 255, 120, 0.45);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(120, 255, 120, 0.35);
  border-radius: 3px;
  text-transform: uppercase;
  text-align: center;
}

/* Confetti bursts are handled by the reusable .confetti component (see confetti.css).
 * The cameo just includes <div class="confetti" data-controller="confetti"> as a child. */

@keyframes celebration-poweron {
  0% {
    transform: scale(0.55);
    opacity: 0;
  }

  60% {
    transform: scale(1.03);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes celebration-poweroff {
  0% {
    transform: scaleY(1) scaleX(1);
    opacity: 1;
    filter: brightness(1);
  }

  35% {
    transform: scaleY(0.02) scaleX(1);
    opacity: 1;
    filter: brightness(2.4);
  }

  60% {
    transform: scaleY(0.02) scaleX(0.02);
    opacity: 0.9;
    filter: brightness(2.4);
  }

  100% {
    transform: scaleY(0.02) scaleX(0);
    opacity: 0;
    filter: brightness(1);
  }
}

@keyframes celebration-flicker {
  0%, 100% { opacity: 1; }
  3%       { opacity: 0.4; }
  6%       { opacity: 1; }
  12%      { opacity: 0.7; }
  14%      { opacity: 1; }
}

@keyframes celebration-sweep {
  0% {
    top: -30%;
    opacity: 0.9;
  }

  100% {
    top: 110%;
    opacity: 0.2;
  }
}

@keyframes celebration-rec-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* Reduced motion: plain fade, no flicker/sweep/confetti */
.celebration-cameo--reduced {
  animation: celebration-fade-in 200ms ease-out both;
}

.celebration-cameo--reduced.celebration-exiting {
  animation: celebration-fade-out 300ms ease-in forwards;
}

.celebration-cameo--reduced .celebration-bezel { animation: none; }
.celebration-cameo--reduced .celebration-screen__sweep { display: none; }
.celebration-cameo--reduced .celebration-rec { animation: none; }

@keyframes celebration-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes celebration-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .celebration-cameo,
  .celebration-cameo.celebration-exiting {
    animation-duration: 200ms;
  }

  .celebration-screen__scanlines,
  .celebration-screen__sweep {
    display: none;
  }
  .celebration-rec { animation: none; }
}

/* Mobile/tablet: shrink and center horizontally, still hug the bottom */
@media (width <= 900px) {
  .celebration-cameo {
    width: 300px;
    max-width: 90vw;
    left: 0;
    right: 0;
    margin-inline: auto;
    bottom: calc(var(--space-8, 2rem) + env(safe-area-inset-bottom, 0px));
  }
}
