/* Tahani template engine styles (assets/invite/engine.js). Everything is prefixed tx- and themed through
   custom properties set by applyTheme(); RTL/LTR follows the document via logical properties.
   Sizes inside the decoration layer use container units (cqw/cqh) so a phone-sized preview box and the
   full-screen invitation look the same. */

@font-face { font-family: "IBM Plex Sans Arabic"; src: url("/assets/fonts/IBMPlexSansArabic-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("/assets/fonts/IBMPlexSansArabic-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Reem Kufi"; src: url("/assets/fonts/ReemKufi-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("/assets/fonts/Amiri-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("/assets/fonts/Amiri-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Aref Ruqaa"; src: url("/assets/fonts/ArefRuqaa-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Aref Ruqaa"; src: url("/assets/fonts/ArefRuqaa-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

/* ---------- stage ---------- */

.tx-stage {
  --tx-bg: #FAF6EC; --tx-ink: #0F3D2E; --tx-muted: #66665F; --tx-accent: #9C7A1C; --tx-card: #FFFDF7;
  position: relative;
  box-sizing: border-box;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 20px;
  background: var(--tx-bg);
  color: var(--tx-ink);
  font-family: var(--tx-body-font);
  overflow: hidden;
  container-type: inline-size;
  -webkit-font-smoothing: antialiased;
}
.tx-stage *, .tx-stage *::before, .tx-stage *::after { box-sizing: border-box; }
.tx-stage.tx-opened.tx-hero-lanterns { justify-content: flex-start; padding-top: max(210px, calc(30 * var(--tx-vh, 1vh))); }
.tx-stage.tx-opened.tx-hero-crescent { justify-content: flex-start; padding-top: max(170px, calc(24 * var(--tx-vh, 1vh))); }
.tx-stage.tx-opened.tx-hero-balloons { justify-content: flex-start; padding-top: max(150px, calc(22 * var(--tx-vh, 1vh))); }
/* A lantern row hanging at the top (400x74 band, full width) stays visible above the card. */
.tx-stage.tx-opened.tx-band-top-lantern_row:not(.tx-hero-page) { justify-content: flex-start; }
.tx-stage.tx-band-top-lantern_row:not(.tx-hero-page) > .tx-card { margin-top: max(0px, calc(18.5cqw - 6px)); }
.tx-stage.tx-opened.tx-arch-clear { justify-content: flex-start; }
.tx-stage.tx-arch-clear > .tx-card { margin-top: max(64px, calc(11 * var(--tx-vh, 1vh))); }

.tx-decor { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; container-type: size; }
.tx-stage > .tx-card { position: relative; z-index: 2; }

/* ---------- card ---------- */

.tx-card {
  width: min(100%, 440px);
  padding: 34px 24px 30px;
  text-align: center;
  color: var(--tx-ink);
  border-radius: var(--tx-radius);
}
.tx-card-paper {
  background: var(--tx-card);
  border: 1px solid color-mix(in srgb, var(--tx-accent) 22%, var(--tx-card));
  box-shadow: 0 0 0 6px var(--tx-card), 0 0 0 7px color-mix(in srgb, var(--tx-seal) 55%, transparent), 0 24px 50px color-mix(in srgb, var(--tx-ink) 12%, transparent);
  margin-top: 8px;
}
.tx-card-glass {
  background: color-mix(in srgb, var(--tx-card) var(--tx-glass), transparent);
  border: 1px solid color-mix(in srgb, var(--tx-accent) 35%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.tx-light .tx-card-glass { border-color: transparent; box-shadow: 0 20px 50px color-mix(in srgb, var(--tx-ink) 12%, transparent); }
.tx-card-outline {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--tx-accent) 70%, transparent);
  outline: 1px solid color-mix(in srgb, var(--tx-accent) 35%, transparent);
  outline-offset: -7px;
}
.tx-card-none { width: min(100%, 400px); padding: 40px 30px 30px; }
/* One diagonal sheen across the card once it has landed. */
.tx-card-paper, .tx-card-glass { position: relative; overflow: hidden; }
.tx-card-paper::after, .tx-card-glass::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%) 0 0 / 300% 100% no-repeat;
  background-position: 150% 0; opacity: 0;
}
.tx-dark .tx-card-paper::after, .tx-dark .tx-card-glass::after { background-image: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .14) 50%, transparent 65%); }

