/* Scene styles. One clearly marked section per scene. */

/* ==========================================================================
   Shared paper objects: envelope, wax seal, letter
   ========================================================================== */

.scene--envelope {
  --env-w: min(84vw, 62svh * 1.45, 430px);
  --env-h: calc(var(--env-w) / 1.45);
  --letter-w: min(88vw, 420px);
  --letter-h: min(54svh, 420px);
}

.envelope-wrap {
  position: relative;
  width: var(--env-w);
  height: var(--env-h);
  perspective: 1100px;
}

.envelope {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.envelope__back {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--r-paper);
  background: linear-gradient(180deg, var(--paper-shade), color-mix(in oklab, var(--paper-shade) 86%, var(--ink)));
  box-shadow: var(--shadow-lift);
}

.envelope__pocket {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border-radius: var(--r-paper);
}

.pocket__side {
  fill: color-mix(in oklab, var(--paper) 92%, var(--ink));
}

.pocket__bottom {
  fill: var(--paper);
}

.pocket__fold {
  fill: none;
  stroke: color-mix(in oklab, var(--ink) 20%, transparent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.envelope__fibre,
.envelope__flap-face::after,
.letter::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--paper-fibre);
  background-size: 260px 260px;
  opacity: 0.4;
  pointer-events: none;
  border-radius: inherit;
}

.envelope__fibre {
  z-index: 3;
}

.envelope__flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 54%;
  z-index: 4;
  transform-origin: 50% 0%;
  transform: rotateX(0deg);
}

.envelope__flap-face {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 98%, var(--ink)), color-mix(in oklab, var(--paper) 86%, var(--ink)));
}

.envelope__flap-face::after {
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.envelope__flap.is-inside .envelope__flap-face {
  background: linear-gradient(0deg, color-mix(in oklab, var(--paper) 74%, var(--ink)), color-mix(in oklab, var(--paper) 86%, var(--ink)));
}

.envelope__front {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 72%;
  z-index: 5;
  text-align: center;
  font-size: calc(var(--fs-h3) * var(--hand-scale));
  line-height: 1;
  color: var(--ink);
  pointer-events: none;
}

.envelope__seal {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  z-index: 6;
  border: 0;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms var(--ease-out), opacity 200ms;
}

.envelope__seal:active {
  transform: scale(0.94);
}

.envelope__seal:disabled {
  cursor: default;
}

.seal {
  filter: drop-shadow(0 3px 3px rgba(31, 16, 37, 0.45));
}

.seal__letter {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 36px;
  font-variation-settings: "SOFT" 100;
}

.seal__letter--dark {
  fill: #4a0b1f;
  transform: translate(-0.7px, -0.7px);
}

.seal__letter--light {
  fill: #d97a95;
  opacity: 0.6;
  transform: translate(0.7px, 0.7px);
}

.seal__letter--main {
  fill: #6e1530;
}

.envelope__pieces {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  z-index: 7;
  display: none;
  pointer-events: none;
}

.envelope__pieces.is-live {
  display: block;
}

.envelope__piece {
  position: absolute;
  inset: 0;
}

.envelope__piece .seal {
  width: 68px;
  height: 68px;
  filter: none;
}

/* The letter lives in the envelope wrap, centered, at its final size; it is
   scaled and clipped into the envelope until the seal is tapped. */
.letter {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--letter-w);
  height: var(--letter-h);
  margin-left: calc(var(--letter-w) / -2);
  margin-top: calc(var(--letter-h) / -2);
  z-index: 9;
  padding: clamp(20px, 6vw, 32px) clamp(20px, 6vw, 30px);
  background: linear-gradient(180deg, var(--paper), color-mix(in oklab, var(--paper) 96%, var(--ink)));
  border-radius: var(--r-paper);
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  text-align: start;
  overflow: hidden;
  clip-path: inset(0 0 100% 0);
}

.envelope-wrap.is-open .letter {
  clip-path: none;
}

.letter::after {
  opacity: 0.3;
}

.letter__body {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 0.55em;
  min-height: 0;
}

.letter__line,
.letter__sign {
  font-size: calc(var(--fs-lead) * var(--hand-scale));
  line-height: 1.3;
  color: var(--ink);
}

.letter__sign {
  margin-top: auto;
  text-align: end;
  padding-top: var(--space-4);
}

.btn.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Cake: two tiers on a glass stand, candles, flames, celebration, greeting
   ========================================================================== */

