/* Site shell (the Hallmark stamp is at the top of tokens.css, the first stylesheet): reset, type by language, buttons, the glass nav pill, the statement footer, section shells,
   the gradient highlight, reveal states, focus, the hero silk canvas and the 404 page. */

/* ---------- Reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  background: var(--color-paper);
}

body {
  margin: 0;
  overflow-x: clip;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.55;
  font-synthesis: none;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

main {
  flex: 1 0 auto;
}

main:focus {
  outline: none;
}

:where(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol) {
  margin: 0;
}

:where(ul, ol)[role="list"] {
  list-style: none;
  padding: 0;
}

:where(img, picture, video, canvas) {
  display: block;
  max-width: 100%;
}

:where(img, video) {
  height: auto;
}

:where(input, button, textarea, select) {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

:where(button) {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

:where(a) {
  color: inherit;
}

/* Plain links (no class): ink with an underline (SPEC §1.3) */
:where(a:not([class])) {
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

@media (hover: hover) {
  :where(a:not([class])):hover {
    text-decoration-thickness: 2px;
  }
}

:where(strong, b) {
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--color-cyan-soft);
  color: var(--color-ink);
}

/* ---------- Type by language ---------- */

html:lang(zh) body {
  line-height: 1.7;
  text-autospace: normal;
  line-break: strict;
}

:where(h1, h2, h3, h4, h5, h6) {
  font-style: normal;
  text-wrap: balance;
  overflow-wrap: anywhere;
  min-width: 0;
  color: var(--color-ink);
}

/* Huninn has one weight; never let the browser fake a bold one. Quicksand's Latin is set to match it. */
:where(h1, h2, h3, h4):where(:lang(zh)) {
  font-family: var(--font-display-zh);
  font-weight: 400;
  font-variation-settings: "wght" 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

:where(h1, h2, h3, h4):where(:lang(en)) {
  font-family: var(--font-display-en);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

/* The other languages (owner, 2026-10-02). zh-HK takes every zh rule. Japanese and Korean are set like Chinese
   (roomy lines, headings in their rounded faces); Thai gets tall lines for the marks that stack above and below
   its letters; Vietnamese is set like English, with a little more room for its marks. */
html:is(:lang(ja), :lang(ko)) body {
  line-height: 1.75;
  text-autospace: normal;
}

html:lang(ja) body {
  line-break: strict;
}

html:lang(th) body {
  line-height: 1.8;
}

html:lang(vi) body {
  line-height: 1.65;
}

/* Japanese headings break between phrases (文節), never inside one (Chrome's auto-phrase). */
:where(h1, h2, h3, h4):where(:lang(ja)) {
  font-family: var(--font-display-ja);
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: 0.02em;
  word-break: auto-phrase;
}

/* Jua has one weight, like Huninn: no faux bold, Quicksand's Latin brought up to match. */
:where(h1, h2, h3, h4):where(:lang(ko)) {
  font-family: var(--font-display-ko);
  font-weight: 400;
  font-variation-settings: "wght" 600;
  line-height: 1.3;
  word-break: keep-all;
}

:where(h1, h2, h3, h4):where(:lang(th)) {
  font-family: var(--font-display-th);
  font-weight: 500;
  line-height: 1.42;
}

:where(h1, h2, h3, h4):where(:lang(vi)) {
  font-family: var(--font-display-vi);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

:where(h5, h6) {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.4;
}

:where(p, li, dd, figcaption) {
  text-wrap: pretty;
}

/* Scale helpers; parts may use their own classes instead */
.t-display {
  font-size: var(--text-display);
}

.t-section {
  font-size: var(--text-3xl);
}

.t-sub {
  font-size: var(--text-xl);
}

.t-lede {
  font-size: var(--text-md);
  color: var(--color-ink-2);
}

.t-caption {
  font-size: var(--text-sm);
  color: var(--color-caption);
}

.t-mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  letter-spacing: 0;
}

.measure {
  max-width: var(--measure-zh);
}

.measure:is(:lang(en), :lang(vi), :lang(th)) {
  max-width: var(--measure-en);
}

/* The word MOQI, in the logo's typeface (owner, 2026-10-02): Google Sans Flex tracked -1px, 700 in text and
   900 in headings and display lines. build.mjs wraps it in page text; keyboard.js and site.js in the text
   they write. It keeps its colour (ink, or the gradient inside .hl). */
.moqi-word {
  font-family: var(--font-moqi);
  font-weight: 700;
  font-variation-settings: normal; /* not the "wght" 600 a Chinese heading sets for Quicksand */
  letter-spacing: -1px;
}

:is(h1, h2, h3, h4, .site-foot__statement, .typing__prompt) .moqi-word {
  font-weight: 900;
}

/* The gradient highlight: <em class="hl">…</em> (SPEC §6). Deep stops, AA on white. */
.hl {
  font-style: normal;
  color: var(--color-ink);
}

@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .hl {
    background-image: var(--grad-moqi-text);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  .hl::selection {
    color: var(--color-ink);
    -webkit-text-fill-color: var(--color-ink);
  }
}

@media (forced-colors: active) {
  .hl {
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
}

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.nowrap {
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: var(--z-toast);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-pill);
  background: var(--color-ink);
  color: var(--color-paper);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(calc(-100% - 2 * var(--space-xs)));
}

.skip-link:focus-visible {
  transform: none;
}

/* ---------- Focus: instant, never animated ---------- */

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- Layout shells ---------- */

.wrap {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--page-gutter));
  margin-inline: auto;
  padding-inline: max(var(--page-gutter), env(safe-area-inset-left)) max(var(--page-gutter), env(safe-area-inset-right));
}

