/* =============================================================
   Hi Nima Baby — birthday page
   Design language pulled from the inspo teardown:
   frame -> rounded blush card -> content, arch photo frames with
   an offset outline, two-tone hand-drawn headline (ink + pink),
   filled + outline pills, a circular stamp badge, three type
   voices, a faint scattered motif, one action per screen.
   Mobile-first, self-hosted fonts, no CDN, no framework.
   ============================================================= */

/* ---- self-hosted fonts (latin subset woff2) ---- */
@font-face {
  font-family: "Fredoka";
  src: url("assets/fonts/fredoka-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fredoka";
  src: url("assets/fonts/fredoka-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("assets/fonts/caveat-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("assets/fonts/nunito-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("assets/fonts/nunito-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---- tokens (sampled from inspo pixels) ---- */
:root {
  --frame: #ef1f65;      /* saturated pink outer frame */
  --btn: #ec3676;        /* filled pill */
  --btn-deep: #e01e63;   /* filled pill, deep edge */
  --accent-soft: #f097b8;/* soft pink lettering + outlines */
  --card: #ffedf3;       /* blush card surface */
  --surface: #fef2f7;    /* secondary surface */
  --hi: #fefbfc;         /* near-white highlight, arch interior */
  --ink: #1c1c1c;        /* dark headline word, body-dark */
  --berry: #931132;      /* deep berry edge/shadow */

  --display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --script: "Caveat", "Segoe Script", cursive;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --card-radius: 30px;
  --arch-radius: 46% 46% 16px 16px / 40% 40% 16px 16px;
  --pill-radius: 999px;

  --shadow-soft: 0 10px 28px rgba(147, 17, 50, 0.16);
  --shadow-pill: 0 8px 18px rgba(224, 30, 99, 0.28);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- reset-ish ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--frame);
  /* faint frame texture so the border reads as a printed edge, not flat */
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.10), transparent 42%),
    radial-gradient(circle at 82% 88%, rgba(147, 17, 50, 0.22), transparent 46%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img,
video {
  display: block;
  max-width: 100%;
}

/* =============================================================
   Frame -> card
   The body is the saturated frame. .app is the blush card that
   floats on it with a margin (the frame shows through the gap).
   ============================================================= */
.app {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  background: radial-gradient(circle at 50% -10%, var(--surface), var(--card) 72%);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.55),
    var(--shadow-soft);
  isolation: isolate;
}

/* =============================================================
   Faint scattered motif (behind everything on the card)
   ============================================================= */
.motif {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.motif-glyph {
  position: absolute;
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.14;
  will-change: transform;
  animation: drift 12s var(--ease) infinite;
  user-select: none;
}

@keyframes drift {
  0% {
    transform: translateY(8px) rotate(-6deg);
  }
  50% {
    transform: translateY(-10px) rotate(6deg);
  }
  100% {
    transform: translateY(8px) rotate(-6deg);
  }
}

/* =============================================================
   Screens
   ============================================================= */
.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.7rem, 2.4vh, 1.3rem);
  padding: clamp(1rem, 4vw, 1.8rem);
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
}

.screen[hidden] {
  display: none;
}

.screen.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* =============================================================
   Kicker (script voice)
   ============================================================= */
.kicker {
  margin: 0;
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(1.35rem, 5.4vw, 1.9rem);
  line-height: 1;
  color: var(--berry);
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.kicker-flag {
  font-size: 0.82em;
  filter: saturate(1.05);
}

/* when the flag is off, collapse the span so no leading gap shows */
.kicker-flag:empty {
  display: none;
}

/* =============================================================
   Two-tone headline (display voice)
   ============================================================= */
.greeting {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.01em;
  font-size: clamp(2.6rem, 12vw, 4.2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.greeting-ink {
  color: var(--ink);
  transform: rotate(-1.5deg);
}

.greeting-accent {
  color: var(--frame);
  transform: rotate(1deg);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
}

.doodle-bang {
  position: absolute;
  right: -0.1em;
  top: -0.35em;
  font-family: var(--display);
  font-weight: 700;
  color: var(--accent-soft);
  font-size: 0.7em;
  transform: rotate(12deg);
}

/* =============================================================
   Arch photo frame with offset outline
   ============================================================= */
.arch {
  position: relative;
  width: min(72vw, 270px);
  aspect-ratio: 3 / 4;
  flex: 0 0 auto;
}

/* offset outline behind the photo */
.arch::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translate(9px, 10px);
  border: 2.5px solid var(--accent-soft);
  border-radius: var(--arch-radius);
  z-index: 0;
}

.arch img,
.arch video {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--arch-radius);
  background: var(--hi);
  box-shadow: var(--shadow-soft);
}

/* sizing variants */
.welcome-arch {
  width: min(72vw, 264px);
  height: clamp(220px, 38vh, 332px);
  aspect-ratio: auto;
}

.finale-arch {
  width: min(66vw, 236px);
  height: clamp(198px, 34vh, 292px);
  aspect-ratio: auto;
}

.wish-arch {
  width: min(72vw, 264px);
  height: clamp(212px, 37vh, 326px);
  aspect-ratio: auto;
}

/* =============================================================
   Circular stamp badge (rotating ring text)
   ============================================================= */
.stamp {
  position: absolute;
  z-index: 2;
  right: -14px;
  bottom: -14px;
  width: clamp(78px, 22vw, 96px);
  height: clamp(78px, 22vw, 96px);
  transform: rotate(-8deg);
  pointer-events: none;
}

.stamp svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: stamp-spin 26s linear infinite;
}

.stamp .stamp-disc {
  fill: var(--hi);
  stroke: var(--frame);
  stroke-width: 1.4;
}

.stamp .stamp-ring-text {
  fill: var(--frame);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 8.4px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.stamp .stamp-heart {
  font-size: 20px;
  dominant-baseline: central;
  text-anchor: middle;
}

@keyframes stamp-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =============================================================
   Buttons (filled pill + outline pill)
   ============================================================= */
.btn {
  border: none;
  border-radius: var(--pill-radius);
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(1rem, 3.6vw, 1.12rem);
  letter-spacing: 0.02em;
  padding: 0.85em 1.7em;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(1px) scale(0.985);
}

.btn--fill {
  background: linear-gradient(180deg, var(--btn), var(--btn-deep));
  color: var(--hi);
  box-shadow: var(--shadow-pill);
}

.btn--fill:hover {
  box-shadow: 0 10px 22px rgba(224, 30, 99, 0.36);
}

.btn--outline {
  background: transparent;
  color: var(--btn-deep);
  border: 2px solid var(--btn);
}

.btn--outline:hover {
  background: rgba(236, 54, 118, 0.08);
}

/* =============================================================
   Hint (small sans)
   ============================================================= */
.hint {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  color: rgba(28, 28, 28, 0.5);
  animation: hint-pulse 2.4s var(--ease) infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

/* =============================================================
   Welcome
   ============================================================= */
.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.7rem, 2.4vh, 1.25rem);
  max-width: 420px;
  width: 100%;
}

/* =============================================================
   Celebration burst (display voice, two-tone)
   ============================================================= */
.burst {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.burst-word {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 700;
  line-height: 0.9;
  transform: scale(0.6);
  opacity: 0;
}

.burst.is-live .burst-word {
  animation: burst-pop 0.7s var(--ease) forwards;
}

.burst[hidden] {
  display: none;
}

.burst-ink {
  color: var(--ink);
  font-size: clamp(2.8rem, 13vw, 4.6rem);
  transform: rotate(-2deg);
}

.burst-accent {
  color: var(--frame);
  font-size: clamp(3.2rem, 15vw, 5.4rem);
  transform: rotate(1.5deg);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.5);
}

@keyframes burst-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* =============================================================
   Wishes
   ============================================================= */
.wish-stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.9rem, 3vh, 1.4rem);
  z-index: 2;
}

