/* This post on phones, narrow windows and touch screens. Every rule sits behind a max-width query (900px or less) or a
   coarse-pointer query, or keys on a class that figures.js only sets when something overflows, so a desktop window
   (901px and up, with a mouse) is untouched. Rules for one figure live with it (cloud.css, arch.css, train.css). */

/* ---- the drop cap keeps its final box (dropcap.js: 119 x 126) while its font loads, so the opening paragraph does not
   reflow when the drawn B arrives; until then the plain letter stands in its place ---- */
@media (max-width: 900px) {
  #dropcap:not(.on) { float: left; width: 119px; height: 126px; margin: 2px 10px 0 -14px; font: 700 104px/126px var(--fig); text-align: center; color: var(--fig-ink); }
}
@media (max-width: 760px) { #dropcap:not(.on) { margin-left: -8px; } }

/* ---- touch: every pill and button is at least 40px tall; the molecule box is 16px so iOS does not zoom into it ---- */
@media (pointer: coarse) {
  .seg button, .act, .obj, .chip { min-height: 40px; box-sizing: border-box; }
  #typer .smi-in { font-size: 16px; }
}
/* a touch screen keeps :hover on whatever was tapped last, so a tapped button would stay darker; there it keeps its
   resting colour (the press itself still shrinks it). Figures that answer taps do not flash grey under the finger. */
@media (hover: none) {
  .act:hover, .cl-wide .v.bare .sbtn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
}
#title span, #arch svg, .q canvas, #fixed-lines, .rm, #train .trn-big, #train .trn-sm { -webkit-tap-highlight-color: transparent; }

/* ---- sideways scrollers (tables, the five lines) fade on the side that has more; figures.js sets more-l / more-r ---- */
.more-r { -webkit-mask-image: linear-gradient(to left, transparent, #000 44px); mask-image: linear-gradient(to left, transparent, #000 44px); }
.more-l { -webkit-mask-image: linear-gradient(to right, transparent, #000 44px); mask-image: linear-gradient(to right, transparent, #000 44px); }
.more-l.more-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); }

/* ---- tables: a narrow table fits the screen instead of scrolling; wide ones still scroll, and stay inside their box ---- */
@media (max-width: 600px) {
  .tbl { overscroll-behavior-x: contain; }
  .tbl table.plain:not(.text):not(.dense) { min-width: 0; }
  .tbl table.plain th, .tbl table.plain.dense th, .tbl table.plain th .rnd2 { font-size: 10.5px; }
  .tbl table.plain th:has(.rnd2) { min-width: 6.5em; }   /* a two-part header keeps a few words per line */
}

/* ---- router figure: on a phone the label column is gone, so the characters get the whole width and line up with the
   text; the readout keeps the height of its longest text, so nothing below jumps as a finger moves along it ---- */
@media (max-width: 620px) {
  #router .ctl, #router .ctl > .rx-mol { margin-left: 0; }
  #router .ctl > .rx-mol { white-space: normal; }   /* a long molecule breaks onto a second line instead of running off the screen */
  #router .rm-cols { margin-left: 28px; }
  #router .rm-chars .rm-cols span { font-size: clamp(9px, calc((100cqw - 28px) / var(--n) / .74), 13px); }
  .rm .rm-tk { font-size: 10.5px; }
  #router .hero-say { min-height: 8em; }
  #typer .hero-say { min-height: 4.8em; }
}

/* ---- fixed tokenizer against learned: the five lines scroll sideways together at a readable size, names stay put ---- */
@media (max-width: 700px) {
  #fixed-lines { gap: 14px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding-bottom: 2px; }
  #fixed-lines::-webkit-scrollbar { display: none; }
  #fixed-lines .line { grid-template-columns: 1fr; gap: 4px; width: max-content; min-width: 100%; }
  #fixed-lines .l-lab { position: sticky; left: 0; width: max-content; display: flex; gap: 10px; align-items: baseline; }
  #fixed-lines .l-ct { padding-left: 0; }
  #fixed-lines .bytes { --fs: 11px !important; overflow: visible; }
  /* the names stick to the left edge, so only the right edge fades */
  #fixed-lines.more-l { -webkit-mask-image: none; mask-image: none; }
  #fixed-lines.more-r { -webkit-mask-image: linear-gradient(to left, transparent, #000 44px); mask-image: linear-gradient(to left, transparent, #000 44px); }
}

/* ---- the atlas on a small screen: a placeholder in the figure style until the reader loads it (figures.js) ---- */
