/*
 * Mobile content-selection contract.
 *
 * Studiverse behaves as an application on touch-first devices. Prevent iOS
 * and other mobile browsers from turning long presses or small scroll drags
 * into document selections, callouts, or image drags. Text-entry surfaces
 * remain fully editable so caret movement and cut/copy/paste keep working.
 *
 * Never cancel touch events or apply touch-action to the document: scrolling,
 * pinching, drawing canvases, and authored gestures remain component-owned.
 * The zero-specificity control rule below suppresses only double-tap zoom and
 * deliberately keeps pan/pinch available; any authored gesture rule wins.
 */
@media (hover: none) and (pointer: coarse) {
  :where(
    a[href],
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    [role="button"],
    summary,
    label[for]
  ) {
    touch-action: manipulation;
  }

  html:root,
  html:root body,
  html:root body :where(*) {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  /* Editable fields are interaction surfaces, not selectable page content. */
  html:root body :where(
    textarea,
    input:not([type]),
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    [contenteditable]:not([contenteditable="false"]),
    [contenteditable]:not([contenteditable="false"]) :where(*)
  ) {
    -webkit-touch-callout: default !important;
    -webkit-user-select: text !important;
    user-select: text !important;
  }

  /* iOS magnifies focused fields whose computed type is below 16px. Preserve
     larger component typography while enforcing that native threshold. */
  html:root body :where(
    textarea,
    select,
    input:not(:is(
      [type="button"],
      [type="submit"],
      [type="reset"],
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="color"],
      [type="file"],
      [type="hidden"]
    )),
    [contenteditable]:not([contenteditable="false"])
  ) {
    font-size: max(16px, 1em) !important;
  }

  html:root body :where(img, svg) {
    -webkit-user-drag: none !important;
  }
}
