/*
 * Page defaults shared by every screen.
 *
 * The reset is deliberately small: only what the design system actually contradicts in the
 * browser defaults. A blanket reset would hide, not solve, the differences.
 */

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

html {
    /* The page itself never scrolls sideways at any phone width (core.md §5.5);
       a wide table scrolls inside its own box instead. */
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--fs-body);
    line-height: var(--lh-text);
    /* A flat colour. No gradients, textures, patterns or background images anywhere. */
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
}

h1 {
    font-size: var(--fs-page);
}

h2 {
    font-size: var(--fs-h2);
}

h3 {
    font-size: var(--fs-section);
}

p {
    margin: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-link-hover);
}

/*
 * The hover underline belongs to links that read as text. Written through :where() so its
 * specificity is zero: a component that styles a link as a control — a tab, a card, a cell —
 * turns it off with a plain `text-decoration: none` of its own, instead of every module
 * re-fighting `a:hover` at higher specificity.
 */
:where(a:hover) {
    text-decoration: underline;
}

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

/* Every figure is tabular, so digits keep their column from row to row. */
.app-num {
    font-variant-numeric: var(--numeric);
    /* A number is never broken across two lines (core.md §3.4). */
    white-space: nowrap;
}

/* Visible focus is kept: it is the only affordance a keyboard user has. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-glyph);
}

/* Glyphs sit on a 20x20 grid and inherit the current colour. */
.app-icon {
    display: block;
    flex: none;
    width: var(--glyph);
    height: var(--glyph);
}

/* Inside a control with text the glyph equals the type size and drops to the optical
   centre of the lowercase letters. */
.app-icon--inline {
    width: var(--glyph-inline);
    height: var(--glyph-inline);
    transform: translateY(var(--glyph-nudge));
}

.app-icon--head {
    width: var(--glyph-head);
    height: var(--glyph-head);
}

/* Screen-reader only: used where a control is a glyph and its name must still be read. */
.app-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@keyframes app-spin {
    to {
        transform: rotate(360deg);
    }
}

/* The only two animations in the system are a 120ms state transition and this ring. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* An absent value, said with a dash rather than with emptiness: an empty cell reads as a
   forgotten one. */
.app-muted {
    color: var(--text-4);
}

/* An explanation next to a figure or a control: quieter than the text it explains, and never
   wider than a line the eye takes in at once. */
.app-note {
    max-width: var(--w-prose);
    margin: 0;
    color: var(--text-3);
    font-size: var(--fs-caption);
    line-height: var(--lh-text);
}

.app-note + .app-note {
    margin-top: var(--space-2);
}

.app-note code {
    font-size: inherit;
}
