/* The recipient experience. One stage, eight scenes, no scroll. */

.experience {
  background:
    radial-gradient(900px 620px at 50% -8%, color-mix(in srgb, var(--flame) 18%, transparent), transparent 62%),
    radial-gradient(700px 500px at 100% 110%, color-mix(in srgb, var(--berry) 12%, transparent), transparent 60%),
    var(--ink-950);
}

.exp-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 540px);
  min-height: 100dvh;
  margin-inline: auto;
  padding: max(0.75rem, env(safe-area-inset-top)) var(--space-5)
    max(0.75rem, env(safe-area-inset-bottom));
  overflow: hidden;
}

.exp-bar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3rem;
}

.exp-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--cream);
  text-decoration: none;
}

.exp-brand-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--flame);
  box-shadow: 0 0 18px 3px color-mix(in srgb, var(--flame) 55%, transparent);
}

.exp-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.7rem;
  border: 1px solid color-mix(in srgb, var(--cream) 16%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--ink-900) 70%, transparent);
  color: var(--cream);
  font-size: var(--step--1);
  cursor: pointer;
  transition:
    background-color var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--cream) 10%, transparent);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.icon-btn.is-on {
  border-color: color-mix(in srgb, var(--flame) 55%, transparent);
  color: var(--flame);
}

.exp-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* Gate */
.gate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding-block: var(--space-5);
  text-align: center;
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out);
}

.gate.is-leaving {
  opacity: 0;
  transform: translateY(-14px) scale(0.985);
  pointer-events: none;
}

.gate-inner {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  width: min(100%, 24rem);
}

.gate-penguin {
  width: clamp(9rem, 34vw, 12.5rem);
  filter: drop-shadow(0 26px 40px rgba(0, 0, 0, 0.45));
  animation: gate-bob 5s var(--ease-io) infinite;
}

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

.gate-kicker {
  font-size: var(--step--1);
  color: var(--muted-light);
}

.gate-name {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  font-weight: 600;
  line-height: 1;
  color: var(--cream);
  overflow-wrap: break-word;
  max-width: 12ch;
}

.gate-sender {
  color: var(--muted);
  font-size: var(--step--1);
}

.gate .btn {
  margin-top: var(--space-2);
}

.gate-note {
  font-size: var(--step--1);
  color: var(--muted);
}

/* Scene shell */
.scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4) 0;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out);
}

.scene.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.scene-inner {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  width: 100%;
  text-align: center;
}

.scene-kicker {
  font-size: var(--step--1);
  color: var(--flame);
}

.scene-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 600;
  line-height: 1.04;
  color: var(--cream);
  max-width: 16ch;
  overflow-wrap: break-word;
}

.scene-text {
  max-width: 30rem;
  color: var(--muted-light);
  font-size: var(--step-0);
}

.scene-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.scene-note {
  font-size: var(--step--1);
  color: var(--muted);
}

/* Welcome */
.welcome-name {
  font-size: clamp(2.6rem, 12vw, 4.2rem);
}

.welcome-name span {
  display: inline-block;
  opacity: 0;
  transform: translateY(14px);
  animation: letter-in 520ms var(--ease-out) forwards;
}

@keyframes letter-in {
  to { opacity: 1; transform: none; }
}

/* Cake */
.cake-wrap {
  position: relative;
  width: min(100%, 21rem);
}

.cake-wrap svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.cake-tap {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.cake-hint {
  color: var(--muted-light);
  font-size: var(--step--1);
}

.cake-wish {
  font-family: var(--font-display);
  font-size: var(--step-2);
  color: var(--flame);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out);
}

.cake-wish.is-on {
  opacity: 1;
  transform: none;
}

/* Sticker scene */
.sticker-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}

.sticker {
  padding: 0.5rem 1rem;
  border: 2px solid var(--ink-950);
  border-radius: var(--radius-pill);
  color: var(--ink-950);
  font-weight: 700;
  font-size: var(--step--1);
  box-shadow: 4px 4px 0 var(--ink-950);
}

.sticker:nth-child(1) { background: var(--chaos-pink); transform: rotate(-2deg); }
.sticker:nth-child(2) { background: var(--chaos-sun); transform: rotate(1.5deg); }
.sticker:nth-child(3) { background: var(--chaos-blue); color: var(--cream); transform: rotate(-1deg); }

