/* my-gui touch: sizes for fingers on touch screens, readable small print on phones, and the long-press tooltip
   (js/touch.js). data-m-touch="off" on <html> keeps the compact sizes. docs/spec.md 21.
   Fields, the table, the text area, the combo box and voice input bring their own rules. */

@media (pointer: coarse) {
  :root:not([data-m-touch="off"]) .m-btn { min-height: 44px; }
  :root:not([data-m-touch="off"]) .m-btn--icon { min-width: 44px; }
  :root:not([data-m-touch="off"]) .m-mi { height: auto; min-height: 44px; }
  :root:not([data-m-touch="off"]) .m-seg > button,
  :root:not([data-m-touch="off"]) .m-seg > [role="tab"] { min-height: 40px; min-width: 44px; }
  :root:not([data-m-touch="off"]) .m-sidenav .m-row { min-height: 44px; }
  :root:not([data-m-touch="off"]) select.m-select,
  :root:not([data-m-touch="off"]) input.m-input { min-height: 44px; }
  /* check boxes, radios and switches keep their shape: the label is the target, the mark is a little bigger,
     and the switch's invisible input reaches above and below the drawn track */
  :root:not([data-m-touch="off"]) .m-check { min-height: 44px; }
  :root:not([data-m-touch="off"]) :is(.m-checkbox, .m-radio) { width: 22px; height: 22px; }
  :root:not([data-m-touch="off"]) .m-checkbox:checked::after { top: 3px; left: 7.5px; width: 5px; height: 11px; }
  :root:not([data-m-touch="off"]) .m-radio:checked::after { top: 6.5px; left: 6.5px; width: 9px; height: 9px; }
  :root:not([data-m-touch="off"]) .m-switch input { top: 50%; bottom: auto; height: 44px; margin-top: -22px; }
  :root:not([data-m-touch="off"]) .m-toast-act,
  :root:not([data-m-touch="off"]) .m-toast-x { min-width: 44px; min-height: 44px; }
  :root:not([data-m-touch="off"]) summary { min-height: 44px; }

  /* small controls whose drawing stays: the area that takes the finger grows around them */
  :root:not([data-m-touch="off"]) .m-tag-x,
  :root:not([data-m-touch="off"]) a.m-cite { position: relative; }
  :root:not([data-m-touch="off"]) .m-tag-x::before,
  :root:not([data-m-touch="off"]) a.m-cite::before { content: ""; position: absolute; inset: -12px; }

  button[data-tip], a[data-tip] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

[data-tip].is-tip::after { opacity: 1; transform: translate(-50%, 0); }
[data-tip-pos="below"].is-tip::after { transform: translate(-50%, 0); }
[data-tip-pos="below-end"].is-tip::after,
[data-tip-pos="end"].is-tip::after { transform: none; }
[data-tip-pos="right"].is-tip::after { transform: translate(0, -50%); }

@media (pointer: coarse) {
  :root:not([data-m-touch="off"]) .m-tag--pick { min-height: 32px; }
  :root:not([data-m-touch="off"]) .m-colmenu-btn,
  :root:not([data-m-touch="off"]) .m-reorder-handle { min-width: 36px; min-height: 36px; }
  :root:not([data-m-touch="off"]) input.m-range { min-height: 32px; }
  :root:not([data-m-touch="off"]) .m-ai-input textarea { min-height: 44px; padding-block: 11px; }
}

/* phones: the small print is at least 11px (text drawn inside charts keeps its size, the layout depends on it) */
@media screen and (max-width: 600px) {
  :root:not([data-m-touch="off"]) :is(.m-label, .m-sort, .m-badge, .m-count, .m-kbd, .m-sum-kind, .m-cite, .m-ai-mark),
  :root:not([data-m-touch="off"]) .m-table th { font-size: 11px; }
}
