/* FlexLex — shared design system layer (r8, 2026-11-22).
 *
 * Loaded on every page right after fx.css. Small, global, additive:
 *   S1  Base rendering: selection, desktop scrollbar, text inflation, figures
 *   S2  Focus-visible rings (white on coloured buttons, green elsewhere)
 *   S3  Buttons: a press that matches the ledge, disabled + busy states
 *   S4  Menu button: three bars that fold into an X (fx.js §64)
 *   S5  Reading progress: a hairline inside the island's bottom edge
 *   S6  In-prose links: quiet underline at rest, full on hover
 *   S7  Page-to-page transitions: sequenced, direction-aware
 *   S8  Phone nav sheet: the tile icons pop in as the tiles arrive
 *   S9  Portrait tablets: back-to-top stacks above the dock
 * Motion policy as everywhere: OS "reduce motion" never stops an entrance
 * or a transition here — none of these are ambient loops.
 */

/* ── S1 · Base rendering ─────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); color: #fff; text-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  html { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) var(--scaffold); }
}
[data-count], .stat__n, .stat b { font-variant-numeric: tabular-nums; }
h1, h2, h3, .btn { text-rendering: optimizeLegibility; }

/* ── S2 · Focus-visible ──────────────────────────────────────────────── */
:focus:not(:focus-visible) { outline: none; }
/* A green ring on a green button read as a glow, not focus: coloured
   buttons get a near-white ring instead. */
.btn:focus-visible,
.dock a:focus-visible,
.qr-btn:focus-visible {
  outline: 2.5px solid color-mix(in srgb, #fff 90%, var(--accent));
  outline-offset: 3px;
}
.btn.btn--quiet:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; }
/* Nav links: a lighter 2px ring hugging the link, and the label lights up
   as it does on hover (the 3px ring around muted grey text read heavy). */
.nav .nav__links a:not(.btn):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; color: var(--ink); }
.nav .nav__logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; border-radius: 12px; }
:is(input, textarea, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.skip:focus, .skip:focus-visible { outline: 3px solid color-mix(in srgb, #fff 85%, transparent); outline-offset: 3px; }

/* ── S3 · Buttons ────────────────────────────────────────────────────── */
/* The face sinks exactly as deep as its ledge (4px, 3px on .btn--sm) and
   no further — no scale, so the ledge never peeks out at the sides. A
   70ms press, a springy release. */
.btn:active { transform: translateY(4px); transition-duration: 70ms; }
.btn--sm:active { transform: translateY(3px); }
/* Measured ledges: Google Play 5px, outline buttons 3px. */
.btn.btn--play:active { transform: translateY(5px); }
.btn.btn--line:active { transform: translateY(3px); }
.btn:is(:disabled, [aria-disabled="true"]) {
  opacity: .48;
  filter: saturate(.35);
  cursor: not-allowed;
  transform: none !important;
  pointer-events: none;
}
/* Busy: the label steps aside for a spinner (functional, so it keeps
   spinning under reduce motion). */
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .32);
  border-top-color: #fff;
  animation: sys-spin 700ms linear infinite;
}
@keyframes sys-spin { to { transform: rotate(360deg); } }

/* The divider in the Google Play button stays upright: it used to be the
   droid's own border-left, so the droid's hover wiggle (and the hero's
   periodic wave) tilted the line with it. Now it belongs to the label.
   Same spot, same size: 13px flex gap + the droid's 6px margin, 34px tall. */
.btn--play .btn--play__t { position: relative; }
.btn--play .btn--play__t::after {
  content: '';
  position: absolute;
  right: -20px; top: 50%;
  width: 1px; height: 34px; margin-top: -17px;
  background: rgba(255, 255, 255, .16);
  pointer-events: none;
}
.btn--play .btn--play__droid { border-left-color: transparent; }

/* ── S4 · Menu button: bars → X ──────────────────────────────────────── */
#navToggle.has-bars { position: relative; color: var(--ink); }
#navToggle.has-bars > .sym { position: absolute; opacity: 0 !important; pointer-events: none; }
.nt-bars { position: relative; display: block; width: 20px; height: 14px; }
/* Optical balance: the logo mark sits 15px inside the island's left
   end, so the bars sit 16px inside its right end (not 21px). */
.nav.is-island #navToggle.has-bars { margin-right: -5px; }
.nt-bars i {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  transition: transform 460ms cubic-bezier(.34, 1.56, .64, 1), top 200ms cubic-bezier(.2, .8, .3, 1),
              right 260ms cubic-bezier(.2, .8, .3, 1), opacity 160ms ease;
}
.nt-bars i:nth-child(1) { top: 0; }
.nt-bars i:nth-child(2) { top: 6px; }
.nt-bars i:nth-child(3) { top: 12px; right: 6px; }
#navToggle[aria-expanded="true"] .nt-bars i:nth-child(1) { top: 6px; transform: rotate(45deg); }
#navToggle[aria-expanded="true"] .nt-bars i:nth-child(2) { opacity: 0; transform: scaleX(.2); }
#navToggle[aria-expanded="true"] .nt-bars i:nth-child(3) { top: 6px; right: 0; transform: rotate(-45deg); }

/* ── S5 · Reading progress inside the island ─────────────────────────── */
/* fx.js §64 moves the strip into .nav__inner and adds .has-progress once
   the page has moved ~140px. Same strip, same scroll timeline / script
   (style.css, script.js) — only where it sits and when it shows. */
.nav.is-island .nav__inner > .nav__progress {
  position: absolute;
  /* Laid over the island's bottom border, so the edge itself lights up
     (on the border, not 1px above it). */
  top: auto; bottom: -1px;
  left: 28px; right: 28px;
  height: 2px;
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms ease;
}
.nav.is-island .nav__inner > .nav__progress i {
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), #12CDB0 60%, #12B6F3);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 50%, transparent);
}
.nav.is-island.has-progress .nav__inner > .nav__progress { opacity: .9; }
body.fx-tour-on .nav.is-island .nav__inner > .nav__progress,
html.fx-sheet-open .nav.is-island .nav__inner > .nav__progress { opacity: 0; }
/* 28px in = where the island's rounded ends turn flat (56px tall on
   phones, 52px on desktop), so the line never pokes past the curve. */

