.christmas-lights {
  position: relative;
  display: flex;
  justify-content: space-between;
  margin: 0 .25rem .55rem;
  padding: 3px .45rem 0;
  border-top: 1px solid #92264a;
  pointer-events: none;
}
.christmas-lights i {
  --light: #ffe099;
  width: clamp(5px, 1.5vw, 10px);
  aspect-ratio: .76;
  border-radius: 50%;
  background: var(--light);
  box-shadow: 0 0 .85rem var(--light);
  animation: christmas-twinkle 1.6s infinite alternate ease-in-out;
}
.christmas-lights i:nth-child(4n + 2) { --light: #92f2da; animation-delay: -.6s; }
.christmas-lights i:nth-child(4n + 3) { --light: #fff9f1; animation-delay: -.95s; }
.christmas-lights i:nth-child(4n) { --light: #ffc4df; animation-delay: -1.25s; }
@keyframes christmas-twinkle { from { opacity: .55; } to { opacity: 1; } }

.christmas-snow { position: absolute; z-index: 3; inset: 0; pointer-events: none; overflow: hidden; }
.christmas-snow i {
  position: absolute; top: -8px; left: var(--left); width: var(--size); aspect-ratio: 1;
  border-radius: 50%; background: #fff9f0; opacity: var(--opacity);
  animation: christmas-snowfall var(--duration) var(--delay) linear infinite;
}
.advent-board .christmas-snow { opacity: .55; }
@keyframes christmas-snowfall { to { transform: translate(var(--drift), var(--fall, 150vh)); } }

.advent-reveal {
  position: fixed; inset: 0;
  width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none;
  padding: 0; margin: 0; border: 0;
  overflow: auto; overscroll-behavior: contain;
  background: #c4146b; color: #fff;
}
.advent-reveal::backdrop { background: #c4146b; }
html:has(.advent-reveal[open]) { overflow: hidden; }
.advent-reveal-shell {
  position: relative; isolation: isolate; overflow: clip;
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center; align-items: center;
  gap: clamp(.4rem, 1.6vh, .75rem);
  min-height: 100%; height: 100%;
  padding: max(1.6rem, calc(env(safe-area-inset-top) + .8rem))
    max(.8rem, env(safe-area-inset-right))
    max(.9rem, env(safe-area-inset-bottom))
    max(.8rem, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 43%, #e24d9a, #c4146b 60%, #ae075b);
}
.advent-reveal .christmas-lights {
  position: absolute; z-index: 4;
  top: max(.45rem, env(safe-area-inset-top));
  left: max(.55rem, env(safe-area-inset-left)); right: max(.55rem, env(safe-area-inset-right));
}
.advent-reveal-scene {
  position: relative; align-self: stretch; width: min(100%, 56rem);
  display: grid; grid-template: minmax(0,1fr) / minmax(0,1fr);
  place-items: center; min-width: 0; min-height: 0; touch-action: pan-x;
}
.advent-reveal-scene > * { grid-area: 1/1; }
.advent-reveal-rays,.advent-reveal-halo {
  display: block; pointer-events: none;
}
.advent-reveal-rays {
  position: absolute; left: 50%; top: 50%; width: max(260vmax, 1000px); aspect-ratio: 1;
  background: repeating-conic-gradient(#ffcf6c38 0deg 7deg, transparent 7deg 15deg);
  animation: christmas-spin 27s linear infinite;
  mask-image: radial-gradient(circle, #000 24%, #0006 60%, transparent 72%);
}
@keyframes christmas-spin { from { transform: translate(-50%,-50%); } to { transform: translate(-50%,-50%) rotate(360deg); } }
.advent-reveal-halo {
  width: min(87vw, 61vh, 42rem); aspect-ratio: 1;
  background: radial-gradient(circle, #ffdb8cd9 0%, #ff93bdd9 30%, transparent 69%);
}
.advent-reveal-window {
  position: relative; z-index: 3; isolation: isolate; perspective: 760px;
  width: min(55vw, 37dvh, 17rem); aspect-ratio: 1;
  background: radial-gradient(circle,#fff2b9,#f3a057 78%);
  border: 5px dashed #fff8e6; border-radius: .35rem;
  box-shadow: 0 0 22px #ffe1a3, 0 0 70px #ffb266;
}
.advent-reveal-cover {
  position: absolute; inset: 0; transform-origin: left center;
  transform-style: preserve-3d;
}
.advent-reveal-cover > .advent-cover {
  border-right: 3px solid #fff1be; transform: translateZ(1px);
  -webkit-backface-visibility: hidden;
}
.advent-reveal-door-back {
  position: absolute; inset: 0; transform: rotateY(180deg) translateZ(1px); backface-visibility: hidden;
  -webkit-backface-visibility: hidden; visibility: hidden;
  background: repeating-linear-gradient(45deg,#fff3db 0 9px,#f8b5d0 9px 18px);
  border: 2px solid #ffecbb;
}
.advent-present {
  --box-width: min(43vw, 27dvh, 12rem);
  z-index: 1; align-self: center;
  opacity: 0; transform: translateY(20%) scale(.2);
}
.advent-reveal-gift {
  position: absolute; grid-area: auto; inset: 3% 5%; z-index: 2;
  opacity: 0; transform: translateY(24%) scale(.34);
  pointer-events: none;
}
.advent-reveal-gift .gift-media,.advent-reveal-gift .gift-placeholder {
  position: absolute; inset: 0; background: transparent; overflow: visible;
}
.advent-reveal-gift .gift-media img {
  position: absolute; inset: 0;
  filter: drop-shadow(0 .5rem .85rem #6013348c);
}
.advent-reveal-gift img[data-compact-photo] {
  max-width: 285px;
  max-height: 330px;
  margin: auto;
}
.advent-reveal-gift .gift-placeholder { --box-width: min(51vw, 32dvh, 15rem); }
.advent-reveal-gift .gift-placeholder-name { display: none; }
.advent-reveal-copy,.advent-reveal-actions { position: relative; z-index: 4; width: min(100%, 39rem); }
.advent-reveal-copy { text-align: center; }
.advent-reveal-copy .eyebrow { color: #fff0bc; margin: 0 0 .2rem; }
.advent-reveal-copy h2 {
  margin: 0; font-size: clamp(1.55rem, 5.55vw, 3rem); line-height: 1.08;
  color: #fff; text-wrap: balance; text-shadow: 0 1px 3px #780631;
}
.advent-reveal-actions { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 28rem); gap: .5rem; }
.advent-reveal-actions .button { min-height: 44px; padding: .6rem .35rem; font-size: clamp(.83rem,3.25vw,.98rem); }
.advent-reveal-actions a.button { background: #fff; color: #8d123f; }
.advent-reveal-actions button.button { background: #83003755; border-color: #fff; color: #fff; }
.advent-reveal .button[hidden] { display: none; }
.advent-reveal-actions a[hidden] + button { grid-column: 2; }
.advent-reveal #advent-reveal-title:focus { outline: none; }
.advent-reveal:is([data-phase="loading"],[data-phase="revealing"]) .advent-reveal-copy { opacity: .68; }
.advent-reveal[data-phase="revealing"] .advent-reveal-window { animation: christmas-door-fade 730ms ease both; }
.advent-reveal[data-phase="revealing"] .advent-reveal-cover { animation: christmas-hinge 690ms cubic-bezier(.44,0,.34,1) both; }
.advent-reveal[data-phase="revealing"] .advent-reveal-door-back { animation: christmas-back-face 690ms step-end both; }
.advent-reveal[data-phase="revealing"] .advent-present { animation: christmas-box 1600ms both; }
.advent-reveal[data-phase="revealing"] .advent-present .christmas-present-lid { animation: christmas-lid 700ms 880ms both; }
.advent-reveal[data-phase="revealing"] .advent-reveal-gift { animation: christmas-rise 740ms 880ms both; }
.advent-reveal[data-phase="ready"] .advent-reveal-window,
.advent-reveal[data-phase="error"] .advent-reveal-scene { visibility: hidden; }
.advent-reveal[data-phase="ready"] .advent-reveal-gift { opacity: 1; transform: none; }
.advent-reveal[data-phase="ready"] .advent-present { opacity: 1; transform: translateY(138%) scale(.67); }
.advent-reveal[data-phase="ready"] .advent-present .christmas-present-lid { opacity: 0; }
.advent-reveal[data-phase="closing"] .advent-reveal-scene {
  animation: christmas-return 340ms cubic-bezier(.55,.12,.85,.42) both;
}
.advent-reveal[data-phase="closing"] .advent-reveal-window,
.advent-reveal[data-phase="closing"] .advent-reveal-copy,
.advent-reveal[data-phase="closing"] .advent-reveal-actions { visibility: hidden; }
.advent-reveal[data-phase="closing"] .advent-reveal-gift { opacity: 1; transform: none; }
.advent-reveal[data-phase="closing"] .advent-reveal-shell { animation: christmas-dismiss 340ms ease both; }
.advent-reveal[data-phase="closing"]::backdrop { background: transparent; }
.advent-reveal[data-phase="closing"] { background: transparent; pointer-events: none; }
@keyframes christmas-hinge { to { transform: rotateY(-123deg); } }
@keyframes christmas-back-face { 0% { visibility: hidden; } 62%, 100% { visibility: visible; } }
@keyframes christmas-door-fade { 0%, 67% { opacity: 1; } to { opacity: 0; } }
@keyframes christmas-box {
  0%, 27% { opacity: 0; transform: translateY(18%) scale(.1); }
  47% { opacity: 1; transform: scale(1.12); }
  53% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: translateY(138%) scale(.67); }
}
@keyframes christmas-lid {
  0% { opacity: 1; transform: none; }
  65%, 100% { opacity: 0; transform: translate(90%, -420%) rotate(35deg); }
}
@keyframes christmas-rise {
  from { opacity: 0; transform: translateY(28%) scale(.34); }
  28% { opacity: 1; }
  78% { transform: translateY(-1%) scale(1.02); }
  to { opacity: 1; transform: none; }
}
@keyframes christmas-return {
  to { transform: translate(var(--return-x,0px), var(--return-y,0px)) scale(var(--return-scale,.18)); opacity: 0; }
}
@keyframes christmas-dismiss { to { opacity: 0; } }

@media (max-height: 500px) and (orientation: landscape) {
  .advent-reveal-shell { grid-template: 1fr auto auto 1fr / 1fr 1fr; column-gap: 1rem; }
  .advent-reveal-scene { grid-area: 1/1/5/2; }
  .advent-reveal-copy { grid-area: 2/2; }
  .advent-reveal-actions { grid-area: 3/2; }
  .advent-reveal-gift { inset-block: .5%; }
  .advent-reveal-copy h2 { font-size: clamp(1.4rem,5.5vh,2rem); }
}
@media (prefers-reduced-motion: reduce) {
  .advent-reveal-rays,.christmas-snow,.advent-reveal-window,.advent-present { display: none; }
  .christmas-lights i { animation: none; }
  .advent-reveal[data-phase="ready"] .advent-reveal-gift { animation: christmas-simple-fade 180ms ease both !important; animation-duration: 180ms !important; }
}
@keyframes christmas-simple-fade { from { opacity: 0; } to { opacity: 1; } }
