/* Phone pass (upright first): fixes found by playing the game at 390 x 844, 360 x 640 and 430 x 932 with touch only.
   Linked LAST in index.html. Every rule is scoped to body.touch and / or a phone-sized media query, so desktop is untouched.
   Module stylesheets that are injected later than this file are out-ranked by the body.touch prefix. */

/* ───────────── start menu ───────────── */
@media (orientation: portrait) and (max-width: 700px) {
  .sm-left .sm-who { font-size: 12px; }
  .sm-foot { font-size: 11px; line-height: 1.3; }
}
/* small Android (360 wide / 640 tall): the hint needs two lines, so the list and hint step up and the small print stays at two lines; the title shrinks so the founder's head is not behind it */
@media (orientation: portrait) and (max-width: 380px) {
  .sm-foot { font-size: 10px; }
  .sm-hint { bottom: calc(var(--pb) + 64px); }
  .sm-list { bottom: calc(var(--pb) + 104px); }
  .sm-row { font-size: 27px; }
  .sm-left .sm-x { bottom: calc(var(--pb) + 292px); }
  .sm-left .sm-who { bottom: calc(var(--pb) + 340px); }
}
@media (orientation: portrait) and (max-width: 700px) and (max-height: 700px) {
  #menu-title { --tu: calc(var(--u) * .7); top: calc(8px + var(--safe-t, 0px)); }
}

/* ───────────── HUD ───────────── */
@media (max-width: 760px) and (orientation: portrait) {
  /* the car radio sat on top of the stats card and the minimap: it now hangs under whatever card is showing, clear of the dock */
  body.touch #radio-chip, body.touch #radio-chip.low { left: calc(8px + var(--safe-l)); right: calc(66px + var(--safe-r)); top: calc(max(var(--hl-moment-b, 150px), var(--hl-left-b, 150px)) + 8px); transform: none; max-width: none; z-index: 6; }
  /* the first objectives are long on purpose (they teach the controls): four lines instead of three before the ellipsis */
  body.touch #objective { -webkit-line-clamp: 4; line-clamp: 4; }
  /* More menu: on a 640 px tall screen its last rows ran off the bottom; it now ends above the home bar and scrolls inside */
  body.touch #hl-more-menu { max-height: calc(100dvh - var(--hl-nav-b, 150px) - 178px - var(--safe-b)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  /* mission title banner: starts under the dock column instead of sliding beneath its buttons */
  body.touch #banner { top: max(34%, calc(var(--hl-nav-b, 150px) + 182px)); }
}

/* ───────────── phone (the in-game device is full-screen on a real phone) ───────────── */
/* home bar: 18 px was the only way home / out of an app; a thumb needs more */
body.touch #phone .ph-screen { grid-template-rows: calc(34px + var(--safe-t)) minmax(0, 1fr) calc(30px + var(--safe-b)); }
body.touch .ph-gest { min-height: 30px; padding-bottom: var(--safe-b); }
body.touch .ph-gest::before { content: ''; position: absolute; left: 25%; right: 25%; top: -10px; bottom: 0; } /* 40 px tall hit area around the pill, not across the whole row above it */
body.touch .mg-input { height: 44px; }
body.touch .mg-send { width: 44px; height: 44px; }
/* on-screen keyboard: the composer and the ride search stay above it (--kb is kept current by js/touch.js) */
body.touch.kb-open .mg-form { padding-bottom: calc(10px + var(--kb, 0px)); }
body.touch.kb-open #phone .mp.ride:has(#ride-q:focus) .mp-map { display: none; }
body.touch.kb-open #phone .mp.ride:has(#ride-q:focus) { grid-template-rows: minmax(0, 1fr); }
body.touch.kb-open #phone .mp-side { padding-bottom: calc(16px + var(--kb, 0px)); }