.wrap--narrow {
  max-width: calc(48rem + 2 * var(--page-gutter));
}

/* Paper bands only; there are no dark sections (SPEC §1.1). Padding varies on purpose. */
.section {
  position: relative;
  padding-block: var(--section-pad-top, var(--section-pad)) var(--section-pad-bottom, var(--section-pad));
  --section-pad: var(--space-2xl);
}

@media (min-width: 60rem) {
  .section {
    --section-pad: var(--space-3xl);
  }
}

.section--tight {
  --section-pad: var(--space-xl);
}

@media (min-width: 60rem) {
  .section--tight {
    --section-pad: var(--space-2xl);
  }

  .section--roomy {
    --section-pad: var(--space-4xl);
  }
}

.section--paper {
  background: var(--color-paper);
  color: var(--color-ink);
}

/* Muted grey drops below AA on paper-2, so captions there use ink-2 */
.section--paper-2 {
  background: var(--color-paper-2);
  color: var(--color-ink);
  --color-caption: var(--color-ink-2);
}

.section--hairline {
  border-top: var(--rule-hair) solid var(--color-rule);
}

/* ---------- Buttons ---------- */

.btn {
  --btn-h: 48px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: var(--btn-h);
  padding: 0 1.4em;
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Only transform and opacity move (SPEC §5); colour and shadow change at once */
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-out);
}

.btn:is(:lang(zh), :lang(ja)) {
  letter-spacing: 0.04em;
}

.btn--sm {
  --btn-h: 40px;
  padding: 0 1.15em;
  font-size: var(--text-sm);
}

/* Keep 44px of touch target around the smaller button */
.btn--sm::before {
  content: "";
  position: absolute;
  inset: -4px -2px;
}

/* Primary: cyan fill, dark ink on it (never white). Not used on the pages any more (every CTA is .btn--3d,
   below); kept for anything that needs a flat one. */
.btn--primary {
  background-color: var(--color-cyan);
  color: var(--color-on-brand);
  box-shadow: var(--shadow-soft);
}

/* Hover only deepens the fill; the press below does the moving */
@media (hover: hover) {
  .btn--primary:hover {
    background-color: color-mix(in oklch, var(--color-cyan) 90%, var(--color-on-brand));
  }
}

.btn--primary:active {
  background-color: color-mix(in oklch, var(--color-cyan) 82%, var(--color-on-brand));
  box-shadow: var(--shadow-soft);
  transform: scale(0.965);
  transition-duration: 90ms;
}

/* Glassy 3D (owner, 2026-10-02; the nav's 搶先試用, then every solid CTA on the site: the hero's, the join
   section's, the 404's; "圓圓的 3D", then "淺淺的就好"): a gently rounded capsule of cyan glass. The
   roundness is light and shade, never a colour gradient: a thin rounded band of white gloss along the top
   (.btn__gloss), a faint bounce of light along the bottom (white light play, like the rest of the glass),
   soft deeper cyan where the sides and underside curve away (inset shadows), and a soft cyan shadow. It floats up a pixel under the
   pointer and sinks in when pressed, so its shadow eases with it (the one button whose shadow moves).
   Opaque, so it needs no backdrop blur. */
.btn--3d {
  --glass-radius: var(--radius-pill);
  --glass-spec-size: 4.5rem;
  --btn-deep: color-mix(in oklch, var(--color-cyan) 60%, var(--color-on-brand));
  color: var(--color-on-brand);
  transition:
    translate 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    transform var(--dur) var(--ease-out),
    --glass-spec 240ms var(--ease-out),
    --gx 520ms var(--ease-out),
    --gy 520ms var(--ease-out);
}

.btn--3d.glass {
  background:
    /* the pointer light, as glass.css draws it */
    radial-gradient(
      circle var(--glass-spec-size) at var(--gx, 26%) var(--gy, 0%),
      oklch(var(--glass-light) / var(--glass-spec, .32)),
      oklch(var(--glass-light) / calc(var(--glass-spec, .32) * .35)) 38%,
      oklch(var(--glass-light) / 0) 72%
    ),
    /* light bouncing back up along the bottom */
    radial-gradient(
      ellipse 70% 40% at 50% 104%,
      oklch(var(--glass-light) / 0.26),
      oklch(var(--glass-light) / 0) 72%
    ),
    var(--color-cyan);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow:
    inset 0 1px 1px -0.5px oklch(100% 0 0 / 0.9),
    inset 0 -4px 7px -5px color-mix(in oklch, var(--btn-deep) 75%, transparent),
    inset 6px 0 8px -8px color-mix(in oklch, var(--btn-deep) 60%, transparent),
    inset -6px 0 8px -8px color-mix(in oklch, var(--btn-deep) 60%, transparent),
    0 0 0 1px color-mix(in oklch, var(--btn-deep) 22%, transparent),
    0 1px 2px color-mix(in oklch, var(--btn-deep) 22%, transparent),
    0 6px 14px -7px color-mix(in oklch, var(--btn-deep) 55%, transparent);
}

