/* D235 phone flight layout (owner t107u / t108u / t110u; audit in sf-notes/ux-audit.md). body.phoneUi is
   set by phone/dock.js under (pointer: coarse), (max-width: 879px). The ship and space own the screen:
   a top bar that fits, speed and lamps top-left, a 96 px minimap top-right, one message lane under them,
   and a bottom dock (NAV · GUNS · ABIL · bell · MENU) whose sheets open above it. */

/* #pft-back is our own link (index.html): the Tavern door only injects one when the page has none, so
   nothing lands on the header (no Tavern change). Desktop keeps style.css's spot under the brand; a phone
   shows it only on the login screen, bottom-left, and keeps the way back in the MENU sheet (dock.js). */
body.phoneUi #pft-back { display: none; }
body.phoneUi:has(#loginGate:not([hidden])) #pft-back {
  display: inline-flex; align-items: center; top: auto; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); min-height: 44px; padding: 0 14px;
  border: 1px solid #5a4d33; border-radius: 999px; background: rgba(11, 13, 16, 0.88); color: #f3e6c4; font-size: 12px; opacity: 1;
}

body.phoneUi {
  --hud: 48px;
  --dock: calc(56px + env(safe-area-inset-bottom, 0px));
  --lane: 200px; /* the message lane starts under the minimap and the thumb microphone (D286) */
}

/* Top bar: callsign, hull, scrap and FLARE in one row that never scrolls. */
body.phoneUi #hud { overflow: hidden; gap: 8px; padding: 0 8px; }
body.phoneUi .brand, body.phoneUi .pilot span, body.phoneUi #fleetChip { display: none !important; }
body.phoneUi .pilot { min-width: 0; flex-shrink: 1; }
body.phoneUi .pilot b { max-width: 96px; display: block; }
body.phoneUi #flareBtn { min-height: 44px; min-width: 52px; }
body.phoneUi #scrapHud { min-height: 44px; min-width: 44px; }
body.phoneUi .hull { margin-left: auto; }