.tx-title { margin: 0; font-family: var(--tx-label-font); word-spacing: .12em; font-size: 18px; color: var(--tx-accent); }
:lang(en) .tx-title, :lang(fr) .tx-title { letter-spacing: .08em; text-transform: uppercase; font-size: 14px; }
.tx-hosts {
  margin: 10px 0 0;
  font-family: var(--tx-title-font);
  font-weight: 500;
  font-size: clamp(32px, 10cqi, 46px);
  line-height: 1.3;
  color: var(--tx-ink);
  overflow-wrap: anywhere;
}
/* Names in "foil": ink with a light accent sheen that sweeps across (text stays ink-dark, so contrast holds). */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .tx-hosts {
    background: linear-gradient(105deg, var(--tx-ink) 0%, var(--tx-ink) 40%, color-mix(in srgb, var(--tx-accent) 70%, var(--tx-ink)) 50%, var(--tx-ink) 60%, var(--tx-ink) 100%) 0 0 / 250% 100%;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    background-position: 100% 0;
  }
}
.tx-divider { display: block; margin: 16px auto; color: var(--tx-accent); }
.tx-line { width: 72px; height: 1px; margin: 18px auto; background: linear-gradient(90deg, transparent, var(--tx-accent), transparent); }
.tx-fleuron { width: 96px; height: auto; color: var(--tx-accent); }
.tx-crown { display: block; margin: 0 auto 12px; }
.tx-diamonds { width: 110px; height: auto; }
.tx-message {
  margin: 0 auto;
  max-width: 34ch;
  font-family: var(--tx-body-font);
  font-size: 17px;
  line-height: 1.85;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
/* Date / time / place: soft tiles with a small icon (modern, scannable). */
.tx-details { margin: 24px auto 0; padding: 0; max-width: 360px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tx-detail {
  display: grid; gap: 2px; justify-items: center; align-content: start;
  padding: 14px 12px 13px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--tx-accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--tx-accent) 18%, transparent);
}
/* The date (longest) gets its own row; time and place share the next one, or take it alone. */
.tx-detail-date, .tx-detail:only-child, .tx-detail-time:last-child, .tx-detail-date + .tx-detail-place, .tx-detail-place:first-child { grid-column: 1 / -1; }
.tx-detail-icon { width: 22px; height: 22px; color: var(--tx-accent); margin-bottom: 4px; }
.tx-detail dt { font-size: 12px; color: var(--tx-accent); }
:lang(en) .tx-detail dt, :lang(fr) .tx-detail dt { letter-spacing: .1em; text-transform: uppercase; }
.tx-detail dd { margin: 0; font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.tx-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }
.tx-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--tx-accent);
  font: inherit; font-size: 15px; font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tx-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--tx-accent) 88%, white), var(--tx-accent));
  color: var(--tx-on-accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--tx-accent) 32%, transparent);
}
.tx-btn { transition: transform .15s ease, box-shadow .2s ease; }
.tx-btn:active { transform: scale(.97); }
.tx-ghost { background: transparent; color: var(--tx-ink); }
.tx-btn:focus-visible { outline: 2px solid var(--tx-accent); outline-offset: 3px; }