/* The gloss: a thin rounded band of window light along the top, fading as the dome turns away; under the
   label (z-index -1 inside the glass's own stacking context). Shallow on purpose (owner: 淺淺的就好). */
.btn__gloss {
  position: absolute;
  inset: 2px 12% 56%;
  z-index: -1;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, oklch(100% 0 0 / 0.5), oklch(100% 0 0 / 0));
  pointer-events: none;
  transition: opacity 180ms var(--ease-out);
}

.btn--3d:active .btn__gloss,
.btn--3d.is-pressed .btn__gloss {
  opacity: 0.6;
}

@media (hover: hover) {
  .btn--3d:hover {
    translate: 0 -1px;
  }

  .btn--3d.glass:hover {
    box-shadow:
      inset 0 1px 1px -0.5px oklch(100% 0 0 / 0.9),
      inset 0 -4px 7px -5px color-mix(in oklch, var(--btn-deep) 75%, transparent),
      inset 6px 0 8px -8px color-mix(in oklch, var(--btn-deep) 60%, transparent),
      inset -6px 0 8px -8px color-mix(in oklch, var(--btn-deep) 60%, transparent),
      0 0 0 1px color-mix(in oklch, var(--btn-deep) 22%, transparent),
      0 2px 4px color-mix(in oklch, var(--btn-deep) 22%, transparent),
      0 9px 18px -8px color-mix(in oklch, var(--btn-deep) 60%, transparent);
  }
}

/* Pressed: it sinks in a little (glass.js squeezes it too) and the shadow tucks under */
.btn--3d:active,
.btn--3d.is-pressed {
  translate: 0 1px;
  transition-duration: 80ms;
}

.btn--3d.glass:active,
.btn--3d.glass.is-pressed {
  box-shadow:
    inset 0 1px 1px -0.5px oklch(100% 0 0 / 0.75),
    inset 0 2px 5px -3px color-mix(in oklch, var(--btn-deep) 55%, transparent),
    inset 0 -3px 6px -5px color-mix(in oklch, var(--btn-deep) 70%, transparent),
    0 0 0 1px color-mix(in oklch, var(--btn-deep) 26%, transparent),
    0 1px 2px color-mix(in oklch, var(--btn-deep) 26%, transparent),
    0 3px 8px -5px color-mix(in oklch, var(--btn-deep) 50%, transparent);
}

/* Secondary: an ink text link whose underline redraws itself on hover */
.btn--secondary {
  --btn-h: 44px;
  padding: 0 0.15em;
  background: none;
  color: var(--color-ink);
  font-weight: 600;
}

.btn--secondary::after {
  content: "";
  position: absolute;
  left: 0.15em;
  right: 0.15em;
  bottom: calc(50% - 0.95em);
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
  transform-origin: left center;
}

@media (hover: hover) {
  .btn--secondary:hover::after {
    animation: underline-redraw 560ms var(--ease-out);
  }
}

.btn--secondary:active {
  transform: translateY(1px);
  transition-duration: 80ms;
}

@keyframes underline-redraw {
  0% {
    transform: scaleX(1);
    transform-origin: right center;
  }
  38% {
    transform: scaleX(0);
    transform-origin: right center;
  }
  39% {
    transform: scaleX(0);
    transform-origin: left center;
  }
  100% {
    transform: scaleX(1);
    transform-origin: left center;
  }
}

/* Disabled (also for links: aria-disabled) */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  pointer-events: none;
}

/* Loading: the label stays; three dots light up in turn, like MOQI's working label */
.btn[aria-busy="true"] {
  cursor: progress;
}

.btn[aria-busy="true"]::after {
  content: "\2022\2009\2022\2009\2022";
  font-size: 0.8em;
  letter-spacing: 0;
  animation: btn-working 1.1s var(--ease-in-out) infinite;
}

