:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --party: linear-gradient(90deg, #ff0844, #ff9a00, #8a2be2, #00b4ff, #ff2fa0, #ff0844);
}

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

html { scroll-behavior: smooth; background: #fff; }
body { overflow-x: hidden; background: #fff; }

body {
  font-family: var(--font);
  color: #000;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ───────────────────────── one page ───────────────────────── */

.deck {
  position: relative;
  /* 1 Figma px (frames are 1512 × 982) */
  --u: min(calc(100vw / 1512), calc(100vh / 982));
}
@supports (height: 100svh) {
  .deck { --u: min(calc(100vw / 1512), calc(100svh / 982)); }
}

.slide {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background: #fff;
}

/* parallax — values set from app.js while scrolling */
.stage, .voucher {
  transform: translate3d(0, var(--py, 0px), 0) scale(var(--ps, 1));
  opacity: var(--po, 1);
  will-change: transform, opacity;
}

.stage {
  position: relative;
  z-index: 2;
  width: calc(1512 * var(--u));
  height: calc(982 * var(--u));
}

.abs { position: absolute; left: calc(var(--x) * var(--u)); top: calc(var(--y) * var(--u)); }
.sized { width: calc(var(--w) * var(--u)); height: calc(var(--h) * var(--u)); }
.sized > img, .sized > .kb > img { display: block; width: 100%; height: 100%; object-fit: cover; }

.t {
  font-size: calc(var(--fs, 64) * var(--u));
  font-weight: 400;
  line-height: normal;
  white-space: nowrap;
}

/* ───────────────────────── reveal on enter ───────────────────────── */

.r {
  opacity: 0;
  transform: translateY(calc(48 * var(--u)));
  filter: blur(8px);
  transition: opacity .6s var(--ease), transform .8s var(--ease), filter .6s var(--ease);
}
.r.pop { transform: scale(.35) rotate(-10deg); }
.r.right { transform: translateX(calc(140 * var(--u))) rotate(4deg); }
.r.photo { transform: translateY(calc(120 * var(--u))) rotate(var(--tilt)) scale(.9); }
.r.peek { transform: translateY(calc(380 * var(--u))) rotate(calc(var(--rot) * -2)); }

.is-active .r {
  opacity: 1;
  transform: none;
  filter: blur(0);
  transition: opacity .9s var(--ease), transform 1.1s var(--spring), filter .9s var(--ease);
  transition-delay: calc(var(--d, 0) * 1ms + 250ms);
}
.is-active .r.photo { transition-timing-function: var(--ease), cubic-bezier(.2, 1.3, .4, 1), var(--ease); transition-duration: .9s, 1.4s, .9s; }

/* split text → letters */
.w { display: inline-block; white-space: nowrap; }
[data-split] .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(.55em) rotate(10deg) scale(.5);
}
.is-active [data-split] .ch {
  animation: ch-in .75s var(--spring) forwards;
  animation-delay: calc(var(--ci) * 28ms + var(--d, 0) * 1ms + 280ms);
}
.is-active .wave .ch {
  animation: ch-in .75s var(--spring) forwards, wave 1.6s ease-in-out infinite;
  animation-delay:
    calc(var(--ci) * 28ms + var(--d, 0) * 1ms + 280ms),
    calc(var(--ci) * 90ms + 2.2s);
}
@keyframes ch-in { to { opacity: 1; transform: none; } }
@keyframes wave {
  0%, 60%, 100% { transform: none; }
  30% { transform: translateY(-.28em); }
}

/* floating sprinkles behind slide content */
.sprinkles { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.sprinkles i {
  position: absolute;
  width: 6px;
  height: 16px;
  border-radius: 4px;
  background: var(--c);
  opacity: .28;
  transform: rotate(var(--r));
  animation: drift var(--dur) ease-in-out var(--del) infinite alternate;
}
.sprinkles i.dot { width: 9px; height: 9px; border-radius: 50%; }
@keyframes drift {
  to { transform: translate(var(--dx), var(--dy)) rotate(calc(var(--r) + 160deg)); }
}

/* ───────────────────────── per-slide pieces ───────────────────────── */

/* intro arrow */
.arrow {
  width: calc(74 * var(--u));
  height: calc(74 * var(--u));
  display: grid;
  place-items: center;
}
.arrow img {
  width: calc(74 * var(--u));
  transform: rotate(90deg);
  animation: nudge 1.4s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 calc(18 * var(--u)); }
}

/* emoji */
.emoji { display: block; width: 100%; height: 100%; object-fit: contain; }
.wobble { animation: wobble 2.6s ease-in-out 1.3s infinite; transform-origin: 50% 70%; }
@keyframes wobble {
  0%, 100% { transform: rotate(0) scale(1); }
  8% { transform: rotate(-7deg) scale(1.06); }
  16% { transform: rotate(6deg) scale(1.06); }
  24% { transform: rotate(-3deg) scale(1.02); }
  32% { transform: rotate(0) scale(1); }
}

/* stickers (red panda) */
.sticker { width: calc(var(--w) * var(--u)); height: calc(var(--h) * var(--u)); z-index: 3; }
.sticker-in {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: calc(7 * var(--u)) solid #fff;
  border-radius: calc(26 * var(--u));
  box-shadow: 0 calc(14 * var(--u)) calc(36 * var(--u)) rgba(0, 0, 0, .22), 0 0 0 1px rgba(0, 0, 0, .06);
  rotate: var(--rot);
  animation: bob 3.4s ease-in-out infinite;
  transition: scale .4s var(--spring);
}
.sticker-in:hover { scale: 1.08; }
.sticker-in img { display: block; width: 100%; height: 100%; object-fit: cover; animation: breathe 2.2s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(calc(-14 * var(--u))) rotate(2deg); }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* "Желаю тебе" */
.wish { width: calc(393.171 * var(--u)); height: calc(94.9975 * var(--u)); z-index: 2; }
.wish .float { width: 100%; height: 100%; animation: float 4s ease-in-out infinite; }
.wish svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 calc(6 * var(--u)) calc(14 * var(--u)) rgba(120, 60, 255, .22)); }
.wish .draw { clip-path: inset(-20% 100% -20% 0); transition: clip-path .5s var(--ease); }
.is-active .wish .draw { clip-path: inset(-20% -2% -20% 0); transition: clip-path 1.5s var(--ease) .25s; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(calc(-10 * var(--u))) rotate(-1.2deg); }
}