.cake-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.cake-stage {
  position: relative;
  width: min(88vw, 54svh * (300 / 270), 430px);
  aspect-ratio: 300 / 270;
  container-type: inline-size;
  transition: transform 800ms var(--ease-in-out);
  transform-origin: 50% 50%;
}

.cake {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 18px 24px rgba(15, 6, 20, 0.55));
}

.cake__glow {
  transition: opacity 300ms;
}

.cake-bloom {
  position: absolute;
  left: 50%;
  top: 29%;
  width: 60%;
  aspect-ratio: 1;
  margin-left: -30%;
  margin-top: -30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 243, 214, 0.9), rgba(243, 185, 95, 0.55) 35%, rgba(243, 185, 95, 0) 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.candles {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.candle {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 2;
}

.candle--back {
  z-index: 1;
}

.candle__body {
  position: absolute;
  bottom: 0;
  left: calc(-1.8cqw * var(--cs));
  width: calc(3.6cqw * var(--cs));
  height: calc(11.5cqw * var(--cs));
  border-radius: 1px 1px 2px 2px;
  background: repeating-linear-gradient(-58deg, transparent 0 5px, rgba(243, 185, 95, 0.85) 5px 6.4px),
    linear-gradient(90deg, #d9c1a2, #fbf1e4 40%, #f4e4cc 70%, #cfb28f);
  box-shadow: 0 1px 2px rgba(31, 16, 37, 0.35);
}

.candle__wick {
  position: absolute;
  bottom: calc(11.5cqw * var(--cs) - 1px);
  left: calc(-0.35cqw * var(--cs));
  width: calc(0.7cqw * var(--cs));
  height: calc(2cqw * var(--cs));
  background: linear-gradient(180deg, #e08a3c, #3b2230 60%);
  border-radius: 1px;
}

.flame {
  position: absolute;
  bottom: calc(11.5cqw * var(--cs) - 0.2cqw);
  left: calc(-3.4cqw * var(--cs));
  width: calc(6.8cqw * var(--cs));
  height: calc(10.9cqw * var(--cs));
  transform-origin: 50% 88%;
  will-change: transform;
}

.flame__body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: blur(0.25px);
}

.flame__glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 330%;
  aspect-ratio: 1;
  transform: translate(-50%, -46%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 150, 0.5), rgba(243, 185, 95, 0.22) 38%, rgba(243, 185, 95, 0) 68%);
  mix-blend-mode: screen;
  opacity: 0.85;
  pointer-events: none;
}

.flame.is-out {
  will-change: auto;
  pointer-events: none;
}

.candle.is-out .candle__wick {
  background: #3b2230;
}

.candle__hit {
  position: absolute;
  bottom: -6px;
  left: calc(-1 * max(14px, 5cqw));
  width: max(28px, 10cqw);
  height: calc(11.5cqw * var(--cs) + 9.3cqw * var(--cs) + 16px);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: var(--r-pill);
}

.candle__hit:focus-visible {
  box-shadow: var(--ring);
}

.cake-greeting {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  text-align: center;
  padding-top: var(--space-2);
}

.cake-greeting[hidden] {
  display: none;
}

.greeting__line {
  font-weight: 400;
  line-height: var(--lh-tight);
  text-wrap: balance;
}

.greeting__primary {
  font-size: var(--fs-display);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.greeting__primary.arabic {
  font-size: calc(var(--fs-display) * 0.9);
  line-height: 1.5;
}

.greeting__secondary {
  font-size: var(--fs-h2);
  color: var(--candle);
  line-height: 1.6;
}

.greeting__secondary:not(.arabic) {
  font-size: var(--fs-h3);
}

.greeting__word {
  display: inline-block;
  white-space: nowrap;
}

.greeting__primary .ltr {
  display: inline-block;
  opacity: 0;
  color: var(--text-dim);
  text-shadow: 0 0 10px color-mix(in oklab, var(--candle) 45%, transparent);
}

.greeting__primary.is-in .ltr {
  animation: letter-light 900ms var(--ease-out) forwards;
  animation-delay: var(--d);
}

.cake-greeting.is-lit .ltr {
  animation: none;
  opacity: 1;
  color: var(--text);
}

@keyframes letter-light {
  0% {
    opacity: 0;
    color: var(--text-dim);
    transform: translateY(5px);
  }
  40% {
    opacity: 1;
    color: var(--flame-core);
    transform: translateY(-1px);
  }
  100% {
    opacity: 1;
    color: var(--text);
    transform: none;
  }
}

.wipe {
  clip-path: inset(0 0 0 100%);
}

html[dir="rtl"] .wipe:not(.arabic) {
  clip-path: inset(0 100% 0 0);
}

.wipe.is-in {
  animation: wipe-in 720ms var(--ease-out) forwards;
}

.cake-greeting.is-lit .greeting__line.wipe {
  animation: none;
  clip-path: none;
}

@keyframes wipe-in {
  to {
    clip-path: inset(0 0 0 0);
  }
}

html.reduced .greeting__primary.is-in .ltr {
  animation: fade-only 600ms forwards;
}

html.reduced .wipe.is-in {
  animation: fade-only 600ms forwards;
  clip-path: none;
}

@keyframes fade-only {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
    color: var(--text);
  }
}

