"use client"; /** * safe.tsx — a brushed-steel plate with a combination dial and a heavy vault door. * Hover and the dial ticks through its detents; click dials the code, swings the door open on warm gold, then locks again. * * Part of toy-buttons. MIT licensed. Only depends on React. */ import { useEffect, useId, useImperativeHandle, useRef, useState, type ButtonHTMLAttributes, type MouseEvent, type ReactNode, type Ref } from "react"; type Props = Omit, "children"> & { children?: ReactNode; ref?: Ref; /** the three numbers (0-99) the dial is turned to: right, left, right */ code?: [number, number, number]; }; const W = 290; const H = 116; const DIAL = 104; const DIAL_CX = 232; const DIAL_CY = 58; const OPEN = 118; // door angle, degrees const STEP = 3.6; // one dial tick const ACCENT = "#e6b468"; const GOLD = "#e6b468"; const REST_TEXT = "#d6dadd"; const T_END = 3300; const T_DOOR = 940; const T_OPEN = 1560; const T_CLOSE = 2400; const T_IMPACT = 2860; const HOLD_EXTRA = 800; const EDGE_LAYERS = 10; const EDGE = ["#a9b0b6", "#7d8389", "#5d6267", "#53585c", "#25282b", "#53585c", "#4a4f53", "#41454a", "#33373a", "#232527"]; const TICK_ANG = [-28, 0, 28, 152, 180, 208]; const clamp = (n: number, lo = 0, hi = 1) => Math.max(lo, Math.min(hi, n)); const rot = (deg: number) => `rotate(${deg.toFixed(2)}deg)`; const door = (deg: number, y = 0) => `rotateY(${deg}deg) translateY(${y}px)`; type Frame = [number, Record, string?]; const TICKS = Array.from({ length: 100 }, (_, i) => { const a = (i * Math.PI * 2) / 100; const long = i % 10 === 0; const r1 = 41.8; const r0 = long ? 34.8 : 38.6; return { long, x1: 52 + Math.sin(a) * r0, y1: 52 - Math.cos(a) * r0, x2: 52 + Math.sin(a) * r1, y2: 52 - Math.cos(a) * r1 }; }); export function SafeButton({ children = "unlock", code = [30, 70, 10], onClick, className, type = "button", disabled = false, ref, ...rest }: Props) { const btnRef = useRef(null); const wrapRef = useRef(null); const playRef = useRef<() => void>(() => {}); const [state, setState] = useState<"idle" | "playing">("idle"); useImperativeHandle(ref, () => btnRef.current!, []); const codeKey = code.join(","); const uid = `tb-safe-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`; useEffect(() => { const btn = btnRef.current; const wrap = wrapRef.current; if (!btn || !wrap) return; const q = (s: string) => wrap.querySelector(s); const body = q(".tb-safe-body"); const doorEl = q(".tb-safe-door"); const dial = q(".tb-safe-dial"); const ghosts = Array.from(wrap.querySelectorAll(".tb-safe-ghost")); const index = q(".tb-safe-index"); const label = q(".tb-safe-label"); const light = q(".tb-safe-light"); const spill = q(".tb-safe-spill"); const bloom = q(".tb-safe-bloom"); const ticks = Array.from(wrap.querySelectorAll(".tb-safe-tick")); const shade = q(".tb-safe-shade"); const seam = q(".tb-safe-seam"); const bolts = q(".tb-safe-bolts"); const motes = Array.from(wrap.querySelectorAll(".tb-safe-mote")); const dust = Array.from(wrap.querySelectorAll(".tb-safe-dust")); const media = window.matchMedia("(prefers-reduced-motion: reduce)"); const isDisabled = () => btn.matches(":disabled"); const nums = codeKey.split(",").map((n) => ((Math.round(Number(n)) % 100) + 100) % 100); let angle = 0; let hovered = false; let near = false; let dir = 1; let count = 0; let playing = false; let extended = false; let tickTimer = 0; let endTimer = 0; let rmTimers: number[] = []; let anims: Animation[] = []; let rect: DOMRect | undefined; let visible = true; let epoch = 0; const run = (el: Element | null, frames: Keyframe[], opts: KeyframeAnimationOptions) => { if (!el) return null; const a = el.animate(frames, opts); anims.push(a); a.onfinish = () => { anims = anims.filter((x) => x !== a); }; return a; }; const track = (el: Element | null, T: number, list: Frame[]) => run(el, list.map(([t, p, e]) => ({ offset: clamp(t / T), ...p, ...(e ? { easing: e } : {}) })), { duration: T, fill: "none" }); const cancelAll = () => { anims.forEach((a) => a.cancel()); anims = []; }; const stopTick = () => { window.clearTimeout(tickTimer); tickTimer = 0; }; // ---- hover ticking ---- const step = (delta: number) => { const from = angle; angle += delta; if (dial) { dial.style.transform = rot(angle); run(dial, [{ transform: rot(from) }, { transform: rot(angle + 0.6 * Math.sign(delta)), offset: 0.6 }, { transform: rot(angle) }], { duration: 80, easing: "ease-out" }); } run(index, [{ opacity: 0.85 }, { opacity: 1, offset: 0.4 }, { opacity: 0.85 }], { duration: 60 }); }; const canTick = () => hovered && !playing && !media.matches && !isDisabled() && !document.hidden && visible; const tickStep = () => { tickTimer = 0; if (!canTick()) return; step(dir * STEP); count++; if (count >= 6) { count = 0; dir = -dir; tickTimer = window.setTimeout(tickStep, 700); } else tickTimer = window.setTimeout(tickStep, near ? 70 : 110); }; const homeStep = () => { tickTimer = 0; if (playing || hovered) return; if (Math.abs(angle) < 0.01) { angle = 0; return; } step(Math.sign(-angle) * Math.min(STEP, Math.abs(angle))); tickTimer = window.setTimeout(homeStep, 70); }; const startTick = () => { if (!tickTimer && canTick()) tickTimer = window.setTimeout(tickStep, 110); }; // ---- click timeline ---- const build = (E: number, a0: number) => { const T = T_END + E; const tc = T_CLOSE + E; const ti = T_IMPACT + E; const d1 = (nums[0] + 100) % 100; const d2 = (nums[0] - nums[1] + 100) % 100; const d3 = (nums[2] - nums[1] + 100) % 100; const a1 = a0 + d1 * STEP; const a2 = a1 - d2 * STEP; const a3 = a2 + d3 * STEP; const move = (t: number, dur: number, from: number, to: number): Frame[] => [ [t, { transform: rot(from) }, "cubic-bezier(.4,0,.2,1)"], [t + dur * 0.8, { transform: rot(to + 2 * Math.sign(to - from)) }, "ease-out"], ]; const dialList: Frame[] = [ ...move(0, 260, a0, a1), ...move(260, 320, a1, a2), ...move(580, 240, a2, a3), [820, { transform: rot(a3) }], [930, { transform: rot(a3 + 1) }], [990, { transform: rot(a3) }], [tc, { transform: rot(a3) }, "cubic-bezier(.4,0,.2,1)"], [tc + 460, { transform: rot(0) }], [ti, { transform: rot(0) }], [ti + 40, { transform: rot(1.5) }], [ti + 120, { transform: rot(0) }], [T, { transform: rot(0) }], ]; track(dial, T, dialList); ghosts.forEach((g, i) => { run(g, dialList.map(([t, p, e]) => ({ offset: clamp(t / T), ...p, ...(e ? { easing: e } : {}) })), { duration: T, delay: 22 * (i + 1), fill: "none" }); const o = i === 0 ? 0.3 : 0.15; track(g, T, [[0, { opacity: 0 }], [40, { opacity: o }], [780, { opacity: o }], [860, { opacity: 0 }], [tc, { opacity: 0 }], [tc + 40, { opacity: o * 0.7 }], [tc + 420, { opacity: o * 0.7 }], [tc + 470, { opacity: 0 }], [T, { opacity: 0 }]]); }); track(doorEl, T, [ [0, { transform: door(0) }], [T_DOOR, { transform: door(0) }, "cubic-bezier(.3,0,.2,1)"], [T_OPEN, { transform: door(OPEN, 1) }, "ease-out"], [T_OPEN + 150, { transform: door(OPEN - 4, 1) }, "ease-in-out"], [T_OPEN + 300, { transform: door(OPEN, 1) }], [tc, { transform: door(OPEN, 1) }, "cubic-bezier(.5,0,.9,.6)"], [ti, { transform: door(0) }, "ease-out"], [ti + 70, { transform: door(3) }, "ease-out"], [ti + 150, { transform: door(0) }], [T, { transform: door(0) }], ]); track(shade, T, [[0, { opacity: 0 }], [T_DOOR, { opacity: 0 }], [T_OPEN, { opacity: 0.6 }], [tc, { opacity: 0.6 }], [ti, { opacity: 0 }], [T, { opacity: 0 }]]); track(bolts, T, [[0, { transform: "translateX(0)" }], [820, { transform: "translateX(0)" }, "ease-out"], [940, { transform: "translateX(6px)" }], [ti, { transform: "translateX(6px)" }], [ti + 100, { transform: "translateX(0)" }], [T, { transform: "translateX(0)" }]]); track(seam, T, [[0, { opacity: 0 }], [820, { opacity: 0 }], [900, { opacity: 1 }], [ti, { opacity: 1 }], [ti + 60, { opacity: 0 }], [T, { opacity: 0 }]]); const lightFrames: Frame[] = [[0, { opacity: 0 }], [T_DOOR, { opacity: 0 }, "ease-out"], [T_OPEN, { opacity: 1 }], [ti, { opacity: 1 }], [ti + 40, { opacity: 0 }], [T, { opacity: 0 }]]; track(light, T, lightFrames); track(spill, T, lightFrames); track(bloom, T, lightFrames); const ts0 = "0 -1px 0 rgba(0,0,0,.9)"; const ts1 = "0 -1px 0 rgba(0,0,0,.6),0 0 10px rgba(230,180,104,.55)"; track(label, T, [[0, { color: REST_TEXT, textShadow: ts0 }], [T_OPEN, { color: REST_TEXT, textShadow: ts0 }], [T_OPEN + 100, { color: GOLD, textShadow: ts1 }], [ti, { color: GOLD, textShadow: ts1 }], [T, { color: REST_TEXT, textShadow: ts0 }]]); track(body, T, [ [0, { transform: "translateX(0)" }], [ti, { transform: "translateX(0)" }], [ti + 25, { transform: "translateX(1.5px)" }], [ti + 55, { transform: "translateX(-1.5px)" }], [ti + 90, { transform: "translateX(1px)" }], [ti + 130, { transform: "translateX(0)" }], [T, { transform: "translateX(0)" }], ]); motes.forEach((m, i) => { run(m, [{ transform: "translateY(0)", opacity: 0 }, { opacity: 0.9, offset: 0.3 }, { transform: "translateY(-22px)", opacity: 0 }], { duration: 1100, delay: T_DOOR + 120 + i * 110, easing: "linear" }); }); dust.forEach((d, i) => { const dx = (i - 2.5) * 3.2; run(d, [{ transform: "translate(0,0) scale(.6)", opacity: 0.9 }, { transform: `translate(${dx.toFixed(1)}px,${4 + (i % 2) * 2}px) scale(1.3)`, opacity: 0 }], { duration: 420, delay: ti + i * 25, easing: "ease-out" }); }); ticks.forEach((t, i) => { const a = TICK_ANG[i] * Math.PI / 180; const o = `translate(${(Math.sin(a) * 6).toFixed(1)}px,${(-Math.cos(a) * 6).toFixed(1)}px) rotate(${TICK_ANG[i]}deg) scaleY(.4)`; const b = `rotate(${TICK_ANG[i]}deg)`; const kf = [{ transform: b, opacity: 0 }, { opacity: 1, offset: 0.2 }, { transform: o, opacity: 0 }]; run(t, kf, { duration: 240, delay: 930, easing: "ease-out" }); run(t, kf, { duration: 240, delay: ti, easing: "ease-out" }); }); return T; }; const finish = () => { playing = false; extended = false; angle = 0; if (dial) dial.style.transform = rot(0); cancelAll(); setState("idle"); dir = 1; count = 0; if (hovered) startTick(); }; const armEnd = (ms: number) => { window.clearTimeout(endTimer); const my = ++epoch; endTimer = window.setTimeout(() => { if (my === epoch) finish(); }, ms + 30); }; const reduced = () => { wrap.dataset.tbOpen = "true"; rmTimers.forEach((t) => window.clearTimeout(t)); cancelAll(); run(light, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, easing: "ease-out" }); run(spill, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, easing: "ease-out" }); run(bloom, [{ opacity: 0 }, { opacity: 1 }], { duration: 150, easing: "ease-out" }); rmTimers = [ window.setTimeout(() => { const a = run(light, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); run(spill, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); run(bloom, [{ opacity: 1 }, { opacity: 0 }], { duration: 150, fill: "forwards" }); if (a) a.onfinish = () => { delete wrap.dataset.tbOpen; cancelAll(); }; }, 1200), ]; }; playRef.current = () => { if (isDisabled()) return; if (media.matches) { reduced(); return; } if (playing) { const t = anims.find((a) => a.effect && a.currentTime != null)?.currentTime; const elapsed = typeof t === "number" ? t : 0; if (!extended && elapsed < T_CLOSE) { extended = true; cancelAll(); // rebuild with a longer hold and continue from the same moment const a0 = angleAtStart; const T = build(HOLD_EXTRA, a0); anims.forEach((a) => { try { a.currentTime = elapsed; } catch { /* ignore */ } }); armEnd(T - elapsed); } return; } stopTick(); playing = true; extended = false; angleAtStart = angle; setState("playing"); const T = build(0, angle); armEnd(T); }; let angleAtStart = 0; // ---- pointer ---- const locate = () => { rect = btn.getBoundingClientRect(); }; const move = (e: PointerEvent) => { if (!hovered) return; if (!rect) locate(); const r = rect!; const scale = r.width / (btn.offsetWidth || 1) || 1; const fx = clamp((e.clientX - r.left) / (W * scale)); wrap.style.setProperty("--tb-safe-hx", `${(38 + fx * 24).toFixed(1)}%`); const dx = (e.clientX - r.left) / scale - DIAL_CX; const dy = (e.clientY - r.top) / scale - DIAL_CY; near = Math.hypot(dx, dy) < DIAL / 2 + 70; }; const enter = () => { if (isDisabled() || media.matches) return; locate(); hovered = true; stopTick(); dir = 1; count = 0; startTick(); }; const leave = () => { hovered = false; stopTick(); wrap.style.setProperty("--tb-safe-hx", "50%"); if (!playing && Math.abs(angle) > 0.01) tickTimer = window.setTimeout(homeStep, 70); }; const invalidate = () => { rect = undefined; }; const syncVis = () => { wrap.dataset.tbPaused = String(!visible || document.hidden); if (!canTick()) stopTick(); else if (hovered) startTick(); }; const onMedia = () => { if (media.matches) { stopTick(); if (!playing) { angle = 0; if (dial) dial.style.transform = rot(0); } } }; const io = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver(([en]) => { visible = en.isIntersecting; syncVis(); }); io?.observe(wrap); btn.addEventListener("pointerenter", enter); btn.addEventListener("pointerleave", leave); window.addEventListener("pointermove", move, { passive: true }); window.addEventListener("resize", invalidate); window.addEventListener("scroll", invalidate, true); document.addEventListener("visibilitychange", syncVis); media.addEventListener("change", onMedia); return () => { playRef.current = () => {}; epoch++; stopTick(); window.clearTimeout(endTimer); rmTimers.forEach((t) => window.clearTimeout(t)); cancelAll(); io?.disconnect(); btn.removeEventListener("pointerenter", enter); btn.removeEventListener("pointerleave", leave); window.removeEventListener("pointermove", move); window.removeEventListener("resize", invalidate); window.removeEventListener("scroll", invalidate, true); document.removeEventListener("visibilitychange", syncVis); media.removeEventListener("change", onMedia); delete wrap.dataset.tbOpen; if (dial) dial.style.transform = rot(0); }; }, [disabled, codeKey]); const click = (e: MouseEvent) => { if (disabled || e.currentTarget.matches(":disabled")) return; onClick?.(e); if (e.defaultPrevented) return; playRef.current(); }; const numbers = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]; const ringSvg = (id: string, cls?: string) => ( ); const dialSvg = ( {TICKS.map((t, i) => ( ))} {numbers.map((n) => ( {n === 0 ? "0" : n} ))} ); const knob = ; return ( ); } export default SafeButton; const css = ` .tb-safe-wrap{display:inline-flex;position:relative;vertical-align:middle;width:${W}px;height:${H}px;--tb-safe-hx:50%} .tb-safe-btn{position:relative;display:block;box-sizing:border-box;width:${W}px;height:${H}px;padding:0;margin:0;border:0;border-radius:${H / 2}px; background:transparent;overflow:visible;cursor:pointer;-webkit-tap-highlight-color:transparent;color:${REST_TEXT}; font:800 24px/1 ui-sans-serif,"DIN Alternate","Bahnschrift","Segoe UI",system-ui,sans-serif;transition:transform 180ms cubic-bezier(.2,.8,.2,1)} .tb-safe-btn:hover:not(:disabled){transform:translateY(-2px)} .tb-safe-btn:active:not(:disabled){transform:translateY(1px) scale(.985);transition-duration:70ms} .tb-safe-btn:focus-visible{outline:3px solid ${ACCENT};outline-offset:6px} .tb-safe-btn:disabled{cursor:default;opacity:.6;filter:saturate(.5)} .tb-safe-body,.tb-safe-fx{position:absolute;left:0;top:0;width:${W}px;height:${H}px;pointer-events:none} .tb-safe-plate{position:absolute;inset:0;border-radius:${H / 2}px;overflow:hidden; background:linear-gradient(180deg,#d9dee2 0%,#8a9095 22%,#4e5357 55%,#2a2d30 85%,#6d7378 100%); box-shadow:inset 0 1px 0 #d4dade,inset 0 -1px 0 #1d1f21,0 0 0 1px rgba(0,0,0,.55),0 2px 3px rgba(0,0,0,.45),0 10px 22px rgba(0,0,0,.5); transition:box-shadow 180ms ease-out} .tb-safe-btn:hover:not(:disabled) .tb-safe-plate{box-shadow:inset 0 1px 0 #d4dade,inset 0 -1px 0 #1d1f21,0 0 0 1px rgba(0,0,0,.55),0 3px 4px rgba(0,0,0,.4),0 16px 30px rgba(0,0,0,.5)} .tb-safe-btn:active:not(:disabled) .tb-safe-plate{box-shadow:inset 0 1px 0 #d4dade,inset 0 -1px 0 #1d1f21,0 0 0 1px rgba(0,0,0,.55),0 1px 2px rgba(0,0,0,.6),0 5px 12px rgba(0,0,0,.45)} .tb-safe-plate::before{content:"";position:absolute;inset:6px;border-radius:${H / 2 - 6}px; background:repeating-linear-gradient(0deg,rgba(255,255,255,.045) 0 1px,transparent 1px 2px),repeating-linear-gradient(0deg,rgba(0,0,0,.06) 0 1px,transparent 1px 3px),repeating-linear-gradient(0deg,rgba(255,255,255,.035) 0 1px,transparent 1px 7px),repeating-linear-gradient(0deg,rgba(0,0,0,.07) 0 1px,transparent 1px 11px),radial-gradient(140% 120% at 30% 0%,rgba(255,255,255,.08),transparent 60%),linear-gradient(180deg,#575c60 0%,#484c50 50%,#383b3e 100%); box-shadow:inset 0 2px 3px rgba(0,0,0,.6),inset 0 -1px 0 rgba(255,255,255,.18),0 0 0 1px rgba(0,0,0,.35)} .tb-safe-sheen{position:absolute;inset:0;z-index:1; background:linear-gradient(100deg,transparent calc(var(--tb-safe-hx) - 12%),rgba(255,255,255,.05) calc(var(--tb-safe-hx) - 5%),rgba(255,255,255,.13) var(--tb-safe-hx),rgba(255,255,255,.05) calc(var(--tb-safe-hx) + 5%),transparent calc(var(--tb-safe-hx) + 12%))} .tb-safe-rivet{position:absolute;width:8px;height:8px;border-radius:50%; background:radial-gradient(circle at 35% 30%,#eef1f3 0 12%,#9aa0a6 30%,#4a4e52 70%,#2a2d30 100%);box-shadow:0 0 0 1px rgba(0,0,0,.5),0 1.5px 1.5px rgba(0,0,0,.55),0 -.5px 0 rgba(255,255,255,.25)} .tb-safe-slot{position:absolute;left:22px;top:36px;width:150px;height:44px;border-radius:22px;background:linear-gradient(180deg,#131516,#1e2123); box-shadow:inset 0 3px 6px rgba(0,0,0,.8),inset 0 -1px 0 rgba(255,255,255,.06),0 1px 0 rgba(255,255,255,.18),0 -1px 0 rgba(0,0,0,.35)} .tb-safe-labelwrap{position:absolute;left:22px;top:36px;width:150px;height:44px;display:flex;align-items:center;justify-content:center;pointer-events:none} .tb-safe-label{text-transform:uppercase;letter-spacing:.07em;font-stretch:condensed;white-space:nowrap;color:${REST_TEXT};text-shadow:0 -1px 0 rgba(0,0,0,.9),0 1px 0 rgba(255,255,255,.07)} .tb-safe-spill{position:absolute;inset:0;z-index:2;opacity:0; background:radial-gradient(130px 84px at ${DIAL_CX}px 50%,rgba(255,196,110,.42),rgba(230,180,104,.12) 55%,transparent 75%)} .tb-safe-bloom{position:absolute;left:${DIAL_CX - 75}px;top:${DIAL_CY - 75}px;width:150px;height:150px;border-radius:50%; background:radial-gradient(circle,rgba(230,180,104,.22),transparent 70%);opacity:0} .tb-safe-hinge{position:absolute;left:${DIAL_CX + 49}px;top:${DIAL_CY - 18}px;width:9px;height:36px;border-radius:4.5px;background:linear-gradient(90deg,#1e2022 0%,#6c7277 22%,#e4e8eb 45%,#8d949a 62%,#2a2d30 100%);box-shadow:0 2px 3px rgba(0,0,0,.6),0 0 0 .5px rgba(0,0,0,.6)} .tb-safe-hinge::before{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(180deg,transparent 11.5px,rgba(0,0,0,.6) 11.5px 12.5px,transparent 12.5px 23.5px,rgba(0,0,0,.6) 23.5px 24.5px,transparent 24.5px)} .tb-safe-hinge::after{content:"";position:absolute;left:1.5px;top:-2.5px;width:6px;height:4px;border-radius:2px;background:linear-gradient(#e6e9ec,#7d8389);box-shadow:0 37px 0 #5d6267} .tb-safe-hole{position:absolute;left:${DIAL_CX - 56}px;top:${DIAL_CY - 56}px;width:112px;height:112px} .tb-safe-hole svg{position:absolute;left:0;top:0} .tb-safe-hole::after{content:"";position:absolute;inset:2px;border-radius:50%;pointer-events:none; box-shadow:0 0 0 1px rgba(190,215,240,0),0 0 0 0 rgba(150,190,240,0);transition:box-shadow 220ms ease-out} .tb-safe-btn:hover:not(:disabled) .tb-safe-hole::after{box-shadow:0 0 0 1px rgba(190,215,240,.45),0 0 16px 2px rgba(150,190,240,.28)} .tb-safe-light{opacity:0} .tb-safe-holeclip{position:absolute;left:6px;top:6px;width:100px;height:100px;border-radius:50%;overflow:hidden} .tb-safe-mote{position:absolute;width:2px;height:2px;border-radius:50%;background:#fff1c2;opacity:0;box-shadow:0 0 3px 1px rgba(255,220,150,.7)} .tb-safe-dust{position:absolute;width:3px;height:3px;border-radius:50%;background:#aeb4b9;opacity:0} .tb-safe-tick{position:absolute;width:1.5px;height:7px;border-radius:1px;background:#f2f4f6;opacity:0} .tb-safe-defs{position:absolute;width:0;height:0} .tb-safe-stage{position:absolute;left:0;top:0;width:${W}px;height:${H}px;perspective:560px;perspective-origin:${DIAL_CX + 20}px ${DIAL_CY}px} .tb-safe-door{position:absolute;left:${DIAL_CX - DIAL / 2}px;top:${DIAL_CY - DIAL / 2}px;width:${DIAL}px;height:${DIAL}px; transform-style:preserve-3d;transform-origin:100% 50%} .tb-safe-edge{position:absolute;inset:0;border-radius:50%} .tb-safe-pins{position:absolute;left:-6px;top:28px;width:12px;height:48px;transform:translateZ(-6px) rotateY(-90deg);background:radial-gradient(circle 3.6px at 50% 8px,#fff0b8 0,#e0ac4c 40%,#8a5e1c 72%,#1e1508 86%,transparent 92%) 0 0/12px 16px repeat-y} .tb-safe-back{position:absolute;inset:0;border-radius:50%;overflow:hidden;backface-visibility:hidden;transform:translateZ(-12px) rotateY(180deg)} .tb-safe-back svg,.tb-safe-dial-static{position:absolute;left:0;top:0} .tb-safe-dial-static{width:${DIAL}px;height:${DIAL}px} .tb-safe-dial-static svg{position:absolute;left:0;top:0} .tb-safe-backshade{position:absolute;inset:0;border-radius:50%;background:linear-gradient(90deg,rgba(230,180,104,.22) 0%,rgba(0,0,0,0) 35%,rgba(0,0,0,.62) 100%);box-shadow:inset 7px 0 10px -5px rgba(230,180,104,.6)} .tb-safe-front{position:absolute;inset:0;border-radius:50%;backface-visibility:hidden} .tb-safe-ring,.tb-safe-faceshade{position:absolute;left:0;top:0;pointer-events:none} .tb-safe-dial{position:absolute;left:0;top:0;width:${DIAL}px;height:${DIAL}px;transform:rotate(0deg)} .tb-safe-dial svg{position:absolute;left:0;top:0} .tb-safe-ghost{position:absolute;left:0;top:0;width:104px;height:104px;opacity:0;pointer-events:none}.tb-safe-ghost svg{position:absolute;left:0;top:0} .tb-safe-knob{position:absolute;left:29px;top:29px;width:46px;height:46px;border-radius:50%; background:#a3a9ae; box-shadow:0 2px 0 rgba(0,0,0,.35),0 4px 7px rgba(0,0,0,.6),inset 0 0 0 1px rgba(0,0,0,.45);transition:transform 70ms} .tb-safe-btn:active:not(:disabled) .tb-safe-knob{transform:scale(.96)} .tb-safe-knob::before{content:"";position:absolute;inset:0;border-radius:50%; background:repeating-conic-gradient(rgba(0,0,0,.38) 0 2deg,rgba(255,255,255,.16) 2deg 5deg); -webkit-mask:radial-gradient(circle,transparent 18.5px,#000 19px);mask:radial-gradient(circle,transparent 18.5px,#000 19px)} .tb-safe-knob i{position:absolute;left:5px;top:5px;width:36px;height:36px;border-radius:50%; background:repeating-radial-gradient(circle,rgba(255,255,255,.08) 0 .6px,rgba(0,0,0,.08) .6px 1.4px),#b4babf;box-shadow:inset 0 0 0 1px rgba(0,0,0,.35),0 1.5px 2px rgba(0,0,0,.5)} .tb-safe-knobshine{position:absolute;left:29px;top:29px;width:46px;height:46px;border-radius:50%;pointer-events:none;background:radial-gradient(circle at 36% 30%,rgba(255,255,255,.75),rgba(255,255,255,0) 26%),conic-gradient(from 210deg,rgba(255,255,255,.5),rgba(0,0,0,.05) 18%,rgba(0,0,0,.32) 36%,rgba(255,255,255,.34) 54%,rgba(0,0,0,.22) 72%,rgba(255,255,255,.5));transition:transform 70ms} .tb-safe-btn:active:not(:disabled) .tb-safe-knobshine{transform:scale(.96)} .tb-safe-index{position:absolute;left:44px;top:0;opacity:.7;filter:drop-shadow(0 0 3px rgba(255,255,255,.5))} .tb-safe-btn:hover:not(:disabled) .tb-safe-index{opacity:.9} .tb-safe-seam{position:absolute;inset:-1px;border-radius:50%;box-shadow:0 0 0 1.5px ${GOLD},0 0 8px rgba(230,180,104,.8);opacity:0} .tb-safe-bolts i{position:absolute;left:-5px;width:9px;height:5px;border-radius:2.5px;background:linear-gradient(180deg,#c3c9ce,#6c7277 50%,#2f3235);box-shadow:0 0 0 1.5px #16181a,0 1px 1px rgba(0,0,0,.5)} .tb-safe-bolts i:nth-child(1){top:23px}.tb-safe-bolts i:nth-child(2){top:49px}.tb-safe-bolts i:nth-child(3){top:75px} .tb-safe-shade{position:absolute;inset:0;border-radius:50%;background:#000;opacity:0} .tb-safe-wrap[data-tb-open=true] .tb-safe-door{transform:${door(OPEN, 1)}} .tb-safe-wrap[data-tb-open=true] .tb-safe-shade{opacity:.6} .tb-safe-wrap[data-tb-open=true] .tb-safe-label{color:${GOLD};text-shadow:0 -1px 0 rgba(0,0,0,.6),0 0 10px rgba(230,180,104,.55)} .tb-safe-wrap[data-tb-open=true] .tb-safe-light,.tb-safe-wrap[data-tb-open=true] .tb-safe-spill,.tb-safe-wrap[data-tb-open=true] .tb-safe-bloom{opacity:1} .tb-safe-swoosh{position:absolute;left:0;top:0;overflow:visible;pointer-events:none;opacity:0;transform:rotate(-10deg);transform-origin:${DIAL_CX}px ${DIAL_CY}px;transition:opacity 220ms ease-out,transform 320ms cubic-bezier(.2,.8,.2,1)} .tb-safe-btn:hover:not(:disabled) .tb-safe-swoosh{opacity:1;transform:rotate(0deg)} .tb-safe-wrap[data-tb-state=playing] .tb-safe-swoosh{opacity:0} .tb-safe-wrap[data-tb-paused=true] *{animation-play-state:paused!important} @media (prefers-reduced-motion:reduce){.tb-safe-swoosh{display:none}.tb-safe-wrap *,.tb-safe-wrap *::before,.tb-safe-wrap *::after{animation:none!important;transition:none!important}} `;