/* The MathZetta sites' shared look.
 *
 *   tokens      --mz-* colours (light and dark), fonts, radius. The chrome and body.mz use only
 *               these, so a page's own variables can't restyle them. The unprefixed names many
 *               pages already use (--fg, --bg, --accent, --muted, --line, --soft …) are aliases: a
 *               page that drops its own :root block picks up the shared palette, dark mode included.
 *   chrome      the header (.mz-top) and footer (.mz-foot) that chrome.js mounts; self-contained,
 *               and defended against a page's bare `header`/`nav`/`footer` rules.
 *   body.mz     base styles for documents (landing pages, docs, forms): type, links, buttons,
 *               inputs, tables, cards. An app page with its own UI leaves the class off and keeps
 *               only the tokens, the chrome and the focus ring.
 *
 * Responsive (nothing fixed-width; the header wraps; the family menu drops to the bottom on
 * phones) and keyboard-friendly (a visible focus ring everywhere, a skip link, reduced motion). */

:root {
    color-scheme: light dark;
    --mz-bg: #ffffff;
    --mz-fg: #1b1b1f;
    --mz-muted: #5d6270;          /* 6.4:1 on --mz-bg */
    --mz-line: #dcdfe5;
    --mz-soft: #f5f6f8;           /* panels, code, zebra rows */
    --mz-zebra: #fafbfc;
    --mz-accent: #1f5fd6;         /* links, buttons: 5.4:1 on --mz-bg, 4.6:1 on --mz-soft */
    --mz-accent-fg: #ffffff;
    --mz-accent-soft: #e8efff;
    --mz-err: #b3261e;
    --mz-ok: #1d7a43;
    --mz-warn: #8a5a00;
    --mz-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mz-mono: ui-monospace, Menlo, Consolas, monospace;
    --mz-radius: 8px;
    --mz-radius-sm: 6px;
    --mz-shadow: 0 1px 3px rgba(20, 24, 40, 0.08), 0 4px 16px rgba(20, 24, 40, 0.06);
    --mz-measure: 72ch;
    /* the names the pages use */
    --bg: var(--mz-bg); --fg: var(--mz-fg); --muted: var(--mz-muted); --line: var(--mz-line); --soft: var(--mz-soft);
    --zebra: var(--mz-zebra); --accent: var(--mz-accent); --accent-fg: var(--mz-accent-fg); --accent-soft: var(--mz-accent-soft);
    --err: var(--mz-err); --ok: var(--mz-ok); --warn: var(--mz-warn); --font: var(--mz-font); --mono: var(--mz-mono);
    --radius: var(--mz-radius); --shadow: var(--mz-shadow);
}
@media (prefers-color-scheme: dark) {
    :root {
        --mz-bg: #15161a;
        --mz-fg: #e6e6ea;
        --mz-muted: #a0a4ae;      /* 7.6:1 */
        --mz-line: #33363d;
        --mz-soft: #1e2026;
        --mz-zebra: #191a1f;
        --mz-accent: #7aa7ff;     /* 7.5:1 */
        --mz-accent-fg: #0b1a3a;
        --mz-accent-soft: #1d2a45;
        --mz-err: #ff8a7a;
        --mz-ok: #6ccf93;
        --mz-warn: #e8b85a;
        --mz-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 20px rgba(0, 0, 0, 0.35);
    }
}

