/* The 3D bench: home page "Try a piece" and the lessons built on it. */
/* the bench is the whole screen: the floor runs to every edge and the HUD floats over it, no frame */
html:has(.bench), html:has(.bench) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.bench { position: fixed; inset: 0; overflow: hidden; --pad: 16px; --pt: max(var(--pad), env(safe-area-inset-top)); --pb: max(var(--pad), env(safe-area-inset-bottom)); --pl: max(var(--pad), env(safe-area-inset-left)); --pr: max(var(--pad), env(safe-area-inset-right)); }
.bench canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
/* edges sink into the dark so the floor reads as a world, and the HUD text stays readable over it */
.bench::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 75% 70% at 50% 55%, transparent 55%, color-mix(in srgb, var(--fl-bg) 70%, transparent)), linear-gradient(var(--fl-bg), transparent 22%, transparent 82%, color-mix(in srgb, var(--fl-bg) 80%, transparent)); }
.hud-title { position: absolute; top: var(--pt); left: var(--pl); display: flex; align-items: center; gap: 10px; }
.hud-title .back { display: grid; place-items: center; width: 44px; height: 44px; color: var(--fl-text); background: color-mix(in srgb, var(--fl-surface) 85%, transparent); border: 1px solid color-mix(in srgb, var(--fl-holo) 30%, transparent); border-radius: var(--fl-radius); }
.hud-title .back:hover, .hud-title .back:focus-visible { border-color: var(--fl-holo); color: var(--fl-holo); outline: none; }
.hud-title h1 { margin: 0; font-size: var(--fl-h3); line-height: 1.1; }
.hud-title p { margin: 0; font: var(--fl-small) var(--fl-font-display); color: var(--fl-muted); }
.bench canvas[data-cur="grab"] { cursor: var(--cur-grab); }
.bench canvas[data-cur="grabbing"] { cursor: var(--cur-grabbing); }
.bench canvas[data-cur="turn"] { cursor: var(--cur-turn); }
.bench canvas[data-cur="crosshair"] { cursor: var(--cur-wire); }
.bench canvas[data-cur="move"] { cursor: var(--cur-move); }
.bench canvas[data-cur="copy"] { cursor: var(--cur-place); }
.bench canvas[data-cur="pointer"] { cursor: var(--cur-pointer); }
.traffic { display: flex; gap: 8px; align-items: center; font: var(--fl-small) var(--fl-font-display); color: var(--fl-muted); }
.traffic input { accent-color: var(--fl-holo); width: 110px; }
/* part cards and tips: drop in top-right, one at a time */
.card { position: absolute; top: var(--pt); right: var(--pr); width: min(360px, calc(100% - 32px)); max-height: calc(100% - 2 * var(--pad)); overflow: auto; padding: 12px 16px; background: color-mix(in srgb, var(--fl-surface) 92%, transparent); border: 1px solid var(--fl-holo); border-radius: var(--fl-radius); box-shadow: 0 0 24px rgb(61 220 255 / .15); font-size: .8125rem; line-height: 1.45; }
.card.tip { border-color: var(--fl-hazard); box-shadow: 0 0 24px rgb(255 120 40 / .15); }
.card .k { margin: 0 0 4px; font: var(--fl-small) var(--fl-font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--fl-holo); }
.card.tip .k { color: var(--fl-hazard); }
.card h3 { margin: 0 0 6px; font-size: 1.0625rem; color: var(--fl-text); }
.card p { margin: 0 0 6px; }
.card .real { color: var(--fl-muted); font-size: .75rem; margin: 0; }
.card .act:not(:empty) { margin-top: 10px; }
.card .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--fl-muted); font: 18px var(--fl-font-display); cursor: var(--cur-pointer); padding: 4px 6px; }
@media (prefers-reduced-motion: no-preference) { .card:not([hidden]) { animation: fl-card-in .35s var(--fl-ease); } @keyframes fl-card-in { from { opacity: 0; transform: translateY(-8px); } } }
.readout { position: absolute; top: calc(var(--pt) + 60px); left: var(--pl); font: var(--fl-small)/1.6 var(--fl-font-display); color: var(--fl-muted); pointer-events: none; }
.readout b { font-weight: 400; color: var(--fl-text); }
.readout .hot { color: var(--fl-hazard); }
.readout .hint { margin-top: 4px; opacity: .7; }
.readout .goal { display: block; margin-top: 8px; padding: 4px 8px; border: 0; border-left: 2px solid var(--fl-holo); background: none; font: inherit; text-align: left; color: var(--fl-text); max-width: 300px; cursor: var(--cur-pointer); pointer-events: auto; }
.readout .goal.done { border-left-color: var(--fl-hazard); color: var(--fl-hazard); }
.card .act { display: flex; flex-wrap: wrap; gap: 6px; }
.card .act small { flex-basis: 100%; color: var(--fl-muted); font: var(--fl-small) var(--fl-font-display); }
.card .act .btn.ghost { font-size: 12px; padding: 6px 10px; }
.tools { position: absolute; left: var(--pl); right: var(--pr); bottom: var(--pb); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#status { flex: 1 1 220px; font: var(--fl-small)/1.4 var(--fl-font-display); color: var(--fl-muted); text-align: right; }

@media (max-width: 860px) {
  #status { text-align: left; }
  /* phones: still full screen; the card, toolbox and controls stack up from the bottom over the floor like a game's dock */
  .bench { display: flex; flex-direction: column; justify-content: flex-end; --pad: 12px; }
  .card { position: relative; top: 0; right: 0; width: auto; max-height: 40vh; margin: 0 var(--pr) 8px var(--pl); }
  .tools { position: relative; left: 0; right: 0; bottom: 0; padding: 0 var(--pr) var(--pb) var(--pl); }
}
/* live tags over each part (bench.js stepTags); the readout says the same for screen readers */
.tags { position: absolute; top: 0; left: 0; pointer-events: none; }
.tag { position: absolute; top: 0; left: 0; white-space: nowrap; padding: 2px 6px; font: 11px/1.3 var(--fl-font-display); color: var(--fl-text); background: color-mix(in srgb, var(--fl-bg) 70%, transparent); border: 1px solid color-mix(in srgb, var(--fl-holo) 45%, transparent); border-radius: 2px; }
.tag.hot { color: var(--fl-hazard); border-color: var(--fl-hazard); }
.tag[hidden] { display: none; }
.tag.sel { color: var(--fl-hazard); border-color: var(--fl-hazard); }
.tag.target { border-color: var(--fl-holo); box-shadow: 0 0 10px rgb(61 220 255 / .45); }
.tag.over { color: var(--fl-bg); background: var(--fl-holo); }
.tag.dim { opacity: .35; }
/* the ✕ on a selected cable's middle */
.cable-x { position: absolute; top: 0; left: 0; z-index: 2; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--fl-hazard); border-radius: 50%; background: var(--fl-surface); color: var(--fl-hazard); font: 16px/1 var(--fl-font-display); cursor: var(--cur-pointer); }
.cable-x:hover, .cable-x:focus-visible { background: var(--fl-hazard); color: var(--fl-hazard-ink); outline: none; }
.cable-x[hidden] { display: none; }
@media (pointer: coarse) { .cable-x { width: 44px; height: 44px; } }
#undo:disabled { opacity: .4; cursor: var(--cur); }
/* toolbox down the left: pictures of the real parts. Tap adds one, drag drops it where you let go */
.readout { left: calc(var(--pl) + 88px); }
.toolbox { position: absolute; left: var(--pl); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; padding: 6px; background: color-mix(in srgb, var(--fl-surface) 85%, transparent); border: 1px solid color-mix(in srgb, var(--fl-holo) 30%, transparent); border-radius: var(--fl-radius); }
.tool { display: grid; place-items: center; width: 66px; height: 66px; padding: 4px; background: none; border: 1px solid transparent; border-radius: var(--fl-radius); cursor: var(--cur-grab); touch-action: none; }
.tool img { width: 100%; height: 100%; pointer-events: none; }
.tool:hover, .tool:focus-visible { border-color: var(--fl-holo); box-shadow: 0 0 12px rgb(61 220 255 / .2); outline: none; }
.tool[aria-pressed="true"] { border-color: var(--fl-hazard); background: color-mix(in srgb, var(--fl-hazard) 12%, transparent); box-shadow: 0 0 12px rgb(255 122 26 / .25); }
.tool { position: relative; }
.tool-n { position: absolute; right: 5px; bottom: 3px; font: 11px/1 var(--fl-font-display); color: var(--fl-muted); }
.tool:disabled { cursor: var(--cur-no); }
.tool:disabled img { opacity: .4; }
.tool:disabled .tool-n { color: var(--fl-hazard); }
.tool-ghost { position: fixed; top: 0; left: 0; width: 66px; height: 66px; pointer-events: none; opacity: .85; z-index: 10; filter: drop-shadow(0 0 8px var(--fl-holo)); }
/* right-click / hold menu */
.menu { position: absolute; z-index: 5; min-width: 160px; padding: 4px; background: var(--fl-surface); border: 1px solid var(--fl-holo); border-radius: var(--fl-radius); box-shadow: 0 0 24px rgb(61 220 255 / .15); }
.menu small { display: block; padding: 4px 8px; font: 11px var(--fl-font-display); letter-spacing: .08em; text-transform: uppercase; color: var(--fl-muted); }
.menu button { display: block; width: 100%; padding: 6px 8px; background: none; border: 0; border-radius: 2px; text-align: left; font: var(--fl-small) var(--fl-font-display); color: var(--fl-text); cursor: var(--cur-pointer); }
.menu button:hover, .menu button:focus-visible { background: color-mix(in srgb, var(--fl-holo) 15%, transparent); outline: none; }
.menu[hidden] { display: none; }
@media (max-width: 860px) {
  .readout { left: var(--pl); top: calc(var(--pt) + 52px); }
  .toolbox { position: relative; top: 0; left: 0; transform: none; flex-direction: row; justify-content: center; align-self: center; margin: 0 0 8px; }
}
