/* web/hud/phone.css
   The play page on a phone (data-phone, web/hud/phone_layout.js): tabs, Game first,
   then each panel shown (web/hud/phone_tabs.js). Upright, a tab is the whole screen and
   the tabs run along the bottom; sideways, they run down the left, and a panel's tab
   shows it beside the game text, the two sharing the width by a line
   (web/hud/phone_split.js). The input line is on every tab. Every rule keys on
   data-phone, so a tablet and a desktop are never touched, and the dock's own placing
   of its columns is overridden here rather than changed. */

#phonetabs, #phonesplit, body > header .hico { display: none; }

/* ---- the header, in one row ---------------------------------------------- */
/* The connection is its dot, and Story, Report and Settings their drawn icons; each
   keeps its words for a screen reader and as hover text. The title gives up what room
   the rest needs, ending in an ellipsis. */
:root[data-phone] body > header { flex-wrap: nowrap; gap: 10px; }
:root[data-phone] body > header > .spacer { display: none; }
:root[data-phone] body > header > :not(h1) { flex: none; white-space: nowrap; }
:root[data-phone] body > header > h1 {
  flex: 0 1 auto; min-width: 0; margin-right: auto;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
:root[data-phone] #status { width: 7px; overflow: hidden; }
:root[data-phone] #panelsbtn { white-space: nowrap; }
:root[data-phone] #storybtn, :root[data-phone] #reportbtn, :root[data-phone] #settingsbtn,
:root[data-phone] #armorybtn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 9px;
}
:root[data-phone] #storybtn[hidden], :root[data-phone] #reportbtn[hidden],
:root[data-phone] #armorybtn[hidden] { display: none; }
:root[data-phone][data-arriving] #storybtn[hidden], :root[data-phone][data-arriving] #armorybtn[hidden],
:root[data-phone][data-arriving] #reportbtn[hidden] { display: inline-flex; visibility: hidden; }
:root[data-phone] body > header .hico {
  display: block; width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
:root[data-phone] #settingsbtn .gear { display: none; }
:root[data-phone] body > header .hword {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* The centre is a grid; the header's column buttons and the grips belong to the
   columns, which a phone does not have. The column showing a panel takes its place in
   the grid. */
:root[data-phone] #centre { display: grid; padding: 0 !important; }
:root[data-phone] #centre > .railgrip,
:root[data-phone] .colfold { display: none !important; }
:root[data-phone] #wintabs { grid-area: wintabs; }
:root[data-phone] #screen { grid-area: main; min-width: 0; min-height: 0; }
:root[data-phone] #hud { grid-area: hud; }
:root[data-phone] #prompt { grid-area: prompt; }
:root[data-phone] #centre .rail {
  position: relative; inset: auto !important; width: auto !important; min-width: 0; min-height: 0;
  z-index: 1; border: 0; overflow: hidden; scrollbar-gutter: auto;
}
:root[data-phone] #centre .rail:not([data-tab-on]) { display: none !important; }
:root[data-phone] #centre .rail[data-tab-on] { display: flex !important; }

/* Upright: the game text or one panel, the bar, the input line, then the tabs. The
   game text keeps its place and its scroll under a panel's tab, out of sight. */
:root[data-phone="upright"] #centre {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "wintabs" "main" "hud" "prompt" "tabs";
}
:root[data-phone="upright"] #centre .rail { grid-area: main; }
:root[data-phone="upright"]:not([data-phone-tab="game"]) #screen { visibility: hidden; }
:root[data-phone="upright"]:not([data-phone-tab="game"]) #wintabs { display: none !important; }
:root[data-phone="upright"]:not([data-phone-tab="game"]):not([data-typing]) #newlines { display: none !important; }
:root[data-phone="upright"] #screen, :root[data-phone="upright"] #centre .rail {
  touch-action: pan-y pinch-zoom;
}

/* Sideways: the tabs down the left; Game gives the game text the whole width, and a
   panel's tab puts the panel beside it, the line between them dragged to share. */
:root[data-phone="sideways"] #centre {
  grid-template-columns: auto minmax(0, var(--ph-game, 58fr)) auto minmax(0, var(--ph-panel, 42fr));
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "tabs wintabs split   side"
    "tabs main    split   side"
    "tabs hud     hud     hud"
    "tabs prompt  prompt  prompt";
}
:root[data-phone="sideways"][data-phone-tab="game"] #centre { grid-template-columns: auto minmax(0, 1fr) 0 0; }
:root[data-phone="sideways"] #centre .rail { grid-area: side; }
:root[data-phone="sideways"]:not([data-phone-tab="game"]) #phonesplit { display: block; }

