/* الدوائر · Circuits Lab: the bench inside the workbench frame.
   The bench is a 1920 x 1080 scene scaled to fit the frame; the world inside it moves for close-ups. */

@font-face { font-family: "Plex Mono"; src: url("../../proto/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; }

/* the frame takes the place of the logic lab's board. The bench runs the full width of the screen: the 1920 x 1080
   scene is fitted to the frame's height and centred, and on both sides the lab photo carries on (the scene shows
   only its bottom-centre part, 1200 x 675 from (236, 266) of the 1672 x 941 photo, at 1.6 world px per photo px).
   The scene is centred on the photo's middle (devices from x -330 to 2251), so the photo covers the view up to 2.477 : 1;
   past that the frame stops. */
#bench-wrap {
    --board-h: calc(100svh - 76px - 112px - 56px);
    position: relative; width: min(100%, calc(var(--board-h) * 2.477)); aspect-ratio: 1920 / 1505.6; max-height: var(--board-h);
    margin: 0 auto; overflow: hidden; background: #000;
}
@media (min-width: 901px) {
    #board-scroll { margin: 0 -20px; }
    #board-scroll .board-frame { width: 100%; padding: 24px 0; }
    #board-scroll .fl-tl, #board-scroll .fl-bl { left: 20px; }
    #board-scroll .fl-tr, #board-scroll .fl-br { right: 20px; }
}
/* the view: its size in scene px is set by main.mjs (fit) */
#bench { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; direction: ltr; overflow: hidden; background: #1b1712; }
#bench::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 9;
                background: radial-gradient(120% 90% at 50% 55%, transparent 55%, rgba(0, 0, 0, .32)); }
#world { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; transition: transform .55s var(--expo); }
#world.panning { transition: none; }
/* the whole photo, inside the world so it moves and zooms with the devices */
.bench-bg { position: absolute; left: -377.6px; top: -425.6px; width: 2675.2px; height: 1505.6px; z-index: 0; pointer-events: none;
            background: url("../img/bench-bg-wide.webp") 0 0 / 100% 100% no-repeat; }

.device { position: absolute; background-repeat: no-repeat; background-size: 100% 100%; z-index: 1; }
.shadow { position: absolute; border-radius: 50%; background: rgba(20, 16, 10, .55); filter: blur(14px); }

/* scope */
.scr { position: absolute; display: block; background: #000; }
.glass { position: absolute; pointer-events: none; background: linear-gradient(165deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, 0) 38%);
         box-shadow: inset 0 0 10px 2px rgba(0, 0, 0, .55); }
.key, .pbtn { position: absolute; padding: 0; margin: 0; border: 0; background: transparent; cursor: pointer; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
.key.round, .pbtn.round { border-radius: 50%; }
.key::before, .key::after, .pbtn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.key:hover::after, .pbtn:hover::after { background: rgba(255, 255, 255, .10); }
.key.down::after, .key:active::after { background: rgba(0, 0, 0, .20); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .45); }
.key.lit::before { background: var(--led); mix-blend-mode: multiply; opacity: .78; }
.key.lit { box-shadow: 0 0 10px 1px var(--led); }
.pbtn.in::after { background: rgba(0, 0, 0, .22); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .5); }
#bench .key:focus-visible, #bench .knob:focus-visible, #bench .pot:focus-visible, #bench .pbtn:focus-visible, #bench .slide:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.knob, .pot { position: absolute; border-radius: 50%; cursor: grab; touch-action: none; padding: 0; border: 0; background-repeat: no-repeat; }
.knob:active, .pot:active { cursor: grabbing; }
.knob::after { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
               background: radial-gradient(circle at 38% 30%, rgba(255, 255, 255, .22), transparent 55%); }
.knob:hover, .pot:hover { filter: brightness(1.05); }

