/* App-feel rules — loaded last on every page.
 *
 * The platform is mostly used from the mobile app's WebView, where the browser
 * defaults give away that it is a web page: a blue flash on every tap, text that
 * turns blue and grows handles when a finger rests on it, and a system sheet
 * that pops up on a long-pressed link or image. Native apps do none of that, so
 * none of it happens here either.
 *
 * Linked AFTER the page stylesheet on purpose: these are deliberate overrides of
 * whatever a page happened to declare, and several page stylesheets set
 * user-select themselves.
 */

/* ---- 1. no blue tap highlight ------------------------------------------- */
/* Inherited, but declared on * as well because a few UA stylesheets re-assert
   it on links and form controls. */
html,
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* The focus ring stays for keyboard users — :focus-visible is exactly the
   "did they tab here or tap here" distinction — but a tap or click no longer
   leaves a box behind. */
:focus:not(:focus-visible) {
    outline: none;
}

/* SweetAlert2 (loaded on the courses pages) ships its own blue box-shadow
   focus ring on .swal2-styled and a blue border/glow on .swal2-input — both
   fire on tap, not just keyboard focus, which undoes the rule above wherever
   SweetAlert2 is loaded. Keyboard users still get it via :focus-visible. */
.swal2-styled:focus:not(:focus-visible),
.swal2-input:focus:not(:focus-visible) {
    box-shadow: none;
    border-color: inherit;
}

/* ---- 2. text is not selectable ------------------------------------------ */
html,
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ---- 3. no long-press callout on links and images ----------------------- */
/* iOS/Safari: suppresses the "Open / Copy Link / Add to Reading List" sheet.
   Android WebView gets the same effect from user-select: none above. */
html,
body,
a,
img,
video {
    -webkit-touch-callout: none;
}

/* Dragging an image out of the page is the same escape hatch by another name. */
img {
    -webkit-user-drag: none;
    user-drag: none;
}

/* ---- exceptions --------------------------------------------------------- */
/* Anything the user types into has to stay selectable — without this, placing a
   caret mid-word, double-tapping to fix a typo and select-all in a field all
   stop working, which breaks every form on the platform.
   `.allow-select` / [data-allow-select] is the opt-out for content that is
   meant to be copied (codes, links, IDs). */
input,
textarea,
select,
[contenteditable="true"],
[contenteditable=""],
.allow-select,
[data-allow-select] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}