.wish-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.9rem, 3vh, 1.35rem);
  width: 100%;
  opacity: 0;
  transform: translateY(14px);
}

.wish-card.is-in {
  animation: wish-in 0.6s var(--ease) forwards;
}

.wish-card.is-out {
  animation: wish-out 0.4s var(--ease) forwards;
}

@keyframes wish-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes wish-out {
  to { opacity: 0; transform: translateY(-14px); }
}

.wish-text {
  margin: 0;
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(1.45rem, 6vw, 2rem);
  line-height: 1.18;
  color: var(--ink);
  max-width: 22ch;
  text-wrap: balance;
}

/* =============================================================
   Dot progress (warm, no numeric counter)
   ============================================================= */
.dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 2;
  min-height: 12px;
}

.dots[hidden] {
  display: none;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-soft);
  opacity: 0.4;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), background 0.3s var(--ease);
}

.dot.is-on {
  opacity: 1;
  background: var(--btn);
  transform: scale(1.35);
}

.tap-hint[hidden] {
  display: none;
}

/* =============================================================
   Finale
   ============================================================= */
.finale-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.7rem, 2.4vh, 1.2rem);
  max-width: 420px;
  width: 100%;
}

.finale-line1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1;
  color: var(--ink);
  transform: rotate(-1.5deg);
}

