/* Lorenzo - Laurea — party edition */

:root {
  --bg-a: #0b0620;
  --bg-b: #1a0b3d;
  --bg-c: #33104f;
  --pink:   #ff3d9a;
  --gold:   #ffd23f;
  --cyan:   #2fe6d9;
  --violet: #a78bfa;
  --orange: #ff8a3d;
  --white:  #f5f0ff;
  --muted:  rgba(245, 240, 255, .65);
  --card-bg: rgba(255, 255, 255, .07);
  --card-border: rgba(255, 255, 255, .16);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background: linear-gradient(120deg, var(--bg-a), var(--bg-b), var(--bg-c), var(--bg-b));
  background-size: 300% 300%;
  animation: bgShift 16s ease-in-out infinite;
  color: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.hidden { display: none !important; }

/* layers */
.confetti-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

#fireworks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.foam-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}

.bottle {
  position: fixed;
  left: 50%;
  bottom: 18px;
  font-size: 46px;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  transform: translateX(-50%);
  transform-origin: 70% 90%;
}

.bottle.shake {
  opacity: 1;
  animation: bottleShake .6s ease-in-out;
}

.bottle.pop {
  opacity: 1;
  animation: bottlePop .5s cubic-bezier(.3, 1.6, .4, 1) forwards;
}

@keyframes bottleShake {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  15% { transform: translateX(-53%) rotate(-14deg); }
  30% { transform: translateX(-47%) rotate(12deg); }
  45% { transform: translateX(-53%) rotate(-16deg); }
  60% { transform: translateX(-47%) rotate(14deg); }
  75% { transform: translateX(-52%) rotate(-10deg); }
  90% { transform: translateX(-48%) rotate(8deg); }
}

@keyframes bottlePop {
  0%   { transform: translateX(-50%) rotate(0deg) scale(1); }
  35%  { transform: translateX(-50%) rotate(-35deg) scale(1.18); }
  100% { transform: translateX(-50%) rotate(-26deg) scale(1); opacity: 0; }
}

.foam-blob {
  position: absolute;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .95), rgba(255, 243, 214, .5));
  border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
  opacity: 0;
  animation: foamLife 3.4s ease-out forwards;
}

@keyframes foamLife {
  0%   { opacity: 0; transform: translateY(0) scale(.5); }
  12%  { opacity: .92; transform: translateY(0) scale(1); }
  70%  { opacity: .8; transform: translateY(40px) scale(1); }
  100% { opacity: 0; transform: translateY(140px) scale(.85); }
}

.page {
  position: relative;
  z-index: 2;
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}

/* ── copertina ── */
.cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.cap {
  font-size: 60px;
  animation: capBounce 2.2s ease-in-out infinite;
}

@keyframes capBounce {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-14px) rotate(6deg); }
}

.cover-title {
  margin: 0;
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 800;
  background: linear-gradient(90deg, var(--pink), var(--gold), var(--cyan), var(--violet), var(--pink));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleGradient 5s linear infinite, popIn .7s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes titleGradient {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

@keyframes popIn {
  0%   { transform: scale(.4) rotate(-8deg); opacity: 0; }
  70%  { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.cover-sub {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 17px;
}

/* ── bottoni ── */
.btn {
  border: none;
  border-radius: 999px;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #1a0b2e;
  background: linear-gradient(90deg, var(--gold), var(--pink));
  cursor: pointer;
  box-shadow: 0 10px 26px -8px rgba(255, 61, 154, .55);
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn:active { transform: scale(.94); }

.btn-replay {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 10px 26px -8px rgba(167, 139, 250, .55);
  color: #12042e;
}

.btn-champagne {
  background: linear-gradient(90deg, var(--gold), var(--orange));
  box-shadow: 0 10px 26px -8px rgba(255, 138, 61, .55);
  color: #2a1400;
}

/* ── lettore a carte ── */
.reader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.dots {
  display: flex;
  gap: 9px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card-border);
  transition: transform .25s ease, background .25s ease;
}

.dot.active { background: var(--gold); transform: scale(1.35); }
.dot.done   { background: var(--pink); }

.card {
  width: 100%;
  min-height: 180px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 30px 24px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.card-text {
  margin: 0;
  font-size: 19px;
  line-height: 1.65;
  color: var(--white);
}

.card-text.final {
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 800;
  background: linear-gradient(90deg, var(--pink), var(--gold), var(--cyan), var(--violet), var(--pink));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleGradient 3.5s linear infinite;
}

.card.enter { animation: cardIn .55s cubic-bezier(.2, .9, .3, 1.3) both; }
.card.exit  { animation: cardOut .38s ease-in both; }

@keyframes cardIn {
  0%   { transform: translateX(70px) rotate(9deg) scale(.85); opacity: 0; }
  100% { transform: translateX(0) rotate(0) scale(1); opacity: 1; }
}

@keyframes cardOut {
  0%   { transform: translateX(0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translateX(-70px) rotate(-9deg) scale(.85); opacity: 0; }
}

/* ── coriandoli ambientali ── */
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  opacity: .85;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.confetti-piece.burst {
  animation-name: confettiBurst;
  animation-timing-function: ease-out;
  animation-iteration-count: 1;
}

@keyframes confettiFall {
  0%   { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
  10%  { opacity: .9; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: .6; }
}

@keyframes confettiBurst {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(70vh) rotate(500deg); opacity: 0; }
}

/* schermi più larghi (tablet/desktop) */
@media (min-width: 768px) {
  .page { padding: 56px 24px; gap: 30px; }
  .card { padding: 40px 36px; }
}

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