/* [mob-a] phone fixes, group a (see scratchpad/mobile-issues.md). Loaded after theme.css.
   The in-game HUD on touch screens: readable needs, the Panels card, the guide box, the action buttons, the floor chat above the
   keyboard, the Saath card and the whodunit nudge kept off the buttons. Everything below the desktop block is scoped to touch
   (html.touchy is set by hudkit.js on a coarse pointer; html.typing / html.kb-open and --kb by kbd.js), so a desktop looks as before. */

/* ---------- every screen: the needs got one box each (sim.js), which a desktop does not see ---------- */
#needs .nd{display:contents}
#needs .nic{display:none}
#needs .nlb{font:inherit;color:inherit}
#more .hb.mfit-off{display:none!important}
/* [mobe] the starter-tasks chip: its title and what is left never run together ("Starter tasks 1/2Daily puzzle"); what is left takes its own line,
   except on a phone held sideways (one line, cut with an ellipsis, below) */
#left .gd-chip{display:flex;flex-wrap:wrap;align-items:center;column-gap:6px;row-gap:1px}
#left .gd-chip>span:last-child{flex:1 1 100%;min-width:0;white-space:normal;overflow:visible}

/* ---------- touch: no double-tap zoom on the game's buttons and cards (the canvas and the joystick keep touch-action:none) ---------- */
html.touchy,html.touchy body{touch-action:manipulation}

