:root{color-scheme:only dark;font-family:Georgia,serif;background:#160907;color:#f7dca7}
*{box-sizing:border-box}
body{margin:0}
main{height:100dvh;min-height:270px;isolation:isolate;position:relative;display:grid;grid-template-columns:minmax(0,1fr);place-items:center;overflow:hidden;background:radial-gradient(ellipse,#4e190e 0%,#210a08 55%,#0c0504 100%)}
.stage{width:min(100vw,177.778dvh);aspect-ratio:16/9;position:relative;container-type:inline-size}
.artwork,.mechanism,.snow{position:absolute;inset:0;width:100%;height:100%}
.artwork{background:url('../assets/backgrounds/automaton.webp') center/100% 100% no-repeat}
.mechanism{overflow:visible}
.plinth{
  position:absolute;left:50%;top:89.1%;margin:0;transform:translate(-50%,-50%);
  font-size:3.02cqw;white-space:nowrap;line-height:1.12;text-align:center;
  font-weight:700;text-transform:uppercase;letter-spacing:.018em;
  color:#ffdc94;
  text-shadow:0 -.055cqw #fff8d9,0 .075cqw #a87232,
    .035cqw .16cqw .08cqw #361409,0 0 .42cqw #ffb344aa;
}
.plinth::before{
  content:"";position:absolute;inset:-31% -8%;pointer-events:none;
  background:radial-gradient(ellipse,#ffc16b54 0%,#f5a04630 44%,transparent 75%);
}
.plinth>span{
  position:relative;display:inline-block;
  -webkit-text-fill-color:currentColor;
  -webkit-text-stroke:.022cqw #9b632c;
}

.toolbar{display:flex;gap:.45rem;position:absolute;right:clamp(.65rem,2vw,1.65rem);bottom:clamp(.7rem,2vw,1.45rem)}
button,select,input,summary{font:inherit}
button,select,summary{color:inherit}
button,select{border:1px solid #a97a47;background:#210e0de8;border-radius:.35rem;padding:.45rem .65rem}
button{cursor:pointer}
button:hover,button[aria-pressed=true]{background:#522017}
:focus-visible{outline:2px solid #ffe8aa;outline-offset:3px}
#sound span:first-child{margin-right:.22em}
#calendar-state{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
#debug{position:absolute;z-index:3;top:.6rem;left:.6rem;width:min(24rem,calc(100% - 1.2rem));max-height:80dvh;overflow:auto;background:#210e0df5;border:1px solid #a97a47;border-radius:.4rem;padding:.65rem;font: .9rem system-ui}
#debug summary{cursor:pointer}
#debug .controls{display:grid;gap:.55rem;margin-top:.65rem}
#debug .row{display:flex;flex-wrap:wrap;align-items:center;gap:.4rem}
#debug label{display:inline-flex;align-items:center;gap:.3rem}
#debug output{font-variant-numeric:tabular-nums}
[hidden],.layer-hidden{display:none!important}
.snow{pointer-events:none;overflow:hidden;display:none}
.festive .snow,.snow-preview .snow{display:block}
.no-snow .snow{display:none}
.snow i{position:absolute;left:var(--x);top:-5%;width:var(--size);aspect-ratio:1;border-radius:50%;background:#fbe7b9;box-shadow:0 0 .4rem #f3ae63;animation:fall var(--time) var(--delay) linear infinite}
@keyframes fall{to{transform:translate(var(--drift),105cqh);opacity:0}}
.stage{container-type:size;height:min(56.25vw,100dvh)}
.festive .plinth{color:#ffe5ab}
.christmas-light,.snow-flurry{opacity:0}
.festive .christmas-light{opacity:.32}
.celebrate .christmas-light{animation:christmas-light 8.7s ease-in-out both}
.snow-flurry{position:absolute;inset:0;display:none}
.celebrate.festive .snow-flurry{display:block;animation:christmas-flurry 7s ease-in-out both}
.celebrate.festive .plinth{animation:glow 1.5s ease-in-out 4 alternate}
@keyframes christmas-light{0%{opacity:0}30%{opacity:1}60%{opacity:.78}100%{opacity:.32}}
@keyframes christmas-flurry{0%,100%{opacity:0}24%,60%{opacity:.86}}
@keyframes glow{to{text-shadow:0 -.055cqw #fff8d9,0 .075cqw #a87232,
  .035cqw .16cqw .08cqw #361409,0 0 .85cqw #ffb33cdd}}
.no-light .light{display:none}
@media (max-aspect-ratio:4/5){
  .stage{width:min(143vw,140dvh);height:min(80.4375vw,78.75dvh)}
  .toolbar{bottom:1rem}
}
@media(prefers-reduced-motion:reduce){
  .snow i{animation:none;top:var(--y);opacity:.6}
  .celebrate.festive .plinth,.celebrate .christmas-light,.celebrate.festive .snow-flurry{animation:none}
}

/* Temporary test controls, mounted only in debug mode. */
#test-toolbar{position:absolute;z-index:2;top:.6rem;right:.6rem;display:flex;justify-content:flex-end;flex-wrap:wrap;gap:.35rem;max-width:min(31rem,calc(100% - 1.2rem));padding:.35rem;background:#210e0de8;border:1px solid #a97a47;border-radius:.4rem;font:.875rem system-ui}
#test-toolbar button{min-height:2.3rem}
@media(max-width:58rem){
  #test-toolbar{top:3.7rem;left:.6rem;right:.6rem;justify-content:flex-start}
}

.mechanism:not(.articulating) .articulation-active,.mechanism.articulating .articulation-rest{display:none}

#replay{min-height:2.75rem}
@media(max-width:36rem){
  .toolbar{left:clamp(.65rem,2vw,1.65rem);justify-content:flex-end;flex-wrap:wrap}
}

/* Keep the photograph and SVG on the same 16:9 stage, including fold and orientation changes. */
main{height:100vh;height:100dvh;background:radial-gradient(ellipse at 50% 49%,#3a130d,#210a08 63%,#100604)}
.stage{height:auto;aspect-ratio:16/9;container-type:inline-size}
.artwork{z-index:0}
.mechanism{z-index:1;overflow:hidden}
.snow{z-index:3;container-type:normal}
.plinth{z-index:4}
.toolbar{z-index:5!important}
#debug,#test-toolbar{z-index:6!important}
@media(max-aspect-ratio:4/5){
  .stage{width:min(143vw,140dvh)}
}
@media(max-aspect-ratio:16/10){
  .artwork{
    -webkit-mask-image:linear-gradient(transparent,#000 4%,#000 98%,transparent);
    mask-image:linear-gradient(transparent,#000 4%,#000 98%,transparent);
  }
}
@keyframes fall{to{transform:translate(var(--drift),60cqw);opacity:0}}
.artwork,.mechanism{forced-color-adjust:none}

.carved-eyelid{opacity:0;transform:scaleY(.03)}
.blink .carved-eyelid{animation:eyelid .29s ease-in-out}
.double-blink .carved-eyelid{animation:eyelid .24s ease-in-out 2}
@keyframes eyelid{0%,100%{opacity:0;transform:scaleY(.03)}36%,57%{opacity:1;transform:scaleY(1)}}

.atmosphere{position:absolute;inset:0;pointer-events:none;z-index:1}
.atmosphere i{position:absolute;width:2cqw;aspect-ratio:1;transform:translate(-50%,-50%);
  background:radial-gradient(circle,#ffdc93 0%,#fbb05425 28%,transparent 66%);
  animation:fairy-twinkle var(--twinkle) var(--twinkle-delay) ease-in-out infinite;opacity:.12}
@keyframes fairy-twinkle{0%,65%,100%{opacity:.08}80%{opacity:.43}}
.light>circle{animation:amber-breathe 17s ease-in-out infinite alternate}
.light>circle:nth-child(2n){animation-delay:-8s;animation-duration:23s}
@keyframes amber-breathe{from{opacity:.80}to{opacity:1}}
.collection-complete .christmas-light{animation:collection-light 4.3s ease-in-out both}
@keyframes collection-light{0%,100%{opacity:0}51%{opacity:.77}}
@media(prefers-reduced-motion:reduce){
  .atmosphere i,.light>circle,.collection-complete .christmas-light,.blink .carved-eyelid,.double-blink .carved-eyelid{animation:none}
}

@media(min-aspect-ratio:2/1){
  .artwork{
    -webkit-mask-image:linear-gradient(90deg,transparent,#000 4%,#000 96%,transparent);
    mask-image:linear-gradient(90deg,transparent,#000 4%,#000 96%,transparent);
  }
}
@supports not (height:100dvh){.stage{width:min(100vw,177.778vh)}}
.brass-glint{opacity:0;animation:brass-glint 23s var(--glint-delay) ease-in-out infinite}
@keyframes brass-glint{0%,71%,100%{opacity:0}79%{opacity:.42;stroke-dashoffset:-18}89%{opacity:0;stroke-dashoffset:-35}}
@media(prefers-reduced-motion:reduce){.brass-glint{animation:none}}

.plinth-brand small{font-size:.43em;vertical-align:super;margin-left:.08em;-webkit-text-stroke:.025cqw #603b20}
