/* A printed photo with doors cut into it. Deliberately plain: the photo is the design. */
:root {
  --paper: #efeae0;
  --white: #fbf8f2;
  --ink: #211d19;
  --soft: #6f675d;
  --red: #842129;
  --rule: #d5ccbc;
  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .25 0 0 0 0 .18 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { background: var(--paper); }
body { min-height: 100vh; min-height: 100dvh; background: var(--grain), var(--paper); color: var(--ink); font-family: var(--serif); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

#app { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; max-width: 460px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 10px calc(14px + env(safe-area-inset-bottom)); animation: arrive 1.4s ease both; }
@keyframes arrive { from { opacity: 0; } }

header { text-align: center; padding-bottom: 14px; }
h1 { font: italic 500 40px/1.05 var(--serif); overflow-wrap: anywhere; }
#subheading { margin-top: 3px; font-size: 17px; color: var(--soft); }

/* the whole calendar fits on one phone screen */
.print-frame { width: min(100%, calc((100vh - 190px) * .75 + 14px)); width: min(100%, calc((100dvh - 190px) * .75 + 14px)); min-width: min(100%, 320px); padding: 7px; background: var(--white); box-shadow: 0 1px 2px rgb(40 30 15 / .2), 0 14px 34px -10px rgb(40 30 15 / .38); }
.board { position: relative; aspect-ratio: 3 / 4; container-type: inline-size; }
#cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.board.broken::after { content: "Cover photo not found. Check media/cover.jpg"; position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; background: var(--rule); }

.door { position: absolute; left: var(--l); top: var(--t); width: var(--w); height: var(--h); perspective: 700px; -webkit-tap-highlight-color: transparent; }
.door.open { z-index: 2; }
.door:focus-visible { z-index: 3; outline-color: var(--white); outline-offset: 1px; }

.behind { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; background: var(--grain), var(--red); color: var(--white); box-shadow: inset 3px 4px 9px rgb(0 0 0 / .5), inset -1px -1px 2px rgb(0 0 0 / .25); opacity: 0; }
.behind span { font: italic 400 7cqw/1 var(--serif); }
.behind img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.behind::after { content: ""; position: absolute; inset: 0; box-shadow: inset 3px 4px 9px rgb(0 0 0 / .45); }
.door.open .behind { opacity: 1; }

.flap { position: absolute; inset: 0; transform-origin: left center; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.55, .05, .2, 1); }
.face, .back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face { display: grid; place-items: center; background-repeat: no-repeat; box-shadow: 0 0 0 .6px rgb(30 20 10 / .38), 1px 1px 0 .3px rgb(255 255 255 / .42); }
.back { transform: rotateY(180deg); background: var(--grain), linear-gradient(90deg, #d9d0bf, #f7f2e8 30%); box-shadow: inset 0 0 0 .5px rgb(0 0 0 / .25); }

.num { font: 500 6.6cqw/1 var(--serif); font-variant-numeric: lining-nums; }
.ink-light .num { color: #fff; text-shadow: 0 0 2px rgb(0 0 0 / .75), 0 1px 7px rgb(0 0 0 / .7); }
.ink-dark .num { color: var(--ink); text-shadow: 0 0 5px rgb(255 255 255 / .9); }
.d24 .num { font-size: 15cqw; font-style: italic; }

/* a door that can be opened stands a little proud of the paper */
.door.ready { z-index: 1; }
/* no CSS filter on .flap: it flattens the 3D door and shows the number mirrored on its back */
.door.ready .flap { transform: rotateY(-22deg); }
.door.ready .face { box-shadow: 0 0 0 .6px rgb(30 20 10 / .38), 5px 4px 9px rgb(0 0 0 / .4); }
.door.ready .behind { opacity: 1; background: #f6c870; box-shadow: 0 0 9px 2px rgb(255 196 92 / .75); } /* lamplight through the gap */
.door.ready .behind > * { visibility: hidden; }
.door.ready .behind::after { box-shadow: none; }
.door.ready.today .flap { animation: ajar 3.6s ease-in-out infinite; }
@keyframes ajar { 0%, 62%, 100% { transform: rotateY(-22deg); } 78% { transform: rotateY(-36deg); } }
.door.nudge .flap { animation: nudge .5s ease; }
@keyframes nudge { 35% { transform: rotateY(-9deg); } 65% { transform: rotateY(2deg); } }
.door.open .flap { transform: rotateY(-118deg); }
.door.open .back { box-shadow: 0 0 0 .5px rgb(0 0 0 / .25), -5px 5px 10px rgb(0 0 0 / .32); }

.countdown { min-height: 24px; padding-top: 15px; font-size: 18px; color: var(--soft); text-align: center; font-variant-numeric: tabular-nums lining-nums; }
.countdown b { font-weight: 500; color: var(--ink); }

.preview-bar { position: fixed; z-index: 5; left: 50%; bottom: calc(8px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); display: flex; gap: 12px; align-items: center; padding: 6px 6px 6px 14px; border-radius: 8px; background: #111e; color: #fff; font: 12px system-ui, sans-serif; }
.preview-bar button { background: #fff; color: #111; border-radius: 5px; padding: 5px 10px; white-space: nowrap; }

/* ---------- what is behind a door: a playful Christmas card ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: calc(66px + env(safe-area-inset-top)) 16px calc(30px + env(safe-area-inset-bottom)); background: rgb(30 4 10 / .74); animation: arrive .35s ease; }
.overlay.leaving { opacity: 0; transition: opacity .3s; }
.page { --accent: #a32232; position: relative; isolation: isolate; flex: none; width: min(100%, 420px); margin: auto; padding: 66px 28px 36px; border-radius: 26px; text-align: center; color: var(--ink); outline: none; background: repeating-linear-gradient(-45deg, var(--accent) 0 13px, #fdf6e8 13px 26px); box-shadow: 0 26px 60px rgb(10 0 3 / .6); }
.page::before { content: ""; position: absolute; z-index: -1; inset: 10px; border-radius: 18px; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 13%, transparent) 2px, transparent 2.5px) 0 0 / 26px 26px, var(--grain), #fffaf0; }
.theme-1 { --accent: #1d6044; }
.theme-2 { --accent: #b07a1f; }
.theme-3 { --accent: #2b4a7c; }
.overlay.leaving .page { transform: scale(.85) rotate(4deg); transition: transform .3s ease-in; }

.sticker { position: absolute; top: -48px; left: 50%; width: 96px; height: 96px; margin-left: -48px; display: grid; place-items: center; border-radius: 50%; background: #fffaf0; border: 4px solid var(--accent); box-shadow: 0 0 0 4px #fffaf0, 0 10px 20px rgb(30 5 0 / .35); cursor: pointer; animation: bob 3s ease-in-out infinite; }
.sticker svg { width: 66px; height: 66px; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(5deg); } }
.sticker.poked { animation: poked .8s ease; }
@keyframes poked { 20% { transform: scale(1.25) rotate(-18deg); } 45% { transform: scale(.92) rotate(14deg); } 70% { transform: scale(1.08) rotate(-6deg); } }
.bit { position: fixed; z-index: 70; pointer-events: none; line-height: 1; animation: fling 1.1s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes fling { from { transform: translate(-50%, -50%) scale(.3); opacity: 1; } 70% { opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 40px)) rotate(var(--turn)) scale(1); opacity: 0; } }

.close { position: absolute; z-index: 2; top: -10px; right: -6px; width: 46px; height: 46px; border-radius: 50%; border: 3px solid #fffaf0; background: var(--accent); color: #fffaf0; font: 400 28px/1 var(--serif); box-shadow: 0 5px 12px rgb(20 0 5 / .4); transition: transform .25s; }
.close:active { transform: rotate(90deg) scale(.9); }
.card-date { display: inline-block; padding: 3px 18px 5px; border-radius: 99px; background: var(--accent); color: #fffaf0; font: 700 19px/1.2 'Caveat', cursive; rotate: -3deg; }
.page h2 { margin-top: 10px; font: 700 40px/1.08 'Caveat', cursive; color: var(--accent); text-wrap: balance; overflow-wrap: anywhere; }
.page h2::after { content: ""; display: block; width: 120px; height: 12px; margin: 8px auto 0; background: var(--accent); opacity: .55; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='12'%3E%3Cpath d='M3 6Q9 0 15 6T27 6T39 6T51 6T63 6T75 6T87 6T99 6T111 6' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 120px 12px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='12'%3E%3Cpath d='M3 6Q9 0 15 6T27 6T39 6T51 6T63 6T75 6T87 6T99 6T111 6' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 120px 12px no-repeat; }

.block { margin-top: 26px; animation: pop-in .6s cubic-bezier(.25, 1.55, .45, 1) backwards; animation-delay: var(--delay); }
@keyframes pop-in { from { opacity: 0; transform: translateY(30px) scale(.8) rotate(-5deg); } }
.text { font: 500 27px/1.35 'Caveat', cursive; white-space: pre-line; overflow-wrap: anywhere; }

.letter { position: relative; padding: 31px 18px 20px 42px; text-align: left; font: 500 25px/32px 'Caveat', cursive; white-space: pre-line; overflow-wrap: anywhere; rotate: -1deg; background: linear-gradient(90deg, transparent 30px, #e29a9a 30px 31.5px, transparent 31.5px), repeating-linear-gradient(transparent 0 31px, #cfe0ea 31px 32px), #fff; box-shadow: 0 8px 18px rgb(70 40 10 / .22); }
.letter .signoff { display: block; margin-top: 32px; text-align: right; font-weight: 700; color: var(--accent); }

figure { position: relative; display: inline-block; max-width: calc(100% - 10px); padding: 11px 11px 14px; background: #fff; box-shadow: 0 12px 24px rgb(50 25 5 / .3); rotate: -2.5deg; }
.block:nth-child(even) figure { rotate: 2.2deg; }
figure::before, figure::after { content: ""; position: absolute; z-index: 1; top: 2px; width: 70px; height: 24px; background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--accent) 70%, transparent) 0 7px, rgb(253 240 210 / .75) 7px 13px); }
figure::before { left: -20px; rotate: -40deg; }
figure::after { right: -20px; rotate: 40deg; }
figure img { display: block; max-width: 100%; max-height: 56vh; margin: 0 auto; }
.caption { margin-top: 10px; font: 500 25px/1.2 'Caveat', cursive; overflow-wrap: anywhere; }
video { display: block; width: 100%; max-height: 58vh; background: #000; border: 8px solid #fff; border-radius: 8px; box-shadow: 0 12px 24px rgb(50 25 5 / .3); rotate: 1deg; }

.cassette { padding: 14px 14px 12px; border-radius: 16px; background: var(--accent); color: var(--ink); box-shadow: inset 0 2px 0 rgb(255 255 255 / .35), inset 0 -4px 0 rgb(0 0 0 / .22), 0 12px 24px rgb(40 15 0 / .32); rotate: -1deg; }
.cas-label { display: block; padding: 4px 10px 6px; border-radius: 6px; background: #fffaf0; font: 700 24px/1.2 'Caveat', cursive; overflow-wrap: anywhere; }
.cas-window { display: flex; align-items: center; justify-content: space-between; width: 76%; margin: 12px auto; padding: 8px 12px; border-radius: 99px; background: #2c1b14; box-shadow: 0 0 0 3px rgb(255 250 240 / .8); }
.reel { width: 34px; height: 34px; border-radius: 50%; background: repeating-conic-gradient(#fdf1da 0 30deg, #6a4a3a 30deg 60deg); -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px); mask: radial-gradient(circle, transparent 5px, #000 6px); }
.playing .reel { animation: spin 1.6s linear infinite; }
@keyframes spin { to { rotate: 1turn; } }
.tapewin { flex: 1; height: 12px; margin: 0 9px; background: repeating-linear-gradient(90deg, #7a5946 0 2px, #3d281c 2px 5px); }
.player { display: flex; align-items: center; gap: 12px; padding: 7px 14px 7px 7px; border-radius: 99px; background: #fffaf0; }
.play { flex: none; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fffaf0; box-shadow: 0 4px 0 rgb(0 0 0 / .22); }
.play:active { transform: translateY(3px); box-shadow: 0 1px 0 rgb(0 0 0 / .22); }
.play svg { width: 21px; height: 21px; fill: currentColor; }
.bar { flex: 1; height: 30px; cursor: pointer; background: linear-gradient(var(--accent), var(--accent)) 0 50% / var(--done, 0%) 7px no-repeat, linear-gradient(#ead9b8, #ead9b8) 0 50% / 100% 7px no-repeat; }
.time { font: 700 19px 'Caveat', cursive; font-variant-numeric: tabular-nums; }

.voucher { position: relative; display: flex; rotate: -2deg; filter: drop-shadow(0 10px 12px rgb(60 30 0 / .32)); animation: wiggle 4s ease-in-out 1.6s infinite; }
@keyframes wiggle { 0%, 82%, 100% { transform: none; } 86% { transform: rotate(3deg) scale(1.03); } 90% { transform: rotate(-2.5deg); } 94% { transform: rotate(1.5deg); } }
.voucher-inner, .stub { background: radial-gradient(circle, rgb(255 255 255 / .35) 1.5px, transparent 2px) 0 0 / 15px 15px, linear-gradient(135deg, #fbe6a6, #eec45d 55%, #d9a539); }
.voucher-inner { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; min-height: 176px; padding: 20px 14px; border-radius: 14px 0 0 14px; }
.stub { width: 50px; display: grid; place-items: center; border-radius: 0 14px 14px 0; border-left: 3px dashed #8c1d2b; }
.stub span { writing-mode: vertical-rl; font: 700 22px 'Caveat', cursive; color: #7a1624; }
.voucher small { font: 700 21px 'Caveat', cursive; color: #8c1d2b; }
.voucher strong { margin: 4px 0 6px; font: 700 34px/1.05 'Caveat', cursive; color: #4a1119; overflow-wrap: anywhere; }
.voucher .details { font: 500 20px/1.25 'Caveat', cursive; white-space: pre-line; overflow-wrap: anywhere; }
.scratch { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; border-radius: 14px; touch-action: none; cursor: grab; transition: opacity .7s; }
.scratch.done { opacity: 0; pointer-events: none; }

.list h3 { margin-bottom: 10px; font: 700 28px/1.2 'Caveat', cursive; }
.list ol { list-style: none; counter-reset: n; text-align: left; }
.list li { --ball: #a32232; counter-increment: n; display: flex; gap: 14px; align-items: center; margin-top: 12px; padding: 12px 16px 12px 12px; border-radius: 99px 20px 20px 99px; background: #fff; box-shadow: 0 5px 12px rgb(70 40 10 / .16); font: 500 24px/1.2 'Caveat', cursive; overflow-wrap: anywhere; animation: slide-in .55s cubic-bezier(.25, 1.5, .45, 1) backwards; }
.list li:nth-child(4n+2) { --ball: #1d6044; }
.list li:nth-child(4n+3) { --ball: #b07a1f; }
.list li:nth-child(4n) { --ball: #2b4a7c; }
.list li:nth-child(odd) { rotate: -.8deg; }
.list li:nth-child(even) { rotate: .8deg; }
.list li:nth-child(1) { animation-delay: .5s; } .list li:nth-child(2) { animation-delay: .75s; } .list li:nth-child(3) { animation-delay: 1s; } .list li:nth-child(4) { animation-delay: 1.25s; } .list li:nth-child(n+5) { animation-delay: 1.5s; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-70px) rotate(-8deg); } }
.list li::before { content: counter(n); flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 34% 30%, rgb(255 255 255 / .75) 0 8%, transparent 30%), var(--ball); color: #fff; font: 700 22px 'Caveat', cursive; box-shadow: inset 0 -3px 6px rgb(0 0 0 / .25); }

.quiz h3 { margin-bottom: 8px; font: 700 29px/1.15 'Caveat', cursive; }
.option { display: block; width: 100%; margin-top: 11px; padding: 11px 16px 13px; border: 2.5px solid var(--accent); border-radius: 99px; background: #fff; font: 700 25px 'Caveat', cursive; box-shadow: 0 4px 0 var(--accent); transition: transform .15s, background .25s; }
.option:active { transform: translateY(4px); box-shadow: none; }
.option.right { background: #1d6044; border-color: #1d6044; box-shadow: 0 4px 0 #0f3425; color: #fff; animation: poked .7s; }
.option.wrong { opacity: .5; text-decoration: line-through; animation: no .45s; }
@keyframes no { 25% { transform: translateX(-9px) rotate(-2deg); } 50% { transform: translateX(8px) rotate(2deg); } 75% { transform: translateX(-4px); } }
.feedback { min-height: 1.5em; margin-top: 14px; font: 700 28px 'Caveat', cursive; color: var(--accent); }

.link-btn { display: inline-block; padding: 13px 36px 15px; border-radius: 99px; background: var(--accent); color: #fffaf0; font: 700 26px 'Caveat', cursive; text-decoration: none; box-shadow: 0 6px 0 rgb(0 0 0 / .25), 0 12px 22px rgb(40 15 0 / .25); animation: beat 2.2s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.06) rotate(-1.5deg); } }
.empty { font: 700 29px/1.25 'Caveat', cursive; color: var(--accent); }
.missing { padding: 14px; border: 1px dashed #842129; background: #fff; font: 13px system-ui, sans-serif; overflow-wrap: anywhere; }
.finale-title { margin-bottom: 14px; font: 700 28px 'Caveat', cursive; color: var(--accent); }
.collage { columns: 2; column-gap: 10px; }
.collage img { display: block; width: 100%; margin-bottom: 10px; padding: 5px 5px 12px; background: #fff; box-shadow: 0 6px 14px rgb(50 25 5 / .28); rotate: -2deg; }
.collage img:nth-child(even) { rotate: 2.5deg; }

.toast { position: fixed; z-index: 45; left: 50%; top: calc(16px + env(safe-area-inset-top)); width: max-content; max-width: calc(100% - 32px); padding: 11px 22px 13px; background: var(--ink); color: var(--white); font-size: 18px; text-align: center; transform: translate(-50%, -12px); opacity: 0; visibility: hidden; transition: opacity .35s, transform .35s, visibility .35s; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}

/* ---------- Christmas ---------- */
:root { --berry: #6a1620; --pine: #1d4a35; --gold: #ecc873; --cream: #fbf3e2; }
html { background: #3d0a12; }
body { color: var(--cream); background: var(--grain), radial-gradient(110% 75% at 50% 18%, #9a2733 0%, var(--berry) 48%, #3d0a12 100%); }
#snow { position: fixed; z-index: 4; inset: 0; width: 100%; height: 100%; pointer-events: none; }
header { padding-bottom: 0; }
h1 { color: var(--cream); text-shadow: 0 2px 12px rgb(30 0 6 / .6); }
#subheading { color: var(--gold); font-style: italic; font-size: 19px; }
.garland { position: relative; z-index: 3; width: calc(100% + 20px); margin-top: 12px; margin-bottom: -22px; pointer-events: none; filter: drop-shadow(0 6px 6px rgb(25 0 5 / .45)); }
.garland svg { display: block; width: 100%; height: auto; overflow: visible; }
.bulb { animation: twinkle 2.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .45; } }
.swing { transform-box: view-box; animation: swing 4.5s ease-in-out infinite alternate; }
@keyframes swing { from { rotate: -3deg; } to { rotate: 3deg; } }
.print-frame { position: relative; width: min(100%, calc((100vh - 287px) * .75 + 14px)); width: min(100%, calc((100dvh - 287px) * .75 + 14px)); min-width: min(100%, 300px); background: var(--cream); box-shadow: 0 0 0 1px var(--gold), 0 0 0 5px var(--pine), 0 0 0 6px var(--gold), 0 22px 44px -8px rgb(20 0 4 / .7); }
.behind { background: var(--grain), var(--pine); }
.d24 .face { align-content: center; }
.star { font-size: 10cqw; line-height: .9; color: var(--gold); text-shadow: 0 1px 6px rgb(0 0 0 / .65); }
.countdown { padding-top: 16px; color: rgb(251 243 226 / .85); }
.countdown b { color: var(--cream); }
.sleeps { font-style: italic; font-size: 17px; color: var(--gold); }
.toast { background: var(--cream); color: var(--berry); box-shadow: 0 0 0 1px var(--gold), 0 14px 30px rgb(20 0 4 / .5); }
@media (prefers-reduced-motion: reduce) { #snow { display: none; } }
