/* 73_3dguide.css - KP Equipment 3D view: the "How to move around" card (drawn by js/73_3dguide.js inside the 3D stage).
 * Colours come from the app tokens in 01_tokens.css, each with a fallback, and the card follows the theme the same way
 * 70_3d.css does: [data-theme="dark"] on the page. Layout follows the size of the STAGE (container queries), not the window:
 * narrow stage = 2 columns, wide stage = 3 columns, wide and short stage (phone on its side) = one row. */
.kp3dg {
  --g-surface: var(--surface, #ffffff); --g-tile: var(--surface-alt, #f8fafc); --g-line: var(--line, #e2e8f0);
  --g-ink: var(--ink, #0f172a); --g-ink-soft: var(--ink-soft, #475569);
  --g-art: #1e3a5f; --g-move: var(--brand-solid, #2563eb);
  --g-btn: #1e3a5f; --g-btn-hover: #2b4d78; --g-btn-ink: #ffffff; --g-focus: var(--brand, #2563eb);
  --g-scrim: rgba(15, 23, 42, .38);
  position: absolute; inset: 0; z-index: 20; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 12px;
  container: kp3dg / size; background: var(--g-scrim); font-family: var(--font, 'Segoe UI', system-ui, sans-serif); color: var(--g-ink);
  touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; animation: kp3dg-fade .18s ease-out;
}
[data-theme="dark"] .kp3dg {
  --g-surface: var(--surface, #1e293b); --g-tile: var(--surface-alt, #0f172a); --g-line: var(--line, #334155);
  --g-ink: var(--ink, #f1f5f9); --g-ink-soft: var(--ink-soft, #cbd5e1);
  --g-art: #e2e8f0; --g-move: var(--brand, #60a5fa);
  --g-btn: var(--brand, #60a5fa); --g-btn-hover: var(--brand-hover, #93c5fd); --g-btn-ink: var(--on-brand, #0b1120); --g-focus: #ffffff;
  --g-scrim: rgba(2, 6, 23, .62);
}
/* only used when the stage it is given has no position of its own */
.kp3dg-host { position: relative; }

.kp3dg-card { box-sizing: border-box; width: 100%; max-width: 372px; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 16px; border: 1px solid var(--g-line); border-radius: 12px; background: var(--g-surface); box-shadow: var(--shadow-lg, 0 12px 32px rgba(15, 23, 42, .14)); outline: none; animation: kp3dg-rise .2s ease-out; }
.kp3dg-title { margin: 0 0 12px; padding: 0; font-size: 18px; font-weight: 700; line-height: 1.25; letter-spacing: 0; text-align: center; color: var(--g-ink); }
.kp3dg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.kp3dg-tile { display: flex; flex-direction: column; align-items: center; min-width: 0; margin: 0; padding: 8px 6px 10px; border: 1px solid var(--g-line); border-radius: 8px; background: var(--g-tile); text-align: center; }
.kp3dg-grid[data-n="5"] .kp3dg-tile:last-child { grid-column: 1 / -1; }
.kp3dg-pic { display: block; flex: none; width: 56px; height: 56px; overflow: hidden; }
.kp3dg-name { display: block; margin-top: 4px; font-size: 15px; font-weight: 600; line-height: 1.25; color: var(--g-ink); }
.kp3dg-how { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; line-height: 1.3; color: var(--g-ink-soft); }
.kp3dg-keys { margin: 12px 0 0; padding: 0; font-size: 13px; line-height: 1.4; text-align: center; color: var(--g-ink-soft); }
.kp3dg-keys b { font-weight: 600; color: var(--g-ink); }
.kp3dg-ok { display: block; box-sizing: border-box; width: 100%; min-height: 48px; margin: 14px 0 0; padding: 0 28px; border: 0; border-radius: var(--r-sm, 6px); background: var(--g-btn); color: var(--g-btn-ink); font-family: inherit; font-size: 16px; font-weight: 600; line-height: 1.2; cursor: pointer; touch-action: manipulation; }
.kp3dg-ok:active { filter: brightness(.92); }
.kp3dg-ok:focus-visible { outline: 3px solid var(--g-focus); outline-offset: 2px; }
@media (hover: hover) { .kp3dg-ok:hover { background: var(--g-btn-hover); } }

/* the pictures: fingers and mouse in the house navy, the movement in the app blue */
.kp3dg-art, .kp3dg-skin, .kp3dg-thin, .kp3dg-tint, .kp3dg-fillart { stroke: var(--g-art); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.kp3dg-art, .kp3dg-thin { fill: none; }
.kp3dg-thin { stroke-width: 1.5; }
.kp3dg-skin { fill: var(--g-tile); }
.kp3dg-tint { fill: var(--g-move); fill-opacity: .16; }
.kp3dg-fill { fill: var(--g-move); stroke: none; }
.kp3dg-fillart { fill: var(--g-move); }
.kp3dg-halo { fill: var(--g-move); fill-opacity: .24; stroke: none; }
.kp3dg-move, .kp3dg-ring, .kp3dg-ring2 { fill: none; stroke: var(--g-move); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.kp3dg-ring2 { stroke-opacity: .5; }

/* wide stage (tablet, PC): three across, larger pictures and words for reading at arm's length */
.kp3dg-grid { grid-auto-rows: 1fr; } /* every row the same height, even when one line of words wraps */
@container kp3dg (min-width: 600px) {
  .kp3dg-card { max-width: 700px; padding: 24px; } /* 700: "Slide two fingers up or down" stays on one line */
  .kp3dg-title { margin-bottom: 16px; font-size: 20px; }
  .kp3dg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .kp3dg-grid[data-n="5"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kp3dg-grid[data-n="5"] .kp3dg-tile, .kp3dg-grid[data-n="5"] .kp3dg-tile:last-child { grid-column: span 2; }
  .kp3dg-grid[data-n="5"] .kp3dg-tile:nth-child(4) { grid-column: 2 / span 2; }
  .kp3dg-tile { padding: 12px 8px 14px; }
  .kp3dg-pic { width: 72px; height: 72px; }
  .kp3dg-name { margin-top: 6px; font-size: 17px; }
  .kp3dg-how { font-size: 14px; }
  .kp3dg-keys { margin-top: 16px; font-size: 14px; }
  .kp3dg-ok { width: auto; min-width: 200px; margin: 20px auto 0; }
}
/* PC: the five mouse tiles sit in one row */
@container kp3dg (min-width: 900px) {
  .kp3dg-card.is-mouse { max-width: 860px; }
  .kp3dg-grid[data-n="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kp3dg-grid[data-n="5"] .kp3dg-tile, .kp3dg-grid[data-n="5"] .kp3dg-tile:last-child, .kp3dg-grid[data-n="5"] .kp3dg-tile:nth-child(4) { grid-column: auto; }
}
/* wide but short stage (a phone on its side): everything in one row so it still fits without scrolling */
@container kp3dg (min-width: 600px) and (max-height: 500px) {
  .kp3dg-card, .kp3dg-card.is-mouse { max-width: 860px; padding: 14px 16px; }
  .kp3dg-title { margin-bottom: 10px; font-size: 18px; }
  .kp3dg-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
  .kp3dg-grid[data-n="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kp3dg-grid[data-n="5"] .kp3dg-tile, .kp3dg-grid[data-n="5"] .kp3dg-tile:last-child, .kp3dg-grid[data-n="5"] .kp3dg-tile:nth-child(4) { grid-column: auto; }
  .kp3dg-tile { padding: 8px 6px 10px; }
  .kp3dg-pic { width: 56px; height: 56px; }
  .kp3dg-name { margin-top: 4px; font-size: 15px; }
  .kp3dg-how { font-size: 13px; }
  .kp3dg-keys { margin-top: 10px; font-size: 13px; }
  .kp3dg-ok { min-height: 44px; margin-top: 10px; }
}

/* ---- Drone cards ("How to fly"). Every rule here hangs off .is-drone, .kp3dg-stick, .kp3dg-pad, .kp3dg-dir, .kp3dg-kl or .kp3dg-cap,
 *      none of which the Map cards carry, so the Map cards are untouched.
 *      Two stick tiles (the stick's name, then its picture with a word at each arrow), then the small tiles.
 *      The mouse card lists the keys underneath as key caps. ---- */
.kp3dg-card.is-drone .kp3dg-grid { grid-auto-rows: auto; }
.kp3dg-stick .kp3dg-name { margin-top: 0; }
.kp3dg-pad { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; justify-items: center; gap: 2px 4px; width: 100%; margin-top: 4px; }
.kp3dg-pad .kp3dg-pic { grid-area: 2 / 2; }
.kp3dg-dir { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--g-ink); }
.kp3dg-dir.is-u { grid-area: 1 / 2; }
.kp3dg-dir.is-d { grid-area: 3 / 2; }
.kp3dg-dir.is-l { grid-area: 2 / 1; justify-self: end; }
.kp3dg-dir.is-r { grid-area: 2 / 3; justify-self: start; }
.kp3dg-kl { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.3; color: var(--g-ink-soft); }
.kp3dg-kl li { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; white-space: nowrap; }
.kp3dg-cap { display: block; box-sizing: border-box; min-width: 26px; padding: 3px 6px; border: 1px solid var(--g-art); border-bottom-width: 3px; border-radius: 5px; background: var(--g-tile); font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; color: var(--g-ink); }
.kp3dg-kw { margin-left: 3px; }
@container kp3dg (min-width: 600px) {
  .kp3dg-card.is-drone, .kp3dg-card.is-drone.is-mouse { max-width: 760px; } /* 760: four small tiles across, each line of words on one line */
  .kp3dg-card.is-drone .kp3dg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kp3dg-stick { grid-column: span 2; }
  .kp3dg-stick .kp3dg-pic { width: 88px; height: 88px; }
  .kp3dg-pad { gap: 4px 8px; margin-top: 6px; }
  .kp3dg-dir { font-size: 15px; }
  .kp3dg-kl { gap: 10px 22px; margin-top: 16px; font-size: 14px; }
  .kp3dg-cap { min-width: 28px; font-size: 14px; }
}
/* wide but short stage (a phone on its side): the two sticks and the four small tiles in one row */
@container kp3dg (min-width: 600px) and (max-height: 500px) {
  .kp3dg-card.is-drone, .kp3dg-card.is-drone.is-mouse { max-width: 860px; }
  .kp3dg-card.is-drone:not(.is-mouse) .kp3dg-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.35fr) repeat(4, minmax(0, 1fr)); }
  .kp3dg-stick { grid-column: auto; }
  .kp3dg-stick .kp3dg-pic { width: 56px; height: 56px; }
  .kp3dg-pad { gap: 2px 4px; margin-top: 4px; }
  .kp3dg-dir { font-size: 13px; }
  .kp3dg-kl { gap: 8px 18px; margin-top: 10px; font-size: 13px; }
  .kp3dg-cap { min-width: 26px; font-size: 13px; }
}

/* ---- Drone touch card when the hold-to-tilt buttons are on screen: one more small tile ("Tilt"), seven in all; the card then carries .is-tilt.
 *      Narrow stage: the last tile takes the full width. Wide stage: the five small tiles sit in one row under the two sticks. ---- */
.kp3dg-card.is-tilt .kp3dg-tile:last-child { grid-column: 1 / -1; }
@container kp3dg (min-width: 600px) {
  .kp3dg-card.is-drone.is-tilt .kp3dg-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .kp3dg-card.is-tilt .kp3dg-tile, .kp3dg-card.is-tilt .kp3dg-tile:last-child { grid-column: span 2; }
  .kp3dg-card.is-tilt .kp3dg-stick { grid-column: span 5; }
}
@container kp3dg (min-width: 1000px) {
  .kp3dg-card.is-drone.is-tilt { max-width: 960px; } /* 960: five small tiles across, each line of words on one line */
}
@container kp3dg (min-width: 600px) and (max-height: 500px) {
  .kp3dg-card.is-drone.is-tilt .kp3dg-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.35fr) repeat(5, minmax(0, 1fr)); }
  .kp3dg-card.is-tilt .kp3dg-tile, .kp3dg-card.is-tilt .kp3dg-tile:last-child, .kp3dg-card.is-tilt .kp3dg-stick { grid-column: auto; }
}

@keyframes kp3dg-fade { from { opacity: 0; } }
@keyframes kp3dg-rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .kp3dg, .kp3dg-card { animation: none; } }
@media print { .kp3dg { display: none; } }

/* ==== H-A (Fable, 16/11/2026): the card on a phone ====
 * On a 360 x 700 phone the six tiles were taller than the stage, the whole card scrolled, and "Got it" sat cut off at
 * the bottom of it. Now the card is a column that never leaves the stage: the title and "Got it" stay put and only the
 * tiles scroll. A narrow, short stage also gets slightly smaller pictures and spacing, so the six tiles normally fit
 * with no scrolling at all. Phone only. */
html[data-device="phone"] .kp3dg-card { display: flex; flex-direction: column; overflow: hidden; }
html[data-device="phone"] .kp3dg-card > * { flex: none; }
html[data-device="phone"] .kp3dg-card > .kp3dg-grid { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; }
@container kp3dg (max-width: 599.98px) and (max-height: 600px) {
  html[data-device="phone"] .kp3dg-card { padding: 12px; }
  html[data-device="phone"] .kp3dg-title { margin-bottom: 8px; }
  html[data-device="phone"] .kp3dg-grid { gap: 6px; }
  html[data-device="phone"] .kp3dg-tile { padding: 6px 6px 8px; }
  html[data-device="phone"] .kp3dg-pic { width: 48px; height: 48px; }
  html[data-device="phone"] .kp3dg-keys, html[data-device="phone"] .kp3dg-kl { margin-top: 8px; }
  html[data-device="phone"] .kp3dg-ok { margin-top: 10px; }
}
/* ==== end H-A ==== */
