/*
 * Chamak — Disco Birthday (Boyfriend Day family, Birthday Series 4 of 4).
 *
 * Palette: stage black #111111, neon gold #F4EA00, metallic gold #D4AF37,
 * neon pink #FF4FA3. Fraunces italic 900 display, Bricolage Grotesque 700
 * body.
 *
 * MOTION BUDGET (Director's hard rule): exactly TWO continuous animated
 * layers — the ball spin and the light-dot drift. Everything else is
 * triggered (letter stagger, box pop, confetti fall, marquee is transform
 * only). prefers-reduced-motion stills the two loops.
 */
:root {
  --stage: #111111;
  --neon-gold: #F4EA00;
  --gold: #D4AF37;
  --pink: #FF4FA3;
  --paper: #FFFDF8;
  --ease-chip: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body { height: 100%; }

body {
  background: var(--stage);
  color: var(--paper);
  font-family: 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.cm { position: relative; min-height: 100vh; min-height: 100svh; }

.cm-stage {
  min-height: 100vh;
  min-height: 100svh;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}

.cm-stage.is-active { display: flex; }

/* ---------- ① the ball stage ---------- */
.cm-ball {
  position: absolute;
  top: -14vw;
  left: 50%;
  width: clamp(150px, 38vw, 300px);
  height: auto;
  transform: translateX(-50%);
  filter: drop-shadow(0 18px 40px rgba(244, 234, 0, 0.14));
  /* animated layer 1 of 2: the spin (a gentle sway — the facets carry the mirror feel) */
  animation: cm-spin 9s ease-in-out infinite;
  transform-origin: 50% -10%;
}

@keyframes cm-spin {
  0%, 100% { transform: translateX(-50%) rotate(-2.2deg); }
  50% { transform: translateX(-50%) rotate(2.2deg); }
}

/* animated layer 2 of 2: the drifting light dots (created by chamak.js) */
.cm-dots { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.cm-dots i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 251, 214, 0.95), rgba(244, 234, 0, 0));
  animation: cm-drift linear infinite;
}

@keyframes cm-drift {
  from { transform: translate(0, -4vh) scale(0.8); opacity: 0; }
  12% { opacity: 0.85; }
  85% { opacity: 0.5; }
  to { transform: translate(var(--dx, 20px), 104vh) scale(1.15); opacity: 0; }
}

.cm-name-wrap { position: relative; z-index: 2; margin-top: 24vw; }

.cm-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--pink);
  margin-bottom: 14px;
}

.cm-name {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(44px, 13vw, 96px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  filter: drop-shadow(0 2px 18px rgba(244, 234, 0, 0.28));
}

/* The foil gradient must live on the LETTER spans, not the parent —
   background-clip:text does not cascade through child spans (each span
   clipped its own nonexistent background and the name painted invisible).
   Each span carries the full gradient; at 96px a per-letter restart is
   invisible in practice (Director's Option A). */
.cm-ch, .cm-name {
  background: linear-gradient(168deg, #FFF3A0 0%, var(--neon-gold) 38%, var(--gold) 62%, #B8860B 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.cm-ch { display: inline-block; opacity: 0; transform: translateY(0.55em) rotate(4deg); }

.cm-name.is-in .cm-ch { animation: cm-letter 0.55s var(--ease-spring) calc(var(--i) * 0.06s) forwards; }

@keyframes cm-letter {
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

.cm-sp { display: inline-block; width: 0.34em; }

/* the neon marquee strip */
.cm-marquee {
  position: absolute;
  bottom: 12%;
  left: 0;
  right: 0;
  overflow: hidden;
  padding: 10px 0;
  background: rgba(255, 79, 163, 0.12);
  border-top: 1px solid rgba(255, 79, 163, 0.55);
  border-bottom: 1px solid rgba(255, 79, 163, 0.55);
  transform: none;
}

.cm-marquee__track {
  display: inline-flex;
  white-space: nowrap;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.4em;
  color: var(--pink);
  text-shadow: 0 0 12px rgba(255, 79, 163, 0.65);
  animation: cm-marquee 14s linear infinite;
}

@keyframes cm-marquee {
  to { transform: translateX(-50%); }
}

/* ---------- ② the gift box ---------- */
.cm-box-btn {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 10px;
}

.cm-box__img {
  width: clamp(210px, 58vw, 330px);
  height: auto;
  filter: drop-shadow(0 18px 40px rgba(212, 175, 55, 0.22));
  transition: transform 0.25s var(--ease-spring);
}

.cm-box-btn:active .cm-box__img { transform: scale(0.95); }

.cm-box__img.is-rattling { animation: cm-rattle 0.6s ease; }

@keyframes cm-rattle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-3deg) translateX(-4px); }
  40% { transform: rotate(3deg) translateX(4px); }
  60% { transform: rotate(-2deg); }
  80% { transform: rotate(2deg); }
}

.cm-boxline {
  margin-top: 26px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--neon-gold);
  text-shadow: 0 0 14px rgba(244, 234, 0, 0.6);
}