/* ==========================================================================
   Bouquet: paper cone, growing flowers, ribbon
   ========================================================================== */

.bouquet {
  position: relative;
  width: min(92vw, 62svh * (300 / 360), 400px);
  aspect-ratio: 300 / 360;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.bouquet:focus-visible {
  box-shadow: var(--ring);
  border-radius: 20px;
}

.cone {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 16px 22px rgba(15, 6, 20, 0.55));
}

.flower__stem {
  stroke: var(--stem);
  stroke-linecap: round;
}

.flower__leaf {
  fill: var(--leaf);
}

.flower__sepal {
  fill: var(--stem);
}

.flower__bud {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.ribbon-band {
  fill: url(#ribbon-gold);
  fill: #f3b95f;
}

.ribbon-band-edge {
  stroke: #c98a2e;
  stroke-width: 1.2;
}

.ribbon-band-group {
  clip-path: inset(0 100% 0 0);
}

.ribbon-bow,
.ribbon-tag {
  opacity: 0;
}

.bouquet-ribbon.is-tied .ribbon-band-group {
  clip-path: none;
}

.bouquet-ribbon.is-tied .ribbon-bow,
.bouquet-ribbon.is-tied .ribbon-tag {
  opacity: 1;
}

.ribbon-tag__text {
  font-family: var(--font-hand);
  font-size: 15px;
  fill: var(--ink);
}

html[lang="ar"] .ribbon-tag__text {
  font-family: var(--font-arabic-hand);
  font-size: 13px;
}

/* ==========================================================================
   Wishes jar: glass jar and folded notes
   ========================================================================== */

.jar-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.jar {
  position: relative;
  width: min(62vw, 42svh / 1.3, 300px);
  aspect-ratio: 200 / 260;
  cursor: pointer;
  touch-action: manipulation;
  transform-origin: 50% 90%;
  transition: opacity 400ms, transform 500ms var(--ease-out);
  border-radius: 30px;
}

.jar:focus-visible {
  box-shadow: var(--ring);
}

.jar.is-dimmed {
  opacity: 0.4;
  transform: scale(0.92) translateY(6%);
}

.jar__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 16px 20px rgba(15, 6, 20, 0.5));
}

.jar__glass-back {
  fill: rgba(255, 255, 255, 0.06);
}

.jar__glass {
  fill: rgba(255, 255, 255, 0.09);
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 1.3;
}

.jar__rim {
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1;
}

.jar__shine {
  fill: none;
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.jar__lid {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.jar__label {
  position: absolute;
  left: 17%;
  right: 17%;
  top: 56%;
  padding: 6% 5%;
  background: linear-gradient(180deg, var(--paper), var(--paper-shade));
  color: var(--ink);
  border-radius: 2px;
  box-shadow: 0 2px 5px rgba(31, 16, 37, 0.35);
  transform: rotate(-2.5deg);
  font-size: calc(var(--fs-body) * var(--hand-scale));
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
}

.jar.is-empty .jar__notes {
  display: none;
}

/* the note that flies out and unfolds */
.note {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(84vw, 380px);
  height: min(46svh, 340px);
  transform: translate(-50%, -50%);
  z-index: 3;
  perspective: 1000px;
  cursor: pointer;
}

.note[hidden] {
  display: none;
}

.note__half {
  position: absolute;
  inset: 0;
  padding: clamp(18px, 6vw, 30px) clamp(18px, 6vw, 28px);
  background: linear-gradient(180deg, var(--paper), color-mix(in oklab, var(--paper) 95%, var(--ink)));
  border-radius: var(--r-paper);
  box-shadow: var(--shadow-lift);
  display: grid;
  align-content: center;
  gap: var(--space-4);
  backface-visibility: hidden;
  transition: transform 420ms var(--ease-in-out);
}

.note__half::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--paper-fibre);
  background-size: 260px 260px;
  opacity: 0.25;
  pointer-events: none;
}

