/* web/hud/touch.css
   The play page on a touch screen, and with touch controls. What is about the screen
   keys on the pointer being coarse, whatever Settings' Controls says. What is about
   tapping keys on data-controls="touch" (web/hud/controls.js): Controls set to Touch,
   or on Automatic nothing being able to hover, so a tablet with a trackpad or a mouse
   keeps the desktop's sizes. Never on a width. Each tapping rule's condition sits in
   :where(), so it weighs no more than the media query it replaced. */

@media (pointer: coarse) {
  /* The page fills what you can see (web/hud/page_fit.js), and keeps clear of the notch
     and the home bar; with the keyboard up there is no home bar to keep clear of.
     Fixed, so it can follow an iPhone sliding the page up to show the input line. */
  html { height: var(--seen-h, 100dvh); overflow: hidden; }
  body {
    position: fixed; left: 0; right: 0; top: var(--seen-top, 0);
    height: var(--seen-h, 100dvh);
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  :root[data-keyboard] body { padding-bottom: 0; }

  /* An iPhone zooms in on a field whose text is under 16px, so none is, whatever
     the game's text size. */
  #line { font-size: max(16px, var(--mono-size)) !important; }
  input:not(#line), select, textarea { font-size: max(16px, 1em) !important; }

  /* The Panels menu stops above the home bar, and the Report window keeps clear of
     the notch. In Settings an option too wide to sit beside its name goes under it,
     so every one can be reached. */
  .menu {
    max-height: calc(var(--seen-h, 100dvh) - 60px - env(safe-area-inset-top)
      - env(safe-area-inset-bottom));
  }
  .overlay {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .sw-pane { grid-template-columns: minmax(0, 1fr); }
  .sw-pane label, .sw-pane .sw-row { flex-wrap: wrap; }
  .sw-pane select { min-width: 0; max-width: 100%; }
}

/* With touch controls, everything you tap is about 44px square, and so is a word in
   the Help panel's lists of commands. A link inside a sentence keeps the sentence's
   height. */
:where(:root[data-controls="touch"]) button,
:where(:root[data-controls="touch"]) select,
:where(:root[data-controls="touch"]) #line,
:where(:root[data-controls="touch"]) input[type="text"],
:where(:root[data-controls="touch"]) input[type="search"],
:where(:root[data-controls="touch"]) input[type="number"] {
  min-height: 44px;
}
:where(:root[data-controls="touch"]) button { min-width: 44px; }
:where(:root[data-controls="touch"]) .hp-gverbs .hp-link {
  display: inline-flex; align-items: center; min-height: 44px;
}

/* A row as wide as its panel is a big target already, so 32px tall is enough: a
   Loadout row, a thing in the Inventory, a thing worn in the Equipment. */
:where(:root[data-controls="touch"]) .lo-pick,
:where(:root[data-controls="touch"]) .lo-fixed,
:where(:root[data-controls="touch"]) .inv-item.act,
:where(:root[data-controls="touch"]) .eq-row.act { min-height: 32px; }

/* A column that is out is widened by its inner edge: a strip a finger can hold, 12px
   either side of the edge, over the column's padding and the text's margin. Its grip
   always shows, mid-height on the column's side, drawn as a panel's foot draws its
   own (web/hud/panel_height.css); held, the grip and the column's edge take the accent. */
:where(:root[data-controls="touch"]) .railgrip,
:where(:root[data-controls="touch"]) .railgrip:hover,
:where(:root[data-controls="touch"]) .railgrip.drag { width: 24px; background: none; opacity: 1; }
:where(:root[data-controls="touch"]) #grip-left { margin-left: -12px; }
:where(:root[data-controls="touch"]) #grip-right { margin-right: -12px; }
:where(:root[data-controls="touch"]) .railgrip::after {
  content: ""; position: absolute; top: 50%; width: 3px; height: 36px; margin-top: -18px;
  border-radius: 2px; background: var(--cell-edge);
}
:where(:root[data-controls="touch"]) #grip-left::after { right: 17px; }
:where(:root[data-controls="touch"]) #grip-right::after { left: 17px; }
:where(:root[data-controls="touch"]) .railgrip.drag::after { background: var(--accent); }
:where(:root[data-controls="touch"]) .railgrip.drag::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--accent); opacity: .55;
}
:where(:root[data-controls="touch"]) #grip-left.drag::before { right: 12px; }
:where(:root[data-controls="touch"]) #grip-right.drag::before { left: 12px; }

/* With touch controls, a panel's title is one line: its name, its count and a ⋯
   opening a menu of its controls in words (web/hud/panel_menu.js). The name still
   opens and closes the panel. */
:where(:root[data-controls="touch"]) .dkhead { padding: 0 0 0 8px; }
:where(:root[data-controls="touch"]) .dkhead .dk { display: none; }
:where(:root[data-controls="touch"]) .dkhead .dkmore {
  display: inline-flex; align-items: center; justify-content: center; flex: none; order: 3;
  min-width: 44px; min-height: 44px; margin: 0 0 0 2px; padding: 0;
  background: none; border: none; border-radius: 6px;
  color: var(--pn-label); font-size: 22px; line-height: 1;
}
:where(:root[data-controls="touch"]) .dkhead .dkmore[aria-expanded="true"] { color: var(--ink); background: #222; }
:where(:root[data-controls="touch"]) .menu.dkmenu { position: fixed; right: auto; }
:where(:root[data-controls="touch"]) .dkmenu .mi { min-height: 44px; }