/* a page whose own UI is light-only (html.mz-light) keeps the light palette, chrome included */
html.mz-light { color-scheme: light; --mz-bg: #ffffff; --mz-fg: #1b1b1f; --mz-muted: #5d6270; --mz-line: #dcdfe5; --mz-soft: #f5f6f8; --mz-zebra: #fafbfc; --mz-accent: #1f5fd6; --mz-accent-fg: #ffffff; --mz-accent-soft: #e8efff; --mz-err: #b3261e; --mz-ok: #1d7a43; --mz-warn: #8a5a00; --mz-shadow: 0 1px 3px rgba(20, 24, 40, 0.08), 0 4px 16px rgba(20, 24, 40, 0.06); }

/* ------------------------------------------------------------ everywhere */
:focus-visible { outline: 2px solid var(--mz-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
.mz-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mz-skip { position: absolute; left: 8px; top: -100px; z-index: 1000; padding: 8px 14px; background: var(--mz-accent); color: var(--mz-accent-fg); border-radius: var(--mz-radius-sm); font: 600 14px/1.2 var(--mz-font); text-decoration: none; }
.mz-skip:focus { top: 8px; }

/* the header: the site's name, its pages, and the family. Explicit position/width/margins: a
   page's own `header { position: sticky; … }` or `nav { … }` must not reach it. */
.mz-top { position: static; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 18px; max-width: none; width: auto; margin: 0; padding: 8px 16px; box-shadow: none;
    border: 0; border-bottom: 1px solid var(--mz-line); background: var(--mz-bg); color: var(--mz-fg); font: 14px/1.4 var(--mz-font); box-sizing: border-box; }
.mz-top.mz-compact { padding: 4px 12px; font-size: 13px; }
.mz-top a { color: inherit; text-decoration: none; padding: 6px 2px; border-radius: 4px; background: none; border: 0; font-weight: inherit; }
.mz-top a:hover { color: var(--mz-accent); text-decoration: none; }
.mz-top .mz-brand { font-weight: 700; font-size: 16px; }
.mz-top.mz-compact .mz-brand { font-size: 14px; }
.mz-top .mz-brand small { font-weight: 400; font-size: 13px; color: var(--mz-muted); margin-left: 8px; }
.mz-top nav.mz-nav { display: flex; flex-wrap: wrap; gap: 0 12px; position: static; margin: 0; padding: 0; background: none; border: 0; }
.mz-top nav.mz-nav a[aria-current="page"] { color: var(--mz-accent); font-weight: 600; box-shadow: inset 0 -2px var(--mz-accent); }
.mz-top .mz-family { margin-left: auto; position: relative; }
.mz-top .mz-family summary { list-style: none; cursor: pointer; padding: 5px 10px; border: 1px solid var(--mz-line); border-radius: 999px; color: var(--mz-muted); white-space: nowrap; font-size: 13px; }
.mz-top .mz-family summary::-webkit-details-marker { display: none; }
.mz-top .mz-family summary:hover, .mz-top .mz-family[open] summary { color: var(--mz-fg); border-color: var(--mz-muted); }
.mz-top .mz-family-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 260px; max-width: min(92vw, 380px); padding: 8px; margin: 0; list-style: none; background: var(--mz-bg); border: 1px solid var(--mz-line); border-radius: var(--mz-radius); box-shadow: var(--mz-shadow); font-size: 14px; }
.mz-top .mz-family-menu li { margin: 0; padding: 0; max-width: none; }
.mz-top .mz-family-menu a { display: block; padding: 8px 10px; border-radius: var(--mz-radius-sm); color: var(--mz-fg); }
.mz-top .mz-family-menu a:hover { background: var(--mz-soft); color: var(--mz-fg); }
.mz-top .mz-family-menu a[aria-current="true"] { color: var(--mz-accent); font-weight: 600; }
.mz-top .mz-family-menu small { display: block; color: var(--mz-muted); font-size: 12.5px; font-weight: 400; }
@media (max-width: 560px) {
    .mz-top { gap: 0 10px; padding: 6px 12px; }
    .mz-top .mz-family-menu { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; max-width: none; max-height: 70vh; overflow: auto; }
}

/* the footer */
.mz-foot { position: static; max-width: none; margin: 40px 0 0; padding: 20px 16px 28px; border: 0; border-top: 1px solid var(--mz-line); color: var(--mz-muted); font: 13.5px/1.5 var(--mz-font); background: var(--mz-bg); box-sizing: border-box; }
.mz-foot p { margin: 0 0 8px; max-width: var(--mz-measure); }
.mz-foot a { color: var(--mz-accent); background: none; }
.mz-foot .mz-brand { color: var(--mz-fg); font-weight: 700; text-decoration: none; }
.mz-foot nav { display: flex; flex-wrap: wrap; gap: 2px 16px; position: static; margin: 0; padding: 0; background: none; border: 0; }
.mz-foot nav a { color: var(--mz-muted); text-decoration: none; padding: 4px 0; font-weight: 400; }
.mz-foot nav a:hover { color: var(--mz-accent); text-decoration: underline; }
.mz-foot nav a[aria-current="true"] { color: var(--mz-fg); }

/* cards of pages (the showcase on MathZetta's home, a site's index): self-contained like the chrome */
.mz-showcase { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin: 16px 0; padding: 0; list-style: none; }
.mz-showcase > li { margin: 0; padding: 0; max-width: none; }
a.mz-card { display: block; height: 100%; box-sizing: border-box; padding: 14px 16px; border: 1px solid var(--mz-line); border-radius: var(--mz-radius); background: var(--mz-bg); color: var(--mz-fg); text-decoration: none; font: 14px/1.5 var(--mz-font); }
a.mz-card:hover { border-color: var(--mz-accent); box-shadow: var(--mz-shadow); text-decoration: none; }
a.mz-card strong { font-size: 15px; }
a.mz-card:hover strong { color: var(--mz-accent); }
a.mz-card .mz-what { display: block; color: var(--mz-muted); margin-top: 4px; }
a.mz-card .mz-uses { display: block; font-size: 13.5px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--mz-line); }
.mz-tag { display: inline-block; font: 12px/1.4 var(--mz-font); color: var(--mz-muted); border: 1px solid var(--mz-line); border-radius: 999px; padding: 0 8px; vertical-align: middle; margin-left: 4px; }

/* ------------------------------------------------------------ documents: body.mz */
body.mz { margin: 0; font: 16px/1.55 var(--mz-font); color: var(--mz-fg); background: var(--mz-bg); -webkit-text-size-adjust: 100%; }
body.mz main, body.mz .mz-main { max-width: 1000px; margin: 0 auto; padding: 24px 16px 40px; box-sizing: border-box; }
body.mz main.mz-narrow { max-width: 760px; }
body.mz main.mz-wide { max-width: 1400px; }
body.mz h1 { font-size: clamp(24px, 2.4vw + 14px, 32px); line-height: 1.2; margin: 0.4em 0 0.5em; }
body.mz h2 { font-size: 20px; margin: 1.6em 0 0.5em; }
body.mz h3 { font-size: 16px; margin: 1.3em 0 0.4em; }
body.mz p, body.mz li { max-width: var(--mz-measure); }
body.mz p { margin: 0 0 1em; }
body.mz a { color: var(--mz-accent); text-underline-offset: 2px; }
body.mz a:hover { text-decoration-thickness: 2px; }
body.mz .muted { color: var(--mz-muted); }
body.mz .err { color: var(--mz-err); }
body.mz .ok { color: var(--mz-ok); }
body.mz .mono, body.mz code, body.mz pre, body.mz kbd { font-family: var(--mz-mono); font-size: 0.92em; }
body.mz code { background: var(--mz-soft); padding: 1px 5px; border-radius: 4px; }
body.mz pre { background: var(--mz-soft); padding: 12px 14px; border-radius: var(--mz-radius); overflow: auto; }
body.mz pre code { background: none; padding: 0; }
body.mz hr { border: 0; border-top: 1px solid var(--mz-line); margin: 24px 0; }
body.mz img, body.mz video, body.mz canvas { max-width: 100%; height: auto; }

/* controls: the same shape everywhere; big enough to tap */
body.mz button, body.mz input, body.mz select, body.mz textarea {
    font: inherit; color: var(--mz-fg); background: var(--mz-bg); border: 1px solid var(--mz-line); border-radius: var(--mz-radius-sm);
    padding: 7px 10px; min-height: 36px; max-width: 100%; box-sizing: border-box;
}
body.mz input[type="checkbox"], body.mz input[type="radio"] { min-height: 0; width: 18px; height: 18px; padding: 0; accent-color: var(--mz-accent); }
body.mz button, body.mz .button { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; text-decoration: none; background: var(--mz-soft); }
body.mz button:hover, body.mz .button:hover { border-color: var(--mz-muted); }
body.mz button.primary, body.mz .button.primary { background: var(--mz-accent); color: var(--mz-accent-fg); border-color: var(--mz-accent); font-weight: 600; }
body.mz button.primary:hover, body.mz .button.primary:hover { filter: brightness(1.08); }
body.mz button:disabled { opacity: 0.5; cursor: default; }
body.mz textarea { line-height: 1.45; min-height: 80px; }
body.mz label { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.mz .field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; }
body.mz .field > span { font-size: 14px; color: var(--mz-muted); }
body.mz .row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 8px 0; }
body.mz .drop { display: block; border: 2px dashed var(--mz-line); border-radius: var(--mz-radius); padding: 28px; text-align: center; color: var(--mz-muted); cursor: pointer; }
body.mz .drop.over, body.mz .drop:focus-within { border-color: var(--mz-accent); color: var(--mz-accent); background: var(--mz-accent-soft); }

/* tables and cards */
body.mz table { border-collapse: collapse; font-size: 14px; max-width: 100%; }
body.mz th, body.mz td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--mz-line); vertical-align: top; }
body.mz th { color: var(--mz-muted); font-weight: 600; }
body.mz td.num, body.mz th.num { text-align: right; font-variant-numeric: tabular-nums; }
body.mz .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body.mz .card { border: 1px solid var(--mz-line); border-radius: var(--mz-radius); padding: 16px 18px; background: var(--mz-bg); }
body.mz .lead { font-size: 18px; color: var(--mz-muted); max-width: var(--mz-measure); }
