/*
 * Overlay MemeCatchBot — sorgente browser per OBS Studio.
 *
 * Regole di base:
 *  - sfondo trasparente ovunque: OBS compone sopra la scena
 *  - stage fisso 1920x1080, scalato con transform per altre risoluzioni
 *  - solo animazioni su transform/opacity, che il compositor gestisce sulla
 *    GPU: filtri e ombre animate fanno cadere i frame nella cattura OBS
 */

:root {
  --font: 'Segoe UI', 'Inter', system-ui, sans-serif;
  --rarity: #b0b7c3;
  --ink: #ffffff;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  --panel: rgba(14, 15, 22, 0.82);
  --gold: #ffd75e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  background: transparent;
  font-family: var(--font);
  color: var(--ink);
  /* OBS cattura con sfondo trasparente: nessun colore di fondo. */
}

.stage {
  position: relative;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
}

/* ==================================================================
   Sfondo video (solo stream 24/7, attivato con ?bg=...)
   ================================================================== */

.backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Dietro ai widget ma dentro lo stage: lo stage ha una transform, quindi
     crea un contesto di impilamento e lo z-index negativo non sfugge. */
  z-index: -1;
}

.backdrop[hidden] { display: none; }

/* ==================================================================
   Banner dello spawn
   ================================================================== */

.spawn-card {
  position: absolute;
  top: 48px;
  left: 50%;
  width: 760px;
  transform: translateX(-50%);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 3px solid var(--rarity);
  overflow: hidden;
  animation: card-in 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.spawn-card[hidden] { display: none; }

.spawn-card.is-leaving { animation: card-out 380ms ease forwards; }

.spawn-card__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 140% at 50% 0%, var(--rarity), transparent 62%);
  opacity: 0.28;
  pointer-events: none;
}

.spawn-card__body {
  position: relative;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 26px 32px;
}

.spawn-card__emoji {
  font-size: 76px;
  line-height: 1;
  animation: bob 2.2s ease-in-out infinite;
}

.spawn-card__text { flex: 1; min-width: 0; }

.spawn-card__label {
  font-size: 19px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}

.spawn-card__name {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}

.spawn-card__rarity {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
  color: var(--rarity);
  letter-spacing: 0.06em;
}

.spawn-card__cta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.spawn-card__command {
  display: inline-block;
  padding: 14px 22px;
  border-radius: 14px;
  background: var(--rarity);
  color: #10121a;
  font-size: 28px;
  font-weight: 800;
  white-space: nowrap;
  animation: pulse 1.5s ease-in-out infinite;
}

.spawn-card__hint {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.78;
}

.spawn-card__hint[hidden] { display: none; }

/* ------------------------------------------------------------------
   Variante Drop: la card si sposta al centro dello schermo e il codice
   diventa l'elemento dominante. Chi guarda la diretta deve leggerlo da
   lontano, quindi il codice pesa piu' del nome del meme.
   ------------------------------------------------------------------ */

.spawn-card.is-drop {
  top: 50%;
  width: 900px;
  transform: translate(-50%, -50%);
  animation: drop-in 620ms cubic-bezier(0.16, 1, 0.3, 1);
}

.spawn-card.is-drop.is-leaving { animation: drop-out 380ms ease forwards; }

.spawn-card.is-drop .spawn-card__body {
  flex-direction: column;
  gap: 14px;
  padding: 38px 40px 32px;
  text-align: center;
}

.spawn-card.is-drop .spawn-card__emoji { font-size: 112px; }
.spawn-card.is-drop .spawn-card__text { flex: none; }
.spawn-card.is-drop .spawn-card__name { font-size: 54px; }

.spawn-card.is-drop .spawn-card__cta {
  flex-direction: row;
  align-items: baseline;
  gap: 14px;
  margin-top: 10px;
}

.spawn-card.is-drop .spawn-card__command {
  padding: 18px 34px;
  font-size: 52px;
  letter-spacing: 0.04em;
}

.spawn-card.is-drop .spawn-card__hint { font-size: 26px; }

/* Con il codice, l'allarme del Mitico non deve sovrascrivere drop-in. */
.spawn-card.is-drop.is-global {
  animation: drop-in 620ms cubic-bezier(0.16, 1, 0.3, 1),
    alarm 1s ease-in-out infinite 620ms;
}

.spawn-card__timer {
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.spawn-card__timer-fill {
  height: 100%;
  width: 100%;
  background: var(--rarity);
  transform-origin: left center;
}

/* Varianti speciali */

.spawn-card.is-shiny { border-color: var(--gold); }
.spawn-card.is-shiny .spawn-card__glow {
  background: linear-gradient(100deg, transparent 20%, rgba(255, 215, 94, 0.55) 50%, transparent 80%);
  background-size: 260% 100%;
  opacity: 0.6;
  animation: shimmer 2.1s linear infinite;
}

.spawn-card.is-global {
  animation: card-in 520ms cubic-bezier(0.16, 1, 0.3, 1), alarm 1s ease-in-out infinite 520ms;
}

/* ==================================================================
   Pop-up del vincitore
   ================================================================== */

.winner {
  position: absolute;
  top: 300px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.winner[hidden] { display: none; }
.winner.is-leaving { animation: winner-out 420ms ease forwards; }

.winner__rays {
  position: absolute;
  width: 900px;
  height: 900px;
  background: conic-gradient(
    from 0deg,
    transparent 0deg 12deg, rgba(255, 255, 255, 0.10) 12deg 24deg
  );
  border-radius: 50%;
  opacity: 0;
  animation: rays 5s linear infinite;
}

.winner.is-special .winner__rays { opacity: 0.85; }

.winner__card {
  position: relative;
  min-width: 620px;
  padding: 40px 56px;
  border-radius: 26px;
  background: var(--panel);
  border: 3px solid var(--rarity);
  box-shadow: var(--shadow);
  text-align: center;
  animation: winner-in 620ms cubic-bezier(0.16, 1, 0.3, 1);
}

.winner.is-special .winner__card {
  border-color: var(--gold);
  animation: winner-in 620ms cubic-bezier(0.16, 1, 0.3, 1), glow-pulse 1.4s ease-in-out infinite 620ms;
}

.winner__banner {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--rarity);
  text-transform: uppercase;
}

.winner__meme {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 14px 0 6px;
}

.winner__emoji { font-size: 66px; line-height: 1; }

.winner__meme-name {
  font-size: 48px;
  font-weight: 800;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.6);
}