/* one pinned "Желаю тебе" over the four wishes */
.wishes { position: relative; }
.wish-pin {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100svh;
  margin-bottom: -100vh;
  margin-bottom: -100svh;
  pointer-events: none;
}
.pin-stage { position: relative; width: calc(1512 * var(--u)); height: calc(982 * var(--u)); }
.wish .tone { opacity: 0; transition: opacity .9s var(--ease); }
.wishes[data-tone="red"] .tone.red,
.wishes[data-tone="blue"] .tone.blue,
.wishes[data-tone="green"] .tone.green { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Minecraft hearts — sliced from the Figma heart bar */
.hearts { display: flex; z-index: 2; }
.heart {
  position: relative;
  flex: none;
  width: calc(75 * var(--u));
  aspect-ratio: 224 / 226;
  margin-right: calc(-9.5 * var(--u));
}
.heart img { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.heart .full { clip-path: inset(100% 0 0 0); transition: clip-path .45s steps(7, end); }
.heart.filled .full { clip-path: inset(0 0 0 0); }
.heart.filled { animation: heart-pop .5s var(--spring); }
.hearts:not(.full) .heart:not(.filled) { animation: mc-shake .32s steps(2, end) infinite; animation-delay: calc(var(--k) * -70ms); }
.hearts.full .heart { animation: beat 1.3s ease-in-out infinite; animation-delay: calc(var(--k) * 90ms); }
@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.32) translateY(-12%); }
  100% { transform: scale(1); }
}
@keyframes mc-shake {
  0% { transform: translateY(0); }
  50% { transform: translateY(calc(4 * var(--u))); }
}
@keyframes beat {
  0%, 60%, 100% { transform: scale(1); }
  20% { transform: scale(1.14); }
  35% { transform: scale(.98); }
}