/* card heroes */
.tx-card-hero { position: relative; margin: 2px auto 18px; color: var(--tx-hero); }
.tx-card-hero svg { display: block; width: 100%; height: auto; }
.tx-card-hero > .tx-amb-target { position: relative; z-index: 1; }
.tx-card-hero-monogram { width: 76px; }
.tx-card-hero-cap { width: 118px; }
.tx-card-hero-flowers { width: 172px; }
.tx-card-hero-rings { width: 128px; }
.tx-card-hero-cake { width: 108px; }
/* Soft light behind the illustration. */
.tx-halo {
  position: absolute; left: 50%; top: 50%; width: 190%; aspect-ratio: 1; translate: -50% -50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--tx-accent) 26%, transparent) 0%, color-mix(in srgb, var(--tx-bloom) 12%, transparent) 38%, transparent 66%);
  pointer-events: none;
}
/* Twinkling four-point glints around the hero. */
.tx-glint { position: absolute; width: var(--gs); height: var(--gs); color: var(--tx-accent); z-index: 2; opacity: 0; translate: -50% -50%; }
.tx-glint-svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--tx-accent) 70%, transparent)); }
.tx-card-hero-monogram .tx-glint, .tx-card-hero-flowers .tx-glint { color: var(--tx-bloom); }

/* ---------- aura: drifting light in the theme's colors ---------- */

