:root {
  --gold: #ffd27a;
  --red: #b3171d;
  --green: #1f5a36;
  --cream: #fff8ec;
  --ink: #2b2420;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1a33;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Blurred copy of the picture filling the space around it on wide screens */
.backdrop {
  position: fixed;
  inset: -60px;
  background: url("/assets/calendar.webp") center / cover no-repeat;
  filter: blur(28px) brightness(0.5) saturate(1.2);
}

/* Waiting screen */
.loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, #18345f 0%, #0b1a33 65%);
  transition: opacity 0.8s ease, visibility 0.8s;
}
.loader.out { opacity: 0; visibility: hidden; }
.loader .gift {
  width: 88px;
  height: 88px;
  fill: none;
  stroke: var(--gold);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px rgba(255, 210, 122, 0.55));
  animation: gift-spin 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.loader .gift > * {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: gift-draw 0.9s ease forwards;
}
.loader .gift > :nth-child(2) { animation-delay: 0.1s; }
.loader .gift > :nth-child(3) { animation-delay: 0.2s; }
.loader .gift > :nth-child(n+4) { animation-delay: 0.3s; }
@keyframes gift-spin {
  from { transform: perspective(400px) rotateY(0deg); }
  to { transform: perspective(400px) rotateY(360deg); }
}
@keyframes gift-draw { to { stroke-dashoffset: 0; } }

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.stage.ready { opacity: 1; }

.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 100% 100%;
  will-change: transform;
}
.world.animate {
  transition: transform var(--zoom-ms, 2000ms) var(--zoom-ease, cubic-bezier(0.65, 0, 0.3, 1));
}

/* Sharp close-up laid over the main picture; soft edges hide the seam */
.sharp {
  position: absolute;
  background-size: 100% 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
  -webkit-mask: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent),
                linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-composite: source-in;
          mask: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent),
                linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
          mask-composite: intersect;
}
.sharp.on { opacity: 1; }

/* ---------- The door ---------- */
.door {
  position: absolute;
  perspective: 500px;
}
.door .inside {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 65%, #fff1c2 0%, #f5b346 30%, #7a3a0c 70%, #220f04 100%);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}
.door .inside::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 60%, #fffef5 0%, rgba(255, 236, 170, 0.9) 35%, rgba(255, 210, 120, 0) 75%);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 1.2s ease 0.3s, transform 1.4s ease 0.3s;
}
.door.open .inside::after { opacity: 1; transform: scale(1.3); }

.leaf {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  transform-style: preserve-3d;
  transition: transform var(--shutter-ms, 950ms) cubic-bezier(0.45, 0, 0.2, 1);
}
.leaf.l { left: 0; transform-origin: 0 50%; }
.leaf.r { right: 0; transform-origin: 100% 50%; }
.door.open .leaf.l { transform: rotateY(-118deg); }
.door.open .leaf.r { transform: rotateY(118deg); }

.leaf .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-repeat: no-repeat;
}
.leaf .back {
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 2px rgba(255, 230, 190, 0.35), inset 0 0 14px rgba(0, 0, 0, 0.6);
}

/* Pulsing ring that points out today's door before the zoom */
.door .ring {
  position: absolute;
  inset: -5px;
  pointer-events: none;
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px 8px rgba(255, 210, 122, 0.85);
  animation: pulse 1.1s ease-in-out infinite;
  transition: opacity 0.6s;
}
.door.zoomed .ring { opacity: 0; }
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.door.shake .leaf.l { animation: rattle-l 0.5s ease-in-out 3; }
.door.shake .leaf.r { animation: rattle-r 0.5s ease-in-out 3; }
@keyframes rattle-l { 0%, 100% { transform: rotateY(0); } 30% { transform: rotateY(-9deg); } 60% { transform: rotateY(-3deg); } }
@keyframes rattle-r { 0%, 100% { transform: rotateY(0); } 30% { transform: rotateY(9deg); } 60% { transform: rotateY(3deg); } }

/* ---------- Light + particles ---------- */
.bloom {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at var(--bx, 50%) var(--by, 50%),
    rgba(255, 248, 220, 0.95) 0%, rgba(255, 214, 130, 0.55) 18%, rgba(255, 190, 90, 0.15) 45%, rgba(0, 0, 0, 0) 70%);
  transition: opacity 1.2s ease;
}
.bloom.on { opacity: 1; }
.bloom.soft { opacity: 0.55; transition-duration: 2s; }

/* snow and sparkles fall in front of everything: the waiting screen, the calendar and the gift cards */
.fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 11;
  pointer-events: none;
}

/* ---------- Reveal card ---------- */
.reveal {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 16px calc(16px + env(safe-area-inset-bottom));
  pointer-events: none;
  background: rgba(6, 12, 30, 0);
  transition: background 1s ease;
}
.reveal.show {
  pointer-events: auto;
  background: rgba(6, 12, 30, 0.5);
}
/* inside the window: no overlay, the zoomed-in light is the background */
.reveal.show.inside { background: transparent; }