.winner__user {
  font-size: 32px;
  font-weight: 700;
  opacity: 0.94;
}

.winner__pity {
  margin-top: 12px;
  padding: 8px 18px;
  display: inline-block;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.22);
  border: 2px solid #a855f7;
  font-size: 20px;
  font-weight: 700;
}

.winner__pity[hidden] { display: none; }

.winner__coins {
  margin-top: 16px;
  font-size: 40px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.6);
}

/* ==================================================================
   Widget classifica
   ================================================================== */

.board {
  position: absolute;
  right: 48px;
  bottom: 48px;
  width: 400px;
  padding: 20px 22px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.board__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.board__title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.18em;
  opacity: 0.85;
}

.board__icon { font-size: 24px; }

.board__list { list-style: none; }

.board__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  font-size: 22px;
  animation: row-in 380ms ease both;
}

.board__row + .board__row { border-top: 1px solid rgba(255, 255, 255, 0.08); }

.board__rank { width: 34px; font-weight: 800; opacity: 0.8; }
.board__row--1 .board__rank,
.board__row--2 .board__rank,
.board__row--3 .board__rank { font-size: 24px; opacity: 1; }

.board__name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board__coins {
  font-weight: 800;
  color: var(--gold);
  white-space: nowrap;
}

.board__empty {
  padding: 10px 0;
  font-size: 19px;
  opacity: 0.6;
}

/* ==================================================================
   Scudo anti-ad
   ================================================================== */

.shield {
  position: absolute;
  bottom: 56px;
  left: 50%;
  width: 720px;
  transform: translateX(-50%);
  padding: 18px 24px 16px;
  border-radius: 20px;
  background: var(--panel);
  border: 3px solid #3B9DFF;
  box-shadow: var(--shadow);
  animation: card-in 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.shield[hidden] { display: none; }
.shield.is-leaving { animation: card-out 380ms ease forwards; }

/* Scudo retto: passa al dorato e pulsa, si vede a colpo d'occhio. */
.shield.is-held { border-color: var(--gold); }
.shield.is-held .shield__fill { background: linear-gradient(90deg, var(--gold), #ffe9a3); }

.shield__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.shield__title { font-size: 24px; font-weight: 800; letter-spacing: 0.08em; }
.shield__timer { font-size: 26px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.shield__track {
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.shield__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #3B9DFF, #a855f7);
  transition: width 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.shield__foot {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-size: 19px;
  opacity: 0.9;
}

.shield__cta b { color: var(--gold); }

/* ==================================================================
   Debug (?debug=1)
   ================================================================== */

.debug {
  position: absolute;
  left: 20px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 15px;
  font-family: ui-monospace, monospace;
}

.debug[hidden] { display: none; }

.debug__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

.debug__dot.is-online { background: #22c55e; }

/* ==================================================================
   Animazioni
   ================================================================== */

/* Nessuno interagisce con questa pagina: il cursore non deve mai comparire.
   La cattura e' gia' protetta da `-draw_mouse 0` lato ffmpeg, questa regola
   copre il caso in cui la pagina venga aperta in un browser vero. */
body, * { cursor: none !important; }

@keyframes card-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-46px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes card-out {
  to { opacity: 0; transform: translateX(-50%) translateY(-32px) scale(0.96); }
}

/* Il drop e' centrato su entrambi gli assi: le sue keyframes devono
   riportare il translate(-50%, -50%), altrimenti la card scatta in
   alto a sinistra per tutta la durata dell'animazione. */
@keyframes drop-in {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.55) rotate(-6deg); }
  58%  { opacity: 1; transform: translate(-50%, -50%) scale(1.07) rotate(1.5deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
}

@keyframes drop-out {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

@keyframes winner-in {
  0%   { opacity: 0; transform: scale(0.72); }
  62%  { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes winner-out {
  to { opacity: 0; transform: translateX(-50%) scale(0.94); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-9px) rotate(3deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

@keyframes shimmer {
  from { background-position: 160% 0; }
  to   { background-position: -160% 0; }
}

@keyframes alarm {
  0%, 100% { border-color: var(--rarity); }
  50%      { border-color: var(--gold); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 rgba(255, 215, 94, 0); }
  50%      { box-shadow: var(--shadow), 0 0 60px rgba(255, 215, 94, 0.75); }
}

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

@keyframes row-in {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