/* ───────────── laptop (full-screen on a phone) ───────────── */
@media (max-width: 520px) and (orientation: portrait) {
  /* the dock was one row that ran off the right edge (apps 6 to 8 were out of sight): two rows of four, every label readable */
  body.touch .lt-dock { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 0; overflow: visible; padding-top: 8px; }
  body.touch .lt-dock button { min-width: 0; min-height: 66px; }
  body.touch .lt-dock .lt-n { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
  /* an app is open: the dock folds to one row of icons so the window keeps the screen */
  body.touch .lt-screen:has(.lt-win:not([hidden])) .lt-dock { grid-template-columns: repeat(8, minmax(0, 1fr)); padding-top: 6px; }
  body.touch .lt-screen:has(.lt-win:not([hidden])) .lt-dock button { min-height: 52px; padding-bottom: 6px; }
  body.touch .lt-screen:has(.lt-win:not([hidden])) .lt-dock .lt-n { display: none; }
  body.touch .lt-screen:has(.lt-win:not([hidden])) .lt-dock .lt-ic { width: 42px; height: 42px; }
}
body.touch .lt-shut { position: relative; }
body.touch .lt-shut::after { content: ''; position: absolute; inset: 0 -6px -12px -6px; } /* 46 px tall hit area without a taller menu bar */

/* ───────────── small things ───────────── */
body.touch .rotate-hint button { min-width: 44px; min-height: 44px; }
body.touch .rh-stars button { min-height: 44px; min-width: 36px; }
/* feedback board: the form shrinks with the on-screen keyboard instead of sitting under it */
body.touch.kb-open #board { padding-bottom: calc(8px + var(--kb, 0px)); }

/* ───────────── X app (phone and laptop) ───────────── */
body.touch .xa, body.touch #x-send, body.touch .x-btn { min-height: 44px; }
body.touch .xa.dunk, body.touch .xp-av { min-width: 44px; min-height: 44px; }
body.touch .x-link { min-height: 44px; display: inline-flex; align-items: center; padding-left: 8px; }
body.touch .x-ideas button, body.touch .x-idea { min-height: 44px; }
body.touch .lt-wx { width: 44px; height: 44px; }

/* ───────────── side panels ───────────── */
body.touch .co-tabs button { min-height: 44px; }
body.touch .act-row { min-height: 44px; }

/* ───────────── phone apps: thumb-sized controls ───────────── */
body.touch #phone .ph-btn.sm { min-height: 44px; }
body.touch #phone button.ph-chip { min-height: 44px; }
body.touch #phone .ph-tabs button { min-height: 44px; }
body.touch #phone .cam-bar button:not(.cam-shut) { min-height: 44px; }
body.touch #phone input[type="range"] { height: 44px; }
@media (max-width: 420px) { body.touch #phone .cam-bar { padding-left: 10px; padding-right: 10px; } }
body.touch #phone .ph-btn.sm { min-width: 44px; }

/* ───────────── mission overlays ───────────── */
@media (max-width: 760px) and (orientation: portrait) {
  /* mission 4 shoot: the director's caption sat on the minimap corner and the status chips: it hangs under the top row, left of the dock */
  body.touch #m4-cap { left: calc(8px + var(--safe-l)); right: calc(66px + var(--safe-r)); top: calc(max(var(--hl-top-b, 150px), var(--hl-moment-b, 150px)) + 8px); translate: none; max-width: none; text-align: center; }
}
/* mission 5 YC form: thumb-sized field and buttons, no number keys shown, and it rides above the on-screen keyboard */
body.touch #ycui .o input { min-height: 44px; }
body.touch #ycui .o button { min-height: 44px; }
body.touch #ycui .o button kbd { display: none; }
body.touch #ycui .h .t { min-width: 0; } body.touch #ycui .h .t small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch.kb-open #ycui { padding-bottom: var(--kb, 0px); }

/* ───────────── on-screen keyboard: scroll room for the focused field ───────────── */
body.touch.kb-open #creator .cr-body { padding-bottom: calc(20px + var(--kb, 0px)); }
body.touch.kb-open .sm-panel { margin-bottom: var(--kb, 0px); max-height: calc(100% - var(--pb) - 16px - var(--safe-t, 0px) - var(--kb, 0px)); }
body.touch.kb-open #co-panel, body.touch.kb-open .act-card { margin-bottom: var(--kb, 0px); }
