/* The Machine Maker (MAKERS-PLAN.md). The room's layout (the fixed overlay, the
   two-sided grid, the room layers and the creature slot) is shared with the other rooms
   in potions.css, the pantry, plate and dish styles come from kitchen.css, the big
   button from zaplab.css and the bin from studio.css; this file is only the workshop's
   own, and the machines' moving parts, which the Animal Maker's bench shows too. */

#machineshop { --mk-warm: #6a3c5e; --mk-pink: #e28ccf; }

/* ---------------------------------------------------------------- the room */

.mk-plank { stroke: rgba(7, 4, 15, 0.22); stroke-width: 4; }
.mk-board { fill: #8a5a3c; stroke: #5e3a26; stroke-width: 6; }
.mk-holes circle { fill: #4a2e1f; }
.mk-outline { fill: none; stroke: rgba(255, 226, 168, 0.4); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 2 10; }
.mk-cord { stroke: #1c1430; stroke-width: 5; }
.mk-shade { fill: #e28ccf; stroke: #8e3f7c; stroke-width: 4; }
.mk-rug { fill: #8e3f7c; opacity: 0.85; }
.mk-rug-rim { fill: none; stroke: #ffc4ea; stroke-width: 3; stroke-dasharray: 6 8; }

#machineshop .creature-slot { width: 28%; }

/* --------------------------------------------------------------- the benches */

.bench-mk-tools {
  --bench-edge: #ffc46b;
  background: linear-gradient(180deg, #6a4a38, #3d2a22);
  box-shadow: 0 12px 30px rgba(7, 4, 15, 0.55), inset 0 0 0 3px var(--bench-edge);
}
.bench-mk-mats {
  --bench-edge: #e28ccf;
  background: linear-gradient(180deg, #6a3c5e, #3a2040);
  box-shadow: 0 12px 30px rgba(7, 4, 15, 0.55), inset 0 0 0 3px var(--bench-edge);
}
.bench-mk-tools, .bench-mk-mats { position: relative; overflow: visible; }
.bench-mk-tools::after, .bench-mk-mats::after {
  content: ''; position: absolute; top: 50%; width: 22px; height: 22px;
  background: var(--bench-edge); transform: translateY(-50%) rotate(45deg); border-radius: 4px;
}
.bench-mk-tools::after { right: -9px; }
.bench-mk-mats::after  { left: -9px; }
@media (max-aspect-ratio: 5/6) { .bench-mk-tools::after, .bench-mk-mats::after { display: none; } }
/* lighter than the benches, so the grey tools and chains stand out */
.mk-item { background: linear-gradient(180deg, #a98fc0, #7b6497); border-color: rgba(255, 255, 255, 0.35); }
.bench-mk-tools .mk-item { background: linear-gradient(180deg, #c9a27e, #93704f); }
.mk-item[aria-pressed="true"] { border-color: #ffffff; box-shadow: 0 0 0 3px #ffffff, 0 0 16px rgba(255, 226, 168, 0.8); }

/* ---------------------------------------------------------------- the Builder */

.builder {
  position: absolute; aspect-ratio: 300 / 340; transform: translate(-50%, -100%);
  pointer-events: auto;
}
.builder > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible;
  filter: drop-shadow(0 10px 12px rgba(7, 4, 15, 0.55)); }
.builder.bump > svg { animation: bowl-bump 0.35s cubic-bezier(.3, 1.5, .5, 1); }
.builder.over > svg, .builder.can-drop > svg { filter: drop-shadow(0 0 18px rgba(255, 196, 234, 0.9)); }

.mk-foot { fill: #3a2040; }
.mk-cab { fill: #c95fae; stroke: #7a2f68; stroke-width: 4; }
.mk-hopper { fill: #e28ccf; stroke: #7a2f68; stroke-width: 4; stroke-linejoin: round; }
.mk-stack { fill: #8e6f9e; stroke: #3a2040; stroke-width: 3; }
.mk-smoke { fill: #f2e9ff; opacity: 0; }
.mk-crane-arm { fill: none; stroke: #3a2040; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.mk-hammer-head { fill: #b9b2d6; stroke: #3a2040; stroke-width: 3; }
.mk-gear { fill: #ffc46b; stroke: #6a4a20; stroke-width: 2; }
.mk-gear .gear-hole { fill: #3a2040; }
.mk-win { fill: #2a1d48; stroke-width: 4; }
.mk-win-tool { stroke: #ffc46b; }
.mk-win-mat  { stroke: #ffc4ea; }
.mk-plus { stroke: #ffe2f4; stroke-width: 5; stroke-linecap: round; }

/* the pictures in the windows */
.mk-slot { position: absolute; aspect-ratio: 1; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(7, 4, 15, 0.5)); }
.mk-slot[hidden] { display: none; }

/* the button sits a little lower on the Builder than on the Zapper */
.mk-button { top: 80%; width: max(26%, 48px); }

/* Building: the whole thing rattles, the hammer bangs, the cogs turn, the chimney
   puffs, and the four pictures drop into the hopper. */
.builder.building > svg { animation: zap-shake 0.14s linear infinite; }
.builder.building .mk-hammer { animation: mk-bang 0.3s ease-in infinite; }
.builder.building .mk-gear-a { animation: mk-turn 0.9s linear infinite; }
.builder.building .mk-gear-b { animation: mk-turn 0.9s linear infinite reverse; }
.builder.building .mk-smoke { animation: mk-smoke 0.9s ease-out infinite; }
.builder.building .mk-smoke-b { animation-delay: 0.45s; }
.builder.building .mk-slot { animation: mk-drop 1.2s ease-in forwards; }
@keyframes mk-bang { 0%, 100% { rotate: -28deg; } 60% { rotate: 12deg; } }
@keyframes mk-turn { to { rotate: 360deg; } }
@keyframes mk-smoke { 0% { opacity: 0.9; translate: 0 8px; scale: 0.5; } 100% { opacity: 0; translate: 6px -26px; scale: 1.4; } }
@keyframes mk-drop { 40% { translate: 0 -30%; } to { left: 41%; top: 20%; scale: 0.2; opacity: 0; } }

/* ------------------------------------------------------------- the machine */

.result-box-mk {
  background: radial-gradient(ellipse at 50% 45%, #6a3c5e, #33203f 72%);
  box-shadow: inset 0 0 0 3px rgba(255, 196, 234, 0.5), 0 10px 24px rgba(7, 4, 15, 0.45);
}
.dish.made-machine { width: 19%; filter: drop-shadow(0 10px 10px rgba(7, 4, 15, 0.5)) drop-shadow(0 0 18px rgba(255, 154, 213, 0.5)); }
.mk-pic, .mk-pic svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dish.made-machine.wiggle .mk-pic { animation: mk-wiggle 0.7s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes mk-wiggle { 20% { rotate: -8deg; scale: 1.08; } 45% { rotate: 7deg; } 70% { rotate: -4deg; } }

.maker-trash { z-index: 4; }
.maker-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* A machine's moving parts. Each part turns about its own middle unless it says
   otherwise (the arms and the dial carry their own origins). */
.machine-art .m-spin, .machine-art .m-blink, .machine-art .m-puff { transform-box: fill-box; transform-origin: center; }
.machine-art .m-spin { animation: mk-turn 1.6s linear infinite; }
.machine-art .m-blink { animation: zap-blink 1.2s ease-in-out infinite; }
.machine-art .m-puff { animation: mk-smoke 1.8s ease-out infinite; }
.machine-art .m-puff-b { animation-delay: 0.9s; }
.machine-art .m-wave-l { animation: mk-wave-l 1.8s ease-in-out infinite; }
.machine-art .m-wave-r { animation: mk-wave-r 1.8s ease-in-out infinite -0.9s; }
.machine-art .m-dial { animation: mk-dial 2.2s ease-in-out infinite; }
.machine-art .m-boing { animation: mk-boing 0.9s ease-in-out infinite; transform-origin: 120px 232px; }
.machine-art .m-body { animation: mk-hum 2.4s ease-in-out infinite; transform-origin: 120px 232px; }
.machine-art .m-step { animation: mk-step 0.8s ease-in-out infinite; }
.machine-art .m-step-b { animation-delay: -0.4s; }
@keyframes mk-wave-l { 50% { rotate: 14deg; } }
@keyframes mk-wave-r { 50% { rotate: -14deg; } }
@keyframes mk-dial { 30% { rotate: 60deg; } 60% { rotate: -40deg; } }
@keyframes mk-boing { 50% { scale: 1 0.92; } }
@keyframes mk-hum { 50% { translate: 0 -2px; } }
@keyframes mk-step { 50% { translate: 0 -5px; } }

/* On a bench a machine holds still. */
.still .machine-art *, .machine-art.still * { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .machine-art *, .builder.building *, .builder.building > svg { animation: none !important; }
}
