/* Touch controls (core/touch.js builds and works them, data/touch.js says what they are, core/touchlayout.js where they stand) and the glass as a
   screen held in the hand has it. Every colour, size, weight, spacing and time is a token of the HUD (data/hud.js tokens) or a row of data/touch.js TOUCH_LOOK, which core/touch.js hands to the page as --touch-<name>
   once, at boot: nothing here is a colour or a length of its own. What the layout knows of the screen reaches this file as custom properties of the page, --touch-*, which exist only while the controls are on screen
   (core/touch.js keepClear). A ground under words is a background-color from a token. */

/* The browser's own gestures do not fire in play: no pull to refresh, no pinch or double-tap zoom (the page may still pan where it scrolls), no
   callout or highlight on a press, and none at all on the picture and the controls, which are the game's. */
html, body { overscroll-behavior: none; touch-action: pan-x pan-y; -webkit-touch-callout: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#view { touch-action: none; }

/* The layer: over everything, taking no touch itself; the field, the controls and the list take theirs. */
#touch { position: fixed; inset: 0; z-index: 3; pointer-events: none; touch-action: none; user-select: none; }
html:not([data-device='touch']) #touch { display: none; }
.touch .field { position: absolute; pointer-events: auto; touch-action: none; }
.touch .ring, .touch .knob { position: absolute; border-radius: var(--touch-round); pointer-events: none; }
.touch .ring { border: var(--slot-line) solid var(--ink-faint); background-color: var(--wash); transition: border-color var(--fade); }
.touch .ring[data-on='1'] { border-color: var(--ink-dim); }
.touch .ring[data-run='1'] { border-color: var(--lamp); }
.touch .knob { background-color: var(--ink-faint); transition: background-color var(--fade); }
.touch .ring[data-on='1'] .knob { background-color: var(--ink-dim); }
.touch .ring[data-run='1'] .knob { background-color: var(--lamp); }

/* A control is a pill on the HUD's own plate, its word a label in the system's type (capitals set here, the data has the case a sentence has). Lit while the finger is on it, and while what it shows is so
   (the light on, the body crouched): the lamp's colour means that and nothing else. What is pressed all the time (Use, Item) is in full ink with the heavier edge. */
.touch .btn {
  position: absolute; display: grid; place-items: center; box-sizing: border-box; padding: 0;
  border: var(--slot-line) solid var(--ink-dim); border-radius: var(--touch-pill); background-color: var(--dark-veil); color: var(--ink);
  font-family: var(--font-display); font-size: var(--size-label); font-weight: var(--weight-label); line-height: var(--touch-lead); letter-spacing: var(--track-label);
  text-transform: uppercase; text-shadow: none; white-space: nowrap;
  pointer-events: auto; touch-action: none;
}
.touch .btn[data-size='big'] { border-width: var(--plate-rule); border-color: var(--ink); }
.touch .btn[data-down='1'] { background-color: var(--ink); color: var(--black); }
.touch .btn[data-lit='1'] { border-color: var(--lamp); color: var(--lamp); }
.touch .btn[data-open='1'] { background-color: var(--wash); border-color: var(--ink); }

/* The list More opens: a line each, one under another, as written (no capitals: a line of a list is not a button), as tall as a thumb needs, on the sheets' own dark. It stands where core/touchlayout.js trayOf puts it. */
.touch .tray { position: absolute; inset: 0; pointer-events: none; }
.touch .tray[data-open='0'] { display: none; }
.touch .line {
  position: absolute; display: grid; align-items: center; justify-items: start; box-sizing: border-box; padding: 0 var(--touch-linepad);
  border: var(--slot-line) solid var(--ink-faint); background-color: var(--dark-sheet); color: var(--ink);
  font-family: var(--font-text); font-size: var(--size-read); font-weight: var(--weight-say); line-height: var(--touch-lead); white-space: nowrap;
  pointer-events: auto; touch-action: none;
}
.touch .line[data-down='1'] { background-color: var(--ink); color: var(--black); }

/* The probes the layer asks the page's own tokens' widths of (core/touch.js keepClear). */
.probe { position: absolute; left: 0; top: 0; height: 0; visibility: hidden; pointer-events: none; }
.probe[data-token='edge'] { width: var(--edge); }
.probe[data-token='side'] { width: var(--side); }

/* A plate of the prompt that has a control takes a finger (ui/glass/prompt.js writes data-press for a finger and for none else): finger down on it is that control down. It is as tall as a thumb needs. */
html[data-device='touch'] .act[data-press], html[data-device='touch'] .pick-act[data-press] { pointer-events: auto; touch-action: none; min-height: var(--touch-thumb); box-sizing: border-box; }
/* The lock's plate has a line a finger touches (ui/lockpick.js: Let go): it is as wide as the plate, and what is held in its words is centred in its height. The plate hangs under the foot of the controls at the top right where, in the middle of the window, it would
   be across them (ui/lockpick.js writes --pick-half, half of the plate's own height, for the stylesheet to work that out by), and its foot stands above a block of controls at the window's foot that it is over (--pick-foot, where there is one), else inside the window's own foot. */
html[data-device='touch'] .pick-act[data-press] { justify-self: stretch; }
html[data-device='touch'] .pick { top: min(max(50%, calc(var(--touch-right-foot, var(--touch-none)) + var(--touch-air) + var(--pick-half, var(--touch-none)))), calc(min(100% - var(--edge), var(--pick-foot, var(--touch-far)) - var(--touch-air)) - var(--pick-half, var(--touch-none)))); }
/* An offer that is held wears the hold's weighted foot along its own foot, as the key's plate does where a key is drawn (ui/style/keys.css): a finger has no key to draw it on. */
html[data-device='touch'] .act[data-hold='1'] { box-shadow: inset 0 calc(var(--key-size) * var(--touch-foot) * -1) 0 var(--ink-faint); }

/* A finger taps a slot of the strip while it is up; it is the hand's, and as big as a thumb needs. A control of a sheet is as tall as a thumb needs. The glass's
   columns are a little narrower, so that the row across the top has the middle to itself. */
html[data-device='touch'] { --slot: var(--touch-slot) !important; --side: var(--touch-side) !important; }
html[data-device='touch'] .hotbar[data-on='1'] .slot { pointer-events: auto; }
/* Where the room between the hands does not hold the slots the strip is bound to, it stands at the top, under the foot of the controls that stand there, as wide as the frame, so that it holds as many slots as the width does (ui/glass/strip.js sets data-at). */
html[data-device='touch'] .hotbar[data-at='top'] { position: absolute; left: 0; right: 0; top: calc(var(--touch-right-foot, var(--touch-none)) - var(--edge) + var(--touch-air)); width: auto; margin: 0; justify-self: stretch; }
html[data-device='touch'] button:not(.slot) { min-height: var(--touch-thumb); }
html[data-device='touch'] .item { padding-block: var(--touch-pad); }

/* What names a key tells nothing to a finger: the foot of a sheet that says which key closes it, the keys of the fight. (The map's foot is its finger's: Centre and Close are buttons there, and it draws no key.) */
html[data-device='touch'] .sheet-foot > span:not(.status):not(.sheet-entry), html[data-device='touch'] .b-chips { display: none; }

/* The glass keeps clear of the controls. The left column stops where they begin, the right column too; a column the row across the top runs over starts below it; the breath's plate stands to the right of what is at the left. */
.corner.tl { margin-top: var(--touch-push-left, var(--touch-none)); max-height: calc(var(--touch-left-top, var(--touch-far)) - var(--edge) - var(--touch-push-left, var(--touch-none))); }
/* The news's corner begins under what is in its way at the top right: the row across the top, where it runs over the corner, or the controls that stand there (--touch-right-foot: More and Pause in play, the fight's own in a fight), and ends above what stands under it. */
.corner.tr { --news-from: max(var(--touch-push-right, var(--touch-none)), calc(var(--touch-right-foot, var(--touch-none)) - var(--edge))); margin-top: var(--news-from); max-height: min(calc(var(--column-foot) - var(--edge) - var(--news-from)), calc(var(--touch-right-top, var(--touch-far)) - var(--edge) - var(--news-from))); }
.vitals { margin-left: calc(var(--touch-left-width, var(--edge)) - var(--edge)); }

/* What has just gone into the pack, on a finger's screen (a phone held across; #391; on a narrow screen the rule below puts the tiles back over the dot). At a desk the tiles stand in one row, centred over the dot, and nothing else of the glass stands in their row; on a phone the news's column
   stands at the right, in the same height, and the row ran under it. The group keeps to the middle of the glass instead, between the frame's left edge and where the news's column begins (the frame's edge, its column and its gutter, as .frame lays them out and the
   tip's own place reads them), its right edge on that column's, wrapping upward as it did, so that no tile stands under the news. The same room is the tip's: the tip gives way to a tile that crosses it (ui/glass/tips.js). */
html[data-device='touch'] .gained {
  --got-room: calc(var(--edge) + var(--side) + var(--gutter));
  left: auto; right: var(--got-room); transform: none; justify-content: flex-end;
  max-width: calc(100% - var(--edge) - var(--got-room));
}

/* The glass on a narrow screen (a phone held upright, or a window a third of a monitor wide): the second column is as wide as what stands in it needs, which leaves the first all the rest for what to do next.
   The condition is the width of the window, which a custom property cannot be read in. */
@media (max-width: 36rem) {
  .frame { grid-template-columns: minmax(0, 1fr) auto; }
  /* The glass's own second column stands beside what is at the top right: as wide as the wider of the news's column (--side) and the block of controls there (--touch-right-head, from the screen's edge: the frame's own edge is taken off), so that the Now block stands beside More and
     Pause and beside the news, and under neither. With no controls on the screen it is --side, as the news's own column is. (The news's frame keeps its auto column: its corner is --side wide.) */
  .frame:not(.news) { grid-template-columns: minmax(0, 1fr) max(var(--side), calc(var(--touch-right-head, var(--touch-none)) - var(--edge))); }
  .corner.tr { grid-area: 1 / 2; width: var(--side); }   /* the news's column is --side wide, as on a wide screen: the grid's auto track would take whatever its longest line wants */
  .dock { grid-area: 2 / 1 / 3 / 3; }
  .hint { flex-wrap: wrap; }   /* a tip whose words have no room beside its key stands them under it, and they wrap inside the frame (a finger's key can be two plates: More, then the line) */
  html[data-device='touch'] .gained { left: 50%; right: auto; transform: translateX(-50%); justify-content: center; max-width: var(--prompt-wide); }   /* (here the news's column is not beside the tiles' row: they stand centred over the dot, as at a desk, glass.css .gained) */
  /* (no middle column to speak of here: a card has the frame's width, as it had) It begins under the foot of the controls at the top right and, while there is news, under the news's foot (ui/glass/cardface.js keepCards measures it and writes --cards-under); the Now block, which a card that
     is wide enough crosses, gives way to it (ui/glass/nowblock.js). */
  .cards { left: var(--edge); right: var(--edge); top: max(var(--edge), calc(var(--touch-right-foot, var(--touch-none)) + var(--touch-air)), calc(var(--cards-under, var(--touch-none)) + var(--touch-air))); }
}

/* A sheet on a screen held across: the heading takes less of the height, so that the page has the room. The condition is the height of the window, which a custom property cannot be read in. */
@media (max-height: 32rem) {
  .screen > .sheet[data-frame] { padding-top: var(--sheet-narrow-pad-y); }
  .sheet[data-frame] .sheet-head h2 { margin-top: 0; }
}
