/* The phone shell — epic 2 of the Studio evaluation (2026-11-16): finish the piece, on a phone first (3.99.307).

   In 13 days 2,796 of 7,698 arrivals were phones, and a phone got the desktop workspace folded into one page 6,300 px
   tall: six menus and a version line above the canvas, fifteen rail sections under it, and the Order button hidden until
   the first edit. The shell keeps that page and its controls exactly as they are (every id, every listener, every
   spec of the page under it) and shows them as three steps and a tab bar: Words → Style → (Colour) → On a wall, which
   ends at the order, and More for everything else.

   How it is chosen: public/ui1a-boot.js, in <head> before the first paint, sets html[data-phone] (and data-ph-tab) on
   a 1a page whose window matches this file's own media query (index.html loads it only there), never on the read-only
   doorways or a frame (?in=), never for a visitor who chose the full layout (localStorage mashq.phone = off), and not
   in an automated browser unless a spec asks (window.__mashqPhone). The behaviours are lazy lib/phone.js, which sets
   html[data-ph-ready] once its bar is up: until then nothing is hidden but the menu row, so a shell that never loads
   leaves the whole page (app.js takes data-phone off when the chunk fails).

   Rules: tokens only (tools/check-tokens.mjs holds this file to 0 colour literals), logical sides, burgundy only on
   money (the Order button is .btn--pay from styles.css). Its bytes and lib/phone.js's are held by phone-budget.txt
   (tools/preflight.mjs). Guards: tests/173-phone-shell.spec.js, tests/unit/phone-shell.test.mjs. */

html[data-phone] { --ph-bar: 56px; --ph-strip: 50px; --ph-safe: env(safe-area-inset-bottom, 0px); }

/* ── the top: one row of badges and one header row, no menu row (#035: the menus are one list under More) ──
   The menu row stays laid out, only out of sight: lib/palette.js opens each menu unseen to read its rows. */
