/* Live factory scene. Room, sprites, interactive targets and effects are separate. */
#gift-workshop:where(:not([data-screen="RUNE"])) {
  & .gw-scene { position: relative; overflow: hidden; isolation: isolate; }
  & .gw-basket small { display: none; }
  & .gw-stations {
    position: absolute;
    inset: 0 2%;
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    z-index: 2;
  }
  & .gw-station { position: relative; min-width: 0; isolation: isolate; }
  & .gw-equipment {
    position: absolute;
    z-index: 4;
    right: 0;
    bottom: 16%;
    width: var(--gw-machine-width, 66%);
    height: var(--gw-sprite-height, 74%);
    aspect-ratio: 3 / 4;
    pointer-events: none;
  }
  & .gw-equipment::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('assets/workshop-r03/machines.png') var(--gw-machine-cell) center / 400% 100% no-repeat;
    filter: drop-shadow(1px 3px 3px #31170988);
  }
  & .gw-equipment-sort { --gw-machine-cell: 0%; }
  & .gw-equipment-fill { --gw-machine-cell: 33.333333%; }
  & .gw-equipment-charge { --gw-machine-cell: 66.666667%; }
  & .gw-equipment-check { --gw-machine-cell: 100%; }
  & .gw-equipment svg { position: relative; z-index: 2; width: 100%; height: 100%; overflow: visible; }
  & .gw-equipment svg > :not(.wm-dust,.wm-ring,.wm-core) { opacity: 0; }
  & .wm-wheel { transform-origin: 156px 139px; }
  & .wm-ring { transform-origin: 109px 113px; }
  & .gw-equipment-charge::after {
    content: '';
    position: absolute;
    z-index: 1;
    left: 26%;
    top: 24%;
    width: 48%;
    height: 40%;
    border-radius: 50%;
    background: radial-gradient(ellipse,#3b6c73,#163d45);
    box-shadow: inset 0 0 14px #a7e9e855;
  }
  & .gw-equipment-charge .wm-ring > circle:first-child { stroke-width: 3; stroke: #d8b966; fill: none; }
  & :is(.gw-worker,.gw-slot-hit,.gw-machine-control) {
    position: absolute;
    display: block;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  & .gw-worker {
    left: -1%;
    bottom: 17%;
    width: var(--gw-worker-width, 61%);
    height: var(--gw-sprite-height, 72%);
    aspect-ratio: 3 / 4;
    z-index: 3;
    filter: drop-shadow(2px 5px 3px #25160988);
  }
  & .gw-worker .gw-portrait { width: 100%; height: 100%; }
  & .gw-worker .gw-character { object-position: center bottom; }
  & .gw-slot-hit { inset: 12% 0 21% 42%; z-index: 5; }
  & .gw-machine-control {
    right: 22%;
    bottom: 38%;
    width: clamp(28px,6vw,54px);
    height: clamp(28px,8vh,62px);
    z-index: 7;
    transform-origin: 70% 70%;
  }
  & .gw-machine-light {
    position: absolute;
    right: 2px;
    bottom: 5px;
    width: 10px;
    height: 10px;
    border: 2px solid #c1aa6f;
    border-radius: 50%;
    background: #767655;
    box-shadow: 0 0 0 2px #3d3324;
  }
  & .gw-machine-light[data-state="working"] { background: #bce7bf; box-shadow: 0 0 9px #baebad; }
  & .gw-machine-light[data-state="problem"] { background: #f2ca75; box-shadow: 0 0 9px #e7ac54; }
  & :is(.gw-worker-pose,.gw-new-elf) {
    background-repeat: no-repeat;
    background-size: 400% 100%;
    background-position: calc(var(--elf-cell) * 100% / 3) center;
  }
  & .gw-new-elf { display: block; width: 100%; height: 100%; background-image: url('assets/workshop-r03/nori-sivi.png'); }
  & .gw-worker-pose { display: none; position: absolute; inset: 0; background-image: url('assets/workshop-r03/working-elves.png'); }
  & .gw-new-pose { background-image: url('assets/workshop-r03/nori-sivi.png'); }
  & .gw-silhouette { display: block; height: 70%; border-radius: 50%; background: #ba9a63; }
  & .gw-automaton {
    position: absolute;
    bottom: 24%;
    left: 11%;
    color: #cfa664;
    text-shadow: 0 3px #402619;
    font-size: clamp(23px,5vh,47px);
    line-height: 1;
  }
  & .gw-belt {
    position: absolute;
    z-index: 6;
    inset: auto 3% 12%;
    height: 12%;
    border: 4px solid #bd8641;
    border-radius: 999px;
    background: repeating-linear-gradient(90deg,#434643 0 32px,#242d2c 33px 38px,#72705b 39px 40px);
    box-shadow: 0 4px #3a251d, 0 7px #a7763c, inset 0 2px #b7a67d;
    pointer-events: none;
  }
  & .gw-belt-lines {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(90deg,transparent 0 48px,#c8af7933 49px 53px,transparent 55px 103px);
  }
  & .gw-belt-bag {
    position: absolute;
    left: var(--parcel-x);
    bottom: 48%;
    width: calc(25px + var(--parcel-fill,0) * 13px);
    height: calc(28px + var(--parcel-fill,0) * 16px);
    display: grid;
    place-items: center;
    isolation: isolate;
    transform: translateX(-50%);
    border: 2px solid #a06e32;
    border-radius: 10px 10px 16px 16px;
    background: linear-gradient(100deg,#c69344,#f1cf80 40%,#ca9b4a);
    color: #785024;
    box-shadow: 2px 4px 4px #25170b66;
    transition: width .25s, height .25s;
  }
  & .gw-bag-fill { position: absolute; inset: 4px; border-radius: inherit; background: #e9c96388; transform: scaleY(var(--parcel-fill,0)); transform-origin: bottom; z-index: -1; }
  & .gw-bag-tie { position: absolute; inset: -5px 25% auto; height: 7px; border: 2px solid #936c3c; border-radius: 5px; }
  & :is(.gw-bag-rune,.gw-bag-seal) { position: absolute; display: none; }
  & .gw-bag-rune { color: #e1f5ff; font-size: 19px; text-shadow: 0 0 8px #487ebc; }
  & .gw-bag-seal { bottom: 0; right: 2px; color: #9e623d; font-size: 12px; }
  & .gw-belt-bag:is([data-stage="charged"],[data-stage="checked"]) .gw-bag-rune,
  & .gw-belt-bag[data-stage="checked"] .gw-bag-seal { display: block; }
  & .gw-belt-bag:is([data-stage="charged"],[data-stage="checked"]) .gw-bag-mark { opacity: .2; }
  & .gw-basket {
    position: absolute;
    z-index: 6;
    bottom: 16%;
    right: 0;
    width: 5%;
    height: 13%;
    display: grid;
    place-items: center;
    border: 2px solid #ae854d;
    border-radius: 5px 5px 13px 13px;
    background: repeating-linear-gradient(90deg,#8b6940 0 6px,#5f482c 7px 10px);
    color: #e8ca91;
    pointer-events: none;
  }
  & .gw-is-ready .gw-basket { box-shadow: 0 0 22px #f3d98a88; }
  & .gw-is-running .gw-belt-lines { animation: gw-track 1.8s linear infinite; }
  & .gw-is-running .gw-automaton { animation: gw-r03-turn 12s linear infinite; }
  & .gw-performing .gw-working-actor .gw-character { visibility: hidden; }
  & .gw-performing .gw-worker-pose { display: block; animation: gw-r03-work 1.3s ease-in-out infinite; }
  & .gw-performing .gw-machine-control { animation: gw-lever-pull 1.3s ease-in-out infinite; }
  & .gw-performing .wm-wheel { animation: gw-r03-turn 2s linear infinite; }
  & .gw-performing .wm-roller { animation: gw-r03-roll 1s ease-in-out infinite; }
  & .gw-performing .wm-dust { animation: gw-r03-dust .5s linear infinite; }
  & .gw-performing .wm-ring { animation: gw-r03-turn 8s linear infinite; }
  & .gw-performing .wm-core { filter: drop-shadow(0 0 12px #b1faff); }
  & .gw-performing .wm-press { animation: gw-r03-press 1.2s ease-in-out infinite; }
  & .gw-performing .gw-equipment-sort::before { animation: gw-r03-feed .85s ease-in-out infinite; }
  & .gw-performing .gw-equipment-check::before { animation: gw-r03-feed 1.3s ease-in-out infinite; }
  & .gw-performing .gw-equipment-fill::before { filter: drop-shadow(0 0 6px #ffe19e); }
  & .gw-performing .gw-equipment-charge::after { box-shadow: inset 0 0 20px #8ce8f0, 0 0 14px #8ce8f077; }
  & .gw-ability-worker .gw-worker { filter: drop-shadow(0 0 9px #f4d37b); }
  & .gw-ability-worker[data-elf="lumi"] .gw-worker { filter: drop-shadow(0 0 10px #9af0ff); }
  & .gw-ability-worker[data-elf="sivi"] .gw-worker { filter: drop-shadow(0 0 10px #d7b4ef); }
  & .gw-scene[data-ability="sivi"] .gw-belt-bag { box-shadow: 0 0 0 5px #e5d2c344, 0 0 18px #ebd4ff; }
  & .gw-scene[data-ability="nori"] .gw-bag-mark { filter: drop-shadow(0 0 8px #ffd46e); }
  & .gw-scene[data-ability="freya"] .gw-belt { box-shadow: 0 0 18px #e2b85d; }
}

@keyframes gw-track { to { transform: translateX(103px); } }
@keyframes gw-r03-work { 50% { transform: translate(3px,2px) rotate(1deg); } }
@keyframes gw-r03-turn { to { transform: rotate(360deg); } }
@keyframes gw-r03-roll { 50% { transform: translateY(4px); } }
@keyframes gw-r03-dust { to { stroke-dashoffset: -20; } }
@keyframes gw-r03-press { 45%,65% { transform: translateY(22px); } }
@keyframes gw-r03-feed { 45% { transform: translateY(3px); } }
@keyframes gw-lever-pull { 45% { transform: rotate(18deg) translateY(3px); } }

@media (prefers-reduced-motion: reduce) {
  #gift-workshop .gw-scene * { animation: none !important; transition: none !important; }
}