/* Base layer — port of the hub's globals.css reset + element styles +
 * utilities (§§ reset, 1.3 selection, 9 focus, 11 elements, 7 a11y,
 * reveal utilities). Token-mapped per docs/design-tokens.map.md; raw
 * values inlined where no exact token exists (exactness beats elegance).
 */

* {
    box-sizing: border-box;
}

/* Meyer-style reset (hub-verbatim element list). */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}

html {
    font-size: 100%;
    height: 100%;
    scroll-padding-top: calc(64px + 36px); /* header height + 36 */
    scroll-padding-bottom: 32px;
    font-variation-settings: var(--font-variations);
    background: var(--surface-canvas);
}

html,
body {
    max-width: 100vw;
    /* `clip` (not `hidden`): prevents horizontal overflow WITHOUT creating a
     * scroll container — overflow-x:hidden on html/body silently breaks every
     * position:sticky descendant (sidebar, TOC). */
    overflow-x: clip;
}

body,
html,
button,
input,
optgroup,
select,
textarea {
    font-family: var(--font-family-sans);
}

body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizelegibility;
    background: transparent;
    color: var(--text-primary);
    font-variation-settings: var(--font-variations);
}

/* Entrance-reveal utilities — opacity only (nothing may trap sticky
 * descendants); reduced-motion disables. */
@keyframes reveal-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.u-reveal {
    animation: reveal-fade 0.5s cubic-bezier(0.23, 1, 0.32, 1) backwards;
}

.u-reveal-stagger > * {
    animation: reveal-fade 0.5s cubic-bezier(0.23, 1, 0.32, 1) backwards;
}

.u-reveal-stagger > *:nth-child(2) {
    animation-delay: 70ms;
}

.u-reveal-stagger > *:nth-child(3) {
    animation-delay: 140ms;
}

.u-reveal-stagger > *:nth-child(4) {
    animation-delay: 210ms;
}

.u-reveal-stagger > *:nth-child(n + 5) {
    animation-delay: 280ms;
}

@media (prefers-reduced-motion: reduce) {
    .u-reveal,
    .u-reveal-stagger > * {
        animation: none;
    }
}

a {
    color: inherit;
}

a:not([class]) {
    text-decoration: underline;
    text-decoration-thickness: var(--underline-thickness);
    text-underline-offset: var(--underline-offset);
    text-decoration-color: var(--text-quaternary);
    transition: text-decoration-color 0.25s;
}

a:not([class]):hover {
    text-decoration-color: var(--text-primary);
}

/* Heading base — every heading rides the heading face; Prose sets the real
 * ladder. */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--heading-page-family);
    font-size: 1rem;
    font-weight: var(--heading-sub-weight);
    color: var(--text-primary);
    margin: 0;
}

li {
    margin-bottom: 8px;
    margin-left: 24px;
}

hr {
    border: none;
    border-top: 1px solid var(--border-default);
}

b,
strong {
    font-weight: var(--font-weight-semibold);
}

kbd {
    background: var(--surface-canvas);
    min-width: 24px;
    box-shadow: var(--shadow-xs), 0 0 0 1px #52524c; /* hub --color-border-tertiary, dark */
    font-size: 0.8em;
    font-weight: var(--font-weight-medium);
    border-radius: 5px;
    margin: 0 1px;
    padding: 3px 6px;
}

[data-theme='light'] kbd {
    box-shadow: var(--shadow-xs), 0 0 0 1px var(--stone-400);
}

code {
    background: var(--stone-875); /* hub --color-bg-secondary, dark */
    border: 1px solid #464641; /* hub --color-border-secondary, dark */
    border-radius: 0.3em;
    padding: 0.1em 0.25em;
    font-size: 0.875em;
    line-height: 1.3;
    box-decoration-break: clone;
}

[data-theme='light'] code {
    background: var(--stone-150);
    border-color: var(--stone-350);
}

pre {
    /* The one deliberately sunken surface — a code well below the page. */
    background: var(--stone-950); /* hub --color-surface-code, dark */
    border: 1px solid #ffffff12;
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
    overflow-x: auto;
}

[data-theme='light'] pre {
    background: var(--stone-150);
    border-color: #0000000f;
}

/* Live-verified 2026-07-21: the hub sets pre/code in its Inter-as-mono
 * voice — the label-mono token, NOT true mono. */
pre,
code {
    font-family: var(--font-family-label-mono);
    font-variation-settings: normal;
    font-feature-settings: normal;
}

/* Custom scrollbar hook. */
[data-custom-scrollbar]::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

[data-custom-scrollbar]::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
    background-clip: content-box;
    border: 3px solid #0000;
}

/* Selection — same color-mix formulas as the hub, off the brand-teal
 * action token (identical value to the hub's --color-brand-bg). */
::selection {
    color: var(--brand-white);
    background: color-mix(in lch, var(--action-accent-bg), black 10%);
}

[data-theme='light'] ::selection {
    color: currentcolor;
    background: color-mix(in lch, var(--action-accent-bg), transparent 64%);
}

img::selection {
    color: var(--brand-white);
    background: color-mix(in lch, var(--action-accent-bg), transparent 80%);
}

[data-theme='light'] img::selection {
    color: currentcolor;
    background: color-mix(in lch, var(--action-accent-bg), transparent 80%);
}

/* Focus-visible pairing — ring on keyboard focus only. */
:focus-visible {
    outline-style: solid;
    outline-color: var(--color-accent);
    outline-width: 2px;
    outline-offset: 2px;
}

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

/* Clip-rect visually-hidden utility (Link's new-tab hint, SkipNav base). */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