html[data-phone][data-ui="1a"] .ws-menus {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
html[data-phone][data-ui="1a"] #app-version { display: none; }
html[data-phone][data-ui="1a"] .ws-menubar { min-height: 0; padding-block: 2px; }
html[data-phone][data-ui="1a"] .ws-menubar__right { justify-content: flex-start; }
html[data-phone][data-ui="1a"] .ws-header { flex-wrap: nowrap; align-items: center; gap: 8px; padding: 4px 10px; }
html[data-phone][data-ui="1a"] .ws-header .wordmark { flex: 0 1 auto; min-inline-size: 0; }
html[data-phone][data-ui="1a"][data-uilang="en"] .ws-header .wordmark__ar,
html[data-phone][data-ui="1a"][data-uilang="ar"] .ws-header .wordmark__en { display: none; }
html[data-phone][data-ui="1a"] .ws-header__right { flex: 1 0 auto; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
html[data-phone][data-ui="1a"] .ws-header .wordmark__en { font-size: 12px; letter-spacing: .14em; white-space: nowrap; }
/* «Ask support» keeps its place as its 💬 alone (lib/phone.js gives it its name for a screen reader) */
html[data-phone][data-ui="1a"] #ws-ask-btn { font-size: 0; min-inline-size: 44px; min-block-size: 44px; padding: 0; justify-content: center; }
html[data-phone][data-ui="1a"] #ws-ask-btn::before { content: "💬"; font-size: 18px; line-height: 1; }

/* ── the canvas: sticky at the top as before, a little smaller, and smaller again while the keyboard is up (#034) ── */
html[data-phone][data-ui="1a"] #ui1a .stage { height: 42vh; height: 42dvh; min-height: 220px; }
html[data-phone][data-ph-kb][data-ui="1a"] #ui1a .stage { height: 30vh; height: 30dvh; min-height: 150px; }
/* on «On a wall» the wall shows the design: the canvas lets go of the top, and the panel comes up to it */
html[data-phone][data-ph-ready][data-ph-tab="wall"][data-ui="1a"] #ui1a .stage { position: relative; }

/* ── the steps: each tab shows its own sections of the rail; what belongs to no step lives under More ── */
html[data-phone][data-ph-ready] .ws-rail > .ws-acc { display: none; }
html[data-phone][data-ph-ready][data-ph-tab="words"] .ws-rail > .ws-acc[data-acc="text"]:not([hidden]),
html[data-phone][data-ph-ready][data-ph-tab="style"] .ws-rail > .ws-acc[data-acc="script"]:not([hidden]),
html[data-phone][data-ph-ready][data-ph-tab="colour"] .ws-rail > .ws-acc:is([data-acc="ink"], [data-acc="effects"]):not([hidden]),
html[data-phone][data-ph-ready][data-ph-tab="more"] .ws-rail > .ws-acc:not(:is([data-acc="text"], [data-acc="script"], [data-acc="ink"], [data-acc="effects"])):not([hidden]) {
  display: block;
}
/* the tool strip and the selection bar are for arranging: under More. The name box of a first visit: under Words. */
html[data-phone][data-ph-ready]:not([data-ph-tab="more"]) #ui1a :is(.ws-tools, .ws-ctx) { display: none !important; }
html[data-phone][data-ph-ready]:not([data-ph-tab="words"]) .mq-first-bar { display: none; }
/* the sections' own «Next: …» keys (Studio 250 #112) close their section and scroll the page to the top: on a phone the
   strip's key walks the steps instead */
html[data-phone][data-ph-ready] .ws-rail .ai-next { display: none; }
/* the floating Order button gives way to the «On a wall» step, and Undo/Redo move under the thumb (#033) */
html[data-phone][data-ph-ready][data-ui="1a"] #ws-order-btn { display: none !important; }
html[data-phone][data-ph-ready] .ws-status :is(#undo-btn, #redo-btn, .ws-ph) { display: none; }
/* the Order and Export sheets hang from the top and lie over the bars while open (z 22 over 13) */
html[data-phone][data-ph-ready][data-ui="1a"] #ui1a > .ws-fly--order { inset-block: 8px auto; }
html[data-phone][data-ph-ready] body { padding-block-end: calc(var(--ph-bar) + var(--ph-strip) + var(--ph-safe)); }

/* ── 44 px targets inside the steps (#036; tests/173 scans each tab) ── */
html[data-phone][data-ph-ready] :is(.ws-rail, #ph-wall, #ph-more, .mq-first-bar) :is(button, .chip, select, summary, a.btn, input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"])) {
  min-block-size: 44px;
}
html[data-phone][data-ph-ready] :is(.ws-rail, #ph-wall, #ph-more) :is(button, .chip) { min-inline-size: 44px; }

/* ── the tab bar and the strip above it ── */
#ph-tabs, #ph-strip, #ph-wall, #ph-more, #ph-back { display: none; }
html[data-phone][data-ph-ready] #ph-tabs {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 13;
  padding-block-end: var(--ph-safe); background: var(--surface-panel); border-block-start: 1px solid var(--t-border);
}
#ph-tabs > button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-block-size: var(--ph-bar); padding: 4px 2px; border: 0; border-radius: 0; background: none; color: var(--text-muted);
  font: 600 11px/1.15 var(--font-ui); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
#ph-tabs > button > svg { inline-size: 22px; block-size: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#ph-tabs > button[aria-selected="true"] { color: var(--ink-950); background: var(--gold-100); box-shadow: inset 0 3px 0 var(--gold-700); }
#ph-tabs > button[data-tab="wall"] > b { color: var(--money-text); font-weight: 600; }
html[data-phone][data-ph-ready] #ph-strip {
  display: flex; align-items: center; gap: 6px;
  position: fixed; inset-inline: 0; inset-block-end: calc(var(--ph-bar) + var(--ph-safe)); z-index: 13;
  min-block-size: var(--ph-strip); padding: 3px 8px; background: var(--surface-page); border-block-start: 1px solid var(--t-border);
}
#ph-strip .btn { inline-size: auto; flex-direction: row; justify-content: center; }
#ph-strip .ph-ud { min-inline-size: 44px; min-block-size: 44px; padding: 0; font: 400 22px/1 var(--font-ui); }
#ph-strip .ph-ud:disabled { opacity: .4; }
#ph-strip .ph-step { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font: 600 12px/1.2 var(--font-ui); }
#ph-next { flex: 0 1 auto; min-block-size: 44px; min-inline-size: 0; margin: 0; padding: 0 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* while a field has the keyboard the bars step aside, as in a phone's own apps */
html[data-phone][data-ph-kb] :is(#ph-tabs, #ph-strip) { display: none !important; }
html[data-phone][data-ph-kb] body { padding-block-end: 0; }

/* ── «On a wall»: the design framed on a wall, its delivered price, the order (epic 1's sheet) ── */
html[data-phone][data-ph-ready][data-ph-tab="wall"] #ph-wall,
html[data-phone][data-ph-ready][data-ph-tab="more"] #ph-more { display: block; }
.ph-panel { padding: 12px 14px 18px; color: var(--ink-950); font: 400 14px/1.5 var(--font-ui); }
.ph-panel h2 { margin: 0 0 10px; font: 600 15px/1.3 var(--font-ui); color: var(--ink-950); }
.ph-panel p { margin: 0 0 8px; }
.ph-wall__room {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; margin-block-end: 12px; overflow: hidden;
  border-radius: var(--r-ctl, 4px); background: linear-gradient(var(--ivory-200), var(--ivory-300));
}
.ph-wall__room::after { content: ""; position: absolute; inset-inline: 0; inset-block-end: 0; block-size: 13%; background: var(--gold-300); opacity: .55; }
.ph-wall__frame {
  position: relative; z-index: 1; margin-block-end: 6%; padding: 10px;
  background: var(--ivory-50); border: 7px solid var(--ink-950); box-shadow: var(--shadow-overlay);
}
.ph-wall__frame[data-framed="0"] { border-width: 0; box-shadow: var(--shadow-raised); }
/* the picture's own box: at most two thirds of the wall's width and half its height (the wall is 3:4 of the panel) */
.ph-wall__frame img { display: block; inline-size: auto; block-size: auto; max-inline-size: min(60vw, 320px); max-block-size: min(30vw, 34vh); }
.ph-wall__line b { color: var(--money-text); font-weight: 700; unicode-bidi: isolate; }
.ph-wall__sub { color: var(--text-muted); font-size: 13px; }
.ph-wall__go { display: block; inline-size: 100%; margin-block: 6px 10px; }
.ph-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-row > * { flex: 1 1 140px; }
#ph-more .ph-row { margin-block-end: 10px; }
.ph-note { color: var(--text-muted); font-size: 12px; }
/* the way back for a visitor who chose the full layout (lib/phone.js shows it only then) */
html:not([data-phone]) #ph-back:not([hidden]) { display: block; margin: 8px 14px 16px; }

/* ── the menus as one full-screen list (#035): the command palette, made the whole screen on a phone ── */
html[data-phone] #cmd-palette { align-items: stretch; padding: 0; }
html[data-phone] #cmd-palette > div { inline-size: 100vw; max-block-size: none; block-size: 100dvh; margin: 0; border-radius: 0; display: flex; flex-direction: column; }
html[data-phone] #cmd-palette input { min-block-size: 48px; font-size: 16px; }
html[data-phone] #cmd-palette [role="listbox"] { flex: 1 1 auto; max-block-size: none; overflow: auto; }
html[data-phone] #cmd-palette [role="option"] { min-block-size: 44px; display: flex; align-items: center; }

/* ── a phone on its side (#037): the canvas on the start side, the step beside it, one slim bar ── */
@media (orientation: landscape) and (max-height: 500px) {
  html[data-phone] { --ph-bar: 44px; --ph-strip: 0px; }
  html[data-phone][data-ph-ready] #ph-strip { display: none; }
  html[data-phone][data-ph-ready] .ws-status :is(#undo-btn, #redo-btn, .ws-ph) { display: inline-flex; }
  html[data-phone][data-ph-ready] #ph-tabs > button { flex-direction: row; gap: 6px; }
  html[data-phone][data-ph-ready] #ph-tabs > button > svg { inline-size: 18px; block-size: 18px; }
  html[data-phone][data-ph-ready][data-ui="1a"] .ws-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
  html[data-phone][data-ph-ready][data-ui="1a"] .ws-body > * { grid-column: 2; min-inline-size: 0; }
  html[data-phone][data-ph-ready][data-ui="1a"] #ui1a .ws-body > .stage {
    grid-column: 1; grid-row: 1 / span 40; position: sticky; top: 0; align-self: start;
    height: calc(100vh - var(--ph-bar)); height: calc(100dvh - var(--ph-bar)); min-height: 0;
  }
  html[data-phone][data-ph-kb][data-ui="1a"] #ui1a .ws-body > .stage { height: 100dvh; }
}
