/* Taps that feel right on phones (founder 2 Dec: "buttons are hard to click"). One file for every button, link-button,
   chip, tab and menu item on the site; page styles keep their own looks. What it fixes:
   1. The tap fires at once: no wait for a double-tap zoom (touch-action: manipulation).
   2. No grey flash and no text selection or callout when a finger rests on a button.
   3. The press shows instantly (no easing in), and eases back out on release; iPhone shows it too (app.js).
   4. No hover colour stuck on a button after a tap on a touch screen.
   5. Every tap target is at least 44 px. */
:where(a, button, summary, label, select, [role="button"], [role="tab"], input[type="submit"], input[type="button"],
       input[type="checkbox"], input[type="radio"], .btn, .mp-chip) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
:where(button, summary, [role="button"], [role="tab"], .btn, .mp-chip, .ab-tab, .cdock-b, .mp-dock-add, .pub-dock-btn) {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
/* press: instant in, soft out */
:where(button, summary, [role="button"], .btn, .mp-chip, .ab-tab, .ab-logo, .cdock-b, .mp-dock-add, .mp-dock-star,
       .pub-dock-btn, .cr-card, .mp-add-way, .sh-x, .sheet-x):active { transition-duration: 0s !important; }
:where(.mp-chip, .sheet-x, .cr-x, .mp-kebab > summary):active { transform: scale(.95); }
:where(.mp-chip, .sheet-x, .cr-x) { transition: transform 160ms var(--ease-standard, ease), background-color 160ms ease; }
/* touch screens: hover colours never stick after a tap */
@media (hover: none) {
  .btn:hover:not(:active) { color: var(--bs-btn-color); background-color: var(--bs-btn-bg); border-color: var(--bs-btn-border-color); }
}
/* a finger needs 44 px */
.btn-sm, .mp-chip, .sheet-x, .cr-x, .mp-kebab > summary { min-height: 44px; }
.sheet-x, .cr-x, .mp-kebab > summary { min-width: 44px; }
@media (prefers-reduced-motion: reduce) {
  :where(.mp-chip, .sheet-x, .cr-x, .mp-kebab > summary, .btn):active { transform: none; }
}
/* a submit button on its way (app.js): it dims a little and a small ring turns, so the tap was clearly felt */
:is(button, .btn, .cdock-go)[aria-busy="true"] { position: relative; opacity: .78; cursor: progress; }
:is(button, .btn, .cdock-go)[aria-busy="true"]::after { content: ""; width: 14px; height: 14px; margin-left: 8px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: tap-spin 700ms linear infinite; }
@keyframes tap-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { :is(button, .btn, .cdock-go)[aria-busy="true"]::after { animation: none; border-right-color: currentColor; opacity: .5; } }

/* ── UX polish (3 Dec, docs/experiment-4/batches/ux-polish.md) ── */
/* Sheets: open 250 ms easing out; the page behind does not scroll or bounce. Closing is instant (native). */
.mp-sheet-panel { animation-duration: 250ms; animation-timing-function: cubic-bezier(.16, 1, .3, 1); overscroll-behavior: contain; }
.isheet { overscroll-behavior: contain; }
html.sheet-open { overflow: hidden; }   /* set by sheets.js: a page-wide :has() made every tap re-check the whole page */
/* small menus grow from their button */
.mp-kebab > :not(summary), .mp-netmenu .mp-sheet-panel { transform-origin: top right; }
/* the busy ring shows only when the wait is real (after 300 ms), so fast saves never flash it */
:is(button, .btn, .cdock-go)[aria-busy="true"]::after { opacity: 0; animation: tap-spin 700ms linear infinite, tap-show 1ms linear 300ms forwards; }
:is(button, .btn, .cdock-go)[aria-busy="true"] { opacity: 1; }
@keyframes tap-show { to { opacity: 1; } }
/* text: headings wrap evenly, paragraphs avoid a lonely last word; numbers line up */
h1, h2, h3, .pub-h1, .pub-h2, .mp-sheet-title { text-wrap: balance; }
p, li, .mp-help { text-wrap: pretty; }
.mp-count, .mp-price b, .nw-row small, .cr-card small, [data-count] { font-variant-numeric: tabular-nums; }
/* long names never break a row */
.mp-row, .mp-row > span, .nw-row, .cr-card { min-width: 0; }
.mp-row b, .cr-card b, .nw-row b { overflow-wrap: anywhere; }
/* the end of Early access: the ring draws itself, then the dot lands (one moment, once) */
.mp-done-mark circle:first-child { animation: done-ring 640ms cubic-bezier(.16, 1, .3, 1) both; }
.mp-done-mark circle:last-child { transform-box: fill-box; transform-origin: center; animation: done-dot 260ms cubic-bezier(.3, 1.4, .5, 1) 520ms both; }
@keyframes done-ring { from { stroke-dasharray: 0 213.6; } to { stroke-dasharray: 173 40.6; } }
@keyframes done-dot { from { transform: scale(0); } }
@media (prefers-reduced-motion: reduce) {
  .mp-sheet-panel, .mp-done-mark circle { animation: none !important; }
  :is(button, .btn, .cdock-go)[aria-busy="true"]::after { animation: tap-show 1ms linear 300ms forwards; }
}

/* ── Every button shows its state (founder 3 Dec): pressed → open or working → done ──
   1. Pressed: the button sinks a little the moment a finger lands (instant in, soft out). */
:where(.btn, .mp-dock-add, .pub-dock-btn, .cdock-b, .mp-dock-star) { transition-property: color, background-color, border-color, box-shadow, transform; }
:where(.btn, .mp-dock-add, .pub-dock-btn, .cdock-b, .mp-dock-star):active { transform: scale(.97); }
:where(.mp-add-way, .cr-card, a.mp-row, .nw-row):active { transform: scale(.985); }
:where(.mp-add-way, .cr-card, a.mp-row, .nw-row) { transition: transform 160ms var(--ease-standard, ease), background-color 160ms ease; }
/* 2. Open: a button that opens a menu or sheet stays marked while it is open */
:where(details[open] > summary.btn) { background-color: var(--bs-btn-active-bg); border-color: var(--bs-btn-active-border-color); color: var(--bs-btn-active-color); }
:where(details[open] > summary.mp-chip, .mp-kebab[open] > summary, .ci-more[open] > summary, .md-more[open] > summary, .more-menu[open] > summary) { background-color: var(--tint, rgba(28, 24, 40, .08)); }
/* 3. Working: a tapped button or link-button can't be tapped twice; a link to another page shows it is on its way */
:is(button, .btn, a)[aria-busy="true"] { pointer-events: none; }
:is(.mp-add-way)[aria-busy="true"] { opacity: .6; transition: opacity 160ms ease 120ms; }
@media (prefers-reduced-motion: reduce) {
  :where(.btn, .mp-dock-add, .pub-dock-btn, .cdock-b, .mp-dock-star, .mp-add-way, .cr-card, a.mp-row, .nw-row):active { transform: none; }
}

/* A person, circle or network row (founder 3 Dec: "a delay with no feedback before the contact page loads"):
   the row lights up the instant it is touched, and once tapped it stays lit with a small turning ring on the right
   until the next page arrives. The page is also fetched from the moment the finger lands (speculation rules,
   _appbar.html), so it usually opens at once. */
:where(a.mp-row, a.nw-row, .cr-card):active { background-color: var(--tint, rgba(28, 24, 40, .06)); }
:is(a.mp-row, a.nw-row, .cr-card)[aria-busy="true"] { opacity: 1; position: relative; background-color: var(--tint, rgba(28, 24, 40, .06)); }
:is(a.mp-row, a.nw-row)[aria-busy="true"] > .icon:last-child { visibility: hidden; }
:is(a.mp-row, a.nw-row, .cr-card)[aria-busy="true"]::after { content: ""; position: absolute; right: 12px; top: 50%;
  width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; border: 2px solid var(--text-muted, #6B6578);
  border-right-color: transparent; opacity: 0; animation: tap-spin 700ms linear infinite, tap-show 1ms linear 120ms forwards; }
.cr-card[aria-busy="true"]::after { top: 14px; margin-top: 0; right: auto; left: 14px; }
@media (prefers-reduced-motion: reduce) {
  :is(a.mp-row, a.nw-row, .cr-card)[aria-busy="true"]::after { animation: tap-show 1ms linear 120ms forwards; border-right-color: var(--text-muted, #6B6578); opacity: .5; }
}

/* An app, not a web page (founder 3 Dec): no text selection, no long-press link preview or callout, no dragging images
   or links, no browser menu, on every page. Typing still works everywhere: fields, text areas, and anything marked
   data-select (e.g. an email address people may copy) keep selection and the paste menu. Zoom is kept on purpose
   (people with low vision need it). */
html { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable="true"], [data-select], [data-select] * {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, svg, a { -webkit-user-drag: none; }

/* Step forms (founder 4 Dec: the UX rules on every step): back and Help press at once; picked choices and circle chips
   press like cards; the back arrow shows a ring if the previous step is slow; ticks and taps tick (app.js). */
:where(.fx-ibtn, .fx-helpbtn, .mp-choice, .mp-cpick-item, .mp-check) { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:where(.fx-ibtn, .fx-helpbtn) { transition: transform 160ms var(--ease-standard, ease), background-color 160ms ease; }
:where(.fx-ibtn, .fx-helpbtn):active { transform: scale(.95); transition-duration: 0s; }
.fx-help[open] > .fx-helpbtn { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--text); }
:where(.mp-choice, .mp-cpick-item) { transition: transform 160ms var(--ease-standard, ease); }
:where(.mp-choice, .mp-cpick-item):active { transform: scale(.985); transition-duration: 0s; }
.mp-cpick-item, .mp-choice, .mp-check { min-height: 44px; }
a.fx-ibtn { position: relative; }
a.fx-ibtn[aria-busy="true"]::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid transparent;
  border-top-color: currentColor; opacity: 0; animation: tap-spin 700ms linear infinite, tap-show 1ms linear 300ms forwards; }
@media (prefers-reduced-motion: reduce) {
  :where(.fx-ibtn, .fx-helpbtn, .mp-choice, .mp-cpick-item):active { transform: none; }
  a.fx-ibtn[aria-busy="true"]::after { animation: tap-show 1ms linear 300ms forwards; }
}