/* ---------- touch: the needs, as icons and numbers coloured by how low they are ---------- */
html.touchy #left.deck #needs{--hi:#1F6B3A;--hi-bg:#E2F0E5;--mid:#7A4D00;--mid-bg:#FBEACB;--lo:#A3261B;--lo-bg:#F9DAD4;--lv:#A3245A;--lv-bg:#FBE4EE;cursor:pointer;align-items:stretch}
html.touchy #left.deck #needs .nd{display:flex!important;align-items:center;justify-content:center;gap:3px;min-width:0;border-radius:8px;color:var(--hi);background:var(--hi-bg);font:700 12.5px/1 var(--body);font-variant-numeric:tabular-nums}
html.touchy #left.deck #needs .nd[style*="none"]{display:none!important}
html.touchy #left.deck #needs .nd.mid{color:var(--mid);background:var(--mid-bg)}
html.touchy #left.deck #needs .nd.lo{color:var(--lo);background:var(--lo-bg);box-shadow:inset 0 0 0 1.5px var(--lo)}
html.touchy #left.deck #needs .nd.love{color:var(--lv);background:var(--lv-bg)}
html.touchy #left.deck #needs .nd.love.lo{color:var(--lo);background:var(--lo-bg);box-shadow:inset 0 0 0 1.5px var(--lo)}
#needs .nb.love i.low{background:var(--bad)}
html.touchy #left.deck #needs span{display:flex!important;align-items:center;gap:5px;min-width:0;color:inherit}
html.touchy #left.deck #needs .nic{display:inline-flex;line-height:0;flex:none}
html.touchy #left.deck #needs .nic svg{width:16px;height:16px}
html.touchy #left.deck #needs .nlb{display:none}
html.touchy #left.deck #needs em{display:block!important;color:inherit;font:inherit;text-align:center;min-width:0}
html.touchy #left.deck #needs .nb{display:none}
/* the strip (Panels closed, or the Jobs and Chat tabs): one row of eight, icon over number */
html.touchy #left.deck #needs{display:grid;grid-template-columns:repeat(8,minmax(0,1fr))!important;gap:3px!important}
html.touchy #left.deck #needs .nd{flex-direction:column;gap:2px;min-height:38px;padding:3px 0}
/* the Needs tab: every need by name, with its bar and number, two columns */
html.touchy #left.deck[data-tab=needs] #needs{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:5px 8px!important}
html.touchy #left.deck[data-tab=needs] #needs .nd{display:grid!important;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto 6px;align-items:center;gap:3px 6px;min-height:40px;padding:5px 8px;border-radius:9px;justify-content:stretch}
html.touchy #left.deck[data-tab=needs] #needs span{grid-column:1/3;grid-row:1}
html.touchy #left.deck[data-tab=needs] #needs .nlb{display:block;font:600 12.5px/1.1 var(--body);color:var(--fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
html.touchy #left.deck[data-tab=needs] #needs .lv .nlb svg{display:none}
html.touchy #left.deck[data-tab=needs] #needs em{grid-column:3;grid-row:1;font:700 13px var(--body);text-align:right}
html.touchy #left.deck[data-tab=needs] #needs .nb{display:block!important;grid-column:1/-1;grid-row:2;height:6px;border-radius:3px;background:rgba(42,28,18,.12)}
html.touchy #left.deck[data-tab=needs] #needs .nb i{border-radius:3px;background:currentColor!important}
/* the Panels card on a touch screen: the tabs stay put (right under the clock, on every tab) and are big enough to hit */
html.touchy #left.deck>.ltabs{order:2}
html.touchy #left.deck #simSub{order:7}
html.touchy #left.deck[data-tab=needs] #needs{order:4}
html.touchy .ltabs button{min-height:44px;font-size:12px}
html.touchy #left.deck #jobs h3,html.touchy #firstday h3{font-size:12px}
html.touchy #firstday h3 small,html.touchy #jobs h3 small{font-size:12px}
html.touchy #firstday .ghost{min-height:40px;padding:8px 12px!important;font-size:12.5px!important}
html.touchy #jobs li{min-height:40px;display:flex;align-items:center}
html.touchy .gd-chip{min-height:40px;flex-wrap:nowrap;white-space:nowrap;overflow:hidden}
html.touchy .gd-chip b{flex:none}html.touchy .gd-chip span{min-width:0;overflow:hidden;text-overflow:ellipsis}
/* the floor chat: a hint in the box and a Send button */
html.touchy #chatRow{display:flex;gap:6px;align-items:stretch}
html.touchy #chatRow #chatIn{flex:1;min-width:0;min-height:44px}
html.touchy .chat-send{flex:none;display:inline-flex;align-items:center;gap:6px;min-height:44px;min-width:44px;padding:0 14px;border:0;border-radius:var(--r-sm,10px);background:var(--note);color:var(--ink);font:700 14px var(--body);box-shadow:var(--accent-shadow)}
html.touchy .chat-send .ic,html.touchy .chat-send svg{flex:none}
/* while you type in it, the chat rides just above the keyboard, whatever is left of the screen */
html.typing #left.deck:has(#chatIn:focus){-webkit-backdrop-filter:none;backdrop-filter:none}
html.typing #left.deck>#chat:has(#chatIn:focus){display:flex!important;flex-direction:column;gap:6px;position:fixed!important;z-index:1200;left:max(10px,env(safe-area-inset-left,0px));right:max(10px,env(safe-area-inset-right,0px));bottom:calc(var(--kb,0px) + 6px);max-width:640px;margin:0 auto;padding:8px;background:var(--surface);border:1px solid var(--line-strong);border-radius:14px;box-shadow:var(--shadow-lg)}
html.typing #left.deck>#chat:has(#chatIn:focus) #chatLog{max-height:min(96px,calc(var(--vvh,100dvh) - 80px));overflow-y:auto}
/* typing: the guide box, its pointer and the joystick step aside */
html.typing #gdDock,html.typing #gdRing,html.typing #gdArrow{display:none!important}
html.typing #joy{visibility:hidden}
/* the action buttons by things and people: tall enough to hit, readable */
html.touchy #prompt,html.touchy #prompt2{min-height:44px;padding:10px 18px;font-size:14px;line-height:1.2;pointer-events:auto}
/* the action bar's labels, the bell */
html.touchy #hud #abar button{font-size:12px;letter-spacing:-.01em}
html.touchy #bBell{min-width:44px;min-height:44px;justify-content:center;align-items:center}
/* name tags over people and desks: 12 px or more ([mobe]: people were 11 px) */
html.touchy .tag .nm,html.touchy .tag.crew .nm,html.touchy .tag.desk .nm{font-size:12.5px}
/* the whodunit nudge: a real close button; it waits while a banner (payday) is up instead of sitting under it */
html.touchy #gwNudge .x{min-width:44px;min-height:44px}
html.touchy #gwNudge .gw-btn{min-height:40px}
html.touchy body:has(#banner:not([hidden])) #gwNudge{visibility:hidden}
/* [mobe] and it never sits over a menu or a dialog: hidden while More, a card or the phone is open (it used to cover the top of More) */
body.moreopen #gwNudge,body.phone-on #gwNudge,body:has(#mwrap:not([hidden])) #gwNudge,html.touchy body:has(#badgepop) #gwNudge{display:none!important}
/* the Saath card: plain words, a close button you can hit */
html.touchy #tkHud .tk-x{min-width:44px;min-height:44px;margin:-12px -10px -12px 0;font-size:22px;line-height:1}
html.touchy #tkHud .tk-s{font-size:12px}
/* the guide's buttons on a touch screen */
html.touchy #gdDock .gd-row button{min-height:44px}
html.touchy #gdDock .gd-x{min-width:44px;min-height:44px}
html.touchy #gdDock .gd-skip:disabled{opacity:.45}
html.touchy .gd-link{min-height:44px;min-width:44px;justify-content:center}

/* ---------- a tablet (touch, taller than a phone held sideways): the whodunit nudge goes top right, clear of the bottom bar ---------- */
@media (pointer:coarse) and (min-height:501px){
  html.touchy #gwNudge{top:calc(env(safe-area-inset-top,0px) + 12px);bottom:auto;left:auto;right:calc(max(16px,env(safe-area-inset-right,0px)) + 66px);transform:none;max-width:min(440px,calc(50vw - 100px))}
  html.touchy body:has(#gwNudge:not([hidden])) #tkHud{top:calc(env(safe-area-inset-top,0px) + 104px)}
  html.touchy #tkHud{width:min(240px,30vw);font-size:12.5px}
}

/* ---------- a phone held sideways (the [rot1] query) ---------- */
@media (pointer:coarse) and (orientation:landscape) and (max-height:500px){
  /* Panels closed: the clock and the needs as four by two chips (icon and number) */
  #office:not(.hud-open) #left.deck{max-width:216px;width:216px}
  html.touchy #office:not(.hud-open) #left.deck #needs{grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:4px!important}
  html.touchy #office:not(.hud-open) #left.deck #needs .nd{display:flex!important;flex-direction:row;justify-content:center;gap:3px;min-height:30px;padding:0 2px;border-radius:8px}
  html.touchy #office:not(.hud-open) #left.deck #needs .nd[style*="none"]{display:none!important}
  html.touchy #office:not(.hud-open) #left.deck #needs span{display:flex!important}
  html.touchy #office:not(.hud-open) #left.deck #needs .nlb,html.touchy #office:not(.hud-open) #left.deck #needs .nb{display:none!important}
  html.touchy #office:not(.hud-open) #left.deck #needs em{font:700 12.5px/1 var(--body);text-align:center}
  html.touchy #office:not(.hud-open) #left.deck #needs .nic svg{width:15px;height:15px}
  /* the action bar a little wider, so "Walk there" fits on one line at 12 px */
  html.touchy #abar{width:68px}html.touchy #hud #abar button{padding:2px 0;white-space:nowrap}html.touchy #spacer{width:68px!important}
  #more{right:76px}
  /* Panels open: the jobs list keeps its room and the card scrolls; the first-day steps and the starter chip take one line each */
  #office.hud-open #left{grid-row:2/4;align-self:start;max-height:100%}
  #office.hud-open #left.deck{max-height:100%}
  html.touchy #office.hud-open #joy{visibility:hidden}
  #office.hud-open #left.deck>#jobs{min-height:min(160px,calc(100dvh - 230px));flex-shrink:0}
  #office.hud-open #left.deck>#firstday{min-height:0;flex-shrink:0}
  /* on the Jobs and Chat tabs the needs live in the Needs tab (one tap away), and the "do this now" hint keeps to one line, so the list has the room */
  html.touchy #office.hud-open #left.deck:not([data-tab=needs]) #needs{display:none!important}
  #office.hud-open #left.deck:not([data-tab=needs]) #simChips .need-now{white-space:nowrap!important;overflow:hidden;text-overflow:ellipsis}
  #office.hud-open #left.deck>#firstday:not(.open) h3,#office.hud-open #left.deck>#firstday:not(.open) .fd-next{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #office.hud-open #left.deck>#firstday:not(.open) .fd-next{font-size:12.5px}
  #office.hud-open #left .gd-chip{margin-top:2px;padding:5px 9px}
  html.touchy #left .gd-chip{flex-wrap:nowrap}html.touchy #left .gd-chip>span:last-child{flex:1 1 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #office.hud-open #left.deck #chatLog{max-height:96px}
  #left.deck #simSub,#left.deck #simHours{font-size:12px}
  /* [mobe] an announcement starts right of the needs card instead of over its right edge (hudkit.js stacks the Saath card under it) */
  html.touchy #gwNudge{left:calc(max(10px,env(safe-area-inset-left,0px)) + 226px);transform:none;max-width:min(440px,calc(100vw - 316px - max(10px,env(safe-area-inset-left,0px))))}
  html.touchy #banner{left:calc(max(10px,env(safe-area-inset-left,0px)) + 226px);transform:none;max-width:min(440px,calc(100vw - 296px - max(10px,env(safe-area-inset-left,0px))))}
  /* the Saath card: top right, beside the action bar and never on it; short */
  html.touchy #tkHud{top:calc(max(8px,env(safe-area-inset-top,0px)) + 56px);right:calc(max(10px,env(safe-area-inset-right,0px)) + 80px);bottom:auto;width:min(210px,28vw);padding:5px 8px;font-size:12px}
  html.touchy #tkHud .tk-bar{margin:4px 0 3px}
  /* the action buttons */
  html.touchy #prompt{padding:10px 18px;font-size:14px}html.touchy #prompt2{padding:10px 16px;font-size:14px}
  /* the guide box, folded: one slim row (Skip step on the left, the line, Next, the close button); a tap on the line opens it */
  #gdDock.gd-compact .gd-por{width:46px;height:56px;margin-right:-10px}
  #gdDock.gd-compact .gd-box{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;align-items:center;column-gap:8px;padding:4px 4px 4px 16px}
  #gdDock.gd-compact .gd-top,#gdDock.gd-compact .gd-row{display:contents}
  #gdDock.gd-compact .gd-name,#gdDock.gd-compact .gd-ch,#gdDock.gd-compact .gd-spk,#gdDock.gd-compact .gd-link,#gdDock.gd-compact .gd-sp,#gdDock.gd-compact .gd-wait{display:none}
  #gdDock.gd-compact .gd-text{grid-column:2;grid-row:1;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;max-height:none;min-height:0;font-size:13.5px;line-height:1.35;cursor:pointer}
  #gdDock.gd-compact .gd-skip{grid-column:1;grid-row:1}
  #gdDock.gd-compact .gd-next,#gdDock.gd-compact .gd-act{grid-column:3;grid-row:1;white-space:nowrap}
  #gdDock.gd-compact .gd-x:not(.gd-spk){grid-column:4;grid-row:1}
  #gdDock.gd-compact .gd-row button{padding:6px 12px}
  #gdDock.gd-side .gd-por{display:none}#gdDock.gd-side .gd-box{padding-left:10px}
  #gdDock.gd-open .gd-text{cursor:pointer}
  #gdDock.gd-open .gd-top{margin-bottom:0}
  #gdDock.gd-open .gd-row{margin-top:3px}
}
html.kb-open #abar{visibility:hidden}
html.touchy .gd-chip .gd-ic{flex:none}