/* ── S6 · In-prose links ─────────────────────────────────────────────── */
:is(.note, .faq__a, .lede, .hero__ios) a:not(.btn) {
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 38%, transparent);
  transition: text-decoration-color 220ms ease, text-underline-offset 220ms cubic-bezier(.2, .8, .3, 1), color 200ms ease;
}
@media (hover: hover) {
  :is(.note, .faq__a, .lede, .hero__ios) a:not(.btn):hover { text-decoration-color: currentColor; text-underline-offset: 4px; }
}
:is(.note, .faq__a, .lede, .hero__ios) a:not(.btn):focus-visible { text-decoration-color: currentColor; }

/* ── S7 · Page-to-page transitions ───────────────────────────────────── */
/* Sequenced instead of overlapping: the old page lifts away in 150ms,
   the new one rises in right after it, so the two pages' text is never
   on screen together. Back / forward (theme.js adds the "back" type)
   plays the same moves the other way. Under 450ms all in. The theme
   wipe (html.fx-wipe, fx.css) keeps its own reveal and is untouched. */
::view-transition-old(root) { animation: sys-vt-out 150ms cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: sys-vt-in 330ms cubic-bezier(.2, .9, .3, 1) 110ms both; }
@keyframes sys-vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes sys-vt-in { from { opacity: 0; transform: translateY(14px); } }
html:active-view-transition-type(back)::view-transition-old(root) { animation-name: sys-vt-out-back; }
html:active-view-transition-type(back)::view-transition-new(root) { animation-name: sys-vt-in-back; }
@keyframes sys-vt-out-back { to { opacity: 0; transform: translateY(8px); } }
@keyframes sys-vt-in-back { from { opacity: 0; transform: translateY(-14px); } }
html.fx-wipe::view-transition-old(root),
html.fx-wipe::view-transition-new(root) { animation: none; mix-blend-mode: normal; filter: none; transform: none; opacity: 1; }

/* ── S8 · Phone nav sheet ────────────────────────────────────────────── */
@media (max-width: 880px) {
  :root[data-nav="top"] .nav__links.open li .nav__ico {
    animation: sys-ico-pop 480ms cubic-bezier(.34, 1.56, .64, 1) both;
    animation-delay: calc(var(--li, 0) * 30ms + 110ms);
  }
  @keyframes sys-ico-pop { from { opacity: 0; transform: scale(.55) rotate(-10deg); } }
}

/* ── S9 · Portrait tablets: back-to-top stacks above the dock ────────── */
/* There the dock is a small card anchored right (fx.css 62.6) and the
   arrow already sits 96px up, above it; the phone rule that hides the
   arrow while the dock is up left tablets with no way back up. */
@media (min-width: 601px) and (max-width: 899px) and (orientation: portrait) {
  body.fx-dock-up:not(.fx-tour-on):not(.mx-open) .back-to-top.visible:not(.is-tucked) {
    opacity: 1;
    pointer-events: auto;
  }
}
