/* 0. The countdown before the password screen: a starry night and a present waiting for her. */
#countdown { justify-content: center; min-height: 100vh; min-height: 100svh; padding-block: 2rem; max-width: none; }
#countdown::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 45% at 50% 52%, rgba(238, 138, 164, .22), transparent 70%),
    radial-gradient(80% 60% at 50% 0%, #3a2452, transparent 70%),
    var(--night);
}

/* stars */
.cd-sky, .cd-hearts { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.cd-sky i {
  position: absolute; width: var(--z); height: var(--z); border-radius: 50%; background: var(--cream);
  animation: cd-twinkle var(--d) ease-in-out var(--o) infinite;
}
@keyframes cd-twinkle { 0%, 100% { opacity: .15; transform: scale(.7); } 50% { opacity: .9; transform: scale(1); } }

/* hearts drifting up */
.cd-hearts i {
  position: absolute; bottom: -2rem; font-style: normal; font-size: var(--z); color: var(--rose); opacity: 0;
  animation: cd-float var(--d) linear var(--o) infinite;
}
@keyframes cd-float {
  0% { transform: translate(0, 0) rotate(-10deg); opacity: 0; }
  10% { opacity: .55; }
  50% { transform: translate(1.2rem, -55vh) rotate(10deg); }
  90% { opacity: .35; }
  100% { transform: translate(-.8rem, -110vh) rotate(-8deg); opacity: 0; }
}

.cd-wrap { display: flex; flex-direction: column; align-items: center; gap: .9rem; width: 100%; max-width: 30rem; }

/* the stages share each spot on screen and crossfade: waiting -> final 10 -> the wish */
.cd-slot { display: grid; width: 100%; place-items: center; }
.cd-slot > * {
  grid-area: 1 / 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: .6rem;
  transition: opacity .7s ease, transform .7s ease, visibility 0s .7s;
}
.cd-slot > :not(.cd-pre) { opacity: 0; visibility: hidden; transform: translateY(.6rem); }
#countdown.is-final .cd-pre, #countdown.is-wish .cd-pre, #countdown.is-open .cd-pre { opacity: 0; visibility: hidden; transform: translateY(-.6rem); }
#countdown.is-final .cd-final, #countdown.is-wish .cd-wish, #countdown.is-open .cd-wish {
  opacity: 1; visibility: visible; transform: none; transition-delay: .2s, .2s, 0s;
}
#countdown.is-open .cd-bottom .cd-wish { opacity: 0; visibility: hidden; transition-delay: 0s, 0s, .7s; }

