/* The type, the text layer over the canvas, buttons, the dev menu.
   Palette: a bright toy diorama (see BUILD.md, session log 3 Dec). */
:root {
  --night: #0d0a14;
  --glow: #ffeadb;          /* words in the dark, the colour of candlelit paper */
  --ink: #2a1f3d;
  --wall: #c9c2f4;
  --coral: #ff6b5b;
  --sunny: #ffcc4d;
  --teal: #2ec4b6;
  --lilac: #9b7bff;
  --sky: #4cb8ff;
  --pink: #ff8fb8;

  --display: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --text: 'Nunito', ui-rounded, system-ui, sans-serif;
  --pad: 22px;
  --top: max(env(safe-area-inset-top), 14px);
  --bottom: max(env(safe-area-inset-bottom), 14px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; background: var(--night); }
body {
  font-family: var(--text);
  color: var(--glow);
  background: var(--night);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: background-color .8s ease, color .8s ease;
}
body.is-day { background: var(--wall); color: var(--ink); }
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
[hidden] { display: none !important; }
.layer { position: fixed; inset: 0; }

/* ── The canvas and the words over it ── */
#gl {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; outline: none; -webkit-tap-highlight-color: transparent;
  opacity: 0; transition: opacity .6s ease;
}
.is-ready #gl { opacity: 1; }
#text { z-index: 10; pointer-events: none; }

.say {
  position: absolute; left: var(--pad); right: var(--pad); margin: 0; text-align: center;
  opacity: 0; transform: translateY(8px);
  transition: opacity .55s ease, transform .7s cubic-bezier(.22, 1, .36, 1);
}
.say.in { opacity: 1; transform: none; }
.say-line {
  bottom: calc(var(--bottom) + 15vh);
  font: 500 clamp(24px, 7vw, 34px)/1.15 var(--display);
  letter-spacing: .005em;
  text-shadow: 0 0 22px rgba(255, 140, 70, .35);
}
.say-hint {
  bottom: calc(var(--bottom) + 15vh - 34px);
  font: 700 14px/1.3 var(--text); letter-spacing: .03em;
  color: inherit;
}
.say-hint.in { opacity: .6; animation: breathe 2.6s ease-in-out infinite; }
.is-day .say-line { text-shadow: 0 2px 0 rgba(255, 255, 255, .55), 0 0 14px rgba(255, 255, 255, .7); }
/* In the bright room a hint is a white pill, so it reads over the pink rug and the mint cloth */
.is-day .say-hint {
  bottom: calc(var(--bottom) + 18px); left: 0; right: 0; width: max-content; max-width: calc(100% - 2 * var(--pad));
  margin-inline: auto; padding: 9px 16px; border-radius: 999px;
  color: var(--ink); background: rgba(255, 255, 255, .95);
  box-shadow: 0 4px 14px rgba(42, 31, 61, .14);
}
.is-day .say-hint.in { opacity: 1; animation: nudge 2.6s ease-in-out infinite; }
.has-pill .say-hint { bottom: calc(var(--bottom) + 82px) !important; }
@keyframes breathe { 50% { opacity: .32; } }
@keyframes nudge { 50% { opacity: .78; } }

/* ── The swipe hint: a fingertip sweeping across the candles ── */
.swipe-hint { position: absolute; height: 48px; transition: opacity .4s; }
.swipe-hint.gone { opacity: 0; }
.swipe-hint i {
  position: absolute; left: 0; top: 0; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 234, 219, .2); border: 2px solid rgba(255, 234, 219, .75);
  box-shadow: 0 0 18px rgba(255, 170, 110, .35);
  animation: sweep 2.4s cubic-bezier(.45, 0, .2, 1) infinite;
}
.swipe-hint i::after {         /* the streak behind it */
  content: ""; position: absolute; right: 50%; top: 50%; height: 2px; width: 90px; margin-top: -1px;
  background: linear-gradient(90deg, rgba(255, 234, 219, 0), rgba(255, 234, 219, .6));
  border-radius: 2px; opacity: 0; animation: streak 2.4s cubic-bezier(.45, 0, .2, 1) infinite;
}
@keyframes sweep {
  0% { transform: translateX(0) scale(.8); opacity: 0; }
  10%, 18% { transform: translateX(0) scale(1); opacity: 1; }
  68% { transform: translateX(var(--w, 220px)) scale(1); opacity: 1; }
  82%, 100% { transform: translateX(var(--w, 220px)) scale(.8); opacity: 0; }
}
@keyframes streak { 0%, 22% { opacity: 0; } 40%, 62% { opacity: 1; } 78%, 100% { opacity: 0; } }
.swipe-hint.calm i { animation: breathe 2.4s ease-in-out infinite; }
.swipe-hint.calm i::after { display: none; }