@keyframes btn-working {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Error and done: a glyph and an ink ring, never colour alone */
.btn[data-state="error"] {
  box-shadow: 0 0 0 2px var(--color-ink);
}

.btn[data-state="error"]::before,
.btn[data-state="done"]::before {
  position: static;
  inset: auto;
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1;
}

.btn[data-state="error"]::before {
  content: "!";
}

.btn[data-state="done"]::before {
  content: "\2713";
}

/* ---------- Nav: N5 floating pill of liquid glass ---------- */

/* Narrow screens: the logo on the left, a glass disc with the menu button on the right. Wide screens: the logo
   and the pill side by side, centred together. */
.site-nav {
  position: fixed;
  inset: var(--space-xs) 0 auto;
  z-index: var(--z-nav);
  display: flex;
  justify-content: space-between;
  padding-inline: max(var(--space-sm), env(safe-area-inset-left)) max(var(--space-sm), env(safe-area-inset-right));
  pointer-events: none;
}

@media (min-width: 50rem) {
  .site-nav {
    inset-block-start: var(--space-sm);
    justify-content: center;
  }
}

/* The material is glass.css (.glass .glass--lens .glass--pressable); this only shapes the pill. */
.site-nav__pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  min-height: 56px;
  max-width: 100%;
  padding: 6px;
  border-radius: var(--radius-pill);
  --glass-radius: var(--radius-pill);
}

/* Page text scrolls under the nav. Clear glass with only a touch of frost, so what is behind shows and bends
   along the rim (a wide bezel, a full pull); Safari, which cannot refract, gets the frosted, saturated version.
   Two classes, so these knobs win over glass.css's .glass--lens defaults. */
.site-nav__pill.glass {
  --glass-tint: var(--glass-fill-nav);
  --glass-lens-blur: 2px;
  --glass-refract: 1;
  --glass-bezel: 24px;
  --glass-magnify: 1.05;
  --glass-sheen: .3;
}

/* With so little fill, dark text passing under the pill could crowd the labels: a white halo round each
   letter keeps them readable (AA, SPEC §4a). It is invisible over light content. */
.site-nav__pill .site-nav__link {
  text-shadow: 0 0 .5em oklch(100% 0 0 / .95), 0 0 1em oklch(100% 0 0 / .8);
}

/* Outside the pill (owner, 2026-10-02). The y of "key" hangs well below MOQi: the negative bottom margin
   makes the header's stretch centre MOQi on the pill instead of the whole logo. */
.site-nav__logo {
  --logo-height: 50px;
  position: relative;
  isolation: isolate;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: -20px;
  border-radius: var(--radius-key);
  color: var(--color-ink);
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out);
}

/* Once the page scrolls (site.js sets .is-scrolled), text passes under the logo: a patch of frost with no edge
   (the mask fades it out) keeps it readable. None at the top, over the hero silk. */
.site-nav__logo::before {
  content: "";
  position: absolute;
  inset: -12px -26px -4px -22px;
  z-index: -1;
  border-radius: 50%;
  background: oklch(99.3% 0.003 205 / 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask: radial-gradient(closest-side, #000 50%, transparent);
  mask: radial-gradient(closest-side, #000 50%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-out);
}

.site-nav.is-scrolled .site-nav__logo::before {
  opacity: 1;
}

.site-nav__logo:active {
  transform: scale(0.96);
  transition-duration: 90ms;
}

.site-nav__links {
  display: none;
  align-items: center;
  gap: var(--space-3xs);
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out);
}

.site-nav__link:is(:lang(zh), :lang(ja)) {
  letter-spacing: 0.06em;
}

@media (hover: hover) {
  .site-nav__link:hover {
    background-color: color-mix(in oklch, var(--color-ink) 6%, transparent);
  }
}

.site-nav__link:active {
  background-color: color-mix(in oklch, var(--color-ink) 11%, transparent);
  transform: scale(0.96);
  transition-duration: 90ms;
}

/* Current page: a short ink bar under the label */
.site-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 8px;
  width: 14px;
  height: 2px;
  margin-inline: auto;
  border-radius: 1px;
  background: var(--color-ink);
}

.site-nav__link[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* Language menu (owner, 2026-10-02): a capsule with the globe, the language you are reading and a chevron.
   It drops down a glass list of every language, each name in its own script (site.js places it). */
.lang-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 40px;
  padding: 0 13px 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: oklch(100% 0 0 / 0.55);
  box-shadow:
    inset 0 1px 0 oklch(100% 0 0 / 0.95),
    0 0 0 1px var(--glass-hairline),
    0 1px 3px oklch(27.54% 0.0114 225.53 / 0.07);
  color: var(--color-ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out);
}

/* 44px of touch target round the 40px capsule */
.lang-menu::before {
  content: "";
  position: absolute;
  inset: -2px;
}

.lang-menu__ico {
  inline-size: 1em;
  font-size: 1.05em;
}

.lang-menu__chev {
  inline-size: 1em;
  font-size: 0.68em;
  transition: transform 360ms var(--ease-out);
}

.lang-menu.is-open .lang-menu__chev {
  transform: rotate(-180deg);
}

@media (hover: hover) {
  .lang-menu:hover {
    background: oklch(100% 0 0 / 0.85);
  }
}

.lang-menu:active {
  background: oklch(100% 0 0 / 0.95);
  transform: scale(0.96);
  transition-duration: 90ms;
}

.lang-menu.is-open {
  background: oklch(100% 0 0 / 0.95);
}

/* The list: a glass panel in the top layer (a popover), so nothing clips it and its glass sees the page.
   site.js sets top/right (under the nav capsule) or bottom/left (over the footer one) and the point it grows
   from; it opens like the menu sheet, as a droplet. */
.lang-menu__list[popover] {
  pointer-events: auto;
  position: fixed;
  inset: auto;
  min-width: 13.5rem;
  max-height: calc(100dvh - 96px);
  margin: 0;
  padding: 6px;
  overflow: auto;
  border: 0;
  --glass-radius: 22px;
  border-radius: 22px;
  color: var(--color-ink);
  transform-origin: var(--lang-origin, calc(100% - 3rem) -10px);
  opacity: 0;
  transform: scale(0.6, 0.4);
  transition:
    opacity 150ms var(--ease-in),
    transform 190ms var(--ease-in),
    overlay 190ms allow-discrete,
    display 190ms allow-discrete;
}

.lang-menu__list[popover]:popover-open {
  opacity: 1;
  transform: none;
  animation: droplet 560ms var(--ease-out) both;
}

.lang-menu__items {
  display: grid;
  gap: 2px;
}

.lang-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: 0 14px;
  border-radius: 16px;
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out);
}