.note__half--top {
  clip-path: inset(0 0 50% 0);
  transform-origin: 50% 50%;
  transform: rotateX(88deg);
}

/* the fold */
.note__half--top::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -2px;
  background: linear-gradient(180deg, rgba(59, 34, 48, 0) 0%, rgba(59, 34, 48, 0.12) 100%);
  pointer-events: none;
}

.note__half--bottom {
  clip-path: inset(50% 0 0 0);
  transform-origin: 50% 50%;
  transform: rotateX(-88deg);
}

.note.is-open .note__half {
  transform: rotateX(0deg);
}

html.reduced .note__half {
  transition-duration: 220ms;
}

.note__text {
  font-size: calc(var(--fs-h3) * var(--hand-scale));
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.note__counter {
  font-family: var(--font-display);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  text-align: center;
}

/* ==========================================================================
   Scratch card: gold foil over the award
   ========================================================================== */

.scratch-card {
  position: relative;
  width: min(86vw, 420px);
  min-height: min(40svh, 300px);
  border-radius: var(--r-paper);
  background: linear-gradient(180deg, var(--paper), color-mix(in oklab, var(--paper) 95%, var(--ink)));
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.award {
  position: relative;
  display: grid;
  gap: var(--space-2);
  padding: clamp(24px, 7vw, 34px) clamp(20px, 6vw, 30px);
  color: var(--ink);
  text-align: center;
  justify-items: center;
  min-height: min(40svh, 300px);
  align-content: center;
}

.award::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--candle-line);
  outline: 1px solid color-mix(in oklab, var(--candle) 30%, transparent);
  outline-offset: 3px;
  border-radius: 2px;
  pointer-events: none;
}

.award__sub {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  order: 2;
}

.award__title {
  font-size: var(--fs-h2);
  font-weight: 400;
  line-height: 1.1;
  font-variation-settings: "SOFT" 100;
  text-wrap: balance;
  order: 1;
}

.award__line {
  font-size: var(--fs-body);
  color: var(--ink-soft);
  line-height: 1.4;
  order: 3;
  margin-top: var(--space-2);
}

.award__seal {
  order: 4;
  margin-top: var(--space-2);
  transform: rotate(-8deg);
}

.scratch__foil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.scratch__emboss {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: var(--fs-h3);
  color: rgba(120, 82, 20, 0.55);
  text-shadow: 0 1px 0 rgba(255, 245, 215, 0.6), 0 -1px 0 rgba(90, 60, 10, 0.35);
  letter-spacing: 0.01em;
  pointer-events: none;
  transition: opacity 300ms;
}

.scratch__glints {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scratch__glints i {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 252, 240, 0.9), rgba(255, 245, 210, 0.35) 40%, rgba(255, 245, 210, 0) 70%);
  animation: glint-twinkle 3.6s ease-in-out infinite;
}

.scratch__glints i:nth-child(1) { left: 18%; top: 30%; animation-delay: 0s; }
.scratch__glints i:nth-child(2) { left: 74%; top: 22%; animation-delay: 1.1s; }
.scratch__glints i:nth-child(3) { left: 60%; top: 70%; animation-delay: 2s; }
.scratch__glints i:nth-child(4) { left: 30%; top: 78%; animation-delay: 2.8s; }

@keyframes glint-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1); }
}

.scratch-card.is-revealed .scratch__emboss,
.scratch-card.is-revealed .scratch__glints {
  display: none;
}

/* ==========================================================================
   Music box: wooden box, velvet lining, brass crank
   ========================================================================== */

.musicbox {
  position: relative;
  width: min(90vw, 52svh * (300 / 260), 420px);
  aspect-ratio: 300 / 260;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 18px 24px rgba(15, 6, 20, 0.55));
}

.mb__gauge {
  stroke: rgba(243, 185, 95, 0.25);
  stroke-width: 3;
  stroke-linecap: round;
}

