/* 70_3d.css - KP Equipment 3D view (Orkie floor).
 * A6a: the overlay chrome (view buttons, hint, name label, joystick) uses the app tokens from 01_tokens.css, so it
 * follows light and dark with the rest of the page. A6c: the scene follows the theme too (see the end of this file). */
.kp3d { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--kp3d-bg); font-family: var(--font); font-size: 14px; color: var(--ink); }
.kp3d-stage { position: absolute; inset: 0; }
.kp3d-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

/* view buttons: Orbit | Drone as one joined pair, Reset view beside it */
.kp3d-tools { position: absolute; top: 12px; left: 24px; display: flex; align-items: center; max-width: calc(100% - 48px); } /* V2a (CR-2): 24 px from both screen edges */
.kp3d-btn { position: relative; min-height: 44px; min-width: 64px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-soft); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; box-shadow: var(--shadow); }
.kp3d-btn:hover { background: var(--surface-alt); color: var(--ink); }
.kp3d-btn[data-mode="map"] { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.kp3d-btn[data-mode="drone"] { margin-left: -1px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.kp3d-btn:not([data-mode="map"]):not([data-mode="drone"]) { margin-left: 8px; font-weight: 500; }
.kp3d-btn.on, .kp3d-btn.on:hover { z-index: 1; background: var(--navy); border-color: var(--navy); color: #ffffff; }
[data-theme="dark"] .kp3d-btn.on, [data-theme="dark"] .kp3d-btn.on:hover { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.kp3d-btn:focus-visible { z-index: 2; outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: var(--shadow); }

/* loading: a thin line along the top edge of the view */
.kp3d-prog { position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: rgba(30, 58, 95, .12); overflow: hidden; }
.kp3d-bar { height: 100%; width: 0; background: var(--brand-solid); transition: width .15s linear; }

/* hint: a quiet chip in the bottom corner; it steps aside once a machine is picked */
/* V1b: the hint was pale grey on grey; it now uses the page ink on a near-solid card (both themes) and keeps clear of the map buttons */
.kp3d-status { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 104px); padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); background: color-mix(in srgb, var(--surface) 96%, transparent); color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.4; box-shadow: var(--shadow-sm); pointer-events: none; transition: opacity var(--dur-slow) var(--ease); }
.kp3d:has(.kp3d-label:not(.kp3d-hide)) .kp3d-status { opacity: 0; }
/* A6d: with a record open the hint has done its job; it also keeps clear of the phone record sheet */
body.is-3d:has(.drawer:not([hidden])) .kp3d-status { opacity: 0; }
/* ready for 70_3d.js: when it marks the hint .is-ready, the hint fades by itself after a few seconds */
.kp3d-status.is-ready { animation: kp3d-hint-out .4s var(--ease) 6s forwards; }
@keyframes kp3d-hint-out { to { opacity: 0; } }

/* name of the picked machine: shown only while its record is not on screen */
.kp3d-label { position: absolute; left: 12px; right: 12px; bottom: 12px; width: fit-content; max-width: min(560px, calc(100% - 24px)); margin: 0 auto; padding: 10px 18px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; text-align: center; overflow-wrap: anywhere; box-shadow: var(--shadow); }
body.is-3d:not(.drawer-tucked):has(.drawer:not([hidden])) .kp3d-label { display: none; }

/* drone joystick (touch): same place and size as before - 70_3d.js reads its box */
.kp3d-joy { position: absolute; left: 24px; bottom: 70px; width: 110px; height: 110px; border: 2px solid rgba(30, 58, 95, .4); border-radius: 50%; background: rgba(255, 255, 255, .45); display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; font-weight: 600; color: #1e3a5f; pointer-events: none; }
.kp3d-hide { display: none !important; }
@media print { .kp3d { display: none; } }

/* t35a: the 3D view sits exactly over the 2D stage (placed by 70_3d.js setView) */
.kp3d-host { position: fixed; z-index: 40; overflow: hidden; background: var(--kp3d-bg); }
.kp3d-host[hidden] { display: none; }

/* A6a stacking: page chrome that opens over the stage must stay above the 3D view (z 40) */
body.is-3d .kp-bar { z-index: 45; }          /* search results */
body.is-3d .drawer-tab { z-index: 42; }      /* the record panel's Hide / Show tab */
body.is-3d .legend-panel { z-index: 42; }    /* Key */
body.is-3d .changes-menu { z-index: 46; }    /* Changes */

/* a2: phone / short landscape - the record is a bottom sheet (z 30, 30_plan.css); in 3D it must sit above the 3D view.
   With the sheet open the drone joystick lifts clear of the peek card. */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  body.is-3d .drawer:not([hidden]) { z-index: 41; }
  body.is-3d:has(.drawer:not([hidden])) .kp3d-joy { bottom: 170px; }
}

/* ==== A6c: the scene follows the theme and the 2D plan. 70_3d.js reads the first three values for the 3D background, the
   sheet under the building and the caption lettering; machine and area colours come from the plan's own tokens. ==== */
:root { --kp3d-bg: #e6ebef; --kp3d-base: #f8fafc; --kp3d-note: #64748b; --kp3d-area-ink: #334155; --kp3d-halo: rgba(248, 250, 252, .94);
  /* A6d: a solid one-pixel outline plus a soft glow behind every name, so it reads on any floor, box or model */
  --kp3d-out-light: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 -1px 0 #fff, 0 1px 0 #fff, -1px 0 0 #fff, 1px 0 0 #fff, 0 0 4px rgba(255, 255, 255, .95), 0 0 7px rgba(255, 255, 255, .7);
  --kp3d-out-dark: -1px -1px 0 #0b1120, 1px -1px 0 #0b1120, -1px 1px 0 #0b1120, 1px 1px 0 #0b1120, 0 -1px 0 #0b1120, 0 1px 0 #0b1120, -1px 0 0 #0b1120, 1px 0 0 #0b1120, 0 0 4px rgba(11, 17, 32, .95), 0 0 7px rgba(11, 17, 32, .7);
  --kp3d-area-out: var(--kp3d-out-light); }
[data-theme="dark"] { --kp3d-bg: #0b1120; --kp3d-base: #141d30; --kp3d-note: #94a3b8; --kp3d-area-ink: #f1f5f9; --kp3d-halo: rgba(11, 17, 32, .94); --kp3d-area-out: var(--kp3d-out-dark); }

/* names drawn over the scene as page text, so they stay sharp at any zoom; 70_3d.js shows one only where it fits */
.kp3d-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.kp3d-lab { position: absolute; left: 0; top: 0; white-space: nowrap; transition: opacity .16s var(--ease); }
.kp3d-lab-eq { padding: 0 3px; font-size: 12px; font-weight: 600; line-height: 16px; letter-spacing: .01em; }
.kp3d-lab-eq.on-light { color: #0f172a; text-shadow: var(--kp3d-out-light); }
.kp3d-lab-eq.on-dark { color: #f8fafc; text-shadow: var(--kp3d-out-dark); }
/* the picked machine's name: a pill in the app accent, just above the machine. A6d: a long name is cut with an ellipsis and the pill never leaves the view */
.kp3d-lab-eq.is-sel { z-index: 2; box-sizing: border-box; max-width: min(320px, calc(100% - 16px)); overflow: hidden; text-overflow: ellipsis; padding: 5px 13px; border-radius: var(--r-pill); background: var(--brand-solid); color: #ffffff; font-size: 13px; line-height: 18px; text-shadow: none; box-shadow: 0 0 0 2px var(--kp3d-halo), var(--shadow); }
[data-theme="dark"] .kp3d-lab-eq.is-sel { background: var(--brand); color: var(--on-brand); }
/* A6d: a ring marks the picked machine while it is small on screen (phone, whole-floor view) */
.kp3d-ring { position: absolute; left: 0; top: 0; z-index: 1; box-sizing: border-box; border: 3px solid var(--brand-solid); border-radius: 50%; box-shadow: 0 0 0 2px var(--kp3d-halo), inset 0 0 0 2px var(--kp3d-halo); transition: opacity .16s var(--ease); }
[data-theme="dark"] .kp3d-ring { border-color: var(--brand); }
.kp3d-lab-area { padding: 1px 4px; font-weight: 700; line-height: 1.25; letter-spacing: .08em; text-transform: uppercase; color: var(--kp3d-area-ink); text-shadow: var(--kp3d-area-out); }
/* A6d: a name that loses its place fades out instead of blinking off */
.kp3d-off { opacity: 0; visibility: hidden; transition: opacity .16s var(--ease), visibility 0s linear .16s; }
@media (prefers-reduced-motion: reduce) { .kp3d-lab, .kp3d-ring, .kp3d-off { transition: none; } }
[data-theme="dark"] .kp3d-joy { border-color: rgba(147, 197, 253, .5); background: rgba(30, 41, 59, .55); color: #e2e8f0; }
[data-theme="dark"] .kp3d-prog { background: rgba(148, 163, 184, .2); }

/* V1a: Map mode owns every touch on the 3D stage (no browser scroll, pinch-zoom or double-tap zoom); the focused canvas shows a ring for keyboard users */
.kp3d-stage { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.kp3d-canvas:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ==== V1b: the map buttons (compass, zoom in / out, home), bottom-right in thumb reach; 70_3d.js lifts them above the phone record sheet ==== */
/* V1c: the column and the drone joystick sit 24 px from the screen edge (Android edge-swipe keep-clear) */
.kp3d-nav { position: absolute; right: 24px; bottom: 12px; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.kp3d-nb { box-sizing: border-box; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--navy); box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.kp3d-nb:hover { background: var(--surface-alt); }
.kp3d-nb:focus-visible { position: relative; z-index: 1; outline: 3px solid var(--brand); outline-offset: 2px; }
.kp3d-nb svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.kp3d-zin { border-radius: var(--r-sm) var(--r-sm) 0 0; margin-bottom: -11px; }
.kp3d-zout { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.kp3d-compass { border-radius: 50%; }
.kp3d-compass svg { width: 32px; height: 32px; } /* V1c: the needle reads at about 28 px */
.kp3d-needle { transform-box: view-box; transform-origin: 12px 12px; }
.kp3d-compass .kp3d-n { fill: #dc2626; stroke: none; }
.kp3d-compass .kp3d-s { fill: currentColor; stroke: none; opacity: .5; }
[data-theme="dark"] .kp3d-nb { color: var(--ink); }
.kp3d-label { right: 84px; } /* V1c: clear of the button column 24 px from the edge */

/* N1-6b (Fable, 16/11/2026): the V2a area strip and its chips were taken out of the 3D view (70_3d.js, D344/D345); the area filter in the toolbar is the only chooser. Their rules are gone from this file. */

/* ==== V2b: the loading card (centred on the stage, percent and megabytes) and the failure card (one line why, Try again, Back to 2D).
   While the model loads, the view's buttons, strip, stick and hint are hidden (kept in layout, so the opening view is fitted as before). ==== */
.kp3d-card { position: absolute; left: 50%; top: 50%; z-index: 6; box-sizing: border-box; width: min(380px, calc(100% - 48px)); transform: translate(-50%, -50%); padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); text-align: center; box-shadow: var(--shadow); }
.kp3d-card-t { margin: 0 0 6px; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--navy); }
.kp3d-card-m { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--ink); font-variant-numeric: tabular-nums; }
.kp3d-card .kp3d-prog { position: relative; top: auto; left: auto; width: 100%; height: 6px; margin-top: 12px; border-radius: 3px; }
.kp3d-card-b { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.kp3d-card .kp3d-card-b .kp3d-btn { margin: 0; min-width: 120px; min-height: 44px; }
[data-theme="dark"] .kp3d-card-t { color: var(--ink); }
.kp3d.is-loading > .kp3d-tools, .kp3d.is-loading > .kp3d-nav, .kp3d.is-loading > .kp3d-joy, .kp3d.is-loading > .kp3d-status, .kp3d.is-loading > .kp3d-label, .kp3d.is-loading > .kp3d-labels { visibility: hidden !important; pointer-events: none !important; }
.kp3d.is-failed > :not(.kp3d-card) { display: none !important; }
/* V4 (N7): the loading card's spoken line (70_3d.js announce) - read by screen readers, not shown */
.kp3d-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ==== V4 (N3): a short stage in Map mode (70_3d.js shortSync adds .kp3d-short below 440 px high, e.g. a phone on its side). The map buttons go
   two to a row (104 px wide), the area strip ends 8 px before them, and on a touch screen + / - step aside (pinch zooms). Every button stays 48 px. ==== */
.kp3d.kp3d-short > .kp3d-tools { max-width: calc(100% - 160px); }
.kp3d.kp3d-short > .kp3d-nav { display: grid; grid-template-columns: 48px 48px; gap: 8px; align-items: center; justify-items: center; }
.kp3d.kp3d-short .kp3d-zin, .kp3d.kp3d-short .kp3d-zout { margin: 0; border-radius: var(--r-sm); }
@media (pointer: coarse) { .kp3d.kp3d-short .kp3d-zin, .kp3d.kp3d-short .kp3d-zout { display: none; } }

/* ==== D-A: design pass, 10/11/2026 (punch list P1-1, P2-1, P2-5) ==== */
/* P1-1: while the record panel's Hide / Show tab sits on the stage's right edge (44 px wide, mid-height), the map buttons and the name pill step 44 px
   to the left: the tab never covers "?" and 24 px stays clear between them. The sizes are the ones where the record is a side panel (not the phone sheet). */
@media screen and (min-width: 701px) and (min-height: 501px), screen and (min-width: 961px) {
  body.is-3d:has(#drawer-tab:not([hidden])) .kp3d-nav { right: 68px; }
  body.is-3d:has(#drawer-tab:not([hidden])) .kp3d-label { right: 128px; }
}
/* P2-5: in 3D the toolbar keeps what acts on the 3D view (Area, Colour, Key), the count and Changes. Show retired and the 2D plan's zoom buttons
   (Fit, + and -) change nothing there - the 3D view has its own Home and zoom - so they step out until the 2D plan is back. */
body.is-3d .toolbar .check, body.is-3d .toolbar .zoom { display: none; }

/* ==== H-A (Fable, 16/11/2026): the tools row on a phone held upright ====
 * Map | Drone sits 8 px from the edge and has the row to itself; the empty part of the row lets touches through to
 * the map. N1-6b (16/11/2026): the area chips that had a second row here are gone (the area filter in the toolbar is
 * the only chooser, D344/D345), so that row and its rule went with them. Nothing is kept free under Map | Drone.
 * Phone only, and only while the screen is narrow: a phone on its side keeps the one-row layout. */
@media screen and (max-width: 600px) {
  html[data-device="phone"] .kp3d > .kp3d-tools { top: 8px; left: 0; right: 0; box-sizing: border-box; max-width: none; flex-wrap: wrap; row-gap: 4px; padding: 0 8px; pointer-events: none; }
  html[data-device="phone"] .kp3d > .kp3d-tools > * { pointer-events: auto; }
}
/* ==== end H-A ==== */

/* ==== N1-7 (Fable, 16/11/2026): phone - the floating 3D buttons sit at the edge, on one line ====
 * Placement only. No size, colour or control changes; the area chips and the area picker are not touched.
 * Map: the button column (help, compass, zoom, home) was 24 px in from the right edge and covered more of the model
 *      than it needed to. It is now 8 px in, the same margin as the Map / Drone switch on the left, and the hint
 *      beside it may use the room that frees.
 * Drone: Help and Home share a centre line with Map / Drone (they sat 4 px lower), and the hint starts under the
 *      switch at the same 8 px margin instead of 24 px.
 * Tablet and PC are not changed: nothing there overlaps (measured at 800, 1280, 1440 and 1920 px). */
@media screen and (max-width: 600px) {
  html[data-device="phone"] .kp3d > .kp3d-nav { right: 8px; }
  html[data-device="phone"] .kp3d > .kp3d-status { max-width: calc(100% - 88px); }
  html[data-device="phone"] .kp3d.kp3d-has-sticks:has(> .kp3d-sticks:not(.kp3d-hide)) > .kp3d-status { left: 8px; top: 60px; max-width: min(420px, 100% - 16px); }
}
@media screen and (max-width: 600px) and (min-height: 560px) {
  html[data-device="phone"] .kp3d.kp3d-has-sticks:has(> .kp3d-sticks:not(.kp3d-hide)) > .kp3d-nav { top: 6px; }
}
/* ==== end N1-7 ==== */
