/* The turning layer uses the key from the original print at its original scale. */
.engraving-victory { display: none; }
@media (prefers-reduced-motion:no-preference) {
  .engraving[data-key-turn] .engraving-ground,
  .engraving[data-key-turn] .arrival-glints { display: none; }
  .engraving[data-key-turn] .engraving-plate,
  .engraving[data-key-turn] .engraving-victory { display: block; }
  .engraving[data-key-turn] .turning-brass {
    transform-box: view-box;
    transform-origin: 83% 60.5%;
    mix-blend-mode: lighten;
    animation: brass-key-turn 1.2s both;
  }
  @keyframes brass-key-turn {
    0% { transform: rotate(0); animation-timing-function:ease-out; }
    14% { transform: rotate(-3.5deg); animation-timing-function:cubic-bezier(.32,.08,.14,1); }
    53% { transform: rotate(20deg); }
    65% { transform: rotate(18.5deg); animation-timing-function:cubic-bezier(.45,0,.27,1); }
    90% { transform: rotate(-1.5deg); }
    100% { transform: none; }
  }
  .engraving[data-key-turn] .key-polish {
    animation: polished-edge .64s .46s cubic-bezier(.4,.04,.65,.99) both;
  }
  @keyframes polished-edge {
    0% { opacity:0; transform:translateX(0); }
    18%,77% { opacity:.94; }
    100% { opacity:0; transform:translateX(590px); }
  }
  .engraving[data-key-turn] .key-catchlight {
    fill:#ffefbd; transform-box:fill-box; transform-origin:center;
    animation: bow-glint .39s .78s ease-out both;
  }
  @keyframes bow-glint {
    0%,100% { opacity:0; transform:scale(.25); }
    35% { opacity:1; transform:scale(1.75); }
  }
}

/* The constellation has its own area above the drawer and its controls. */
#drawer-stage:has(#key-sky:not([hidden])) {
  display:flex; align-items:center; justify-content:center;
}
#key-sky {
  display:block; pointer-events:none; overflow:hidden; flex:0 1 auto; min-width:0;
  width:min(100%,31rem); height:clamp(6.2rem,19svh,10.8rem); margin:0 auto .12rem;
}
#key-sky[hidden] { display:none; }
.key-starlight {
  fill:none; stroke:url(#sky-metal); stroke-linecap:round; stroke-linejoin:round;
  stroke-width:1.65; stroke-dasharray:1; stroke-dashoffset:0;
}
.key-stars { fill:#ffe6a0; }
.key-stars .sky-bead { fill:#f0c98a; }
.sky-dust { opacity:.68; }
.sky-tracer { mix-blend-mode:normal; filter:drop-shadow(0 0 1px #eecf85a0); }
@media (prefers-reduced-motion:no-preference) {
  #key-sky.tracing .key-starlight { filter:drop-shadow(0 0 1px #edbc6a85); }
  #key-sky.tracing .sky-wing {
    transform-box:view-box; transform-origin:50% 45%;
    animation: star-flight-wing .23s ease-in-out alternate infinite;
  }
  .sky-wing-left { --sweep:5deg; } .sky-wing-right { --sweep:-5deg; }
  @keyframes star-flight-wing {
    from { transform:scaleX(.96); }
    to { transform:skewY(var(--sweep)) scaleX(.62); }
  }
}
#key-sky .sky-aureole { opacity:.45; }
.key-radiance {
  fill:none; stroke:#f9c676; stroke-width:3.8; stroke-linecap:round; stroke-linejoin:round;
  stroke-dasharray:1; stroke-dashoffset:0; opacity:.32; filter:blur(1.7px);
}
.key-flares { fill:#fff4c4; }
.sky-halo { opacity:0; fill:none; stroke:#ffe4a4; pointer-events:none; }
.sky-halo ellipse { transform-box:fill-box; transform-origin:center; stroke-width:1; }
@media (prefers-reduced-motion:no-preference) {
  #key-sky.tracing .sky-aureole { opacity:.23; }
  #key-sky.tracing.finishing .sky-aureole { animation:constellation-dawn 1.05s ease-out both; }
  #key-sky.tracing.finishing .key-radiance { animation:constellation-gleam 1.05s ease-out both; }
  #key-sky.tracing.finishing .sky-halo { animation:constellation-halo .85s ease-out both; }
  #key-sky.tracing.finishing .sky-halo ellipse { animation:constellation-ripple .85s cubic-bezier(.16,.61,.32,1) both; }
  @keyframes constellation-dawn { 0% { opacity:.23; } 31% { opacity:1; } 100% { opacity:.45; } }
  @keyframes constellation-gleam { 0% { opacity:.32; } 27% { opacity:.95; stroke-width:5; } 100% { opacity:.32; } }
  @keyframes constellation-halo { 0% { opacity:0; } 17% { opacity:.72; } 100% { opacity:0; } }
  @keyframes constellation-ripple { from { transform:scale(.88); } to { transform:scale(1.75); } }
}
@media(max-width:760px) { #key-sky { height:clamp(5.2rem,14svh,7.8rem); } }
@media(max-width:360px) and (max-height:650px) { #key-sky { height:4.9rem; } }
@media(max-height:450px) { #key-sky { height:3.25rem; } }
