/* "Cutie muzicală" (Components/Heroes/MusicBoxHero.razor, Carousel.razor, layouts/musicbox.js), over site.css and the theme:
   a little carousel over the classic card; in a browser, first the closed music box. The carousel's cloth and the box take
   the palette's soft accent, the trims a warm gold. Things move up and down or turn in place (the key), never sideways. */
main[data-layout=musicbox]{--box-gold:color-mix(in srgb,var(--gold) 30%,#c9a14f);--box-cloth:color-mix(in srgb,var(--accent-soft,var(--green)) 42%,#fff);
  --box-cloth-deep:color-mix(in srgb,var(--accent-soft,var(--green)) 62%,#fff);--box-wood:color-mix(in srgb,var(--accent-soft,var(--green)) 52%,var(--paper))}

/* — the carousel — */
.carousel{display:block;width:100%;overflow:visible}
.carousel-stripe{fill:var(--box-cloth)}
.carousel-cloth{fill:#fffaf4}
.carousel-trim{stroke:var(--box-gold);stroke-width:1}
.carousel-gold{fill:var(--box-gold)}
.carousel-pole{fill:none;stroke:var(--box-gold);stroke-width:2.2;stroke-linecap:round}
.carousel-base{fill:color-mix(in srgb,var(--box-cloth) 60%,#fff);stroke:var(--box-gold);stroke-width:1.4}
.carousel-base-side{fill:var(--box-cloth-deep);stroke:var(--box-gold);stroke-width:1.4}
.carousel-horse-body{fill:#fffdf9;stroke:var(--box-gold);stroke-width:1;stroke-linejoin:round}
.carousel-mane{fill:none;stroke:var(--box-cloth-deep);stroke-width:2.4;stroke-linecap:round}
.carousel-saddle{fill:var(--box-cloth-deep)}
.carousel-eye{fill:#4a3a33}
/* The horses ride up and down their poles, each in its own time. */
.carousel-horse{animation:horse-rides 1.6s calc(var(--i) * -.55s) ease-in-out infinite alternate}
@keyframes horse-rides{from{transform:translateY(-7px)}to{transform:translateY(7px)}}

/* — open: the carousel over the card — */
.musicbox-closed{display:none}
.musicbox-top{position:relative;z-index:2;width:clamp(170px,30vw,240px);margin:0 auto -54px}
.musicbox-hero .hero-content{padding-top:96px}
.musicbox-hero.just-opened .musicbox-top{animation:carousel-settles 1s cubic-bezier(.2,.8,.2,1) both}
.musicbox-hero.just-opened .hero-frame{animation:card-rises 1s .15s cubic-bezier(.2,.8,.2,1) both}
@keyframes carousel-settles{from{transform:translateY(-30px);opacity:0}to{transform:none;opacity:1}}
@keyframes card-rises{from{transform:translateY(40px);opacity:0}to{transform:none;opacity:1}}

/* — closed (layouts/musicbox.js): only the box on the screen — */
html[data-box] .invite-nav,html[data-box] main>:not(.musicbox-hero):not(.preview-banner):not(script){display:none}
html[data-box] .musicbox-opened{display:none}
html[data-box] .musicbox-hero{min-height:calc(100svh - 40px);display:grid;place-items:center;padding:24px 16px 72px;overflow:hidden}
html[data-box] .musicbox-closed{display:block;width:min(360px,78vw)}
.musicbox{position:relative;display:block;width:100%;aspect-ratio:1/1.12;border:0;padding:0;background:none;cursor:pointer;perspective:900px}
.musicbox:focus-visible{outline:3px solid var(--box-gold);outline-offset:8px;border-radius:12px}
.musicbox-label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
/* The carousel waits inside, under the lid; it rises out of the box when it opens. */
.musicbox-inside{position:absolute;left:7%;right:7%;bottom:44%;height:96%;overflow:hidden;z-index:1}
.musicbox-inside .carousel{position:absolute;bottom:-4%;left:0;transform:translateY(100%)}
.musicbox-body{position:absolute;z-index:2;left:2%;right:2%;bottom:0;height:46%;border-radius:10px 10px 14px 14px;display:grid;place-items:center;
  background:linear-gradient(180deg,color-mix(in srgb,var(--box-wood) 88%,#fff),var(--box-wood) 60%,color-mix(in srgb,var(--box-wood) 80%,#000));
  box-shadow:inset 0 0 0 3px var(--box-gold),inset 0 0 0 7px color-mix(in srgb,var(--box-wood) 85%,#fff),inset 0 0 0 8px var(--box-gold),0 30px 50px rgb(0 0 0 / .18)}
.musicbox-plaque{min-width:44%;padding:10px 16px;border-radius:40px;background:#fffaf2;color:color-mix(in srgb,var(--ink) 85%,var(--box-gold));
  box-shadow:0 0 0 2px var(--box-gold);font-family:var(--serif);font-style:italic;font-size:clamp(20px,6vw,28px);white-space:nowrap}
.musicbox-lid{position:absolute;z-index:3;left:0;right:0;bottom:45%;height:13%;transform-origin:50% 100%}
.musicbox-lid-top{position:absolute;inset:0;border-radius:12px 12px 4px 4px;
  background:linear-gradient(180deg,color-mix(in srgb,var(--box-wood) 70%,#fff),var(--box-wood));box-shadow:inset 0 0 0 3px var(--box-gold),0 6px 10px rgb(0 0 0 / .12)}
.musicbox-lid-top:after{content:'';position:absolute;left:44%;right:44%;top:-22%;height:30%;border-radius:8px 8px 0 0;background:var(--box-gold)}
.musicbox-key{position:absolute;z-index:1;right:-9%;bottom:16%;width:15%;fill:none;stroke:var(--box-gold);stroke-width:3.4;stroke-linecap:round;stroke-linejoin:round;
  animation:key-turns 3s linear infinite}
@keyframes key-turns{from{transform:rotateX(0)}to{transform:rotateX(360deg)}}
.musicbox-hint{margin-top:26px;text-align:center;font-size:11px;letter-spacing:2.4px;text-transform:uppercase;color:var(--muted)}
:is(:lang(zh),:lang(ja)) .musicbox-hint{letter-spacing:1px;font-size:12px}
html[data-box=closed] .musicbox{animation:box-waits 2.6s ease-in-out infinite alternate}
@keyframes box-waits{from{transform:none}to{transform:translateY(-6px)}}
/* Opened: the lid lifts back, the carousel rises out, the key spins faster. */
html[data-box=opening] .musicbox-lid{animation:lid-lifts .7s cubic-bezier(.4,0,.2,1) forwards}
html[data-box=opening] .musicbox-inside .carousel{animation:carousel-rises 1.1s .45s cubic-bezier(.2,.8,.25,1) forwards}
html[data-box=opening] .musicbox-key{animation-duration:.8s}
html[data-box=opening] .musicbox-hint{transition:opacity .4s;opacity:0}
@keyframes lid-lifts{to{transform:translateY(-30%) rotateX(78deg);opacity:.0}}
@keyframes carousel-rises{to{transform:none}}

@media (max-width:700px){
  .musicbox-top{margin-bottom:-40px}
  .musicbox-hero .hero-content{padding-top:76px}
}
@media (prefers-reduced-motion:reduce){.musicbox-hero *{animation:none!important}}
@media print{
  .musicbox-closed{display:none!important}
  .musicbox-opened{display:block!important}
  .musicbox-hero *{animation:none!important}
  .musicbox-top{width:46mm;margin-bottom:-12mm}
}