@media (hover: hover) {
  .lang-menu__item:hover {
    background-color: color-mix(in oklch, var(--color-ink) 6%, transparent);
  }
}

.lang-menu__item:active {
  background-color: color-mix(in oklch, var(--color-ink) 11%, transparent);
  transform: scale(0.98);
  transition-duration: 90ms;
}

.lang-menu__item[aria-current] {
  font-weight: 650;
}

.lang-menu__check {
  inline-size: 1em;
  margin-inline-start: auto;
  font-size: 0.85em;
}

/* The names follow the drop in, one after another */
.lang-menu__list:popover-open .lang-menu__items > li {
  animation: sheet-item 420ms var(--ease-out) backwards;
}

.lang-menu__list:popover-open .lang-menu__items > li:nth-child(1) { animation-delay: 60ms; }
.lang-menu__list:popover-open .lang-menu__items > li:nth-child(2) { animation-delay: 90ms; }
.lang-menu__list:popover-open .lang-menu__items > li:nth-child(3) { animation-delay: 120ms; }
.lang-menu__list:popover-open .lang-menu__items > li:nth-child(4) { animation-delay: 150ms; }
.lang-menu__list:popover-open .lang-menu__items > li:nth-child(5) { animation-delay: 180ms; }
.lang-menu__list:popover-open .lang-menu__items > li:nth-child(6) { animation-delay: 210ms; }
.lang-menu__list:popover-open .lang-menu__items > li:nth-child(7) { animation-delay: 240ms; }

.lang-menu__list--up:popover-open .lang-menu__items > li {
  animation-name: sheet-item-up;
}

@keyframes sheet-item-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.site-nav__lang {
  display: none;
}

.site-nav__cta {
  display: none;
  margin-inline-start: var(--space-3xs);
}

/* Menu button: two bars that turn into a cross while the sheet is open */
.site-nav__menu {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-inline-start: auto;
  border-radius: 50%;
  color: var(--color-ink);
  transition: transform var(--dur) var(--ease-out);
}

@media (hover: hover) {
  .site-nav__menu:hover {
    background-color: color-mix(in oklch, var(--color-ink) 6%, transparent);
  }
}

.site-nav__menu:active {
  background-color: color-mix(in oklch, var(--color-ink) 11%, transparent);
  transform: scale(0.92);
  transition-duration: 90ms;
}

.site-nav__menu:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.site-nav__menu-icon {
  position: relative;
  width: 18px;
  height: 10px;
}

.site-nav__menu-icon > span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition: transform 420ms var(--ease-out);
}

.site-nav__menu-icon > span:first-child {
  top: 0;
}

.site-nav__menu-icon > span:last-child {
  bottom: 0;
  transform: translateX(-2.7px) scaleX(0.7);
}

.site-nav:has(.nav-sheet:popover-open) .site-nav__menu {
  background-color: color-mix(in oklch, var(--color-ink) 8%, transparent);
}

.site-nav:has(.nav-sheet:popover-open) .site-nav__menu-icon > span:first-child {
  transform: translateY(4px) rotate(45deg);
}

.site-nav:has(.nav-sheet:popover-open) .site-nav__menu-icon > span:last-child {
  transform: translateY(-4px) rotate(-45deg);
}

/* Without the Popover API the sheet cannot open; the footer carries every link instead. */
@supports not selector(:popover-open) {
  .site-nav__menu {
    display: none;
  }
}

@media (min-width: 50rem) {
  .site-nav__pill {
    padding: var(--space-3xs) var(--space-2xs) var(--space-3xs) var(--space-md);
  }

  .site-nav__logo {
    margin-inline-end: var(--space-sm);
  }

  .site-nav__links,
  .site-nav__lang,
  .site-nav__cta {
    display: inline-flex;
  }

  .site-nav__lang {
    margin-inline-start: var(--space-3xs);
  }

  .site-nav__menu {
    display: none;
  }
}

/* Between tablet and laptop widths the longer languages (Thai, Vietnamese) would push the pill off screen: the
   language capsule keeps only its globe and chevron, and the links sit a little closer. */
