/* Стили «Аварийной смены». Подключать после общего app.css Фабрики:
   используются общие переменные палитры, safe-area и базовые стили кнопок. */

/* Emergency shift: the same light factory palette, with four physical stations. */
.game-screen[data-game="shift"] { background: var(--paper) url('/static/assets/conveyor-blueprint-background.svg') center / cover; }
.game-screen[data-game="shift"] .game-eyebrow, .game-screen[data-game="shift"] .game-status { display: none; }
.game-screen[data-game="shift"] .game-dom { padding-top: .6rem; }
.game-screen[data-game="shift"] .game-info, .game-screen[data-game="shift"] .timer-badge { background: var(--accent); color: white; border: 0; }
.shift-game { position: relative; width: 100%; max-width: 36rem; margin: 0 auto; padding-bottom: 1rem; }
.shift-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7rem; gap: .5rem; }
.shift-count { font-size: .62rem; font-weight: 700; color: var(--muted); }
.shift-workers { display: flex; gap: .28rem; color: var(--ink); }
.shift-workers svg { width: 1.5rem; height: 1.7rem; transform-origin: 50% 100%; transition: opacity .4s ease, translate .55s cubic-bezier(.34,1.56,.64,1), rotate .55s cubic-bezier(.34,1.56,.64,1); }
.shift-workers .off-duty { opacity: .2; translate: 0 .2rem; rotate: 18deg; }
.shift-task { padding: 1rem 1.1rem; border-radius: 1.3rem; background: var(--accent); }
.shift-task > div { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.shift-command { display: inline-block; font-weight: 800; font-size: 1.15rem; letter-spacing: -.03em; transform-origin: 0 60%; }
.shift-name { font-size: .62rem; font-weight: 700; text-align: right; }
.shift-task h2 { font-size: 1.25rem; font-weight: 600; margin: .7rem 0 .3rem; line-height: 1.2; overflow-wrap: anywhere; }
.shift-task p { font-size: max(12px,.67rem); line-height: 1.4; margin: 0; }
.shift-stage { position: relative; height: 19.8rem; min-height: 280px; margin-top: .7rem; border: 1px solid var(--line); border-radius: 1.35rem; overflow: hidden; background: rgba(252,253,255,.95); touch-action: none; user-select: none; -webkit-user-select: none; transition: border-color .3s; }
.shift-stage-note { position: absolute; bottom: .55rem; left: .65rem; right: .65rem; font-weight: 700; font-size: .48rem; color: var(--muted); text-align: center; }

/* Station: cut. The rig keeps the drawing and its labels in one proportional box,
   so the stage has the same height as every other station. */
.shift-rig { position: relative; height: calc(100% - 2.8rem); max-width: calc(100% - 1rem); aspect-ratio: 360 / 314; margin: .7rem auto 0; }
.shift-machine { position: absolute; top: 0; left: 0; display: block; width: 100%; height: auto; overflow: visible; }
.shift-press { transition: none; }
.shift-rod { transform-box: fill-box; transform-origin: 50% 0; }
.shift-bulb { transform-box: fill-box; transform-origin: 50% 100%; transition: opacity .25s .1s, scale .22s cubic-bezier(.5,0,1,.5); }
.shift-glow { opacity: 0; transition: opacity .4s; }
/* Buttons start exactly where the wires end (260 of 314 units), so each wire plugs into its word. */
.shift-wire-labels { position: absolute; left: 0; right: 0; top: calc(100% * 260 / 314); bottom: 0; }
.shift-wire-button { position: absolute; top: 0; bottom: 0; width: 31%; translate: -50% 0; border: 1.5px solid var(--accent); border-radius: .65rem; background: var(--surface); padding: 0 .2rem; font-size: .82rem; font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; transition: opacity .3s, scale .15s; }
.shift-wire-button:active { scale: .97; }
.shift-wire-button.is-cut { text-decoration: line-through; opacity: .4; }
.wire-top, .wire-end { transform-box: fill-box; transform-origin: 50% 0; fill: none; }
.wire-end { transition: translate .55s cubic-bezier(.5,0,.9,.55), rotate .55s ease-in, opacity .25s .3s ease-in; }
/* The stub sways once and comes to rest straight; the loose end falls away. */
.shift-wire.is-cut .wire-top { animation: shift-sway .8s ease-out; }
@keyframes shift-sway { 25% { rotate: var(--swing); } 55% { rotate: calc(var(--swing) * -.4); } 80% { rotate: calc(var(--swing) * .12); } }
.shift-wire.is-cut .wire-end { translate: 0 24px; rotate: calc(var(--swing) * -2.5); opacity: 0; }
.wire-spark { opacity: 0; }
.wire-spark path { transform-box: fill-box; transform-origin: center; }
.shift-wire.is-cut .wire-spark { opacity: 1; }
.shift-wire.is-cut .wire-spark path { animation: shift-spark .42s ease-out both; }
@keyframes shift-spark { from { opacity: 1; scale: .35; } 60% { opacity: 1; } to { opacity: 0; scale: 1.5; } }

/* Station: scale. */
.shift-scale { display: flex; height: calc(100% - 2.5rem); gap: 1.4rem; align-items: stretch; padding: 1.4rem 1.2rem .2rem; }
/* The gauge uses the same rows as the cards, so every mark sits on its card's centre line. */
.shift-thermometer { position: relative; width: 1.4rem; flex-shrink: 0; display: grid; grid-template-rows: repeat(var(--scale-count,3),1fr); gap: .75rem; place-items: center; }
.shift-thermometer::before { content: ''; position: absolute; left: calc(50% - .2rem); width: .4rem; top: calc((100% - (var(--scale-count,3) - 1) * .75rem) / var(--scale-count,3) / 2); bottom: calc((100% - (var(--scale-count,3) - 1) * .75rem) / var(--scale-count,3) / 2); border-radius: 1rem; background: linear-gradient(#d9e3ff, var(--accent)); transform-origin: 50% 0; }
.shift-thermometer i { position: relative; border-radius: 50%; border: 2px solid var(--ink); background: #d9e3ff; }
.shift-thermometer i:nth-child(1) { width: .75rem; height: .75rem; }
.shift-thermometer i:nth-child(2) { width: 1rem; height: 1rem; background: #94aaff; }
.shift-thermometer i:nth-child(3) { width: 1.25rem; height: 1.25rem; background: var(--accent); }
.shift-success .shift-thermometer::before { animation: shift-fill .6s cubic-bezier(.2,.8,.2,1); }
@keyframes shift-fill { from { scale: 1 0; } }
.shift-scale-words { display: grid; grid-template-rows: repeat(var(--scale-count,3),1fr); gap: .75rem; flex: 1; min-width: 0; }
.shift-scale-word { position: relative; display: flex; align-items: center; gap: .6rem; padding: .7rem; border: 1.5px solid var(--line); background: var(--surface); border-radius: .8rem; min-width: 0; touch-action: none; transition: transform .28s cubic-bezier(.2,.8,.2,1), scale .18s ease, border-color .2s, background-color .2s, box-shadow .2s; }
.shift-scale-word span { font-size: .65rem; color: var(--accent); font-weight: 700; }
.shift-scale-word strong { font-size: .92rem; overflow-wrap: anywhere; }
.shift-scale-word b { margin-left: auto; color: var(--muted); }
.shift-scale-word.selected { border-color: var(--accent); background: #edf1ff; scale: 1.02; }
.shift-scale-word.is-dragging { z-index: 4; background: #edf1ff; border-color: var(--accent); box-shadow: 0 .4rem 1rem #10141c24; scale: 1.03; transition: scale .18s ease, box-shadow .2s; cursor: grabbing; }
.shift-scale-word.is-settling { z-index: 3; }

/* Station: ball. Position is driven from JS with transform. */
/* The field fills the stage (no second frame inside the stage frame); a thin rule separates the note. */
.shift-board { position: absolute; inset: 0 0 1.9rem; border-bottom: 1.5px solid #e4e7ed; background: radial-gradient(#dce3f1 1px,transparent 1px) 9px 9px / 18px 18px; }
.shift-hole { position: absolute; left: var(--hole-x); top: 24%; width: 30%; translate: -50% -1rem; text-align: center; }
.shift-hole i { display: block; width: 2rem; height: 2rem; border-radius: 50%; background: var(--ink); margin: 0 auto; box-shadow: inset 0 .2rem .3rem #000, 0 0 0 .25rem #e4e7ed; transition: box-shadow .25s; }
.shift-hole span { display: block; margin-top: .7rem; font-size: max(12px,.7rem); font-weight: 700; overflow-wrap: anywhere; transition: color .25s; }
.shift-hole.is-near i { box-shadow: inset 0 .2rem .3rem #000, 0 0 0 .25rem #c4d3ff; }
.shift-hole.is-near span, .shift-hole.is-answer span { color: var(--accent); }
.shift-hole.is-answer i { box-shadow: inset 0 .2rem .3rem #000, 0 0 0 .25rem var(--accent); }
.shift-ball { position: absolute; left: 0; top: 0; width: 1.4rem; height: 1.4rem; translate: -50% -50%; border-radius: 50%; background: radial-gradient(circle at 32% 27%,white 0%,#a8bfff 22%,#6a90ff 60%,#4569ca); box-shadow: .1rem .2rem .25rem #10141c33; z-index: 2; will-change: transform; }
.shift-ball.is-sinking { transition: transform .24s cubic-bezier(.5,0,.8,.4), opacity .2s .08s ease-in, box-shadow .12s; box-shadow: none; opacity: .15; }
.shift-board-arrow { position: absolute; left: 50%; top: 51%; translate: -50%; color: #bdc9e7; font-size: 2rem; transition: opacity .4s, translate .4s; }
.shift-board-arrow.is-faded { opacity: 0; translate: -50% -.5rem; }

/* Station: crane. Positions of the trolley, cable, load and shadow are driven from JS (transform only). */
.shift-crane { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.shift-crane:active { cursor: grabbing; }
.crane-beam { position:absolute;left:.85rem;right:.85rem;top:1.05rem;height:.6rem;border-radius:1rem;background:var(--ink); }
.crane-beam::before { content: ''; position: absolute; left: .6rem; right: .6rem; top: calc(50% - 1px); height: 2px; border-radius: 1px; background: rgba(252, 253, 255, .16); }
.crane-trolley { position:absolute;left:0;top:1.6rem;width:3.4rem;height:1.15rem;margin-left:-1.7rem;border-radius:.4rem;background:linear-gradient(180deg,#819eff,var(--accent));box-shadow:0 .2rem .45rem #687eff26;will-change:transform; }
.crane-trolley i { position: absolute; top: -.42rem; width: .62rem; height: .62rem; border: 2px solid var(--ink); border-radius: 50%; background: var(--surface); }
.crane-trolley i:first-child { left: .45rem; }.crane-trolley i:last-child { right: .45rem; }
.crane-cable { position: absolute; left: -1px; top: 0; width: 2px; border-radius: 1px; background: var(--ink); transform-origin: 50% 0; will-change: transform; }
.crane-hook { position:absolute;left:50%;bottom:-3px;width:6px;height:6px;margin-left:-3px;border-radius:2px;background:var(--ink);transform-origin:50% 0;transition:transform .24s ease,opacity .24s ease; }
.crane-hook.is-open { transform:translateY(-3px) scaleX(.65);opacity:.5; }
/* The load sits behind the platforms, so a wrong trapdoor swallows it cleanly.
   The trapdoor is a pair of sliding doors that retract to the edges of the deck. */
.crane-load { width:max-content;max-width:48%;position: absolute; left: 0; top: 0; z-index: 2; padding-top: .65rem; transform-origin: 50% 0; will-change: transform; }
.crane-box { position: relative; display: grid; place-items: center; min-width: 5.4rem; max-width: 100%; min-height: 3rem; padding: .65rem .85rem; border: 1.5px solid var(--accent); border-radius: .65rem; background: var(--surface); box-shadow: 0 .3rem .8rem rgba(46, 64, 108, .09); transform-origin: 50% 100%; }
.crane-box::after { content:'';position:absolute;left:50%;top:-.65rem;width:.65rem;height:.65rem;transform:translateX(-50%);border:2px solid var(--ink);border-radius:50%;background:var(--surface); }
.crane-box b { font-size: .88rem; font-weight: 700; line-height: 1.3; text-align: center; overflow-wrap: anywhere; }
.crane-shadow { position: absolute; left: 0; top: 0; z-index: 1; width: 4.6rem; height: .45rem; margin: -.225rem 0 0 -2.3rem; border-radius: 50%; background: rgba(16, 20, 28, .14); opacity: 0; will-change: transform, opacity; }
.crane-platforms { position: absolute; left: .85rem; right: .85rem; bottom: .85rem; z-index: 3; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.crane-platform { appearance:none;-webkit-appearance:none;position:relative;display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;width:100%;min-width:0;height:4.2rem;margin:0;padding:0;border:0;border-radius:.65rem;background:transparent; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.crane-hatch { position:relative;z-index:0;display:flex;align-self:stretch;flex:0 0 .55rem;width:100%;height:.55rem; }
.crane-hatch i { display:block;flex:1 1 50%;min-width:0;height:100%; background: var(--ink); transition: scale .32s cubic-bezier(.22,.68,.25,1), background-color .2s; }
.crane-hatch i:first-child { border-radius: .35rem 0 0 .35rem; transform-origin: 0 50%; }
.crane-hatch i:last-child { border-radius: 0 .35rem .35rem 0; transform-origin: 100% 50%; }
.crane-platform.is-open .crane-hatch i { scale: .14 1; }
.crane-platform strong { position: relative; z-index: 1; display: grid; place-items:center;align-self:stretch;flex:1;width:calc(100% - .65rem);margin:0 .325rem; border-radius:0 0 .65rem .65rem;background:linear-gradient(180deg,#e5ecff,#dce6ff); font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; transition: background-color .22s ease, color .22s ease; }
.crane-platform.is-target strong { background: #cddaff; }
.crane-platform.is-answer strong { background: var(--accent); color: var(--surface); }
.crane-platform:active:not(:disabled) { opacity:1; }
.crane-platform:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: .5rem; }
.shift-controls .shift-crane-hint { margin: .9rem 0 0; }

.shift-progress { height: .25rem; background: #dfe5ef; border-radius: 1rem; margin: 1rem 0 .7rem; overflow: hidden; }
.shift-progress i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: 0 50%; will-change: transform; }
.shift-controls { min-height: 3.5rem; text-align: center; }
.shift-controls > button { width: 100%; min-height: 3rem; font-size: .8rem; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.shift-controls p,.shift-tilt-status { display: block; color: var(--muted); font-size: .6rem; line-height: 1.4; }
.shift-intro { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: .7rem; background: #f5f6f9dc; border-radius: 1.3rem; }
.shift-intro > div { background: var(--surface); border: 2px solid var(--accent); border-radius: 1.3rem; padding: 1.2rem; box-shadow: 0 1rem 2rem #10141c16; animation: dialog-enter .28s ease-out; }
.shift-intro h3 { margin: .5rem 0; font-size: 1.4rem; }.shift-intro p { font-size: .8rem; line-height: 1.5; }.shift-intro .kicker { font-size: .6rem; }
.shift-intro button { width: 100%; margin-top: .7rem; min-height: 3rem; font-size: .72rem; white-space: normal; }

/* Station changes: new content rises in, old content fades out before the swap. */
.shift-stage > * { animation: shift-in .34s cubic-bezier(.2,.8,.2,1) backwards; }
.shift-game.is-leaving .shift-stage > * { opacity: 0; translate: 0 -.35rem; transition: opacity .2s ease-in, translate .2s ease-in; }
@keyframes shift-in { from { opacity: 0; translate: 0 .5rem; } }

.shift-success { border-color: var(--accent); }
.shift-success .shift-glow { opacity: .14; animation: shift-glow 1.1s ease-in-out .15s infinite alternate; }
@keyframes shift-glow { to { opacity: .24; } }
.shift-success .shift-press { transform: none !important; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.shift-success .shift-rod { transform: none !important; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.shift-accident { border-color: var(--danger); }
.shift-accident .shift-press { transform: translateY(82px) !important; transition: transform .2s cubic-bezier(.55,0,1,.45); }
.shift-accident .shift-rod { transform: scaleY(14.67) !important; transition: transform .2s cubic-bezier(.55,0,1,.45); }
.shift-accident .shift-bulb { opacity: .4; scale: 1.1 .5; }
@media (min-width:700px) { .game-screen[data-game="shift"] .game-dom { max-width: 36rem; margin: 0 auto; width: 100%; } .shift-stage { height: 20rem; } }
@media (prefers-reduced-motion:reduce) { .shift-game *, .shift-game *::after { animation: none !important; transition: none !important; } }
.game-screen[data-game="shift"] .shift-stage { height: clamp(230px, calc(100dvh - var(--app-safe-top) - var(--app-safe-bottom) - 22rem), 19.8rem); min-height: 230px; }