/* The panel on its tab fills it, under its title, and scrolls on its own. It never
   folds here: its name does nothing, and a folded one still shows. Link fight
   scrolls its own lines, so those fill the panel instead. */
:root[data-phone] .rail[data-tab-on] .dkpanel:not([data-tab-on]) { display: none !important; }
:root[data-phone] .dkpanel[data-tab-on] {
  flex: 1 1 auto; min-height: 0; display: flex !important; flex-direction: column;
  margin: 0; border: 0;
}
:root[data-phone] .dkpanel[data-tab-on] > .dkhead,
:root[data-phone] .dkpanel[data-tab-on] > .dkset { flex: none; }
:root[data-phone] .dkpanel[data-tab-on] > .dkbody {
  display: block !important; flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
}
:root[data-phone] .dkhead .dkname { pointer-events: none; }
/* With a mouse its title's fold arrow and moves go too, as its ⋯ leaves the moves out
   (web/hud/panel_menu.js): a tab neither folds nor moves. */
:root[data-phone] .dkhead .dk.t, :root[data-phone] .dkhead .dk[data-act="up"],
:root[data-phone] .dkhead .dk[data-act="down"], :root[data-phone] .dkhead .dk[data-act="railprev"],
:root[data-phone] .dkhead .dk[data-act="railnext"] { display: none; }
:root[data-phone] :is(#d-linkfight, #d-chat) {
  display: flex !important; flex-direction: column; overflow: hidden;
}
:root[data-phone] :is(#d-linkfight > .lf-feed, #d-chat > .chat-feed) {
  flex: 1 1 auto; min-height: 0; max-height: none;
}

/* ---- the tabs ------------------------------------------------------------ */
:root[data-phone] #phonetabs:not([hidden]) { display: flex; grid-area: tabs; }
#phonetabs { background: var(--panel); scrollbar-width: none; overscroll-behavior: contain; }
#phonetabs::-webkit-scrollbar { display: none; }
#phonetabs button {
  position: relative; flex: 1 0 auto; min-width: 64px; min-height: 50px; margin: 0;
  padding: 4px 12px; border: 0; border-radius: 0; background: transparent;
  color: var(--dim); font-size: 12px; white-space: nowrap;
}
#phonetabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 2px 0 var(--accent); }
#phonetabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#phonetabs .ph-dot {
  position: absolute; top: 7px; right: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--warn);
}
#phonetabs .ph-said {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
:root[data-phone="upright"] #phonetabs { overflow-x: auto; border-top: 1px solid var(--line); }
:root[data-phone="sideways"] #phonetabs {
  flex-direction: column; overflow-y: auto; width: 92px; border-right: 1px solid var(--line);
}
:root[data-phone="sideways"] #phonetabs button {
  flex: none; min-height: 44px; padding: 6px 10px; text-align: left;
  white-space: normal; line-height: 1.25;
}
:root[data-phone="sideways"] #phonetabs button[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--accent); }

/* ---- the line between the game text and a panel, sideways ---------------- */
/* Two pixels to see, as a column's edge is, and a hand's width to take hold of. */
#phonesplit {
  grid-area: split; position: relative; z-index: 6; width: 16px; margin: 0 -7px;
  cursor: col-resize; touch-action: none; outline: none;
}
#phonesplit::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 7px; width: 2px; background: #333;
}
#phonesplit::after {
  content: ""; position: absolute; top: 50%; left: 5px; width: 6px; height: 44px; margin-top: -22px;
  border-radius: 3px; background: var(--cell-edge);
}
#phonesplit.drag::after, #phonesplit:focus-visible::after { background: var(--accent); }

/* ---- typing: the keyboard up for the input line (web/hud/phone_typing.js) -- */
/* The game text and the input line alone, whichever tab is showing: the header, the
   game window's tabs, the bar, the Stage and the tabs step aside, and a panel's tab gives
   its place to the game text until the keyboard closes. */
:root[data-phone][data-typing] body > header,
:root[data-phone][data-typing] #wintabs,
:root[data-phone][data-typing] #hud,
:root[data-phone][data-typing] #stage,
:root[data-phone][data-typing] #phonetabs,
:root[data-phone][data-typing] #phonesplit,
:root[data-phone][data-typing] #centre > .rail { display: none !important; }
:root[data-phone][data-typing] #screen { visibility: visible; }
:root[data-phone][data-typing] #prompt { border-top-color: var(--line); }
:root[data-phone="sideways"][data-typing] #centre { grid-template-columns: 0 minmax(0, 1fr) 0 0; }