/* ── The headline: "Happy birthday," and her name, each letter its own colour ── */
.headline {
  position: absolute; left: 0; right: 0; top: calc(var(--top) + 5vh);
  text-align: center; font-family: var(--display); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.headline .l1 { font-weight: 600; font-size: clamp(24px, 7vw, 36px); letter-spacing: .01em; }
.headline .l2 { font-weight: 700; font-size: clamp(54px, 17vw, 96px); line-height: 1; letter-spacing: .01em; }
.headline .ch { display: inline-block; animation: drop .8s cubic-bezier(.3, 1.6, .5, 1) both, bob 3.2s ease-in-out infinite; animation-delay: calc(var(--i) * 42ms + 150ms), calc(var(--i) * 120ms + 1.5s); }
.headline .l2 .ch {
  --sticker: 0 0 0 #fff, 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 2px 2px #fff, -2px -2px #fff, 2px -2px #fff, -2px 2px #fff, 0 7px 0 rgba(42, 31, 61, .16);
  text-shadow: var(--sticker);
}
.headline .l2 .ch:nth-child(5n + 1) { color: #f04c40; }
.headline .l2 .ch:nth-child(5n + 2) { color: #e8a000; }
.headline .l2 .ch:nth-child(5n + 3) { color: #12a596; }
.headline .l2 .ch:nth-child(5n + 4) { color: #7650f0; }
.headline .l2 .ch:nth-child(5n + 5) { color: #2490de; }
.headline-sub { margin: 10px 0 0; font: 600 17px/1.3 var(--text); opacity: .8; }
@keyframes drop {
  0% { transform: translateY(-60px) scale(.3) rotate(-14deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.headline.calm .ch { animation: fade .6s ease both; animation-delay: 0s; }
@keyframes fade { from { opacity: 0; } }

.headline { transition: opacity .6s ease, transform .7s cubic-bezier(.22, 1, .36, 1); }
.headline.away { opacity: 0; transform: translateY(-24px); }

/* ── Buttons on the text layer (the layer itself lets taps through to the canvas) ── */
.pill {
  pointer-events: auto; min-height: 50px; padding: 0 26px; border-radius: 999px;
  font: 600 18px/1 var(--display); letter-spacing: .01em; color: #fff; background: #f04c40;
  box-shadow: 0 6px 0 #c93a30, 0 10px 24px rgba(42, 31, 61, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.pill:active { transform: translateY(4px); box-shadow: 0 2px 0 #c93a30, 0 6px 14px rgba(42, 31, 61, .2); }
.pill.soft { color: var(--ink); background: #fffaf2; box-shadow: 0 5px 0 rgba(42, 31, 61, .14), 0 10px 24px rgba(42, 31, 61, .16); }
.pill.soft:active { box-shadow: 0 1px 0 rgba(42, 31, 61, .14), 0 6px 14px rgba(42, 31, 61, .14); }
.pill-bar {
  position: absolute; left: 0; right: 0; bottom: calc(var(--bottom) + 18px);
  display: flex; justify-content: center; pointer-events: none;
  opacity: 0; transform: translateY(14px); transition: opacity .45s ease, transform .6s cubic-bezier(.22, 1, .36, 1);
}
.pill-bar.in { opacity: 1; transform: none; }

/* ── The tag on the last present ── */
.gift-tag {
  position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform;
  transition: opacity .4s ease;
}
.gift-tag.gone { opacity: 0; }
.gift-tag span {
  position: absolute; left: 0; bottom: 0; display: block; white-space: nowrap;
  padding: 7px 13px 7px 22px; border-radius: 6px 10px 10px 6px;
  font: 600 15px/1.1 var(--display); color: var(--ink); background: #fffaf2;
  box-shadow: 0 3px 0 rgba(42, 31, 61, .12), 0 6px 16px rgba(42, 31, 61, .18);
  transform-origin: 0 100%; transform: rotate(-9deg); animation: swing 3s ease-in-out infinite;
}
.gift-tag span::before {     /* the hole */
  content: ""; position: absolute; left: 8px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: #9b7bff; opacity: .55;
}
.gift-tag.ready span { background: #ffcc4d; animation: hop .9s cubic-bezier(.3, 1.6, .5, 1) 1, swing 3s ease-in-out .9s infinite; }
.gift-tag.nudge span { animation: shake .45s ease 1, swing 3s ease-in-out .45s infinite; }
@keyframes swing { 50% { transform: rotate(-4deg); } }
@keyframes hop { 0% { transform: rotate(-9deg) translateY(0) scale(.6); } 60% { transform: rotate(-6deg) translateY(-8px) scale(1.08); } 100% { transform: rotate(-9deg); } }
@keyframes shake { 20% { transform: rotate(-2deg) translateX(4px); } 40% { transform: rotate(-14deg) translateX(-4px); } 60% { transform: rotate(-5deg) translateX(3px); } 80% { transform: rotate(-11deg); } }

/* ── A caption under the front photo ── */
.caption {
  position: absolute; left: var(--pad); right: var(--pad); margin: 0; text-align: center;
  font: 500 19px/1.3 var(--display); color: #fff; text-shadow: 0 1px 10px rgba(20, 10, 40, .5);
  opacity: 0; transition: opacity .35s ease;
}
.caption.in { opacity: 1; }

/* ── The ticket (its box and font-size are set to sit exactly on the 3D one) ── */
.ticket {
  position: absolute; display: flex; flex-direction: column; overflow: hidden;
  color: var(--ink); background: #fff8ef; border-radius: .96em;
  box-shadow: 0 .9em 2.4em rgba(20, 10, 40, .28);
  pointer-events: auto; user-select: text; -webkit-user-select: text; cursor: auto;
  -webkit-mask: radial-gradient(circle at 0 74%, transparent .88em, #000 calc(.88em + .5px)) left / 51% 100% no-repeat,
                radial-gradient(circle at 100% 74%, transparent .88em, #000 calc(.88em + .5px)) right / 51% 100% no-repeat;
  mask: radial-gradient(circle at 0 74%, transparent .88em, #000 calc(.88em + .5px)) left / 51% 100% no-repeat,
        radial-gradient(circle at 100% 74%, transparent .88em, #000 calc(.88em + .5px)) right / 51% 100% no-repeat;
  opacity: 0; transition: opacity .3s ease;
}
.ticket.in { opacity: 1; }
.ticket > * > * { opacity: 0; transform: translateY(.4em); transition: opacity .5s ease, transform .6s cubic-bezier(.22, 1, .36, 1); }
.ticket.in > * > * { opacity: 1; transform: none; }
.ticket.in > * > :nth-child(2) { transition-delay: .08s; } .ticket.in > * > :nth-child(3) { transition-delay: .16s; }
.ticket.in > * > :nth-child(4) { transition-delay: .24s; } .ticket.in > * > :nth-child(5) { transition-delay: .32s; }
.ticket.in > * > :nth-child(6) { transition-delay: .4s; } .ticket.in > * > :nth-child(7) { transition-delay: .48s; }
.ticket.in > * > :nth-child(8) { transition-delay: .56s; } .ticket.in > .tk-stub > * { transition-delay: .7s; }
.tk-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.3em 1.1em .9em; text-align: center; border-top: .9em solid #2ec4b6;
}
.tk-flower { width: 2.7em; height: 2.7em; margin-bottom: .45em; }
.tk-flower path { fill: #2ec4b6; }
.ticket p, .ticket h2 { margin: 0; text-wrap: balance; }
.tk-kicker { font: 800 .62em/1.2 var(--text); letter-spacing: .16em; text-transform: uppercase; color: #12a596; }
.tk-title { font: 600 2.05em/1.05 var(--display); margin: .12em 0 .32em !important; letter-spacing: .005em; }
.tk-what { font: 700 .98em/1.3 var(--text); }
.tk-extra { font: 600 .86em/1.3 var(--text); opacity: .75; }
.tk-rule { display: block; width: 2.6em; height: .22em; margin: .75em 0 .7em; border-radius: 1em; background: #ff8fb8; }
.tk-where { font: 700 .9em/1.3 var(--text); }
.tk-when { font: 600 1.18em/1.2 var(--display); color: #f04c40; margin-top: .25em !important; }
.tk-stub {
  height: 26%; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3em;
  padding: 0 1.2em; text-align: center; background: #fff1df;
  background-image: radial-gradient(circle, rgba(42, 31, 61, .28) .1em, transparent .12em);
  background-size: .72em 1em; background-repeat: repeat-x; background-position: .6em -.5em;
}
.tk-for { font: 600 1.32em/1.1 var(--display); }
.tk-small { font: 600 .64em/1.35 var(--text); opacity: .72; }

/* ── The note: real text, at her own pace ── */
.note-wrap {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--top) + 10px) 14px calc(var(--bottom) + 10px); pointer-events: none;
}
.note {
  position: relative; pointer-events: auto; width: min(100%, 31rem); max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  color: var(--ink); background: #fffaf2; border-radius: 20px;
  box-shadow: 0 2px 0 rgba(42, 31, 61, .06), 0 24px 60px rgba(20, 10, 40, .35);
  user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; cursor: auto;
  opacity: 0; transition: opacity .4s ease;
}
.note.in { opacity: 1; }
.note.grow { transition: transform .7s cubic-bezier(.22, 1, .36, 1), border-radius .7s ease, opacity .25s ease; }
.note.leave { transition: transform .45s cubic-bezier(.5, 0, .75, 0), opacity .4s ease; opacity: 0; transform: translateY(30px) scale(.96); }
.note-scroll {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  padding: 34px 28px 28px;
}
.note-paper { max-width: 27rem; margin: 0 auto; }
.note-paper > * { opacity: 0; transform: translateY(10px); transition: opacity .7s ease, transform .9s cubic-bezier(.22, 1, .36, 1); }
.note.in .note-paper > * { opacity: 1; transform: none; }
.note.in .note-paper > :nth-child(2) { transition-delay: .45s; } .note.in .note-paper > :nth-child(3) { transition-delay: .9s; }
.note.in .note-paper > :nth-child(4) { transition-delay: 1.3s; } .note.in .note-paper > :nth-child(5) { transition-delay: 1.6s; }
.note.in .note-paper > :nth-child(6) { transition-delay: 1.85s; } .note.in .note-paper > :nth-child(n+7) { transition-delay: 2.1s; }
.note-greeting { margin: 0 0 .7em; font: 600 30px/1.15 var(--display); color: #7650f0; }
.note-p { margin: 0 0 1em; font: 500 19px/1.62 var(--text); }
.note-signoff { margin: 1.5em 0 .1em; font: 500 21px/1.3 var(--display); }
.note-from { margin: 0; font: 600 25px/1.2 var(--display); color: #f04c40; }
.note-end { display: flex; justify-content: center; padding: 30px 0 4px; }
.note-draft {
  position: absolute; top: 12px; right: 14px; padding: 3px 8px; border-radius: 6px;
  font: 800 11px/1 var(--text); letter-spacing: .12em; text-transform: uppercase; color: #fff; background: #f04c40;
}
@media (max-width: 360px) { .note-p { font-size: 18px; } .note-scroll { padding: 28px 22px 24px; } }

/* ── The sound button ── */
#soundBtn {
  position: fixed; z-index: 50; top: var(--top); right: 12px;
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  color: currentColor; background: rgba(255, 255, 255, .08);
  transition: background .6s;
}
.is-day #soundBtn { background: rgba(255, 255, 255, .45); }
#soundBtn svg { width: 22px; height: 22px; opacity: .8; }
#soundBtn .off, #soundBtn.muted .on { display: none; }
#soundBtn.muted .off { display: block; }

/* ── ?dev ── */
#dev { position: fixed; z-index: 100; left: 8px; top: var(--top); font: 600 12px/1.3 ui-monospace, Menlo, monospace; color: #fff; }
#dev > button { padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .55); color: #fff; font: inherit; }
#dev output { display: inline-block; margin-left: 6px; padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, .55); }
#dev nav { margin-top: 6px; padding: 6px; border-radius: 10px; background: rgba(0, 0, 0, .78); display: flex; flex-direction: column; min-width: 190px; }
#dev nav a, #dev nav button { display: block; padding: 8px 10px; color: #fff; text-decoration: none; text-align: left; border-radius: 6px; font: inherit; }
#dev nav a.here { background: rgba(255, 255, 255, .18); }
#dev nav hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .2); margin: 4px 0; width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .say { transition: opacity .4s ease; transform: none; }
  .say-hint.in { animation: none; }
  .gift-tag span, .gift-tag.ready span { animation: none; }
  .note-paper > *, .ticket > * > * { transform: none !important; transition-delay: 0s !important; }
}