@media (min-width: 50rem) and (max-width: 66rem) {
  .site-nav__lang .lang-menu__cur {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .site-nav__lang {
    padding-inline: 11px;
  }

  .site-nav__link {
    padding-inline: 9px;
  }
}

/* The menu sheet: a glass panel that grows out of the menu button like a droplet.
   It sits inside .site-nav, which lets clicks through (pointer-events: none), so it takes them back. */
.nav-sheet[popover] {
  pointer-events: auto;
  position: fixed;
  inset: calc(var(--space-xs) + 64px) 0 auto;
  width: min(22rem, calc(100% - 2 * var(--space-sm)));
  max-height: calc(100dvh - 96px);
  margin: 0 auto;
  padding: var(--space-2xs);
  overflow: auto;
  border: 0;
  border-radius: var(--radius-card);
  color: var(--color-ink);
  /* grows from the menu button, whose centre is 44px in from the right edge of the screen (16px padding +
     half the 56px disc); 50% + 50vw - 44px is that point measured from the centred sheet's left edge */
  transform-origin: calc(50% + 50vw - 44px) -28px;
  opacity: 0;
  transform: scale(0.5, 0.36);
  transition:
    opacity 170ms var(--ease-in),
    transform 210ms var(--ease-in),
    overlay 210ms allow-discrete,
    display 210ms allow-discrete;
}

.nav-sheet[popover]:popover-open {
  opacity: 1;
  transform: none;
  animation: droplet 640ms var(--ease-out) both;
}

.nav-sheet[popover]::backdrop {
  background: color-mix(in oklch, var(--color-ink) 10%, transparent);
  opacity: 0;
  transition:
    opacity 200ms var(--ease-in),
    overlay 200ms allow-discrete,
    display 200ms allow-discrete;
}

.nav-sheet[popover]:popover-open::backdrop {
  opacity: 1;
}

@starting-style {
  .nav-sheet[popover]:popover-open::backdrop {
    opacity: 0;
  }
}

/* A drop leaves the button, stretches as it falls, then settles with a small wobble */
@keyframes droplet {
  0% {
    opacity: 0;
    transform: scale(0.16, 0.08);
  }
  18% {
    opacity: 1;
  }
  42% {
    transform: scale(0.94, 1.05);
  }
  68% {
    transform: scale(1.015, 0.985);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

.nav-sheet__links {
  display: grid;
  gap: var(--space-3xs);
}

.nav-sheet__link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 var(--space-sm);
  border-radius: 18px;
  color: var(--color-ink);
  font-size: var(--text-md);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out);
}

.nav-sheet__link:lang(zh) {
  font-family: var(--font-display-zh);
  font-weight: 400;
  letter-spacing: 0.04em;
}

.nav-sheet__link:lang(ja) {
  font-family: var(--font-display-ja);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.nav-sheet__link:lang(ko) {
  font-family: var(--font-display-ko);
  font-weight: 400;
}

.nav-sheet__link:lang(th) {
  font-family: var(--font-display-th);
  font-weight: 400;
}

@media (hover: hover) {
  .nav-sheet__link:hover {
    background-color: color-mix(in oklch, var(--color-ink) 6%, transparent);
  }
}

.nav-sheet__link:active {
  background-color: color-mix(in oklch, var(--color-ink) 11%, transparent);
  transform: scale(0.98);
  transition-duration: 90ms;
}

.nav-sheet__link[aria-current="page"]::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-inline-start: auto;
  border-radius: 50%;
  background: var(--color-ink);
}

/* Items follow the drop in, not all at once */
.nav-sheet:popover-open .nav-sheet__links > li,
.nav-sheet:popover-open .nav-sheet__langs,
.nav-sheet:popover-open .nav-sheet__foot {
  animation: sheet-item 460ms var(--ease-out) backwards;
}

.nav-sheet:popover-open .nav-sheet__links > li:nth-child(1) { animation-delay: 70ms; }
.nav-sheet:popover-open .nav-sheet__links > li:nth-child(2) { animation-delay: 120ms; }
.nav-sheet:popover-open .nav-sheet__links > li:nth-child(3) { animation-delay: 185ms; }
.nav-sheet:popover-open .nav-sheet__links > li:nth-child(4) { animation-delay: 230ms; }
.nav-sheet:popover-open .nav-sheet__langs { animation-delay: 270ms; }
.nav-sheet:popover-open .nav-sheet__foot { animation-delay: 320ms; }

@keyframes sheet-item {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Every language as a chip, each name in its own script; the one you are reading is outlined and ticked */
.nav-sheet__langs {
  margin-top: var(--space-2xs);
  padding: var(--space-xs) var(--space-3xs) 0;
  border-top: var(--rule-hair) solid var(--glass-hairline);
}

.nav-sheet__label {
  display: flex;
  align-items: center;
  gap: 0.45em;
  margin: 0 0 var(--space-2xs);
  padding-inline: var(--space-2xs);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.nav-sheet__label .lang-menu__ico {
  font-size: 1.1em;
}

.lang-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lang-list__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: oklch(100% 0 0 / 0.55);
  box-shadow:
    inset 0 1px 0 oklch(100% 0 0 / 0.95),
    0 0 0 1px var(--glass-hairline);
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out);
}

.lang-list__item:active {
  background: oklch(100% 0 0 / 0.95);
  transform: scale(0.96);
  transition-duration: 90ms;
}

.lang-list__item[aria-current] {
  box-shadow:
    inset 0 1px 0 oklch(100% 0 0 / 0.95),
    0 0 0 1.5px var(--color-ink);
  font-weight: 650;
}

.lang-list__item .lang-menu__check {
  margin-inline-start: 0;
  font-size: 0.8em;
}

.nav-sheet__foot {
  display: flex;
  margin-top: var(--space-xs);
  padding: var(--space-2xs) var(--space-3xs) var(--space-3xs);
}

.nav-sheet__cta {
  flex: 1;
}

/* For keyboard and screen reader users; the cross on the menu button does the same for pointers */
.nav-sheet__close:not(:focus-visible) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.nav-sheet__close:focus-visible {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: var(--space-3xs);
  border-radius: 18px;
  font-size: var(--text-sm);
  font-weight: 600;
}

@media (min-width: 50rem) {
  .nav-sheet[popover] {
    display: none;
  }
}

/* ---------- Footer: Ft5 statement on paper ---------- */

.site-foot {
  flex-shrink: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  padding-block: var(--space-2xl) var(--space-lg);
}

@media (min-width: 60rem) {
  .site-foot {
    padding-block: var(--space-3xl) var(--space-xl);
  }
}

.site-foot__inner {
  display: grid;
  gap: var(--space-lg);
}

.site-foot__statement {
  max-width: 13em;
  font-size: clamp(2rem, 1.1rem + 4vw, 4rem);
  overflow-wrap: anywhere;
  min-width: 0;
  text-wrap: balance;
}

.site-foot__statement:lang(zh) {
  font-family: var(--font-display-zh);
  font-weight: 400;
  font-variation-settings: "wght" 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
  word-break: keep-all; /* break at the comma, never inside 先問問 */
}

.site-foot__statement:lang(en) {
  max-width: 16em;
  font-family: var(--font-display-en);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.01em;
}

.site-foot__statement:lang(ja) {
  font-family: var(--font-display-ja);
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: 0.02em;
  word-break: auto-phrase;
}

.site-foot__statement:lang(ko) {
  font-family: var(--font-display-ko);
  font-weight: 400;
  font-variation-settings: "wght" 600;
  line-height: 1.3;
  word-break: keep-all;
}

.site-foot__statement:lang(th) {
  max-width: 15em;
  font-family: var(--font-display-th);
  font-weight: 500;
  line-height: 1.42;
}

.site-foot__statement:lang(vi) {
  max-width: 16em;
  font-family: var(--font-display-vi);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.01em;
}

.site-foot__logo {
  --logo-height: 48px;
  display: inline-flex;
  justify-self: start;
  min-height: 44px;
  align-items: center;
  border-radius: var(--radius-key);
  text-decoration: none;
  transition: transform var(--dur) var(--ease-out);
}

.site-foot__logo:active {
  transform: scale(0.97);
  transition-duration: 90ms;
}

.site-foot__meta {
  display: grid;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: var(--rule-hair) solid var(--color-rule);
  font-size: var(--text-sm);
}

.site-foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-md);
}