/* the last 10 seconds */
.cd-final b {
  display: block; font: 400 clamp(6rem, 34vw, 10rem)/1 var(--display); color: var(--flame);
  font-variant-numeric: tabular-nums; text-shadow: 0 0 2.5rem rgba(255, 181, 74, .6), 0 0 .6rem rgba(255, 181, 74, .5);
}
.cd-final b.tick { animation: cd-big .9s cubic-bezier(.2, .8, .3, 1); }
@keyframes cd-big { 0% { transform: scale(1.7); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.is-final .cd-hearts i { animation-duration: 5s; }

/* the wish */
.cd-wish .cd-title { font-size: clamp(2.2rem, 10vw, 3.4rem); }
.is-wish .cd-wish .cd-title, .is-open .cd-wish .cd-title { animation: cd-wishin 1s cubic-bezier(.2, .8, .3, 1.2) .2s backwards; }
@keyframes cd-wishin { from { transform: scale(.6); opacity: 0; } }
.cd-love {
  margin: 0; font: 700 clamp(1.7rem, 7vw, 2.2rem)/1.1 var(--hand); color: var(--rose);
  text-shadow: 0 0 1rem rgba(238, 138, 164, .5);
}
.is-wish .cd-love, .is-open .cd-love { animation: cd-wishin 1s ease 1s backwards, cd-name 3s ease-in-out 2s infinite; }
#countdown.is-wish .cd-bottom .cd-wish { transition-delay: 1.8s, 1.8s, 0s; }
#cd-open { animation: cd-call 1.6s ease-in-out infinite; }
@keyframes cd-call { 50% { transform: scale(1.06); box-shadow: 0 .6rem 2.2rem -0.4rem rgba(255, 181, 74, .95); } }
.cd-title { font: 400 clamp(1.8rem, 7.5vw, 2.7rem)/1.15 var(--display); margin: 0; text-wrap: balance; }
.cd-name {
  display: inline-block; font: 700 1.35em/1 var(--hand); color: var(--rose);
  text-shadow: 0 0 1.2rem rgba(238, 138, 164, .55);
  animation: cd-name 3s ease-in-out infinite;
}
@keyframes cd-name { 50% { transform: translateY(-.12em) rotate(-3deg); } }

/* the present (a button once it can be opened) */
.cd-giftbtn { background: none; border: 0; padding: 0; margin: 0; color: inherit; cursor: default; display: block; border-radius: 1.5rem; }
.is-wish .cd-giftbtn { cursor: pointer; }
.cd-giftbtn.thump { animation: cd-thump .5s ease; }
@keyframes cd-thump { 30% { transform: scale(1.06) rotate(-2deg); } 60% { transform: scale(.98) rotate(1.5deg); } }
.is-wish .cd-glow { opacity: .55; animation: cd-pulse 1.6s ease-in-out infinite; }
@keyframes cd-pulse { 50% { opacity: .9; transform: scale(1.25); } }
.cd-gift { width: min(15rem, 66vw); height: auto; overflow: visible; margin: .2rem 0 -.2rem; }
.cd-gift g { transform-box: fill-box; }
.cd-box, .cd-lid { transform-origin: 50% 100%; }
.cd-box { animation: cd-jiggle 4s ease-in-out infinite; }
.cd-lid { animation: cd-peek 4s ease-in-out infinite; }
.cd-glow { opacity: 0; transform-origin: 50% 50%; filter: blur(14px); }
.cd-kuro .sway { transform-box: fill-box; transform-origin: 50% 100%; animation: cd-bob 1.8s ease-in-out infinite alternate; }
@keyframes cd-jiggle {
  0%, 70%, 100% { transform: none; }
  74% { transform: rotate(-3deg); } 78% { transform: rotate(3deg); }
  82% { transform: rotate(-2deg); } 86% { transform: rotate(1deg); }
}
@keyframes cd-peek {
  0%, 70%, 100% { transform: none; }
  76% { transform: translateY(-9px) rotate(-4deg); } 82% { transform: translateY(-4px) rotate(3deg); } 88% { transform: none; }
}
@keyframes cd-bob { to { transform: translateY(-3px) rotate(2deg); } }
.cd-soon .cd-box, .cd-soon .cd-lid { animation-duration: 1.2s; }
.is-final .cd-box, .is-final .cd-lid, .is-wish .cd-box, .is-wish .cd-lid { animation-duration: .9s; }

/* at the wish Kuromi grows a little and holds up her sunflower bouquet */
.cd-kwrap { transform-box: view-box; transform-origin: 86px 10px; transition: transform .8s cubic-bezier(.3, 1.6, .5, 1) .5s; }
.is-wish .cd-kwrap, .is-open .cd-kwrap { transform: scale(1.5); }
.cd-bq { opacity: 0; transform-box: fill-box; transform-origin: 40% 100%; transform: scale(.2) rotate(-25deg); }
.is-wish .cd-bq, .is-open .cd-bq { animation: cd-bq 1s cubic-bezier(.3, 1.5, .5, 1) .9s forwards, cd-bqsway 2.6s ease-in-out 1.9s infinite alternate; }
@keyframes cd-bq { to { opacity: 1; transform: none; } }
@keyframes cd-bqsway { from { opacity: 1; transform: none; } to { opacity: 1; transform: rotate(5deg); } }

/* the numbers */
.cd-clock { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; width: 100%; }
.cd-clock div {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .85rem .2rem .7rem; border-radius: 1rem;
  background: linear-gradient(180deg, rgba(74, 54, 96, .55), rgba(43, 29, 58, .75));
  border: 1.5px solid rgba(238, 138, 164, .28);
  box-shadow: 0 .8rem 1.8rem -1rem rgba(0, 0, 0, .6), inset 0 1px 0 rgba(251, 239, 228, .08);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.cd-clock b {
  display: block; font: 400 clamp(1.7rem, 8.5vw, 2.6rem)/1 var(--display); color: var(--flame);
  font-variant-numeric: tabular-nums; text-shadow: 0 0 1rem rgba(255, 181, 74, .45);
}
.cd-clock b.tick { animation: cd-tick .35s ease; }
@keyframes cd-tick { 0% { transform: translateY(-.25em); opacity: .3; } 100% { transform: none; opacity: 1; } }
.cd-clock span { font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cd-line { margin: .2rem 0 0; font: 700 1.45rem/1.2 var(--hand); color: var(--cream); opacity: .85; }

/* she opens it: the lid flies off, light spills out and floods the screen */
.is-open .cd-lid { animation: cd-pop 1s cubic-bezier(.2, .8, .3, 1) forwards; }
.is-open .cd-box { animation: none; }
.is-open .cd-glow { animation: cd-shine 1.4s ease forwards; }
@keyframes cd-pop { to { transform: translate(30px, -140px) rotate(28deg); opacity: 0; } }
@keyframes cd-shine { 30% { opacity: .95; transform: scale(1.8); } 100% { opacity: .7; transform: scale(2.6); } }
.cd-flash {
  position: fixed; inset: -20vmax; z-index: 5; pointer-events: none; opacity: 0;
  background: radial-gradient(closest-side, #fff4dc, #ffd9a0 45%, #ffb54a 75%, rgba(255, 181, 74, 0));
}
.is-open .cd-flash { animation: cd-flood 1.3s ease-in .6s forwards; }
@keyframes cd-flood { from { opacity: 0; transform: scale(.15); } 60% { opacity: 1; } to { opacity: 1; transform: scale(1.6); } }