/* tokens */
.tokens { overflow: visible; }
.tokens > img { border-radius: calc(8 * var(--u)); }
.infs { position: absolute; inset: 0; pointer-events: none; }
.infs span {
  position: absolute;
  bottom: 10%;
  left: var(--l);
  font-size: calc(var(--s) * var(--u));
  font-weight: 700;
  color: #8a2be2;
  opacity: 0;
}
.is-active .infs span { animation: rise var(--dur) ease-in var(--del) infinite; }
@keyframes rise {
  0% { opacity: 0; transform: translateY(0) scale(.6); }
  15% { opacity: .8; }
  100% { opacity: 0; transform: translateY(calc(-420 * var(--u))) scale(1.2) rotate(20deg); }
}

/* happy panda */
.happy-panda { animation: giggle 1.8s ease-in-out 1.6s infinite; transform-origin: 50% 100%; }
@keyframes giggle {
  0%, 100% { transform: rotate(0) scale(1); }
  10% { transform: rotate(-2deg) scale(1.03); }
  20% { transform: rotate(2deg) scale(1.03); }
  30% { transform: rotate(-1deg) scale(1.01); }
  40% { transform: rotate(0) scale(1); }
}

/* github card — border + shadow from Figma */
.repo > img { border: 1px solid #000; box-shadow: 0 4px 4px rgba(0, 0, 0, .25); transition: transform .5s var(--spring); }
.repo:hover > img { transform: perspective(800px) rotateX(6deg) rotateY(-8deg) scale(1.04); }

/* photos */
.photo .kb { width: 100%; height: 100%; overflow: hidden; }
.photo .kb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.is-active .photo .kb img { animation: kenburns 14s ease-in-out 1s infinite alternate; }
@keyframes kenburns { to { transform: scale(1.12) translate(-2%, -1%); } }

/* gift */
.gift-wrap { width: calc(160 * var(--u)); display: flex; flex-direction: column; align-items: center; gap: calc(6 * var(--u)); z-index: 4; }
.gift {
  font-size: calc(140 * var(--u));
  line-height: 1;
  filter: drop-shadow(0 calc(14 * var(--u)) calc(18 * var(--u)) rgba(0, 0, 0, .2));
  animation: gift-shake 2.2s ease-in-out 1.8s infinite;
  transition: transform .3s var(--spring);
}
.gift:hover { transform: scale(1.12); }
.gift.opened { animation: gift-open .8s var(--ease) forwards; }
.gift-hint { font-size: calc(26 * var(--u)); color: #777; animation: blink 1.6s ease-in-out infinite; }
@keyframes gift-shake {
  0%, 70%, 100% { transform: rotate(0); }
  74% { transform: rotate(-12deg) scale(1.06); }
  78% { transform: rotate(10deg) scale(1.06); }
  82% { transform: rotate(-8deg); }
  86% { transform: rotate(6deg); }
  90% { transform: rotate(0); }
}
@keyframes gift-open {
  0% { transform: scale(1); }
  20% { transform: scale(.85) rotate(-10deg); }
  45% { transform: scale(1.5) rotate(8deg); opacity: 1; }
  100% { transform: scale(2.6) rotate(0); opacity: 0; }
}
@keyframes blink { 50% { opacity: .35; } }

/* voucher — big rounded card on the page */
.full-bleed { padding: 4vh 3vw; }
.voucher {
  position: relative;
  z-index: 2;
  width: 100%;
  height: calc(100svh - 8vh);
  overflow: hidden;
  border-radius: clamp(18px, 2.4vw, 36px);
  background: #111;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
}
.voucher-bg { display: none; }
.voucher img:not(.voucher-bg) { position: relative; display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.06); }
.is-active .voucher img:not(.voucher-bg) { animation: voucher-in 1.6s var(--ease) forwards, voucher-zoom 12s ease-in-out 1.6s infinite alternate; }
.voucher .shine {
  position: absolute;
  inset: -20% auto -20% -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-18deg);
  opacity: 0;
}
.is-active .voucher .shine { animation: shine 3.2s ease-in-out 1.2s infinite; }
@keyframes voucher-in { from { transform: scale(1.25); filter: blur(10px) brightness(1.6); } to { transform: scale(1); filter: none; } }
@keyframes voucher-zoom { from { transform: scale(1); } to { transform: scale(1.05); } }
@keyframes shine {
  0% { left: -40%; opacity: 0; }
  10% { opacity: 1; }
  45%, 100% { left: 130%; opacity: 0; }
}

