/* =========================================================
   Portal 2.0 · base: reset, type, focus, motion
   Reads tokens.css. No colour values here (the guard checks).

   SCOPE. Everything is inside `.z`: the body of a page built on
   v2, or the root of a v2 region (the shell, a migrated page's
   v2 surface). Nothing here reaches legacy markup, and without
   :root[data-v2] the tokens it reads do not exist.

   css/system owns its reset and base values; nothing below leans
   on legacy portal.css.
   ========================================================= */

/* ── reset ── */
.z, .z *, .z *::before, .z *::after { box-sizing: border-box; }
.z { margin: 0; }
.z :where(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol) { margin: 0; }
.z :where(ul, ol)[role="list"], .z :where(ul, ol).z-plain { list-style: none; padding: 0; }
.z :where(img, svg, video, canvas) { display: block; max-width: 100%; }
.z :where(button, input, select, textarea) { font: inherit; color: inherit; letter-spacing: inherit; }
.z :where(button) { cursor: pointer; }
.z :where(button:disabled) { cursor: default; }
.z :where(a) { color: inherit; }
.z :where(table) { border-collapse: collapse; }

/* ── the page ground ── */
.z {
  background: var(--z-bg);
  color: var(--z-text);
  font-family: var(--z-f-std);
  font-size: var(--z-t-body);
  line-height: 1.5;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.z { min-height: 100vh; min-height: 100dvh; }

/* ── the canvas past the page ──
   colors_and_type.css paints html with --paper, resolved on :root, and
   v2 recolours body, never html. So in dark the space past the page (an
   iPhone's rubber band, a trackpad's bounce, the space under a short page)
   stayed light. For a holder, html takes the page ground wherever the body
   does: here for a page built on v2 (body.z), in frame.css for the rest.
   A page on the shell alone keeps a light body, so its canvas stays light. */
:root[data-v2]:has(> body.z) { background: var(--z-bg); }

/* ── type: one scale, a 12px floor, lowercase headings ── */
.z .z-hero { font-family: var(--z-f-ex); font-weight: 700; font-size: var(--z-t-hero); line-height: 1.02; letter-spacing: -0.04em; }
.z .z-h1   { font-family: var(--z-f-ex); font-weight: 700; font-size: var(--z-t-h1); line-height: 1.05; letter-spacing: -0.035em; }
.z .z-h2   { font-family: var(--z-f-std); font-weight: 600; font-size: var(--z-t-h2); line-height: 1.25; letter-spacing: -0.01em; }
.z .z-h3   { font-family: var(--z-f-std); font-weight: 600; font-size: var(--z-t-h3); line-height: 1.3; }
.z .z-body { font-size: var(--z-t-body); }
.z .z-small { font-size: var(--z-t-small); color: var(--z-text-2); }
.z .z-muted { color: var(--z-text-3); }
.z .z-label { font-family: var(--z-f-cd); font-weight: 600; font-size: var(--z-t-label); letter-spacing: 0.03em; color: var(--z-text-3); }
.z .z-type  { font-family: var(--z-f-cd); font-weight: 600; font-size: var(--z-t-label); letter-spacing: 0.03em; color: var(--z-text-3); }
.z .z-id    { font-family: var(--z-f-cd); font-weight: 600; font-size: var(--z-t-label); letter-spacing: 0.05em; color: var(--z-text-2); font-variant-numeric: tabular-nums; }
.z .z-fig   { font-family: var(--z-f-ex); font-weight: 700; font-size: var(--z-t-fig); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.z .z-num   { font-variant-numeric: tabular-nums; }
.z .z-accent-text { color: var(--z-accent-text); }
.z .z-count { font-family: var(--z-f-cd); font-weight: 600; font-size: var(--z-t-label); letter-spacing: 0.03em; color: var(--z-text-3); font-variant-numeric: tabular-nums; }
.z kbd, .z .z-kbd {
  font-family: var(--z-f-cd); font-weight: 600; font-size: var(--z-t-label);
  min-width: 20px; height: 20px; padding: 0 5px; display: inline-grid; place-items: center;
  border: 1px solid var(--z-line-2); border-bottom-width: 2px; border-radius: 3px;
  color: var(--z-text-2); background: var(--z-bg-raised); line-height: 1;
}
.z .z-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.z .z-grow { flex: 1; }

/* ── a record named in running text ── */
.z .z-mention { color: var(--z-text); text-decoration: underline; text-decoration-color: var(--z-line-2); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.z .z-mention:hover { text-decoration-color: var(--z-text); }

/* ── focus: on every control, 3:1 against what is next to it ── */
.z :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--z-focus);
  outline-offset: 2px;
}
.z :where(a, button, input, select, textarea, summary, [tabindex]):focus:not(:focus-visible) { outline: none; }

/* ── motion: 120ms small, 200ms panels; none if asked ── */
.z :where(a, button, input, select, textarea) {
  transition: background-color var(--z-dur-small) var(--z-ease),
              border-color var(--z-dur-small) var(--z-ease),
              color var(--z-dur-small) var(--z-ease),
              box-shadow var(--z-dur-small) var(--z-ease);
}
@media (prefers-reduced-motion: reduce) {
  .z *, .z *::before, .z *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* ── the phone: 16px body, 16px inputs ── */
@media (max-width: 599px) {
  .z { font-size: 16px; }
  .z .z-body { font-size: 16px; }
  .z :where(input, select, textarea) { font-size: max(16px, 1em); }
}
