/* ══ 📐 b336 §1 (ruling 164, 167, D44) — FOLDED SIDEWAYS: THE SHORT-WIDE SHEET ══
 *
 * The owner's folded phone held sideways is 816x266. This sheet is linked by
 * `index.html` with media="(max-height: 340px) and (min-aspect-ratio: 9/5)" (D80, b342) -
 * the ONE short-wide rule, named in `src/ui/shortWide.js` as `SHORT_WIDE_MQ`
 * (JS asks `matchMedia` with the same string). A sheet whose media does not
 * match never blocks a first paint, so every other frame is byte-identical and
 * the lobby's render-blocking bank (load-budget clause 20) is not touched.
 *
 * ⚠️ IT IS LINKED BEFORE THE BUILT SHEETS, so a tie on specificity would lose to
 * them: every selector here is prefixed `html body` (0,1,2 over a bare class).
 * Two-class rules (`.bk-hud.off`, the end card's scrim hide) still win, which is
 * what they are for. Palette tokens only; no colour is written here. */

/* ── D44: THE SIDE BAND, IN A CABINET ────────────────────────────────────────
 * Left column: `.stk-back`, then the bar's sign, then the score pill and the
 * middle count. Right column: the sound control, then the clock. The play box
 * between them is `sideBandIn()`'s, measured off these very rectangles. */
html body {
  --bk-side-top: calc(var(--bk-corner-t) + var(--bk-thumb) + var(--bk-gap-1));
  --bk-side-sign-h: 28px;
}
html body .bk-sign-bar {
  top: var(--bk-side-top);
  left: var(--bk-corner-l);
  translate: none;
  height: var(--bk-side-sign-h);
}
/* the HUD keeps its own box (gates read it): the score and the count stacked in
   the left column; the clock alone steps out to the right column, under sound
   (a fixed child of an untransformed fixed box is placed against the viewport) */
html body .bk-hud {
  top: calc(var(--bk-side-top) + var(--bk-side-sign-h) + var(--bk-gap-1));
  left: var(--bk-corner-l);
  right: auto;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: var(--bk-gap-1);
}
html body .bk-hud-mid { padding-left: 4px; }
html body .bk-hud-clock {
  position: fixed;
  right: var(--bk-corner-r);
  top: var(--bk-side-top);
}
/* the column keeps its box while the round is not live (start card, end card):
   `sideBandIn()` measures it in a cabinet's fit, which runs before the start
   card is closed; hidden, never removed, so Kiko is never seated into it.
   An empty count still holds its one line. */
html body .bk-hud.off { display: flex; visibility: hidden; }
html body .bk-hud-mid { min-height: 1em; }
/* 👕 b337 §2.2 - the count line (Poppo's chain, Bricko's wave) stays inside the column's width and wraps there, never
   out over Kiko standing beside or under it */
html body .bk-hud .bk-hud-mid { max-width: 66px; font-size: 12px; line-height: 1.1; white-space: normal; }

/* ── RULING 167: THE LOBBY, ONE CENTRED GROUP ────────────────────────────────
 * The Kiko + pod pair and PLAY NOW side by side, centred on the screen as one
 * group, SW_GAP (40) between them (`src/pg/LobbyPod.jsx` centres the pair with
 * PLAY's width and writes the pair's width as `--pgl-sw-pair-w`, so the button
 * lands exactly beside it). Kiko stands on the moon's ground line above the
 * tab bar (`--pgl-sw-feet`), his band as tall as the room under the header
 * (`--pgl-sw-head-b`) leaves; the pod is 1.1x him, so the pair is ~107 px at
 * 816x266. PLAY NOW is centred on the pair's height. The header row and the
 * tab bar are not touched. */
html body .pgl.pgl-m1 {
  /* the view above the tab bar ends on the bar's top; the pair stands 4 px above it (the pod never touches a control, 2 px) */
  --pgl-sw-feet: calc(var(--bk-view-h, 100svh) - 4px);
  --pgl-sw-head-b: 64px;
  --pgl-sw-play-w: 293px;
  --pgl-kiko-band: calc((var(--pgl-sw-feet) - var(--pgl-sw-head-b)) / 0.935);
  --pgl-kiko-top: calc(var(--pgl-sw-feet) - 0.935 * var(--pgl-kiko-band));
  /* the pair's centre: the pod's top is 1.1 x Kiko's drawn figure (0.915 of his band) above the feet */
  --pgl-cta-top: calc(var(--pgl-sw-feet) - 0.5 * 1.1 * 0.915 * var(--pgl-kiko-band) - var(--pgl-cta-h) / 2);
}
html body .pgl.pgl-m1 .pgl-cta.m1 {
  left: calc(50% + (var(--pgl-sw-pair-w, 165px) + 40px - var(--pgl-sw-play-w)) / 2);
  right: auto;
  width: var(--pgl-sw-play-w);
  padding: 0;
  justify-content: flex-start;
}
html body .pgl.pgl-m1 .pgl-cta.m1 .pgl-play {
  flex: 0 0 var(--pgl-sw-play-w);
  max-width: var(--pgl-sw-play-w);
}
/* 🛸 b377 D233 (F376-2): UNTIL HIS HOME'S CHUNK LANDS (or where it stays off) Kiko already stands in the pair's place,
   his box ending 12 px left of PLAY NOW - b376 drew him centred under the button for that while (622x303: his box
   244-378 over PLAY's 267-560, measured with the chunk held). The has-pod rule still places him once it measures;
   its natural read (`data-pair-read`) sees him where he would stand alone. */