.site-foot__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--color-ink);
  white-space: nowrap;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in oklch, var(--color-ink) 35%, transparent);
  text-underline-offset: 0.3em;
  transition: transform var(--dur) var(--ease-out);
}

@media (hover: hover) {
  .site-foot__link:hover {
    text-decoration-thickness: 2px;
    text-decoration-color: currentColor;
  }
}

.site-foot__link:active {
  transform: translateY(1px);
  transition-duration: 80ms;
}

.site-foot__link[aria-current="page"] {
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
  font-weight: 600;
}

.site-foot__small {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-md);
  color: var(--color-caption);
}

.site-foot__small .site-foot__link {
  color: var(--color-ink);
}

.site-foot__lang {
  justify-self: start;
}

@media (min-width: 60rem) {
  .site-foot__meta {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-lg);
  }

}

/* ---------- Typed headings ([data-type]; typist.js, SPEC §5a) ---------- */
/* Until typist.js takes a heading over (.tw-on) it is held back for a moment, so a heading on screen at load
   does not show, vanish and then type. Without JS it simply appears 1.2 s late. */
[data-type]:not(.tw-on) {
  animation: tw-hold 1ms 1.2s backwards;
}

@keyframes tw-hold {
  from { visibility: hidden; }
}

.tw-on {
  position: relative;
}

.tw-rest {
  visibility: hidden;
}

/* The composition: what is typed but not yet committed, underlined as in the app's editor. Inside the
   gradient highlight the text itself is transparent, so the line gets its own colour. */
.tw-buf,
.tw-raw {
  text-decoration-line: underline;
  text-decoration-color: color-mix(in oklch, var(--color-ink) 42%, transparent);
  text-decoration-thickness: max(1.5px, .045em);
  text-underline-offset: .2em;
  text-decoration-skip-ink: none;
}