.card {
  --w: min(420px, calc(100vw - 32px));
  --arch: calc(var(--w) / 2);
  position: relative;
  width: var(--w);
  margin-top: 34px;
  border-radius: var(--arch) var(--arch) 22px 22px;
  padding: 12px;
  background: linear-gradient(#fbf3e4, #e9dcc4);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08), 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 90px rgba(255, 210, 122, 0.4);
  opacity: 0;
  transform: translateY(28px) scale(0.9);
  transition: opacity 0.9s ease, transform 1.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.show .card { opacity: 1; transform: none; }

/* snow resting on top of the window */
.card::before {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: -12px;
  height: 36px;
  border-radius: 50% 50% 40% 40% / 100% 100% 30% 30%;
  background: radial-gradient(circle at 30% 70%, #fff 40%, #eef3ff 70%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

.card .pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: min(62dvh, 600px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  border-radius: calc(var(--arch) - 12px) calc(var(--arch) - 12px) 14px 14px;
  padding: calc(var(--w) * 0.24) 24px 28px;
  text-align: center;
  color: #fff3dc;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 210, 122, 0.25), rgba(255, 210, 122, 0) 60%),
    linear-gradient(var(--pane, #5c1414), #2a0808);
  box-shadow: inset 0 0 0 2px rgba(255, 210, 122, 0.35), inset 0 0 30px rgba(0, 0, 0, 0.6);
}

/* fairy lights along the arch */
.card .lights {
  position: absolute;
  inset: 7px;
  border-radius: calc(var(--arch) - 7px) calc(var(--arch) - 7px) 14px 14px;
  border: 4px dotted #ffd98a;
  filter: drop-shadow(0 0 4px #ffcf6b) drop-shadow(0 0 8px rgba(255, 190, 80, 0.8));
  pointer-events: none;
  z-index: 1;
}
@keyframes twinkle { from { opacity: 0.65; } to { opacity: 1; } }

.card .num {
  position: absolute;
  left: 50%;
  top: -34px;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #3b2a26;
  color: #fff;
  font: 700 1.5rem/1 "Cinzel", Georgia, serif;
  box-shadow: 0 0 0 3px #fbf3e4, 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 3;
}
.card .bow {
  position: absolute;
  left: 50%;
  top: 22px;
  width: 70px;
  transform: translateX(-50%);
  z-index: 3;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35));
}

.card .badge {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.card h1 {
  margin: 0 0 14px;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.45rem, 6.4vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 210, 122, 0.6);
}
.card .msg {
  margin: 0;
  white-space: pre-line;
  font-size: 1.1rem;
  line-height: 1.5;
}
.card img {
  display: block;
  width: 100%;
  margin: 0 0 16px;
  border-radius: 12px;
  box-shadow: 0 0 0 3px rgba(255, 210, 122, 0.5);
}
.card .video {
  position: relative;
  margin: 16px 0 0;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.card .video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.card .btn {
  display: inline-block;
  margin-top: 18px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--gold);
  color: #3b1a06;
  font-weight: 700;
  text-decoration: none;
}
/* centre the content vertically, but never clip it when it's long */
.card .pane > :first-child { margin-top: auto; }
.card .pane > :last-child { margin-bottom: auto; }
/* the day's illustration, above the title */
.card img.icon, .ticket img.icon {
  display: block;
  width: clamp(96px, 30vw, 128px);
  height: auto;
  margin: 2px auto 8px;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}
.card .emoji { font-size: 2.6rem; line-height: 1; margin: 6px 0 10px; }
.card .lock { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }

.replay {
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(45, 22, 5, 0.45);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.6s ease 0.8s;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.reveal.show .replay { opacity: 1; }

/* coupon terms, below a perforated "tear here" line */
.perf {
  position: relative;
  margin: 20px -24px 14px;
  border-top: 2px dashed rgba(255, 210, 122, 0.45);
}
.perf::before, .perf::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #efe4cf;
}
.perf::before { left: -9px; }
.perf::after { right: -9px; }
.terms {
  font-size: 0.82rem;
  line-height: 1.45;
  font-style: italic;
  opacity: 0.85;
}
.terms b {
  display: block;
  margin-bottom: 4px;
  font-style: normal;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.card .msg strong { color: var(--gold); }

/* The card builds up in order: frame + snow, bow, number, lights, then the text lines */
.card .bow { opacity: 0; translate: 0 -10px; transition: opacity 0.45s ease 0.3s, translate 0.45s ease 0.3s; }
.card .num { opacity: 0; scale: 0.6; transition: opacity 0.4s ease 0.5s, scale 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) 0.5s; }
.card .lights { opacity: 0; animation: none; }
.reveal.show .card .bow { opacity: 1; translate: 0 0; }
.reveal.show .card .num { opacity: 1; scale: 1; }
.reveal.show .card .lights { animation: lights-on 0.6s ease 0.7s forwards, twinkle 1.6s ease-in-out 1.3s infinite alternate; }
@keyframes lights-on { from { opacity: 0; } to { opacity: 1; } }

.pane > *, .tk-inner > * {
  opacity: 0;
  translate: 0 10px;
  transition: opacity 0.5s ease, translate 0.5s ease;
}
.reveal.show .pane > *, .reveal.show .tk-inner > * {
  opacity: 1;
  translate: 0 0;
  transition-delay: calc(0.9s + var(--i, 0) * 0.2s);
}
.pane > :nth-child(2), .tk-inner > :nth-child(2) { --i: 1; }
.pane > :nth-child(3), .tk-inner > :nth-child(3) { --i: 2; }
.pane > :nth-child(4), .tk-inner > :nth-child(4) { --i: 3; }
.pane > :nth-child(5), .tk-inner > :nth-child(5) { --i: 4; }
.pane > :nth-child(n+6), .tk-inner > :nth-child(n+6) { --i: 5; }

/* ---------- December 24: the golden ticket ---------- */
.ticket {
  --notch: 16px;
  position: relative;
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 130px);
  padding: 10px;
  border-radius: 14px;
  color: #4a2e00;
  text-align: center;
  background: linear-gradient(135deg, #b8862b 0%, #f7e08a 22%, #fff6c9 38%, #d9a93c 55%, #f9e7a0 75%, #a87420 100%);
  /* semicircle notches on both sides, like a real ticket */
  -webkit-mask: radial-gradient(circle var(--notch) at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle var(--notch) at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle var(--notch) at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle var(--notch) at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
}
.ticket-wrap {
  filter: drop-shadow(0 0 1.5px rgba(80, 40, 0, 0.9)) drop-shadow(0 16px 30px rgba(80, 25, 0, 0.45));
  opacity: 0;
  transform: translateY(28px) scale(0.9);
  transition: opacity 0.9s ease, transform 1.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.show .ticket-wrap { opacity: 1; transform: none; }
.tk-inner {
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  padding: 22px 26px 20px;
  border: 2px solid rgba(90, 55, 0, 0.55);
  border-radius: 8px;
  outline: 1px dashed rgba(90, 55, 0, 0.4);
  outline-offset: -7px;
}
.tk-head {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}
.ticket .emoji { font-size: 3rem; line-height: 1; margin: 10px 0 8px; }
.ticket h1 {
  margin: 0 0 14px;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 6.8vw, 2rem);
  line-height: 1.15;
  color: #3d2400;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.ticket .msg { margin: 0; white-space: pre-line; font-size: 1.05rem; line-height: 1.5; }
.ticket .msg strong { color: #7a1010; }
.ticket .perf { margin: 18px -26px 12px; border-top-color: rgba(90, 55, 0, 0.45); }
.ticket .perf::before, .ticket .perf::after { display: none; }
.ticket .terms b { color: #7a1010; }
.ticket .shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%);
  background-size: 250% 100%;
  background-position: 150% 0;
  mix-blend-mode: soft-light;
  animation: shine 3.2s ease-in-out 1.2s infinite;
}
@keyframes shine {
  0% { background-position: 150% 0; }
  45%, 100% { background-position: -100% 0; }
}

/* Home page hint */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 4;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(11, 26, 51, 0.75);
  color: #fff;
  text-align: center;
  font-weight: 700;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 2px rgba(255, 210, 122, 0.6);
}

/* While the animation plays, taps and pinch-zoom on the scene do nothing */
body.busy { touch-action: none; }
body.busy .stage, body.busy .reveal, body.busy .loader { pointer-events: none; }

/* ?debug overlay */
.dbg {
  position: absolute;
  outline: 2px solid #0ff;
  color: #0ff;
  font: 700 16px/1 monospace;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 2px;
  text-shadow: 0 0 3px #000;
}

/* Short phones (e.g. iPhone SE): tighten the gift cards so everything fits without scrolling */
@media (max-height: 720px) {
  .card img.icon, .ticket img.icon { width: 84px; margin: 0 auto 4px; }
  .card h1, .ticket h1 { font-size: 1.35rem; margin-bottom: 8px; }
  .card .msg, .ticket .msg { font-size: 0.98rem; line-height: 1.4; }
  .tk-inner { padding: 14px 20px 12px; }
  .ticket .emoji { margin: 4px 0; }
  .perf { margin-top: 12px; margin-bottom: 10px; }
  .ticket .perf { margin: 12px -20px 8px; }
  .terms { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .loader .gift { animation: none; }
  .loader .gift > * { animation: none; stroke-dashoffset: 0; }
  .door .ring { animation: none; opacity: 1; }
  .ticket .shine { animation: none; }
  .reveal.show .card .lights { animation: none; opacity: 1; }
}