/* QR */
.qr { overflow: hidden; }
.qr .scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18%;
  background: linear-gradient(180deg, transparent, rgba(0, 180, 255, .28) 70%, rgba(0, 180, 255, .9) 100%);
  border-bottom: 2px solid #00b4ff;
  transform: translateY(-100%);
}
.is-active .qr .scan { animation: scan 2.4s ease-in-out 1.4s infinite; }
@keyframes scan {
  0% { transform: translateY(-100%); }
  50% { transform: translateY(560%); }
  100% { transform: translateY(-100%); }
}
.qr .corner {
  position: absolute;
  width: 14%;
  height: 14%;
  background:
    linear-gradient(#00b4ff, #00b4ff) var(--cx) var(--cy) / 4px 100% no-repeat,
    linear-gradient(#00b4ff, #00b4ff) var(--cx) var(--cy) / 100% 4px no-repeat;
}
.qr .corner.tl { left: 0; top: 0; --cx: left; --cy: top; }
.qr .corner.tr { right: 0; top: 0; --cx: right; --cy: top; }
.qr .corner.bl { left: 0; bottom: 0; --cx: left; --cy: bottom; }
.qr .corner.br { right: 0; bottom: 0; --cx: right; --cy: bottom; }

/* finale */
.cake { font-size: calc(120 * var(--u)); line-height: 1; z-index: 2; }
.is-active .cake { animation: bounce 1.2s var(--ease) 1.4s infinite; }
@keyframes bounce {
  0%, 100% { translate: 0 0; }
  40% { translate: 0 calc(-26 * var(--u)); }
}
.finale-text .ch {
  background: var(--party);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.is-active .finale-text .ch {
  animation: ch-in .75s var(--spring) forwards, party-flow 5s linear infinite, wave 1.8s ease-in-out infinite;
  animation-delay: calc(var(--ci) * 40ms + 700ms), 0s, calc(var(--ci) * 70ms + 2.6s);
}
.finale-text .ch { background-position: calc(var(--ci) * 6%) 0; }
@keyframes party-flow { to { background-position: calc(var(--ci) * 6% + 400%) 0; } }

.finale-actions { width: calc(400 * var(--u)); display: flex; justify-content: center; gap: calc(14 * var(--u)); z-index: 4; }
.btn {
  padding: calc(14 * var(--u)) calc(26 * var(--u));
  border-radius: 999px;
  font-size: calc(24 * var(--u));
  color: #fff;
  background: var(--party);
  background-size: 300% 100%;
  box-shadow: 0 calc(10 * var(--u)) calc(24 * var(--u)) rgba(138, 43, 226, .3);
  animation: party-bg 6s linear infinite;
  transition: transform .3s var(--spring);
  white-space: nowrap;
}
.btn.ghost { background: #fff; color: #000; box-shadow: inset 0 0 0 2px #000; animation: none; }
.btn:hover { transform: translateY(-3px) scale(1.04); }
.btn:active { transform: scale(.96); }
@keyframes party-bg { to { background-position: 300% 0; } }

/* ───────────────────────── chrome: fx, poppers, nav ───────────────────────── */

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

.popper {
  position: fixed;
  bottom: 2vh;
  z-index: 95;
  font-size: clamp(56px, 9vmin, 120px);
  pointer-events: none;
  opacity: 0;
}
.popper.left { left: 2vw; transform: scaleX(-1); }
.popper.right { right: 2vw; }
.popper.left.shoot { animation: pop-left 1.1s var(--ease); }
.popper.right.shoot { animation: pop-right 1.1s var(--ease); }
@keyframes pop-left {
  0% { opacity: 0; transform: scaleX(-1) scale(.3) rotate(20deg); }
  15% { opacity: 1; transform: scaleX(-1) scale(1.25) rotate(-12deg); }
  35% { transform: scaleX(-1) scale(.95) rotate(4deg); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scaleX(-1) scale(1) translateY(20px); }
}
@keyframes pop-right {
  0% { opacity: 0; transform: scale(.3) rotate(20deg); }
  15% { opacity: 1; transform: scale(1.25) rotate(-12deg); }
  35% { transform: scale(.95) rotate(4deg); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(20px); }
}

.progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 80; pointer-events: none; }
.progress span {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: var(--party);
  background-size: 300% 100%;
  animation: party-bg 6s linear infinite;
  transition: width .9s var(--ease);
  border-radius: 0 4px 4px 0;
}

.dots {
  position: fixed;
  right: 14px;
  top: 50%;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateY(-50%);
}
.dots button { width: 18px; height: 18px; display: grid; place-items: center; }
.dots button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .22);
  transition: height .5s var(--spring), background .3s;
}
.dots button:hover::before { background: rgba(0, 0, 0, .5); }
.dots button[aria-current="true"]::before { height: 20px; background: linear-gradient(#ff0844, #8a2be2); }
.dots.dark button::before { background: rgba(255, 255, 255, .45); }
.dots.dark button[aria-current="true"]::before { background: linear-gradient(#ffd54a, #ff7a18); }

/* ───────────────────────── portrait / phones ───────────────────────── */

@media (max-aspect-ratio: 1/1) {
  .stage {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5vh;
    padding: 9vh 8vw;
    text-align: center;
  }
  .abs { position: relative; left: auto; top: auto; }
  .t { font-size: calc(var(--fs, 64) * .12vw); white-space: normal; }
  .t br { display: none; }
  .sized { width: min(84vw, calc(var(--w) * .16vw)); height: auto; aspect-ratio: var(--w) / var(--h); }
  .tokens, .repo { width: 86vw; }
  .photo { width: 86vw; }
  .qr { width: 62vw; }

  .wish { width: 70vw; height: auto; aspect-ratio: 393.171 / 94.9975; order: -1; }
  .pin-stage { width: 100%; height: 100%; }
  .wish-pin .wish.abs { position: absolute; left: 15vw; top: 7vh; }
  .wishes .slide .stage { padding-top: 24vh; }
  .heart { width: 9.6vw; margin-right: -1.22vw; }
  .arrow, .arrow img { width: 14vw; height: 14vw; }

  .sticker { position: absolute; width: calc(var(--w) * .11vw); height: auto; aspect-ratio: var(--w) / var(--h); }
  .sticker-in { border-width: 1.6vw; border-radius: 5vw; }
  .m-br { right: 3vw; bottom: 3vh; }
  .m-bl { left: 3vw; bottom: 3vh; }
  .m-tl { left: 4vw; top: 5vh; }
  .m-tr { right: 4vw; top: 6vh; }

  .gift-wrap { width: auto; }
  .gift { font-size: 32vw; }
  .gift-hint { font-size: 5vw; }

  .full-bleed { padding: 3vh 4vw; }
  .voucher { height: calc(100svh - 6vh); display: grid; place-items: center; }
  .voucher-bg { display: block; position: absolute; inset: -10%; width: 120%; height: 120%; object-fit: cover; filter: blur(28px) brightness(.55); }
  .voucher img:not(.voucher-bg) { height: auto; aspect-ratio: 1536 / 1024; object-fit: contain; }
  .voucher .shine { display: none; }

  .cake { font-size: 22vw; }
  .finale-text { font-size: 9vw; }
  .finale-actions { width: auto; flex-wrap: wrap; gap: 3vw; }
  .btn { font-size: 4.4vw; padding: 3.4vw 5.5vw; }

  .dots { right: 6px; gap: 4px; }
  .dots button { width: 14px; height: 14px; }
  .dots button::before { width: 6px; height: 6px; }
  .dots button[aria-current="true"]::before { height: 16px; }
}

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