/* Keys not yet turned into a character (Zhuyin), at the insertion point; a slip is plain typed text. */
.tw-raw {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  color: var(--color-ink-2);
  white-space: pre;
  pointer-events: none;
}

.tw-raw:lang(zh) {
  font-family: var(--font-zhuyin);
  font-variation-settings: normal;
}

.tw-raw.is-slip {
  color: inherit;
  text-decoration-line: none;
}

.tw-at {
  display: inline;
}

/* The caret of the app's input bar (TypingBubble / InputBar): steady while keys land, blinking between. */
.tw-caret {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  inline-size: max(2px, .055em);
  block-size: 1em;
  border-radius: 1px;
  background: var(--color-cyan-ink);
  pointer-events: none;
  opacity: 0;
}

.tw-on.is-armed .tw-caret {
  opacity: 1;
  animation: tw-blink 530ms cubic-bezier(.4, 0, .2, 1) infinite alternate;
}

.tw-on.is-keying .tw-caret {
  animation: none;
}

.tw-on.is-done .tw-caret {
  opacity: 0;
  animation: none;
  transition: opacity 240ms var(--ease-out);
}

@keyframes tw-blink {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ---------- Reveal on enter ([data-reveal]; site.js adds .js to <html> and .is-in to each) ---------- */
/* Visible without JS. The animation only runs "from", so the element's own transform and transitions
   take over again once it has played. data-reveal: "up" (default) | "grow" | "fade" | "left" | "right". */

.js [data-reveal]:not(.is-in) {
  opacity: 0;
}

.js [data-reveal].is-in {
  animation: reveal-up 820ms var(--ease-out) var(--reveal-delay, 0ms) backwards;
}

.js [data-reveal="grow"].is-in {
  animation-name: reveal-grow;
  animation-duration: 900ms;
}

.js [data-reveal="fade"].is-in {
  animation-name: reveal-fade;
  animation-duration: 700ms;
}

.js [data-reveal="left"].is-in {
  animation-name: reveal-left;
}

.js [data-reveal="right"].is-in {
  animation-name: reveal-right;
}

/* Hand-tuned, uneven steps */
[data-reveal-delay="1"] { --reveal-delay: 70ms; }
[data-reveal-delay="2"] { --reveal-delay: 160ms; }
[data-reveal-delay="3"] { --reveal-delay: 230ms; }
[data-reveal-delay="4"] { --reveal-delay: 340ms; }
[data-reveal-delay="5"] { --reveal-delay: 420ms; }
[data-reveal-delay="6"] { --reveal-delay: 550ms; }

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
}

@keyframes reveal-grow {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
}

@keyframes reveal-fade {
  from {
    opacity: 0;
  }
}

@keyframes reveal-left {
  from {
    opacity: 0;
    transform: translateX(-32px);
  }
}

@keyframes reveal-right {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
}

@media print {
  .js [data-reveal] {
    opacity: 1 !important;
    animation: none !important;
  }

  .site-nav,
  .skip-link {
    display: none;
  }
}

/* ---------- Hero silk (silk.js draws over this; without WebGL this still frame stays) ---------- */
/* Put <canvas class="silk" data-silk aria-hidden="true"> inside the hero; it fills the hero behind its content. */

:where(:has(> .silk)) {
  position: relative;
  isolation: isolate;
}

.silk {
  --silk-stops:
    var(--silk-1) 13%,
    var(--silk-2) 31%,
    color-mix(in srgb, var(--silk-1), var(--silk-2) 30%) 42%,
    var(--silk-3) 62%,
    color-mix(in srgb, var(--silk-1), var(--silk-3) 45%) 76%,
    color-mix(in srgb, var(--silk-2), var(--silk-3) 50%) 100%;
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  background-color: var(--silk-1);
  background-image: linear-gradient(128deg, var(--silk-stops));
  pointer-events: none;
}

@media (min-width: 40rem) {
  .silk {
    background-image: linear-gradient(158deg, var(--silk-stops));
  }
}

/* ---------- 404 ---------- */

.lost {
  display: grid;
  align-items: center;
  gap: var(--space-xl);
  padding-block: calc(96px + var(--space-xl)) var(--space-2xl);
}

.lost__title {
  font-size: var(--text-3xl);
}

.lost__body {
  max-width: 26em;
  margin-top: var(--space-sm);
  color: var(--color-ink-2);
  font-size: var(--text-md);
}

.lost__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-lg);
  margin-top: var(--space-lg);
}

.lost__moqi {
  justify-self: start;
  width: min(44vw, 200px);
  transform: rotate(-8deg);
}

.lost__moqi img {
  width: 100%;
  height: auto;
}

@media (min-width: 48rem) {
  .lost {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    min-height: 70dvh;
    padding-block: calc(96px + var(--space-2xl)) var(--space-3xl);
  }

  .lost__moqi {
    order: 2;
    justify-self: center;
    width: min(28vw, 300px);
  }
}