/* Balloons */
.balloon-field {
  position: relative;
  width: min(100%, 22rem);
  height: min(46vh, 20rem);
}

.balloon {
  position: absolute;
  width: 4.2rem;
  height: 5.4rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-origin: 50% 100%;
  animation: balloon-sway 4.6s var(--ease-io) infinite;
  transition:
    transform var(--dur-2) var(--ease-snap),
    opacity var(--dur-2) var(--ease-out);
}

.balloon svg {
  width: 100%;
  height: 100%;
}

.balloon:nth-child(2n) { animation-delay: -1.4s; }
.balloon:nth-child(3n) { animation-delay: -2.6s; }
.balloon:nth-child(1) { left: 2%; top: 6%; }
.balloon:nth-child(2) { left: 38%; top: 0; }
.balloon:nth-child(3) { right: 1%; top: 9%; }
.balloon:nth-child(4) { left: 20%; top: 33%; }
.balloon:nth-child(5) { right: 22%; top: 31%; }
.balloon:nth-child(6) { left: 0; bottom: 4%; }
.balloon:nth-child(7) { left: 42%; bottom: 0; }
.balloon:nth-child(8) { right: 0; bottom: 6%; }

.balloon.is-popped {
  opacity: 0;
  transform: scale(1.5);
  pointer-events: none;
}

@keyframes balloon-sway {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.balloon-count {
  font-variant-numeric: tabular-nums;
  color: var(--flame);
  font-weight: 700;
}

/* Message card */
.letter {
  position: relative;
  width: min(100%, 21rem);
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-radius: 0.5rem;
  background: var(--chaos-paper);
  color: var(--ink-950);
  text-align: left;
  transform: rotate(-1.2deg);
  box-shadow: 0 26px 60px -30px rgba(0, 0, 0, 0.7);
}

.letter::before {
  content: "";
  position: absolute;
  top: -0.75rem;
  left: 50%;
  width: 4.5rem;
  height: 1.5rem;
  background: color-mix(in srgb, var(--chaos-sun) 72%, transparent);
  transform: translateX(-50%) rotate(1.5deg);
}

.letter p {
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.45;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.letter-sender {
  margin-top: var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: color-mix(in srgb, var(--ink-950) 60%, transparent);
}

/* Photos */
.polaroids {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding-block: var(--space-3);
}

.polaroid {
  width: min(44%, 10.5rem);
  padding: 0.55rem 0.55rem 1.7rem;
  background: var(--cream);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.7);
}

.polaroid:first-child { transform: rotate(-3.5deg); }
.polaroid:nth-child(2) { transform: rotate(4deg) translateY(10px); }

.polaroid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--cream-3);
}

.polaroid-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  background:
    repeating-linear-gradient(45deg, var(--cream-2) 0 8px, var(--cream-3) 8px 16px);
  color: var(--muted);
  font-size: var(--step--1);
}

/* Finale */
.finale-name {
  font-size: clamp(2.6rem, 13vw, 4.4rem);
  color: var(--flame);
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Closing */
.closing-card {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  width: min(100%, 22rem);
  padding: var(--space-6) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--cream) 14%, transparent);
  border-radius: var(--radius-l);
  background: color-mix(in srgb, var(--ink-900) 70%, transparent);
}

.expiry {
  font-size: var(--step--1);
  color: var(--muted);
  text-align: center;
}

.expiry strong {
  color: var(--cream);
  font-weight: 600;
}

/* Progress */
.exp-foot {
  position: relative;
  z-index: 12;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  padding-top: var(--space-3);
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.progress span {
  width: 1.1rem;
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cream) 18%, transparent);
  transition: background-color var(--dur-3) var(--ease-out), width var(--dur-3) var(--ease-out);
}

.progress span.is-on {
  width: 1.7rem;
  background: var(--flame);
}

.exp-foot-note {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Desktop: the experience becomes a stage, not a stretched page */
@media (min-width: 760px) {
  .exp-frame {
    min-height: min(900px, calc(100dvh - 3rem));
    margin-block: 1.5rem;
    padding-inline: var(--space-6);
    border: 1px solid color-mix(in srgb, var(--cream) 12%, transparent);
    border-radius: 2rem;
    background: color-mix(in srgb, var(--ink-900) 45%, transparent);
    box-shadow: var(--shadow-lift);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-penguin,
  .balloon,
  .flame {
    animation: none;
  }

  .welcome-name span {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .scene {
    transform: none;
  }
}