/* foil confetti: rectangles, not dots (Director's ruling) */
.cm-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.cm-confetti.is-done { display: none; }

.cm-confetti i {
  position: absolute;
  top: -4vh;
  width: 10px;
  height: 16px;
  background: linear-gradient(180deg, var(--neon-gold), var(--gold));
  opacity: 0.95;
  animation: cm-fall linear forwards;
}

@keyframes cm-fall {
  to { transform: translateY(112vh) rotate(760deg); }
}

/* ---------- ③ the gold-frame gallery ---------- */
.cm-gallery {
  display: flex;
  gap: 22px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 620px;
  padding: 18px 10px 22px;
  scrollbar-width: none;
}
.cm-gallery::-webkit-scrollbar { display: none; }

.cm-frame {
  flex: 0 0 min(72vw, 280px);
  scroll-snap-align: center;
  position: relative;
  transform: rotate(var(--tilt));
  padding: 26px 26px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* the photo + frame art live in this sub-wrapper so the caption below
   never overlaps the gold (P2) */
.cm-frame__art { position: relative; width: 100%; }

.cm-frame__img {
  display: block;
  width: calc(100% - 48px);
  margin: 24px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.cm-frame__gold {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 16px 34px rgba(212, 175, 55, 0.3));
}

.cm-frame__stamp {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 26%;
  height: auto;
  transform: rotate(12deg);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
}

/* P2: captions live BELOW the frame art on the black stage — gold-on-gold
   on the frame's bottom rail was unreadable (Director's ruling). Neon pink,
   clear of the gold. */
.cm-frame__cap {
  position: static;
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pink);
  text-shadow: 0 0 10px rgba(255, 79, 163, 0.4);
}

.cm-gallery__cue {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--pink);
}

/* ---------- ④ the wish card ---------- */
.cm-vip {
  width: clamp(110px, 26vw, 160px);
  height: auto;
  margin-bottom: 26px;
  filter: drop-shadow(0 14px 30px rgba(244, 234, 0, 0.3));
}

.cm-wish { max-width: 520px; }

.cm-wish__text {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(24px, 6.6vw, 38px);
  line-height: 1.25;
  color: var(--paper);
  margin-bottom: 20px;
}

.cm-wish__sign {
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--pink);
  margin-bottom: 44px;
}

.cm-foot {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 253, 248, 0.45);
  margin-bottom: 24px;
}
.cm-foot a { color: inherit; text-underline-offset: 3px; }

.cm-replay {
  appearance: none;
  border: 1px solid var(--gold);
  background: transparent;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--neon-gold);
  padding: 15px 34px;
  transition: background 0.25s, color 0.25s;
}

.cm-replay:hover { background: var(--gold); color: var(--stage); }

/* ---------- reduced motion: stills the two loops ---------- */
@media (prefers-reduced-motion: reduce) {
  .cm-ball { animation: none; transform: translateX(-50%); }
  .cm-dots { display: none; }
  .cm-marquee__track { animation: none; }
  .cm-name.is-in .cm-ch { animation: none; opacity: 1; transform: none; }
  .cm-box__img.is-rattling { animation: none; }
  .cm-confetti { display: none; }
}