html body .pgl.pgl-m1:not(.has-pod):not([data-pair-read]) .pgl-room.m1 .pgl-kiko { transform: translateX(calc(-100% + (var(--pgl-sw-pair-w, 165px) + 40px - var(--pgl-sw-play-w)) / 2 - 12px)); }

/* ── THE END CARD, FOLDED SIDEWAYS (D31 at this frame, 148) ──────────────────
 * b335 measured all 32 cards RED at 816x266 (Play again, the Daily and Duel a
 * friend under the fold). Here the card uses the width: it is a two-column
 * grid - the title, score and best (with Kiko, the sign and the quiet lines)
 * on the left, every button on the right, the ribbon under the buttons - and
 * the board stands beside the card, its rows tightened so the top three (and
 * the player's own row in the top five) are whole. The pair sits between the
 * back button's column and the sound button's, so nothing runs under a bar
 * control, and nothing is hidden. Only the layout changes: each slot's size is
 * fixed for the frame (145). */
html body .stk-over { padding: 8px 0; }
html body .stk-over .stk-pair.has-board {
  --bk-sw-col: calc(var(--bk-corner-l) + 110px);
  --bk-sw-btn: 158px;
  width: calc(100vw - 2 * var(--bk-sw-col));
  max-width: 640px;
  gap: 10px;
  align-items: stretch;
}
/* the card: its own words flow in the left column; the buttons and the ribbon
   stand in the right column at fixed places (each slot fixed per frame, 145) */
html body .stk-over .stk-pair.has-board > .stk-card {
  flex: 1 1 0; width: auto; min-width: 0;
  position: relative;
  padding: 6px calc(var(--bk-sw-btn) + 20px) 6px 10px; box-sizing: border-box;
  gap: 2px;
}
html body .stk-over .stk-pair.has-board > .stk-card > .stk-sign { height: 22px; margin: 0 auto; }
html body .stk-over .stk-pair.has-board > .stk-card > .stk-title { margin-top: 0; }
html body .stk-over .stk-pair.has-board > .stk-card > .stk-score { margin-block: 6px calc(6px + var(--bk-lip-h)); }
html body .stk-over .stk-pair.has-board > .stk-card > .stk-trophy { position: static; }
html body .stk-over .stk-pair.has-board > .stk-card > .stk-note-sm { font-size: 11px; line-height: 1.15; margin: 0; }
html body .stk-over .stk-pair.has-board > .stk-card .bk-found-words,
html body .stk-over .stk-pair.has-board > .stk-card .bk-found-words > * { font-size: 11px; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; }
html body .stk-over .stk-pair.has-board > .stk-card .bk-found { max-width: 100%; }
/* the ribbon's pill keeps its two lines in the narrower column */
html body .stk-over .stk-pair.has-board > .stk-card > .bk-slot-ribbon * { font-size: 10.5px; line-height: 1.2; }
html body .stk-over .stk-pair.has-board > .stk-card > .bk-cta,
html body .stk-over .stk-pair.has-board > .stk-card > .stk-again,
html body .stk-over .stk-pair.has-board > .stk-card > .bk-slot-bestduel,
html body .stk-over .stk-pair.has-board > .stk-card > .stk-second-pair,
html body .stk-over .stk-pair.has-board > .stk-card > .bk-btn.stk-daily,
html body .stk-over .stk-pair.has-board > .stk-card > .bk-slot-ribbon {
  position: absolute; right: 10px; width: var(--bk-sw-btn); margin: 0; padding-right: 0; box-sizing: border-box; align-self: auto;
}
/* b408 D369: on a best card the duel's reserved slot takes the primary's place (top 8) and Play again stands in the
   pair under it (58); the Daily pill rises to 58 only when the pair holds NO button at all */
html body .stk-over .stk-pair.has-board > .stk-card > .bk-cta,
html body .stk-over .stk-pair.has-board > .stk-card > .bk-slot-bestduel,
html body .stk-over .stk-pair.has-board > .stk-card > .stk-again { top: 8px; }
html body .stk-over .stk-pair.has-board > .stk-card > .stk-second-pair { top: 58px; }
html body .stk-over .stk-pair.has-board > .stk-card > .stk-second-pair > .stk-again { position: static; top: auto; width: auto; }
html body .stk-over .stk-pair.has-board > .stk-card > .bk-btn.stk-daily { top: 106px; bottom: auto; }
html body .stk-over .stk-pair.has-board > .stk-card:not(:has(> .stk-second-pair .bk-btn)) > .bk-btn.stk-daily { top: 58px; }
html body .stk-over .stk-pair.has-board > .stk-card > .bk-slot-ribbon { top: 168px; }
/* Kiko stands outside the card, in the room under the Lobby button, feet on
   the screen's floor; his bubble rises above him in that column, clear of every
   button and sign */
