/* Controls Trainer — Level 1 phone wiring view (cl-batch113). Used by js/l1-phone.js on phone-width screens. */
/* The real board stays laid out at desktop size (its wire geometry and photos are measured from it) but fixed off screen:
   a fixed element adds nothing to any scroll area, so Step 2 never scrolls inside itself. */
.l1p-on .l1-wiring-content{position:fixed !important;left:-4000px;top:0;width:1300px;visibility:hidden;pointer-events:none}
.l1p-on .wire-zoom-controls,.l1p-on .mobile-scroll-hint{display:none !important}
.l1p-back-to-phone[hidden]{display:none !important}

.l1p,.l1p-ops{--l1p-bg:#0b1724;--l1p-surface:#102335;--l1p-line:#24435f;--l1p-ink:#e7eef5;--l1p-muted:#9fb3c6;--l1p-accent:#f28c28;
  font-family:system-ui,"Segoe UI",Arial,sans-serif;font-size:15px;line-height:1.35;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.l1p{margin:10px 0 12px;border:1px solid var(--l1p-line);border-radius:14px;overflow:hidden;background:var(--l1p-surface);color:var(--l1p-ink);position:relative}
.l1p[hidden],.l1p-ops[hidden]{display:none !important}
.l1p *,.l1p-ops *{box-sizing:border-box}
.l1p-top{display:flex;align-items:center;gap:10px;padding:9px 10px;background:var(--l1p-bg);border-bottom:1px solid var(--l1p-line)}
.l1p-top-t{flex:1;min-width:0}
.l1p-top-t b{display:block;font-size:15px;letter-spacing:.3px}
.l1p-top-t span{display:block;color:var(--l1p-muted);font-size:12.5px}
.l1p-btn{font:600 14px system-ui,"Segoe UI",Arial,sans-serif;color:var(--l1p-ink);background:#16304a;border:1px solid var(--l1p-line);border-radius:10px;padding:8px 12px;min-height:40px;cursor:pointer;white-space:nowrap}
.l1p-btn:focus,.l1p-term:focus,.l1p-op:focus,.l1p-hot:focus{outline:3px solid var(--l1p-accent);outline-offset:2px}
.l1p-btn:focus:not(:focus-visible),.l1p-term:focus:not(:focus-visible),.l1p-op:focus:not(:focus-visible),.l1p-hot:focus:not(:focus-visible){outline:none}
.l1p-primary{background:var(--l1p-accent);border-color:var(--l1p-accent);color:#1a0f02}
.l1p-dark{background:#16212b;color:#fff;border:0;flex:none}
.l1p-lock{display:flex;gap:8px;align-items:center;padding:8px 10px;background:#3a1717;color:#ffd5d5;border-bottom:1px solid #6b2a2a;font-size:13px}
.l1p-lock[hidden]{display:none}
.l1p-lock span{flex:1;min-width:0}
.l1p-stage{height:min(74vh,640px);height:min(74svh,640px);min-height:440px;display:flex;flex-direction:column}
.l1p-pane{flex:1 1 0;min-height:0;display:flex;flex-direction:column}
.l1p-stage.split .l1p-pane:last-child{flex-grow:1.25}
.l1p-pane + .l1p-pane{border-top:2px solid var(--l1p-accent)}
.l1p-ov{flex:1;min-height:0;display:flex;padding:6px;background:radial-gradient(ellipse at 50% 40%,#1b3954,var(--l1p-surface) 70%)}
.l1p-ov svg{width:100%;height:100%;display:block}
.l1p-ov image,.l1p-photo img{mix-blend-mode:multiply}   /* the photos' white backgrounds take the backplate's color */
.l1p-dev{cursor:pointer;outline:none}
.l1p-dev.sel,.l1p-dev:focus{stroke:var(--l1p-accent);stroke-width:2}
.l1p-prompt{padding:7px 10px;background:#2a1c0c;color:#ffd7ad;font-size:13.5px;border-top:1px solid #6b4316;border-bottom:1px solid #6b4316}
.l1p-prompt b{color:#fff}

.l1p-zoom{flex:1;min-height:0;overflow:auto;padding:10px 10px 14px;background:linear-gradient(#cfd7de,#bcc6ce);color:#16212b;-webkit-overflow-scrolling:touch}
.l1p-zhead{display:flex;align-items:center;gap:8px;margin-bottom:8px}
/* (cl-batch117) "‹ Back to panel": the orange primary button, and the head stays at the top of the zoomed device's pane
   while its terminal list scrolls under it */
.l1p-panelback{background:var(--l1p-accent);border-color:var(--l1p-accent);color:#1a0f02;font-weight:800;font-size:15px;min-height:44px;padding:8px 14px;box-shadow:0 2px 10px rgba(242,140,40,.35);flex:none}
.l1p-zoom>.l1p-zhead{position:sticky;top:-10px;z-index:2;margin:-10px -10px 8px;padding:8px 10px;background:#cfd7de;box-shadow:0 2px 6px rgba(22,33,43,.18)}
.l1p-stage.split .l1p-zoom>.l1p-zhead{top:-7px;margin:-7px -8px 6px;padding:6px 8px}
.l1p-etag{min-width:0;font-family:ui-monospace,Consolas,monospace;font-size:13px;background:#f4f1e6;color:#1d2a35;border:1px solid #8d8a7d;border-radius:3px;padding:4px 8px}
.l1p-zsub{font-size:13px;color:#33424f;margin:0 0 8px}
/* the device's desktop photo, fitted to the pane, with a tap ring where each terminal really is */
.l1p-photo{position:relative;margin:0 auto 10px;width:min(100%,calc(250px * var(--ar)));max-width:100%}
.l1p-photo::before{content:"";display:block;padding-top:calc(100% / var(--ar))}   /* height from the width (iOS 14 has no aspect-ratio) */
.l1p-photo img{position:absolute;display:block;max-width:none;pointer-events:none}
.l1p-hot{position:absolute;width:26px;height:26px;margin:-13px 0 0 -13px;padding:0;border-radius:50%;border:2.5px solid #1f6fd1;background:rgba(255,255,255,.18);cursor:pointer;box-shadow:0 0 0 1px rgba(0,0,0,.35)}
.l1p-hot.wired{border-color:#2fbf71;background:rgba(47,191,113,.3)}
.l1p-hot.factory{border-color:rgba(138,148,157,.8);background:transparent}
.l1p-hot.picked{border-color:var(--l1p-accent);background:rgba(242,140,40,.45);animation:l1p-pulse 1s ease-in-out infinite}
.l1p-face{background:#2e353c;border-radius:10px;padding:8px 6px;display:grid;gap:8px;color:#e9eef2;box-shadow:0 5px 0 #1b2026}
.l1p-trow{display:flex;flex-wrap:wrap;gap:6px;justify-content:center}
.l1p-term{width:72px;min-height:92px;display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 2px;border-radius:10px;
  background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.14);color:inherit;font:inherit;cursor:pointer}
.l1p-screw{width:38px;height:38px;border-radius:50%;background:radial-gradient(circle at 40% 35%,#fff,#d9dee3 55%,#9aa4ad);border:3px solid #1f6fd1;position:relative;flex:none}
.l1p-screw::before,.l1p-screw::after{content:"";position:absolute;left:50%;top:50%;background:#59636c;transform:translate(-50%,-50%)}
.l1p-screw::before{width:16px;height:3px}.l1p-screw::after{width:3px;height:16px}
.l1p-tid{font-family:ui-monospace,Consolas,monospace;font-size:12.5px;font-weight:600;text-align:center;line-height:1.15}
.l1p-tdesc{font-size:10.5px;line-height:1.2;opacity:.85;text-align:center;min-height:12px}
.l1p-stub{font-family:ui-monospace,Consolas,monospace;font-size:10px;line-height:1.2;padding:2px 4px;border-radius:4px;background:#0d2f57;color:#cfe6ff;text-align:center;word-break:break-word}
.l1p-term.wired .l1p-screw{border-color:#2fbf71}
.l1p-term.factory{opacity:.6}
.l1p-term.factory .l1p-screw{border-color:#8a949d}
.l1p-term.picked{outline:3px solid var(--l1p-accent);outline-offset:1px;background:rgba(242,140,40,.28);opacity:1}
.l1p-term.picked .l1p-screw{border-color:var(--l1p-accent);animation:l1p-pulse 1s ease-in-out infinite}
@keyframes l1p-pulse{50%{box-shadow:0 0 0 6px rgba(242,140,40,.35)}}
.l1p-factory{margin:10px 0 0;font-size:13px;background:#f4f1e6;border:1px solid #c8c2ad;border-radius:8px;padding:9px 11px;color:#3b3626}
/* split screen: compact, so both ends of a wire fit */
.l1p-stage.split .l1p-zoom{padding:7px 8px 9px}
.l1p-stage.split .l1p-zsub{font-size:12px;margin-bottom:5px}
.l1p-stage.split .l1p-photo{width:min(100%,calc(150px * var(--ar)))}
.l1p-stage.split .l1p-hot{width:22px;height:22px;margin:-11px 0 0 -11px}
.l1p-stage.split .l1p-term{width:58px;min-height:72px;padding:4px 1px}
.l1p-stage.split .l1p-screw{width:30px;height:30px;border-width:2.5px}
.l1p-stage.split .l1p-tdesc{font-size:9.5px}

.l1p-toast{position:absolute;left:50%;top:62px;transform:translateX(-50%);width:max-content;max-width:90%;background:#0e2a19;border:1px solid #2f6b4c;color:#bff5d6;padding:8px 12px;border-radius:10px;font-size:13px;text-align:center;pointer-events:none;opacity:0;transition:opacity .2s;z-index:3}
.l1p-toast.show{opacity:1}
.l1p-toast.warn{background:#3a2a0c;border-color:#7a5a1a;color:#ffe3a8}
.l1p-sheet-back{position:absolute;top:0;right:0;bottom:0;left:0;background:rgba(5,12,20,.55);display:flex;align-items:flex-end;z-index:4}
.l1p-sheet{width:100%;max-height:80%;overflow:auto;background:var(--l1p-surface);border-top:2px solid var(--l1p-accent);border-radius:14px 14px 0 0;padding:12px;display:grid;gap:8px}
.l1p-sheet h3{margin:0;font-size:17px;color:var(--l1p-ink)}
.l1p-sheet p{margin:0 0 4px;color:var(--l1p-muted);font-size:13px}

/* operator controls: the door pushbuttons, E-Stop, overload and fuse reset of the hidden board */
.l1p-ops{background:var(--l1p-bg);color:var(--l1p-ink);border-top:1px solid var(--l1p-line);padding:10px}
#restoreTestStep .l1p-ops{border:1px solid var(--l1p-line);border-radius:12px;margin:8px 0 12px}
.l1p-ops-h{display:flex;align-items:center;gap:8px;justify-content:space-between;margin-bottom:8px;flex-wrap:wrap}
.l1p-motor{font:700 12.5px ui-monospace,Consolas,monospace;padding:4px 8px;border-radius:6px;background:#2a1414;color:#ffb4b4;max-width:100%}
.l1p-motor.run{background:#0f3a22;color:#9ff0c4}
/* (cl-batch115) two columns: Start and Stop big on top, E-Stop and the overload smaller under them, the fuse reset (when
   shown) across the full width, so no button is left alone on a row and "Press E-Stop" stays on one line */
.l1p-ops-row{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.l1p-op{touch-action:none;min-width:0;min-height:56px;padding:4px 6px;border-radius:12px;border:2px solid rgba(0,0,0,.35);font:800 16px system-ui,"Segoe UI",Arial,sans-serif;line-height:1.15;color:#fff;cursor:pointer;background:#33475a}
.l1p-op.estop,.l1p-op.ol,.l1p-op.fuse{min-height:44px;font-size:14px}
.l1p-op.fuse{grid-column:1 / -1}
.l1p-op[hidden]{display:none}
.l1p-op.start{background:#1f9d45}
.l1p-op.stop{background:#c8352e}
.l1p-op.estop{background:#8f1414;border-color:#f5c400}
.l1p-op.ol{background:#4d5b69}
.l1p-op.fuse{background:#6b4b12}
.l1p-op.held{filter:brightness(.8);transform:translateY(1px);box-shadow:inset 0 3px 8px rgba(0,0,0,.45)}
.l1p-ops-note{margin:8px 0 0;font-size:12px;color:var(--l1p-muted)}
@media (prefers-reduced-motion:reduce){.l1p-term.picked .l1p-screw,.l1p-hot.picked{animation:none}.l1p-toast{transition:none}}

/* (cl-batch117, John: "Step 4 I/O status needs to be fixed on mobile") trainer.css gives the I/O table a 430px minimum,
   so on a phone its State column sat off the side of the panel. Each row becomes the tag with its address under it and
   the live state as a pill on the right (green while ON or 1: js/l1-phone.js marks it). */
@media (max-width:700px){
  .l1 .io-panel{overflow-x:visible}
  .l1 .io-panel table{min-width:0 !important;width:100%}
  .l1 .io-panel thead{display:none}
  .l1 .io-panel tbody tr{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px;align-items:center;padding:9px 14px;border-bottom:1px solid #e2e8ef}
  .l1 .io-panel tbody td{border:0;padding:0;font-size:.9rem;min-width:0;overflow-wrap:anywhere}
  .l1 .io-panel tbody td:nth-child(2){grid-row:1;grid-column:1;font-weight:700;font-family:ui-monospace,Consolas,monospace}
  .l1 .io-panel tbody td:nth-child(1){grid-row:2;grid-column:1;font-size:.78rem;color:#5d6b78}
  .l1 .io-panel tbody td:nth-child(3){grid-row:1 / span 2;grid-column:2;min-width:58px;text-align:center;font:800 .82rem ui-monospace,Consolas,monospace;padding:6px 10px;border-radius:999px;background:#e8edf2;color:#45576a}
  .l1 .io-panel tbody td.l1p-io-on{background:#d9f3df;color:#166534}
}

/* October 28 mobile polish: readable controls; original board geometry is untouched. */
.l1p-tool-note[hidden] {display:none!important}
#fieldWiringStep.l1p-on #wiringToolbar .ctwt-tip {display:none}
.l1p {margin:12px;border-color:#c9d5df;border-radius:16px;box-shadow:0 4px 16px #102a4110}
.l1p-top {padding:16px;align-items:flex-start;flex-wrap:wrap;gap:12px}
.l1p-top-t {flex-basis:190px}
.l1p-top-t b {font-size:17px;letter-spacing:0}
.l1p-top-t span {font-size:13px;line-height:1.5;margin-top:5px}
.l1p-btn {min-height:44px;border-radius:10px;line-height:1.3;white-space:normal}
.l1p-zoom {background:#e7edf2}
.l1p-zoom>.l1p-zhead {display:grid;grid-template-columns:1fr;gap:8px;background:#e7edf2;box-shadow:0 2px 6px #17314912}
.l1p-panelback {justify-self:start;box-shadow:none;padding:10px 14px}
.l1p-etag {font:650 15px/1.4 system-ui,'Segoe UI',sans-serif;background:transparent;border:0;padding:0;color:#16364c;overflow-wrap:anywhere}
.l1p-zsub {font-size:13px;line-height:1.5;margin:10px 0 14px}
.l1p-face {background:#152b3c;box-shadow:none;padding:10px;border:1px solid #395166;gap:10px}
.l1p-trow {display:grid;grid-template-columns:repeat(auto-fit,minmax(86px,1fr));gap:8px}
.l1p-term {width:100%;min-height:100px;padding:10px 6px;gap:6px;border-radius:10px}
.l1p-tid {font-size:14px;line-height:1.3}
.l1p-tdesc {font-size:12px;line-height:1.35;overflow-wrap:anywhere}
.l1p-stub {font-size:11px;line-height:1.4}
.l1p-stage.split .l1p-term {width:100%;min-height:82px;padding:6px}
.l1p-stage.split .l1p-tdesc {font-size:11px}
.l1p-stage.split .l1p-zhead {gap:4px}
.l1p-stage.split .l1p-etag {font-size:13px}
.l1p-stage.split .l1p-panelback {min-height:40px;padding:6px 10px;font-size:13px}
.l1p-ops {padding:16px}
.l1p-ops-h {line-height:1.5;margin-bottom:12px}
.l1p-op {border-width:1px;min-height:52px;font-weight:700;border-radius:10px}
.l1p-op.start {background:#187b39}
.l1p-op.estop {border-width:2px}
.l1p-ops-note {font-size:13px;line-height:1.5}
.l1p-motor {font:650 12px/1.5 system-ui,'Segoe UI',sans-serif;overflow-wrap:anywhere}
.l1p-sheet h3 {line-height:1.4;overflow-wrap:anywhere}
@media(max-width:700px){
  .l1 .panel-head {padding:18px 16px}
  .l1 .panel-head h2 {font:700 22px/1.3 system-ui,'Segoe UI',sans-serif;letter-spacing:-.02em}
  .l1 .panel-head p {font:400 15px/1.6 system-ui,'Segoe UI',sans-serif;margin-top:10px;color:#526577}
  .l1 .lesson-step {font:700 12px/1.4 system-ui,'Segoe UI',sans-serif;letter-spacing:.1em;margin-bottom:7px}
  #fieldWiringStep.l1p-on #wiringToolbar {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:14px 12px}
  #fieldWiringStep.l1p-on #wiringToolbar button {width:auto;min-width:0;min-height:44px;padding:9px 6px;font:650 13px/1.3 system-ui,'Segoe UI',sans-serif;border:1px solid #b8cbd9;border-radius:10px;background:#fff;color:#173b55;box-shadow:none;white-space:normal}
  #fieldWiringStep.l1p-on #wiringToolbar #showHint {background:#173b55;color:white;border-color:#173b55;order:-1}
  #fieldWiringStep.l1p-on #wiringToolbar #clearWires {color:#873e30}
  #fieldWiringStep.l1p-on #wiringToolbar .l1p-tool-note {grid-column:1/-1;font:400 13px/1.5 system-ui,'Segoe UI',sans-serif;color:#526577}
  #fieldWiringStep.l1p-on .wiring-footer {margin:12px;padding:14px;border-radius:12px;background:#f2f6fa;line-height:1.6;overflow-wrap:anywhere}
  .l1p-lock {flex-wrap:wrap;padding:14px;gap:12px;line-height:1.5}
  .l1p-lock span {flex-basis:180px}
  .l1 .io-panel tbody tr {padding:12px 16px}
}

/* Panel pinch owns only the overview; device views retain normal scrolling.
   Page-level magnification elsewhere and the viewport meta are unchanged. */
/* (cl-batch118) pan-y at Fit: a finger scrolls the lesson natively (with momentum) and the pinch stays with the panel;
   js/l1-phone.js switches it to none while zoomed in, so one finger pans the drawing */
.l1p-ov svg.l1p-gesture-surface{touch-action:pan-y}
/* (cl-batch119) the page itself is magnified: the browser gets the pinch back, so it can zoom out (beats the inline none) */
.l1p.l1p-pagezoom svg.l1p-gesture-surface{touch-action:manipulation!important}
.l1p-panel-zoom{display:flex;flex:none;align-items:center;justify-content:flex-end;gap:8px;padding:6px 10px;background:var(--l1p-bg);border-top:1px solid var(--l1p-line)}
.l1p-panel-zoom .l1p-btn{min-height:44px;min-width:44px;padding:8px 10px}
.l1p-panel-zoom .l1p-percent{margin-right:auto;font-size:13px;font-variant-numeric:tabular-nums;color:var(--l1p-muted)}
.l1p-panel-zoom .l1p-btn:disabled{opacity:.45;cursor:default}

/* (cl-batch120) a device with many screws (js/l1-phone.js marks it .l1p-many): its photo larger on its own, and only its
   terminal list in the half-screen panes of a wire in progress, where the photo's tap rings were piled on each other */
.l1p-zoom.l1p-many .l1p-photo{width:min(100%,calc(420px * var(--ar)))}
.l1p-stage.split .l1p-zoom.l1p-many .l1p-photo{display:none}
.l1p-stage.split .l1p-term{min-height:64px}

/* (cl-batch120) a tutorial card about the wiring (body.l1p-tut-dock, js/l1-phone.js) is a short sheet above the lesson bar,
   with no dimming, so the panel above it stays visible and tappable; its notes scroll inside the sheet */
/* (14px sides: the width the shared layout allows a card; any wider and it finds no place and folds the notes away) */
body.l1p-tut-dock .ct-tutorial-card{top:auto!important;bottom:calc(68px + env(safe-area-inset-bottom,0px))!important;left:14px!important;right:14px!important;
  width:auto!important;max-height:40vh!important;max-height:40svh!important}
body.l1p-tut-dock .ct-tutorial-spotlight,body.l1p-tut-dock .ct-tour-viewport-note{display:none!important}

/* (cl-batch120) the Wiring Guide on a phone is a sheet over the bottom half (above the lesson bar), not the whole screen, so
   the panel stays usable while it is open, as its title bar says */
body.l1p-phone #wiringHint.wiring-guide-window{inset:auto 8px calc(68px + env(safe-area-inset-bottom,0px)) 8px!important;width:auto!important;
  max-height:46vh!important;max-height:46svh!important}

/* (cl-batch120) on a phone the tutorial card drops its "Interactive tutorial" and "Step N of 20" lines and the picker's label
   (the picker itself names the step; screen readers get its aria-label), so its notes fit instead of running under the buttons */
@media (max-width:700px){
  .ct-tutorial-card .ct-tutorial-kicker,.ct-tutorial-card .ct-tutorial-step-count{display:none!important}
  .ct-tutorial-card .ct-tutorial-jump{display:block;font-size:0;margin:0 0 8px}
  .ct-tutorial-card .ct-tutorial-jump select{font-size:14px;min-height:40px;padding:6px 8px;width:100%;margin:0}
  .ct-tutorial-card .ct-tour-position-tools{margin-bottom:6px}
}