.tx-aura { position: absolute; inset: -20%; filter: blur(48px); opacity: .55; }
.tx-dark .tx-aura { opacity: .3; mix-blend-mode: screen; }
.tx-dark .tx-aura-2 { background: color-mix(in srgb, var(--tx-bg2) 60%, var(--tx-bloom)); }
.tx-aura-blob { position: absolute; border-radius: 50%; width: 70cqw; aspect-ratio: 1; }
.tx-aura-0 { left: -6%; top: 4%; background: color-mix(in srgb, var(--tx-accent) 45%, transparent); }
.tx-aura-1 { right: -10%; top: 32%; background: color-mix(in srgb, var(--tx-bloom) 50%, transparent); }
.tx-aura-2 { left: 20%; bottom: -4%; background: color-mix(in srgb, var(--tx-bg2) 85%, var(--tx-accent)); }
.tx-cap-body { fill: color-mix(in srgb, var(--tx-hero) 8%, #17181F); }
.tx-cake-fill { fill: color-mix(in srgb, var(--tx-hero) 14%, var(--tx-card)); }
.tx-candles { fill: var(--tx-bloom); }
.tx-flames { fill: #F2B441; transform-box: fill-box; transform-origin: 50% 100%; }
.tx-bloom { fill: var(--tx-bloom); }

/* ---------- frames, corners, bands ---------- */

.tx-frame { position: absolute; inset: 12px; color: var(--tx-frame); opacity: .75; }
.tx-frame-svg { display: block; width: 100%; height: 100%; }
.tx-corner { position: absolute; width: min(22cqw, 96px); height: auto; color: var(--tx-corner); opacity: .9; }
.tx-corner-floral { width: min(30cqw, 120px); }
.tx-corner.tl { top: 22px; left: 22px; }
.tx-corner.tr { top: 22px; right: 22px; transform: scaleX(-1); }
.tx-corner.bl { bottom: 22px; left: 22px; transform: scaleY(-1); }
.tx-corner.br { bottom: 22px; right: 22px; transform: scale(-1, -1); }
.tx-corner-floral.tl, .tx-corner-floral.tr { top: 18px; }
.tx-corner-floral.bl, .tx-corner-floral.br { bottom: 18px; }
.tx-corner-floral.tl, .tx-corner-floral.bl { left: 18px; }
.tx-corner-floral.tr, .tx-corner-floral.br { right: 18px; }

.tx-band { position: absolute; inset-inline: 0; color: var(--tx-band); }
.tx-band-at-top { top: 0; }
.tx-band-at-bottom { bottom: 0; }
.tx-band-at-bottom.tx-band-arcade, .tx-band-at-bottom.tx-band-scallops { transform: scaleY(-1); }
.tx-band-arcade { display: grid; grid-template-columns: repeat(5, 1fr); opacity: .32; }
.tx-arch { display: block; width: 100%; height: auto; }
.tx-band-svg { display: block; width: 100%; }
.tx-band-scallops .tx-band-svg { height: 34px; }
.tx-band-lanterns { height: auto; }
.tx-ml { transform-box: fill-box; transform-origin: 50% 0; }
.tx-ml-glow { fill: color-mix(in srgb, #FFD27A 75%, var(--tx-band)); }

/* ---------- page heroes ---------- */

.tx-lantern {
  position: absolute; top: 0; inset-inline-start: var(--x);
  width: calc(54px * var(--scale));
  display: flex; flex-direction: column; align-items: center;
  transform-origin: 50% 0;
  color: var(--tx-hero);
}
.tx-lantern-string { width: 1.4px; height: var(--len); background: currentColor; transform-origin: top; }
.tx-lantern-svg { width: 100%; height: auto; margin-top: -1px; position: relative; z-index: 1; }
.tx-lantern-body { fill: color-mix(in srgb, var(--tx-hero) 12%, #241A0B); stroke: color-mix(in srgb, var(--tx-hero) 75%, #FFF6D8); }
.tx-lantern-trim { stroke: color-mix(in srgb, var(--tx-hero) 75%, #FFF6D8); }
.tx-lantern-glow {
  position: absolute; left: 50%; bottom: -30%;
  width: 260%; aspect-ratio: 1; translate: -50% 0;
  background: radial-gradient(circle, rgba(255, 196, 90, .42), transparent 62%);
}

.tx-moon {
  position: absolute; top: 4cqh; inset-inline-end: 5cqw;
  width: min(44cqw, 200px);
  filter: drop-shadow(0 0 26px color-mix(in srgb, var(--tx-hero) 55%, transparent));
}
.tx-crescent-svg { display: block; width: 100%; height: auto; }
.tx-c0 { stop-color: color-mix(in srgb, var(--tx-hero) 30%, #FFFFFF); }
.tx-c1 { stop-color: var(--tx-hero); }
.tx-c2 { stop-color: color-mix(in srgb, var(--tx-hero) 72%, #000000); }

.tx-balloon { position: absolute; width: calc(64px * var(--scale)); }
.tx-balloon .tx-amb-target { display: block; rotate: var(--tilt); }
.tx-balloon-svg { display: block; width: 100%; height: auto; }
.tx-balloon-string { stroke: var(--tx-hero); }
.tx-balloon-knot { fill: color-mix(in srgb, currentColor 80%, #000000); }

.tx-glow {
  position: absolute; left: 50%; top: 34%;
  width: 130cqmax; aspect-ratio: 1; translate: -50% -50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--tx-accent) 20%, transparent), transparent 55%);
}

/* ---------- particles ---------- */

.tx-p { position: absolute; inset-inline-start: calc(var(--x) * 1%); top: calc(var(--y) * 1%); }
.tx-p-twinkle {
  width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--tint); box-shadow: 0 0 6px 1px color-mix(in srgb, var(--tint) 70%, transparent);
  opacity: .8;
}
.tx-p-petals {
  width: var(--s); height: calc(var(--s) * .78);
  border-radius: 75% 0 75% 0;
  background: linear-gradient(135deg, var(--tint), color-mix(in srgb, var(--tint) 45%, white));
  opacity: .9;
  rotate: var(--rot);
}
.tx-p-dots { width: var(--s); height: var(--s); border-radius: 50%; background: var(--tint); opacity: .55; }
.tx-p-bubbles {
  width: var(--s); height: var(--s); border-radius: 50%;
  border: 1.5px solid var(--tint);
  background: radial-gradient(circle at 32% 30%, color-mix(in srgb, white 70%, transparent) 0 14%, color-mix(in srgb, var(--tint) 18%, transparent) 15%);
  opacity: .9;
}
.tx-p-confetti { width: var(--w); height: var(--h); background: var(--tint); border-radius: 2px; rotate: var(--rot); }
.tx-stage:not(.tx-amb-fall) .tx-p-confetti { left: 50%; right: auto; top: 36%; rotate: none; opacity: 0; }

/* ---------- intro (one-off) ---------- */

.tx-card > * { animation: tx-rise .9s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * .14s + .2s); }
.tx-intro-fade .tx-card > * { animation-name: tx-fade-in; animation-duration: 1s; }
.tx-intro-fade .tx-decor > *, .tx-intro-rise .tx-frame, .tx-intro-rise .tx-corner, .tx-intro-rise .tx-band { animation: tx-fade-in 1.4s ease .2s both; }
.tx-intro-draw .tx-stroke { stroke-dasharray: 1; animation: tx-draw 2.4s ease .2s both; }
.tx-intro-draw .tx-frame .tx-stroke + .tx-stroke { animation-delay: .6s; }
.tx-intro-draw .tx-corner { animation: tx-fade-in 1.2s ease 1s both; }
.tx-intro-draw .tx-corner .tx-stroke { animation-duration: 1.8s; animation-delay: 1.2s; }
.tx-intro-draw .tx-arch .tx-stroke { animation-duration: 2.2s; animation-delay: var(--delay); }
.tx-intro-draw .tx-band-svg .tx-stroke { animation-duration: 1.6s; }
.tx-intro-draw .tx-card .tx-stroke { animation-duration: 1.4s; animation-delay: .5s; }
.tx-intro-draw .tx-fade { animation: tx-fade-in 1s ease 1.8s both; }
.tx-intro-draw .tx-arch .tx-fade { animation-delay: calc(var(--delay) + 1.2s); }
.tx-intro-draw .tx-band-lanterns .tx-ml, .tx-intro-rise .tx-band-lanterns .tx-ml { animation: tx-fade-in 1s ease .8s both; }

.tx-lantern { animation: tx-fade-in 1s ease var(--delay) both; }
.tx-intro-rise .tx-lantern-string, .tx-intro-draw .tx-lantern-string { animation: tx-grow 1.1s ease var(--delay) both; }
.tx-moon { animation: tx-fade-in 1.6s ease .1s both; }
.tx-intro-rise .tx-moon, .tx-intro-draw .tx-moon { animation: tx-moon-rise 2.4s cubic-bezier(.2, .8, .2, 1) .1s both; }
.tx-balloon { animation: tx-fade-in 1.4s ease var(--delay) both; }
.tx-intro-rise .tx-balloon, .tx-intro-draw .tx-balloon { animation: tx-float-up 2.4s cubic-bezier(.2, .8, .2, 1) var(--delay) both; }
.tx-intro-rise .tx-card > .tx-card-hero-cap, .tx-intro-draw .tx-card > .tx-card-hero-cap { animation: tx-cap-toss 1.3s cubic-bezier(.2, .8, .2, 1) .15s both; }
.tx-stage:not(.tx-amb-fall) .tx-p-confetti { animation: tx-burst var(--d) cubic-bezier(.12, .7, .3, 1) var(--delay) both; }

/* card lands with a slight 3D tilt, then the sheen sweeps and the names catch the light */
.tx-opened > .tx-card { animation: tx-card-in 1.1s cubic-bezier(.2, .8, .2, 1) .05s both; transform-origin: 50% 0; }
.tx-opened > .tx-card::after { animation: tx-sheen 1.6s ease 1.2s both; }
.tx-opened .tx-hosts { animation: tx-rise .9s cubic-bezier(.2, .7, .2, 1) calc(var(--i, 0) * .14s + .2s) both, tx-foil 2.4s ease calc(var(--i, 0) * .14s + 1.1s) both, tx-foil 2.4s ease 9s infinite; }
/* the hero: pops in, its glints twinkle, and each theme has its own signature motion */
.tx-opened .tx-card > .tx-card-hero:not(.tx-card-hero-cap) { animation: tx-hero-in 1s cubic-bezier(.2, 1.4, .4, 1) .15s both; }
.tx-opened .tx-halo { animation: tx-halo 5s ease-in-out 1s infinite alternate; }
.tx-stage:not(.tx-amb-none).tx-opened .tx-glint { animation: tx-glint 3.2s ease-in-out calc(var(--gd) + 1s) infinite; }
.tx-opened .tx-card-hero-flowers .tx-bloom { transform-box: fill-box; transform-origin: 50% 50%; animation: tx-bloom-pop .8s cubic-bezier(.2, 1.6, .4, 1) 1s both; }
.tx-opened .tx-card-hero-flowers .tx-bloom:nth-of-type(2) { animation-delay: 1.25s; }
.tx-opened .tx-card-hero-flowers .tx-bloom:nth-of-type(3) { animation-delay: 1.5s; }
.tx-opened .tx-card-hero-flowers .tx-stroke, .tx-opened .tx-card-hero-rings .tx-stroke { stroke-dasharray: 1; animation: tx-draw 1.4s ease .3s both; }
.tx-opened .tx-card-hero-rings .tx-stroke + .tx-stroke { animation-delay: .65s; }
.tx-opened .tx-card-hero-rings .tx-bloom { transform-box: fill-box; transform-origin: 50% 100%; animation: tx-bloom-pop .7s cubic-bezier(.2, 1.6, .4, 1) 1.4s both; }
.tx-opened .tx-card-hero-cake .tx-candles rect { transform-box: fill-box; transform-origin: 50% 100%; animation: tx-grow .5s ease 1s both; }
.tx-opened .tx-card-hero-cake .tx-flames { animation: tx-fade-in .4s ease 1.4s both, tx-flicker 1.4s ease-in-out 1.8s infinite alternate; }
.tx-opened .tx-card-hero-monogram path { stroke-dasharray: 400; animation: tx-ink 1.6s ease .3s both; }
/* the aura breathes and drifts slowly */
.tx-stage:not(.tx-amb-none) .tx-aura-0 { animation: tx-aura-a 22s ease-in-out infinite alternate; }
.tx-stage:not(.tx-amb-none) .tx-aura-1 { animation: tx-aura-b 26s ease-in-out infinite alternate; }
.tx-stage:not(.tx-amb-none) .tx-aura-2 { animation: tx-aura-c 30s ease-in-out infinite alternate; }
.tx-aura { animation: tx-fade-in 2s ease both; }

/* ---------- ambient (looping) ---------- */

/* sway */
.tx-amb-sway .tx-lantern { animation: tx-swing var(--sw) ease-in-out var(--delay) infinite alternate, tx-fade-in 1s ease var(--delay) both; }
.tx-amb-sway .tx-amb-target, .tx-amb-sway .tx-ml { animation: tx-rock 3.4s ease-in-out infinite alternate; }
.tx-amb-sway .tx-card-hero .tx-amb-target { transform-origin: 50% 100%; }
.tx-amb-sway .tx-p-petals, .tx-amb-sway .tx-p-dots, .tx-amb-sway .tx-p-bubbles { animation: tx-sway-x var(--d) ease-in-out var(--delay) infinite alternate; }
/* float */
.tx-amb-float .tx-lantern .tx-lantern-svg, .tx-amb-float .tx-amb-target, .tx-amb-float .tx-ml { animation: tx-bob 3.2s ease-in-out infinite alternate; }
.tx-amb-float .tx-balloon .tx-amb-target { animation: tx-bob var(--bob) ease-in-out infinite alternate; }
.tx-amb-float .tx-p-petals, .tx-amb-float .tx-p-dots { animation: tx-drift var(--d) ease-in-out var(--delay) infinite alternate; }
.tx-amb-float .tx-p-bubbles { animation: tx-rise-up var(--d) linear var(--delay) infinite; }
/* twinkle */
.tx-amb-twinkle .tx-moon .tx-amb-target, .tx-amb-twinkle .tx-card-hero .tx-amb-target, .tx-amb-twinkle .tx-glow, .tx-amb-twinkle .tx-ml-glow { animation: tx-glow 4s ease-in-out 2.4s infinite alternate; }
.tx-amb-twinkle .tx-p-petals, .tx-amb-twinkle .tx-p-dots, .tx-amb-twinkle .tx-p-bubbles { animation: tx-pulse var(--d) ease-in-out var(--delay) infinite alternate; }
/* fall */
.tx-amb-fall .tx-p-petals { animation: tx-fall var(--d) linear var(--delay) infinite, tx-spin-sway var(--sway) ease-in-out infinite alternate; }
.tx-amb-fall .tx-p-dots, .tx-amb-fall .tx-p-bubbles { animation: tx-fall calc(var(--d) * 2) linear var(--delay) infinite; }
.tx-amb-fall .tx-p-confetti { animation: tx-rain var(--rain) linear var(--rain-delay) infinite; }
.tx-amb-fall .tx-amb-target { animation: tx-bob 3.6s ease-in-out infinite alternate; }
/* any motion: stars twinkle, lantern glass flickers, candles flicker */
.tx-stage:not(.tx-amb-none) .tx-p-twinkle { animation: tx-twinkle var(--d) ease-in-out var(--delay) infinite alternate; }
.tx-stage:not(.tx-amb-none) .tx-lantern-glow { animation: tx-flicker 2.6s ease-in-out infinite alternate; }
.tx-stage:not(.tx-amb-none) .tx-flames { animation: tx-flicker 1.4s ease-in-out infinite alternate; }

/* ---------- envelope ---------- */

.tx-envelope-screen { gap: 30px; }
.tx-envelope {
  all: unset;
  cursor: pointer;
  position: relative;
  width: min(84cqi, 340px);
  aspect-ratio: 3 / 2;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, .28));
  animation: tx-hover 3.2s ease-in-out infinite alternate;
  -webkit-tap-highlight-color: transparent;
}
.tx-envelope:focus-visible { outline: 2px solid var(--tx-accent); outline-offset: 10px; border-radius: 12px; }
.tx-envelope > span { position: absolute; display: block; }
.tx-env-back { inset: 0; background: var(--tx-env-2); border-radius: 10px; }
.tx-env-letter {
  left: 6%; right: 6%; top: 7%; bottom: 6%;
  background: var(--tx-letter);
  border-radius: 6px;
  display: grid !important; place-items: start center; padding-top: 7%;
  color: var(--tx-env-seal);
  z-index: 1;
  transition: transform .7s cubic-bezier(.2, .8, .2, 1) .55s;
}
.tx-letter-mark { width: 26%; height: auto; }
.tx-env-front { inset: 0; z-index: 2; }
.tx-env-front svg { display: block; width: 100%; height: 100%; }
.tx-pk0 { stop-color: var(--tx-env); }
.tx-pk1 { stop-color: var(--tx-env-2); }
.tx-env-flap {
  left: 0; right: 0; top: 0; height: 60%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tx-env) 88%, white), var(--tx-env));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 10px 10px 0 0;
  transform-origin: top;
  z-index: 3;
  transition: transform .6s cubic-bezier(.4, 0, .2, 1) .15s, z-index 0s linear .45s;
}
.tx-env-seal {
  left: 50%; top: 58%; width: 21%; aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tx-env-seal) 55%, white), var(--tx-env-seal) 55%, color-mix(in srgb, var(--tx-env-seal) 70%, black));
  box-shadow: 0 3px 8px rgba(0, 0, 0, .3), inset 0 0 0 3px color-mix(in srgb, var(--tx-env-seal) 80%, black);
  display: grid !important; place-items: center;
  color: #FFF8E6;
  z-index: 4;
  transition: transform .35s ease, opacity .35s ease;
}
.tx-seal-mark { width: 74%; height: auto; }
.tx-tap-hint { margin: 0; color: var(--tx-muted); font-size: 15px; animation: tx-breathe 1.8s ease-in-out infinite; transition: opacity .3s; }
.tx-opening .tx-envelope { animation: tx-env-out .5s ease 1.05s forwards; }
.tx-opening .tx-env-seal { transform: scale(1.35); opacity: 0; }
.tx-opening .tx-env-flap { transform: perspective(900px) rotateX(180deg); z-index: 0; }
.tx-opening .tx-env-letter { transform: translateY(-44%); }
.tx-opening .tx-tap-hint { opacity: 0; }

/* ---------- keyframes ---------- */

@keyframes tx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes tx-fade-in { from { opacity: 0; } }
@keyframes tx-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes tx-grow { from { transform: scaleY(0); } }
@keyframes tx-moon-rise { from { opacity: 0; transform: translateY(60cqh) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes tx-float-up { from { opacity: 0; translate: 0 90cqh; } to { opacity: 1; translate: 0 0; } }
@keyframes tx-cap-toss { 0% { opacity: 0; transform: translateY(-40px) rotate(-25deg); } 60% { opacity: 1; transform: translateY(4px) rotate(6deg); } 100% { transform: none; } }
@keyframes tx-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(0deg); }
  6% { opacity: 1; }
  28% { opacity: 1; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(calc(var(--spin) * .35)); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx) * 1.15), calc(-50% + var(--dy) + var(--fall))) scale(1) rotate(var(--spin)); }
}
@keyframes tx-swing { from { rotate: -5deg; } to { rotate: 5deg; } }
@keyframes tx-rock { from { rotate: -4deg; } to { rotate: 4deg; } }
@keyframes tx-bob { from { translate: 0 0; } to { translate: 0 -10px; } }
@keyframes tx-drift { from { translate: 0 0; } to { translate: 0 -24px; } }
@keyframes tx-sway-x { from { translate: -10px 0; } to { translate: 10px 0; } }
@keyframes tx-pulse { from { opacity: .2; } to { opacity: .9; } }
@keyframes tx-glow { from { opacity: .75; } to { opacity: 1; } }
@keyframes tx-twinkle { from { opacity: .15; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@keyframes tx-flicker { 0% { opacity: .7; } 40% { opacity: 1; } 70% { opacity: .8; } 100% { opacity: .95; } }
@keyframes tx-fall { from { translate: 0 calc(-1cqh * (var(--y) + 6)); } to { translate: 8cqw calc(1cqh * (106 - var(--y))); } }
@keyframes tx-rise-up { from { translate: 0 calc(1cqh * (106 - var(--y))); } to { translate: 0 calc(-1cqh * (var(--y) + 8)); } }
@keyframes tx-rain { from { translate: 0 calc(-1cqh * (var(--y) + 6)); rotate: 0deg; } to { translate: 6cqw calc(1cqh * (106 - var(--y))); rotate: var(--spin); } }
@keyframes tx-spin-sway { from { rotate: calc(var(--rot) - 40deg); } to { rotate: calc(var(--rot) + 40deg); } }
@keyframes tx-card-in { from { opacity: 0; transform: perspective(1000px) rotateX(10deg) translateY(36px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes tx-sheen { 0% { opacity: 1; background-position: 150% 0; } 100% { opacity: 1; background-position: -50% 0; } }
@keyframes tx-foil { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes tx-hero-in { from { opacity: 0; transform: translateY(10px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes tx-halo { from { opacity: .7; transform: scale(.92); } to { opacity: 1; transform: scale(1.06); } }
@keyframes tx-glint { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); } 18% { opacity: 1; transform: scale(1) rotate(45deg); } 36% { opacity: 0; transform: scale(.4) rotate(90deg); } }
@keyframes tx-bloom-pop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: none; } }
@keyframes tx-ink { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@keyframes tx-aura-a { from { translate: 0 0; scale: 1; } to { translate: 18cqw 10cqh; scale: 1.25; } }
@keyframes tx-aura-b { from { translate: 0 0; scale: 1.1; } to { translate: -20cqw -8cqh; scale: .85; } }
@keyframes tx-aura-c { from { translate: 0 0; scale: .9; } to { translate: 10cqw -14cqh; scale: 1.2; } }
@keyframes tx-hover { from { transform: translateY(0); } to { transform: translateY(-8px); } }
@keyframes tx-breathe { 50% { opacity: .45; } }
@keyframes tx-env-out { to { opacity: 0; transform: scale(1.12); } }

/* ---------- reduced motion: everything resolves to its end state ---------- */

.tx-still *, .tx-still *::before, .tx-still *::after { animation: none !important; transition: none !important; }
.tx-still:not(.tx-amb-fall) .tx-p-confetti { display: none; }
.tx-still .tx-glint, .tx-stage.tx-amb-none .tx-glint { opacity: .8; }
@media (prefers-reduced-motion: reduce) {
  .tx-stage *, .tx-stage *::before, .tx-stage *::after { animation: none !important; transition: none !important; }
  .tx-stage:not(.tx-amb-fall) .tx-p-confetti { display: none; }
}