/* Flight column: speed, warnings and lamps only, each one line. */
body.phoneUi .space-top { top: 8px; left: 10px; right: 116px; gap: 4px; }
body.phoneUi .space-top > [hidden] { display: none !important; }
body.phoneUi .readout { font-size: 15px; }
body.phoneUi .pacing-chip, body.phoneUi .objective-chip, body.phoneUi .explore-signal { font-size: 11px; padding: 3px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
body.phoneUi .dash-lamps { flex-wrap: nowrap; gap: 4px; max-width: 100%; overflow: hidden; }
body.phoneUi .dash-lamp { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
body.phoneUi .track-chip, body.phoneUi .course-resume, body.phoneUi .space-siren { min-height: 44px; max-width: 100%; }
body.phoneUi .minimap { top: 8px; right: 8px; width: 96px; min-width: 0; min-height: 0; padding: 4px; }
body.phoneUi .minimap canvas { width: 86px; height: 86px; }
body.phoneUi .minimap .quad-map { display: none !important; }
body.phoneUi .quad-banner { top: var(--lane); bottom: auto; max-width: calc(100% - 24px); }
body.phoneUi .apex-strip { top: var(--lane); max-width: calc(100% - 20px); font-size: 12px; }

/* One message lane: hail, coach and radio cards under the minimap, short, scrolling inside. */
body.phoneUi .hail, body.phoneUi .coach, body.phoneUi .radio-toast {
  top: var(--lane); bottom: auto; left: 10px; right: 10px; width: auto; transform: none;
  max-height: min(calc(34 * var(--vh)), calc(100% - var(--lane) - var(--dock) - var(--sheet-h, 0px) - 16px));
  overflow-y: auto; font-size: 12px;
}
body.phoneUi .hail.is-min { left: auto; width: auto; }
body.phoneUi .hail-close, body.phoneUi .hail-min, body.phoneUi .coach-close { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
body.phoneUi .hail button, body.phoneUi .coach button { min-height: 44px; min-width: 44px; }
body.phoneUi .coach-quiet { min-height: 44px; display: flex; align-items: center; gap: 6px; }
body.phoneUi .toasts {
  top: auto; left: 10px; right: 10px; width: auto; transform: none;
  bottom: calc(var(--dock) + var(--sheet-h, 0px) + 8px); max-height: 30%;
}
body.phoneUi .move-panel, body.phoneUi .focus-bar { bottom: calc(var(--dock) + var(--sheet-h, 0px) + 8px); }
/* D236: a minimized flight plan in a fight is a 60px strip; toasts stack above it, not behind it. */
body.phoneUi:has(#movePanel.is-min:not([hidden])) .toasts { bottom: calc(var(--dock) + var(--sheet-h, 0px) + 72px); }
body.phoneUi .intro-card { margin-bottom: calc(var(--dock) + 12px); }
body.phoneUi .voice-toggle { min-height: 44px; }
body.phoneUi .voice-prompt {
  top: calc(var(--hud) + 8px);
  left: 10px;
  right: 10px;
  width: auto;
  transform: none;
}
body.phoneUi .voice-prompt-close { width: 44px; height: 44px; }
body.phoneUi .voice-prompt-choice { min-height: 44px; }
/* A dock sheet owns the bottom half of the phone. Lift the card above it while the guide has a sheet
   open, or the card sits on top of the control the blinking ring is asking the player to tap. */
body.phoneUi:not([data-phone-sheet=""]) #intro { align-items: flex-start; }
body.phoneUi:not([data-phone-sheet=""]) .intro-card {
  margin-top: calc(var(--hud) + 8px);
  margin-bottom: 0;
  max-height: 46vh;
  overflow-y: auto;
}

/* The dock. */
.phone-dock { display: none; }
body.phoneUi .phone-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; height: var(--dock);
  padding: 0 6px env(safe-area-inset-bottom, 0px); display: grid; grid-template-columns: repeat(3, 1fr) 56px 1fr; gap: 4px;
  align-items: center; background: linear-gradient(180deg, rgba(8, 13, 20, 0.94), rgba(3, 6, 10, 0.98)); border-top: 1px solid var(--line);
}
/* A full screen (station, cargo, deck, chart, login ...) owns the phone: the dock and its sheet step aside. */
body.siteOpen .phone-dock, body.siteOpen .phone-sheet,
body:has(.sheet:not([hidden])) .phone-dock, body:has(.sheet:not([hidden])) .phone-sheet,
body:has(.deck-overlay:not([hidden])) .phone-dock, body:has(.deck-overlay:not([hidden])) .phone-sheet,
body:has(.radar-overlay.is-open) .phone-dock, body:has(.radar-overlay.is-open) .phone-sheet { display: none !important; }
.phone-dock-btn {
  position: relative; min-height: 48px; min-width: 44px; padding: 3px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid rgba(111, 231, 255, 0.22); background: rgba(6, 12, 18, 0.9); color: var(--ink, #d8f4ff);
}
.phone-dock-btn b { font-size: 12px; letter-spacing: 0.14em; }
.phone-dock-btn em { font-size: 11px; font-style: normal; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; max-width: 100%; }
.phone-dock-btn[aria-expanded="true"] { border-color: var(--cyan); background: rgba(16, 44, 58, 0.95); color: var(--cyan); }
.phone-dock-btn.is-empty { opacity: 0.45; }
.phone-dock-btn.has-news::after { content: ''; position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
body.phoneUi .phone-dock .notice-bar { position: static; transform: none; display: flex; justify-content: center; }
body.phoneUi .phone-dock .notice-btn { width: 52px; min-width: 44px; height: 48px; }
body.phoneUi .notice-tray { position: fixed; left: 10px; right: 10px; width: auto; bottom: calc(var(--dock) + 8px); max-height: calc(50 * var(--vh)); }

/* The sheet above the dock. */
body.phoneUi .phone-sheet {
  position: fixed; left: 0; right: 0; bottom: var(--dock); z-index: 36; max-height: min(calc(58 * var(--vh)), calc(100% - var(--hud) - var(--dock) - 8px));
  overflow-y: auto; padding: 0 10px 10px; background: rgba(4, 8, 13, 0.95); border-top: 1px solid rgba(111, 231, 255, 0.35);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.5); overscroll-behavior: contain;
}
.phone-sheet[hidden], .phone-sheet-body[hidden] { display: none !important; }
.phone-sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; height: 48px; background: rgba(4, 8, 13, 0.98); }
.phone-sheet-head b { font-size: 12px; letter-spacing: 0.18em; color: var(--cyan); }
.phone-sheet-x { width: 44px; height: 44px; font-size: 20px; }