html body .stk-over .stk-pair.has-board > .stk-card > .stk-kiko {
  position: absolute; zoom: 0.4; margin: 0;
  left: calc((var(--bk-corner-l) - var(--bk-sw-col)) / 0.4);
  bottom: calc(-2px / 0.4);
}
html body .stk-over .stk-pair.has-board > .stk-card > .stk-kiko .kiko-say { max-width: calc(96px / 0.4); margin-bottom: 40px; }
/* the board beside it */
html body .stk-over .stk-pair.has-board > .bk-endboard { flex: 0 0 34%; width: auto; margin-top: 0; padding: 6px 10px; gap: 3px; }

/* ── SPOTTO, FOLDED SIDEWAYS (164, D44) ──────────────────────────────────────
 * Spotto's board is DOM, so its tall box is written here: the column's 88 px
 * reserve for the old top HUD row is given back (the HUD stands in the side
 * columns now) and the grid is sized off the height - its timer bar above it,
 * 8 px margins. At 816x266 the grid ran from y 110 to 291, off the screen. */
/* the first tile starts at 24 px, under b263's status-bar floor (viewport-matrix): the bar from 14, the grid from 24 */
html body .spt-wrap { justify-content: flex-start; padding: 14px 8px 4px; gap: 4px; }
html body .spt-hud { padding-top: 0; width: calc(100dvh - 50px); }
html body .spt-grid { width: calc(100dvh - 50px); }

/* ── THE ROOM, FOLDED SIDEWAYS (b338 §1.4, D55) moved to src/landing/room.css (b343 §1.2, D84): the room's own chunk carries it, under the same media string. */

/* ── 📐 b351 §2.3 - THE END CARD ON A NARROWER FOLD (622x303, the owner's phone: D82) ──
 * The three columns above (the card's words, its buttons, the board) were measured at 816x266. At 622x303 the
 * pair is 374 px between the two bar columns: the board took 127, the buttons 178, and the card's own words were
 * left 49 px - "TIME" and the stats stood one letter to a line, the score plate ran under Play again (b350's 32
 * red cards; photographed before this rule). Under 720 px wide the board goes UNDER the card and is scrolled to
 * (185b: on a short one-column card the board begins on the first screen); the card keeps the full width, so its
 * words have their column back. Each slot's place is unchanged (145). */
@media (max-width: 720px) {
  html body .stk-over .stk-pair.has-board { flex-direction: column; align-items: stretch; }
  html body .stk-over .stk-pair.has-board > .stk-card { flex: 0 0 auto; min-height: 226px; }
  html body .stk-over .stk-pair.has-board > .bk-endboard { flex: 0 0 auto; }
  /* Kiko keeps his feet on the screen's floor: the card no longer reaches it (226 px of the view's height) */
  html body .stk-over .stk-pair.has-board > .stk-card > .stk-kiko { bottom: calc((226px - (100dvh - 16px) - 2px) / 0.4); }
}

/* 💡 b365 §3.3 (ruling 208b): folded sideways (622x303) the Ideas pill stood 3 px into PLAY NOW (viewport-matrix, b364's
   dist too). PLAY NOW is never covered: on a short-wide screen the pill steps aside; the end card's ask still opens the sheet. */
html body [data-ideas-door][data-ideas-door][data-ideas-door][data-ideas-door] { display: none; }

/* 🧭 b380 D249.2 (viewport-matrix, 816x266): the one header pattern at its short-wide size - the head took 16 + 48 + 16 px
   and left 2 whole game cards of the 4 the ruling asks; here it stands 6 px down, 44 tall, 6 px over the content */
html body .bk-ph { min-height: 44px; margin-bottom: 6px; }
html body .bk-games, html body .bk-stuff { padding-top: 6px; }

/* 📅 b415 D384 - KIKO'S DAILY PILL, FOLDED SIDEWAYS: it stands under PLAY NOW in PLAY's column (lobbyPod.css); PLAY NOW rises
   only as far as the pill needs to end 8 px over the tab bar (its own place above, its size kept, Kiko's untouched). At 280 px
   tall and under (816x266) there is no room under the header and the pill stands down (lobbyPod.css). */
@media (min-height: 281px) {
  html body .pgl.pgl-m1[data-kdp] { --pgl-cta-top: min(calc(var(--pgl-sw-feet) - 0.5 * 1.1 * 0.915 * var(--pgl-kiko-band) - var(--pgl-cta-h) / 2), calc(var(--bk-view-h, 100svh) - 50px - var(--pgl-cta-h))); }
}