.mb__gauge-fill {
  stroke: #f3b95f;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 200ms linear;
}

.mb__crank-hit {
  position: absolute;
  left: 76%;
  top: 46%;
  width: 24%;
  height: 26%;
  border: 0;
  background: transparent;
  border-radius: var(--r-pill);
  cursor: grab;
  touch-action: none;
}

html[dir="rtl"] .mb__crank-hit {
  left: 76%;
}

.mb__crank-hit:focus-visible {
  box-shadow: var(--ring);
}

.mb__notes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.mb__note {
  position: absolute;
  bottom: 42%;
  font-size: 22px;
  color: var(--candle);
  text-shadow: 0 0 10px color-mix(in oklab, var(--candle) 60%, transparent);
  animation: note-float 2.6s ease-out forwards;
  opacity: 0;
}

@keyframes note-float {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(-8deg);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx, 0px), -150px) rotate(10deg);
  }
}

/* ==========================================================================
   Coupons: perforated tickets in a snap carousel
   ========================================================================== */

.coupons {
  width: 100%;
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  padding: var(--space-4) 9% var(--space-5);
  scrollbar-width: none;
  touch-action: pan-x;
  align-items: center;
}

.coupons::-webkit-scrollbar {
  display: none;
}

.coupon {
  position: relative;
  flex: 0 0 82%;
  max-width: 400px;
  scroll-snap-align: center;
  display: grid;
  grid-template-columns: 26% 1fr;
  min-height: min(34svh, 240px);
  background: linear-gradient(180deg, var(--paper), color-mix(in oklab, var(--paper) 95%, var(--ink)));
  border-radius: var(--r-paper);
  box-shadow: var(--shadow-lift);
  color: var(--ink);
  -webkit-mask-image: radial-gradient(circle 11px at 26% 0, transparent 98%, #000 100%), radial-gradient(circle 11px at 26% 100%, transparent 98%, #000 100%);
  mask-image: radial-gradient(circle 11px at 26% 0, transparent 98%, #000 100%), radial-gradient(circle 11px at 26% 100%, transparent 98%, #000 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

html[dir="rtl"] .coupon {
  -webkit-mask-image: radial-gradient(circle 11px at 74% 0, transparent 98%, #000 100%), radial-gradient(circle 11px at 74% 100%, transparent 98%, #000 100%);
  mask-image: radial-gradient(circle 11px at 74% 0, transparent 98%, #000 100%), radial-gradient(circle 11px at 74% 100%, transparent 98%, #000 100%);
}

.coupon::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--paper-fibre);
  background-size: 260px 260px;
  opacity: 0.22;
  pointer-events: none;
}

.coupon__stub {
  display: grid;
  place-items: center;
  border-inline-end: 2px dashed color-mix(in oklab, var(--ink) 32%, transparent);
  background: color-mix(in oklab, var(--candle) 14%, transparent);
}

.coupon__number {
  font-size: var(--fs-h2);
  color: color-mix(in oklab, var(--ink) 55%, var(--paper));
  transform: rotate(-90deg);
}

.coupon__main {
  position: relative;
  padding: 6%;
  display: grid;
}

.coupon__main.is-tearing {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 2% 92%, 0 84%, 3% 76%, 0 68%, 2% 60%, 0 52%, 3% 44%, 0 36%, 2% 28%, 0 20%, 3% 12%, 0 4%);
}

.coupon__frame {
  border: 1px solid var(--candle-line);
  padding: clamp(14px, 4vw, 22px);
  display: grid;
  align-content: center;
  gap: var(--space-3);
  text-align: start;
  min-height: 100%;
}

.coupon__title {
  font-size: var(--fs-h3);
  font-weight: 400;
  line-height: 1.15;
  font-variation-settings: "SOFT" 100;
  text-wrap: balance;
}

.coupon__fine {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  line-height: 1.4;
}

.coupon__stamp {
  position: absolute;
  right: 8%;
  bottom: 9%;
  padding: 4px 12px;
  border: 3px solid var(--rose);
  border-radius: 6px;
  color: var(--rose);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  transform: rotate(-12deg);
  display: none;
  mix-blend-mode: multiply;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.6 -0.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.6 -0.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  -webkit-mask-size: 120px 120px;
  mask-size: 120px 120px;
}

html[dir="rtl"] .coupon__stamp {
  right: auto;
  left: 8%;
  transform: rotate(12deg);
}

.coupon.is-used .coupon__stamp {
  display: block;
}

.coupon.is-used .coupon__frame {
  opacity: 0.75;
}

.coupon__stamp-word {
  display: block;
  font-size: var(--fs-h3);
}

.coupon__stamp-date {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ==========================================================================
   Wish: stationery writing pad
   ========================================================================== */

.pad {
  position: relative;
  width: min(92vw, 440px);
  height: 100%;
  max-height: min(64svh, 560px);
  min-height: 260px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(180deg, transparent 0 33px, rgba(59, 34, 48, 0.14) 33px 34px),
    linear-gradient(180deg, var(--paper), color-mix(in oklab, var(--paper) 96%, var(--ink)));
  background-position: 0 calc(var(--fs-lead) * var(--hand-scale) + 40px), 0 0;
  border-radius: var(--r-paper);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  align-self: stretch;
}

.pad__prompt {
  position: absolute;
  top: 14px;
  inset-inline-start: 18px;
  inset-inline-end: 60px;
  font-size: calc(var(--fs-lead) * var(--hand-scale));
  color: var(--ink);
  line-height: 1.2;
  text-align: start;
  pointer-events: none;
}

.pad__motif {
  position: absolute;
  inset-inline-end: 10px;
  bottom: 10px;
  width: 44px;
  height: 44px;
  opacity: 0.9;
  pointer-events: none;
}

.pad__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.pad__tools {
  display: flex;
  gap: var(--space-5);
  justify-content: center;
}

.pad__tools .btn--link {
  width: auto;
}

.pad__tools.is-hidden {
  display: none;
}

/* ==========================================================================
   Finale: night sky, fireworks, greeting, signature
   ========================================================================== */

.scene--finale {
  grid-template-rows: minmax(0, 1fr) auto auto;
}

.finale {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  align-items: end;
  justify-items: center;
  padding-bottom: 4%;
}

.sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}

.finale__text {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-3);
  justify-items: center;
  text-align: center;
  padding: var(--space-2) var(--space-2);
  pointer-events: none;
  max-width: 100%;
}

.finale__greeting {
  font-size: calc(var(--fs-display) * 0.86);
  font-weight: 400;
  line-height: var(--lh-tight);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  color: var(--text);
  text-shadow: 0 0 18px color-mix(in oklab, var(--candle) 55%, transparent), 0 0 44px color-mix(in oklab, var(--candle) 30%, transparent);
  text-wrap: balance;
}

.finale__greeting.arabic {
  line-height: 1.5;
}

.finale__second {
  font-size: var(--fs-h3);
  color: var(--candle);
  line-height: 1.6;
}

.finale__lines {
  display: grid;
  gap: var(--space-2);
  max-width: 34ch;
}

.finale__line {
  font-size: var(--fs-body);
  color: var(--text-dim);
  line-height: 1.45;
  text-wrap: balance;
}

.finale__sign {
  position: relative;
  pointer-events: auto;
  font-size: calc(var(--fs-h3) * var(--hand-scale));
  color: var(--text);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.finale__sign::after {
  content: "";
  position: absolute;
  inset-inline-end: 4px;
  top: 30%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--flame-core), color-mix(in oklab, var(--candle) 60%, transparent) 40%, transparent 70%);
  opacity: 0;
  pointer-events: none;
}

.finale__sign.is-glint::after {
  animation: sign-glint 900ms ease-out 1;
}

@keyframes sign-glint {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  40% {
    opacity: 1;
    transform: scale(1.3);
  }
  100% {
    opacity: 0;
    transform: scale(0.6);
  }
}

.secret {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: min(84vw, 380px);
  transform: translate(-50%, -50%) scale(0.9);
  padding: clamp(20px, 6vw, 30px);
  background: linear-gradient(180deg, var(--paper), color-mix(in oklab, var(--paper) 95%, var(--ink)));
  border-radius: var(--r-paper);
  box-shadow: var(--shadow-lift);
  display: grid;
  gap: var(--space-4);
  opacity: 0;
  transition: opacity 260ms var(--ease-out), transform 320ms var(--ease-out);
}

.secret[hidden] {
  display: none;
}

.secret.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.secret__text {
  font-size: calc(var(--fs-lead) * var(--hand-scale));
  line-height: 1.35;
  color: var(--ink);
  text-align: start;
  overflow-wrap: anywhere;
}