.finale-line2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.6rem, 6.6vw, 2.3rem);
  line-height: 1.04;
  color: var(--frame);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5);
}

.finale-flair {
  margin: 0;
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(1.2rem, 4.6vw, 1.55rem);
  color: var(--berry);
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

/* =============================================================
   Letter (self-paced, scrollable blush card)
   ============================================================= */
.letter-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.7rem, 2.2vh, 1.1rem);
  width: 100%;
  max-width: 480px;
  height: 100%;
  justify-content: center;
}

.letter-kicker {
  margin: 0;
}

.letter-body {
  width: 100%;
  max-height: min(56vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  background: var(--hi);
  border: 1.5px solid rgba(240, 151, 184, 0.55);
  border-radius: 22px;
  padding: clamp(1.05rem, 4.5vw, 1.6rem);
  box-shadow: var(--shadow-soft);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-soft) transparent;
}

.letter-body::-webkit-scrollbar {
  width: 7px;
}

.letter-body::-webkit-scrollbar-thumb {
  background: var(--accent-soft);
  border-radius: 999px;
}

.letter-para {
  margin: 0 0 0.85em;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(1rem, 3.9vw, 1.1rem);
  line-height: 1.62;
  color: var(--ink);
}

.letter-para:last-child {
  margin-bottom: 0;
}

/* first line reads like a hand-written salutation */
.letter-para:first-child {
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(1.5rem, 6.4vw, 2.05rem);
  line-height: 1.2;
  color: var(--frame);
  text-align: center;
  margin-bottom: 0.55em;
}

/* =============================================================
   Confetti canvas (above content, below controls)
   ============================================================= */
.fx {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

/* =============================================================
   Controls
   ============================================================= */
.icon-btn {
  position: fixed;
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--btn);
  background: var(--hi);
  color: var(--btn-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s var(--ease);
}

.icon-btn[hidden] {
  display: none;
}

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

.mute-btn {
  top: calc(env(safe-area-inset-top, 0px) + 20px);
  right: calc(env(safe-area-inset-right, 0px) + 20px);
}

.mute-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.mute-btn.is-muted .mute-icon::after {
  content: "";
  position: absolute;
  width: 30px;
  height: 2.5px;
  background: var(--btn-deep);
  transform: rotate(-45deg);
  border-radius: 2px;
}

.mute-btn.is-muted .mute-icon {
  position: relative;
  opacity: 0.55;
}

.sound-fallback {
  position: fixed;
  z-index: 55;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  transform: translateX(-50%);
}

.sound-fallback[hidden] {
  display: none;
}

/* =============================================================
   Preview banner (only when isPlaceholder is true)
   ============================================================= */
.placeholder-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: #1c1c1c;
  color: #fff;
  font-family: var(--sans);
  font-size: 0.8rem;
  text-align: center;
  padding: 8px 12px;
  pointer-events: none;
}

.placeholder-banner[hidden] {
  display: none;
}

/* =============================================================
   Motion / viewport accommodations
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .motif-glyph,
  .stamp svg,
  .hint {
    animation: none !important;
  }
  .screen {
    transition: opacity 0.2s linear;
    transform: none;
  }
  .wish-card.is-in,
  .wish-card.is-out,
  .burst.is-live .burst-word {
    animation-duration: 0.25s;
  }
}

/* short viewports: tighten rhythm so nothing clips inside the card */
@media (max-height: 620px) {
  .screen {
    gap: 0.6rem;
    justify-content: center;
  }
  .greeting {
    font-size: clamp(2.2rem, 10vw, 3rem);
  }
  .welcome-arch {
    height: clamp(165px, 29vh, 224px);
  }
  .wish-arch {
    height: clamp(165px, 29vh, 224px);
  }
  .finale-arch {
    height: clamp(152px, 26vh, 208px);
  }
}

/* wider screens: present it as a designed portrait greeting card,
   centered on the pink field, instead of a stretched phone */
@media (min-width: 620px) {
  body {
    background-image:
      radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.16), transparent 40%),
      radial-gradient(circle at 85% 86%, rgba(147, 17, 50, 0.30), transparent 48%),
      radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.06), transparent 55%);
  }
  .app {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 48px));
    height: min(880px, calc(100vh - 48px));
    border-radius: 34px;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.6),
      0 30px 70px rgba(147, 17, 50, 0.32);
  }
  .letter-body {
    max-height: min(52vh, 460px);
  }
  /* keep the floating controls tucked to the card, not the window corners */
  .mute-btn {
    top: max(calc(env(safe-area-inset-top, 0px) + 20px), calc(50vh - 430px));
    right: max(calc(env(safe-area-inset-right, 0px) + 20px), calc(50vw - 210px));
  }
}
