/* Horologist. Luke Steuber. */
@font-face{font-family:"Plex Mono";src:url("./fonts/IBMPlexMono-500.woff2") format("woff2");font-weight:500;font-display:swap}@font-face{font-family:"Plex Sans";src:url("./fonts/IBMPlexSans-400.woff2") format("woff2");font-weight:400;font-display:swap}
:root{color-scheme:light;--bg:#fff;--ink:#000;--text:#111;--sub:#5e5e5e;--line:#d4d4d4;--guide:#8f8f8f;--frame:#1c1c1c;--scrim:rgba(255,255,255,.84);--metal:#eee;--edge:#8c8c8c;--loose:#f5f5f5;--loose-edge:#444;--outline:#737373;--status-fail:#b53a25;--finish-glow:rgba(0,0,0,.16);--mono:"Plex Mono",monospace;--sans:"Plex Sans",sans-serif}
@media(prefers-color-scheme:dark){:root:not([data-theme=light]){color-scheme:dark;--bg:#000;--ink:#fff;--text:#ededed;--sub:#a6a6a6;--line:#2f2f2f;--frame:#ededed;--scrim:rgba(0,0,0,.8);--metal:#222;--edge:#707070;--loose:#111;--loose-edge:#bbb;--outline:#8c8c8c;--status-fail:#ff856f;--finish-glow:rgba(255,255,255,.32)}}
:root[data-theme=dark]{color-scheme:dark;--bg:#000;--ink:#fff;--text:#ededed;--sub:#a6a6a6;--line:#2f2f2f;--frame:#ededed;--scrim:rgba(0,0,0,.8);--metal:#222;--edge:#707070;--loose:#111;--loose-edge:#bbb;--outline:#8c8c8c;--status-fail:#ff856f;--finish-glow:rgba(255,255,255,.32)}
*{box-sizing:border-box;border-radius:0}body{margin:0;height:100dvh;overflow:hidden;background:var(--bg);color:var(--text);font:16px/1.45 var(--sans);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}button,select{font:inherit;color:inherit}button{cursor:pointer}button:disabled{opacity:.35;cursor:default}button:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.readout{position:fixed;top:max(18px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);font:500 13px/1 var(--mono);letter-spacing:.02em;color:var(--sub);font-variant-numeric:tabular-nums;white-space:nowrap}#restart-btn{position:fixed;left:8px;top:max(0px,env(safe-area-inset-top));z-index:2}
#board{position:absolute;inset:52px 12px 66px;user-select:none;overscroll-behavior:none}#works{display:block;width:100%;height:100%;overflow:visible}#targets{position:absolute;inset:0;pointer-events:none}.piece-target{position:absolute;min-width:44px;min-height:44px;padding:0;border:0;background:transparent;pointer-events:auto;transform:translate(-50%,-50%);border-radius:50%;color:var(--ink)}.piece-target:focus-visible{outline:2px solid var(--ink);outline-offset:4px}#next-btn{position:absolute;right:0;top:0}#next-btn:not([hidden]){animation:arrive .45s .6s both}@keyframes arrive{from{opacity:0}to{opacity:1}}#next-btn[hidden]{display:none}
.toolbar{position:fixed;bottom:max(6px,env(safe-area-inset-bottom));left:8px;right:8px;display:flex;justify-content:space-between}.toolbar>div{display:flex}.ib{display:inline-grid;place-items:center;width:48px;height:48px;min-width:48px;min-height:48px;border:0;background:none;padding:12px;color:var(--ink)}.ib svg{width:24px;height:24px;stroke:currentColor;fill:none;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.ib:active{transform:scale(.94)}
.sheet{width:min(32rem,calc(100vw - 16px));max-height:calc(100dvh - 16px);border:1px solid var(--frame);padding:0;background:var(--bg);color:var(--text)}.sheet[open]{display:flex;flex-direction:column}.sheet::backdrop{background:var(--scrim)}.sheet-head{display:flex;justify-content:space-between;align-items:center;padding:8px 16px;gap:12px;flex:none;border-bottom:1px solid var(--line)}h2{margin:0;font:500 16px/1.3 var(--mono)}.sheet-head form{margin:0}.sheet-x{width:44px;height:44px;min-width:44px;min-height:44px;font:28px/1 var(--sans)}.sheet-body{padding:20px 24px;overflow:auto;min-height:0}.sheet-body p{max-width:60ch;margin:0 0 16px}.row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:52px;border-bottom:1px solid var(--line)}.row select{max-width:65%;min-height:44px;background:var(--bg);border:0;padding:4px 8px}.row button{min-height:44px;background:none;border:0;padding:8px}.row button:not(:disabled){text-decoration:underline;text-underline-offset:4px}.sheet-foot{padding:12px 24px;border-top:1px solid var(--line);flex:none;color:var(--sub);font-size:14px}.sheet-foot a{color:inherit}
.gear-face{fill:var(--metal);stroke:var(--edge);stroke-width:1}.spoke{stroke:var(--edge);stroke-width:1.5;fill:none}.loose .gear-face{fill:var(--loose);stroke:var(--loose-edge);stroke-width:1.5}.loose .spoke{stroke:var(--loose-edge);stroke-width:2}.pinion .gear-face{fill:var(--bg);stroke-width:1.5}.arbor{fill:var(--bg);stroke:var(--sub);stroke-width:1.5}.dial-ring,.dial-tick{fill:none;stroke:var(--sub);stroke-width:1}.hand-halo{fill:var(--bg);stroke:var(--bg);stroke-width:4;stroke-linejoin:round}.hand-outline{fill:none;stroke:var(--outline);stroke-width:2;stroke-linejoin:round}.hand-solid{fill:var(--ink);stroke:var(--bg);stroke-width:1;stroke-linejoin:round}.dial-sign{stroke:var(--ink);stroke-width:2;fill:none;stroke-linecap:round;stroke-linejoin:round}.rail{stroke:var(--line);stroke-width:1;fill:none}.rule{stroke:var(--guide);stroke-width:1;fill:none}.socket{fill:none;stroke:var(--line);stroke-width:1;stroke-dasharray:2 5}.selection,.obstacle{fill:none;stroke:var(--ink);stroke-width:2}.preview{opacity:.35}.removing{opacity:.28}.end-pulse{fill:none;stroke:var(--ink);stroke-width:2}
@media(orientation:landscape) and (max-height:500px){#board{inset:46px 76px 12px 12px}.toolbar{left:auto;right:8px;top:12px;bottom:12px;flex-direction:column;width:48px}.toolbar>div{flex-direction:column}.readout{left:calc(50% - 32px)}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}:root[data-motion=reduce] *{animation:none!important;transition:none!important}
/* Plate, hands and escapement. Luke Steuber. */
#targets .piece-target{pointer-events:none}#targets .piece-target:focus-visible{outline:2px solid var(--ink)}
.hole{fill:var(--guide)}.hole.unavailable{opacity:.22}.catch-ring{fill:var(--ink);stroke:none}.catch-ring.pulsing{fill:var(--ink)}
.gear-face{stroke-width:.8}.wheel.loose .gear-face,.tray-wheel .gear-face{stroke-width:1}.spoke{stroke-width:1}.turn-mark{fill:var(--sub)}
.drive .gear-face{fill:var(--loose);stroke:var(--ink);stroke-width:2.2}.drive .spoke,.drive .turn-mark{stroke:var(--guide);fill:var(--guide)}.drive .arbor{fill:var(--ink);stroke:var(--ink)}
.clock .gear-face{fill:var(--metal)}.face-ground{fill:var(--bg);stroke:none}.clock-ring,.clock-tick{fill:none;stroke:var(--ink);stroke-width:1.3}.clock.right .clock-ring,.clock.right .clock-tick{stroke:var(--sub);stroke-width:1}.clock.still .clock-ring,.clock.back .clock-ring{stroke-width:2.2}.clock-hand{fill:none;stroke:var(--ink);stroke-linecap:round}.clock-hand.second{stroke:var(--sub)}.hand-halo{fill:none;stroke:var(--bg);stroke-linecap:round}.hand-pin{fill:var(--ink)}
.spring{fill:none;stroke:var(--ink);stroke-linecap:round}.plate{fill:none;stroke:var(--line);stroke-width:1}.drive .spoke,.drive .turn-mark{display:none}.pillar{fill:var(--metal);stroke:var(--ink);stroke-width:1.3}.post-slot{fill:none;stroke:var(--ink);stroke-width:1.5;stroke-linecap:round}
.locked .gear-face{stroke:var(--status-fail)!important;stroke-width:3!important}.touch-ring{fill:none;stroke:var(--sub);stroke-width:2}.obstacle{stroke-width:3}.key-ring{fill:none;stroke:var(--ink);stroke-width:2;stroke-dasharray:3 3}.hint-ring{fill:none;stroke:var(--ink);stroke-width:2.5}.drag-wheel{opacity:.55}.preview{opacity:.28}.selection{stroke-width:1.5}

.rim-mark{fill:none;stroke:var(--ink);stroke-width:1.5;stroke-linecap:round}

/* Lift and finish: the solved movement rises to the middle; the plate's holes, screws, edge and the tray fade away. */
#stage{transition:transform .8s cubic-bezier(.3,.7,.2,1)}#stage *{vector-effect:non-scaling-stroke}
#tray,#holes,.plate,.pillar,.post-slot{transition:opacity .5s}
svg.solved #tray,svg.solved #holes,svg.solved .plate,svg.solved .pillar,svg.solved .post-slot{opacity:0}
/* The wheel in hand stands out; the rest of the tray steps back. */
.tray-wheel{transition:opacity .2s}
.tray-wheel.waiting{opacity:.4}
.tray-wheel.in-hand .gear-face{stroke:var(--ink);stroke-width:2.2}
/* Contacts and obstacles are told by the wheel's own edge, not a ring round it. */
.wheel.touching .gear-face{stroke:var(--ink);stroke-width:1.8}
.wheel.obstructing .gear-face{stroke:var(--ink);stroke-width:3.2}
.pillar.obstructing{stroke-width:3}
.barrel-wall{fill:none;stroke:var(--ink)}
.barrel-hub{fill:var(--ink)}
@media(prefers-reduced-motion:reduce){#stage,#tray,#holes,.plate,.pillar,.post-slot,.tray-wheel{transition:none}#next-btn:not([hidden]){animation:none}}
:root[data-motion=reduce] #stage,:root[data-motion=reduce] #tray,:root[data-motion=reduce] #holes,:root[data-motion=reduce] .plate,:root[data-motion=reduce] .pillar,:root[data-motion=reduce] .post-slot{transition:none}:root[data-motion=reduce] #next-btn:not([hidden]){animation:none}

/* Only backwards clocks and jams use colour; patterns still carry the state. */
.clock.still:not(.jammed) .clock-ring{stroke-dasharray:1 4;stroke-linecap:round}
.wheel.clock[data-status=back] .gear-face,.wheel.clock[data-status=jammed] .gear-face,.clock.back .clock-ring,.clock.jammed .clock-ring{stroke:var(--status-fail)}
.clock.jammed .clock-ring{stroke-width:3;stroke-dasharray:none}

/* One steady completion light across the movement, with no success hue. */
svg.solved .wheel .gear-face{fill:var(--metal);stroke:var(--ink)}
svg.solved .wheel .spoke,svg.solved .wheel .arbor,svg.solved .clock .clock-ring,svg.solved .clock .clock-tick,svg.solved .clock .clock-hand.second{stroke:var(--ink)}
svg.solved .wheel .turn-mark{fill:var(--ink)}
svg.solved #stage{filter:drop-shadow(0 0 1.6px var(--finish-glow))}
@media(forced-colors:active){svg.solved #stage{filter:none}}