/* PSU */
.pot { background: url("../img/psu-knob.webp") center / 100% 100% no-repeat; }
.psu-meter { position: absolute; pointer-events: none; }
.lamp { position: absolute; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .08s; mix-blend-mode: screen;
        background: radial-gradient(circle, #fff 0 12%, var(--lamp) 34%, transparent 72%); box-shadow: 0 0 12px 3px var(--lamp); }
.lamp.on { opacity: 1; }

/* resistance box and multimeter */
.slide { position: absolute; padding: 0; border: 0; background: #0d0d0d; border-radius: 3px; cursor: pointer; }
.slide .thumb { position: absolute; left: 5%; right: 5%; top: 3%; height: 47%; border-radius: 3px; transition: top .08s;
                background: repeating-linear-gradient(180deg, #3b3b3b 0 2px, #222 2px 5px), #262626; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18); }
.slide.in .thumb { top: 50%; }
.slide:hover { outline: 2px solid rgba(243, 240, 234, .8); }
.slide.burnt { background: #3a0d05; outline: 2px solid var(--red); }
.device.hot { filter: drop-shadow(0 0 14px rgba(255, 59, 48, .9)); }
.fusefix { position: absolute; z-index: 5; border: 0; border-radius: 999px; cursor: pointer; color: #fff; background: var(--red); font: 600 13px var(--sans); }
.dial { cursor: grab; }
canvas.lcd.lit { box-shadow: 0 0 18px 4px rgba(150, 230, 255, .75); }
.device.rbox { z-index: 2; }
.term.hole { border-radius: 1px; z-index: 2; }
.term.hole:hover { box-shadow: none; }
/* a hole under the pointer lights its whole strip: the five holes joined to it, or its half rail */
.term.hole.lit { background: rgba(255, 59, 48, .55); box-shadow: 0 0 0 .6px rgba(255, 59, 48, .95); }
/* the wire rack under the shelf */
.device.rack { z-index: 1; }
.rack-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rack-item { cursor: pointer; }
.rack-hit { fill: transparent; transition: fill .15s; }
.rack-item:hover .rack-hit { fill: rgba(255, 255, 255, .22); }
.rack-item.in-hand .rack-hit { fill: rgba(255, 59, 48, .16); stroke: var(--red); stroke-width: 2.5; }
.rack-label { direction: rtl; unicode-bidi: embed; font: 600 14px var(--sans); fill: #2c2824; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-width: 3px; }
/* the parts box: closed on the bench; open over the frame, seen from above */
.shadow.box-shadow { border-radius: 18px; background: rgba(20, 16, 10, .38); filter: blur(12px); }
.box-open { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(6, 6, 6, .55);
            opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
.box-open.on { opacity: 1; pointer-events: auto; }
.box-sheet { position: relative; transform-origin: 0 0; transition: transform .55s var(--expo); filter: drop-shadow(0 30px 60px rgba(0, 0, 0, .6)); }
.box-sheet > img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.box-cell { position: absolute; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: pointer; transition: background .15s, box-shadow .15s; }
.box-cell:hover, .box-cell:focus-visible { outline: none; background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 2px rgba(243, 240, 234, .85); }
.box-cell.on { background: rgba(255, 59, 48, .10); box-shadow: inset 0 0 0 3px var(--red); }
.box-close { position: absolute; top: 14px; left: 14px; z-index: 2; }
.box-pick { position: absolute; z-index: 3; width: max-content; min-width: 220px; max-width: 330px; padding: 14px 14px 16px; direction: rtl;
            background: rgba(12, 12, 12, .95); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: 0 18px 40px rgba(0, 0, 0, .5); }
.box-pick[hidden] { display: none; }
.box-pick header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.box-pick header img { width: 64px; height: 44px; object-fit: contain; }
.box-pick h4 { font: 600 16px var(--sans); }
.box-pick header p { font-size: 10.5px; color: var(--ink-3); }
.box-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.box-opts button { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font: 500 12.5px var(--mono); direction: ltr; cursor: pointer; }
.box-opts button.dot::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-inline-end: 6px; border-radius: 50%; background: var(--dot); vertical-align: -1px; }
.box-opts button:hover { background: rgba(243, 240, 234, .1); }
.box-opts button[aria-pressed="true"] { background: var(--ink); color: #000; }
/* parts on the breadboard: over its holes, under the cables */
svg.board-parts { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; z-index: 2; pointer-events: none; overflow: visible; }
svg.board-parts .part { pointer-events: all; cursor: pointer; }
svg.board-parts .part:hover image { filter: brightness(1.12) drop-shadow(0 0 1.5px rgba(255, 255, 255, .9)); }
svg.board-parts .leg { stroke: #c4c8cd; stroke-linecap: round; }
svg.board-parts .part-ghost { stroke: var(--red); stroke-width: 1.2; stroke-dasharray: 3 2; }
svg.board-parts .part-glow { mix-blend-mode: screen; filter: blur(2.5px); pointer-events: none; transition: opacity .08s; }
svg.board-parts .part-text { font-family: var(--mono); font-weight: 600; pointer-events: none; }
.shadow.bb-shadow { border-radius: 14px; background: rgba(20, 16, 10, .42); filter: blur(10px); }

/* cables */
.term { position: absolute; border-radius: 50%; cursor: crosshair; z-index: 2; touch-action: none; }
.term:hover { box-shadow: 0 0 0 3px rgba(243, 240, 234, .85), 0 0 12px rgba(243, 240, 234, .35); }
svg.cables { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; z-index: 3; pointer-events: none; overflow: visible; }
svg.cables .wire, svg.cables .whl, svg.cables .wshadow { fill: none; stroke-linecap: round; }
svg.cables .whl { stroke: rgba(255, 255, 255, .22); transform: translate(-1.5px, -1.5px); }
svg.cables .wshadow { stroke: rgba(0, 0, 0, .35); filter: url(#cblur); transform: translate(5px, 12px); }
svg.cables .plug { pointer-events: all; cursor: grab; }

/* the device the close-up is on */
.capsule-tools .pill-ghost[aria-pressed="true"] { background: var(--ink); color: #000; }

/* intro: a wide picture of the five instruments */
.intro-obj.wide { width: min(53vw, 1000px); left: 2vw; }
@media (max-width: 1280px) { .intro-obj.wide { width: 50vw; } }

/* about sheet: the instruments table opens to a spec list */
#inst-table .trow > button { grid-template-columns: 48px 200px 1fr 190px 28px; }
#inst-table .t-chip { font-size: 18px; white-space: nowrap; }
#inst-table .t-fn { font-size: 14.5px; }
#inst-table .t-pins { white-space: nowrap; letter-spacing: .08em; text-transform: uppercase; }
.spec { list-style: none; display: grid; gap: 6px; padding: 6px 6px 22px; max-width: 860px; }
.spec li { display: flex; gap: 10px; align-items: baseline; font-size: 14.5px; line-height: 1.7; color: var(--ink-2); }
.spec li i { flex: 1; border-bottom: 1px dotted var(--line); transform: translateY(-4px); min-width: 20px; }
.spec li b { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--ink); direction: ltr; }
.three .photo-card img.hero { width: 100%; }

@media (max-width: 1100px) { #bench-wrap { --board-h: calc(100svh - 76px - 160px - 56px); } }
@media (max-width: 900px) {
    #board-scroll { align-items: flex-start; }
    #board-scroll .board-frame { margin: auto; }
    #bench-wrap { width: max(calc(100vw - 64px), 720px); aspect-ratio: 16 / 9; max-height: none; }
    .capsule-aux { max-width: none; }
}
@media (max-width: 900px) { .intro-obj.wide { left: 50%; width: 112vw; } #inst-table .trow > button { grid-template-columns: 34px 150px 1fr 24px; } #inst-table .t-chip { font-size: 15px; } }

/* a number with its unit inside Arabic text keeps its own order */
.u { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.tile-list .rows b { white-space: nowrap; }
/* units keep their case: mA is not MA */
.tt, .rows b.mono, .eq { text-transform: none; letter-spacing: .02em; }
