/* ==========================================================================
   Reset and element defaults.

   Deliberately small: we removed Bootstrap, and a hand-written reset that only
   covers what the site actually uses is easier to reason about than 200 KB of
   framework we override anyway.
   ========================================================================== */

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

html {
    /* Anchor links and skip-links land below the sticky header instead of under it. */
    scroll-padding-top: calc(var(--header-height) + var(--space-4));
    -webkit-text-size-adjust: 100%;

    /* The mobile navigation drawer is parked off-screen to the right with a transform.
       A transformed element still counts towards the scrollable area, so without this
       every page on a phone can be dragged sideways into ~320px of nothing.
       `clip` and not `hidden`: `hidden` would turn html into a scroll container and
       break the sticky header and the sticky category bar. Wide content is still
       scrollable on its own — see .table-wrap and .chip-nav__inner. */
    overflow-x: clip;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--color-surface);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: var(--leading-normal);
    /* Slightly tighter letterforms suit Inter at body size. */
    letter-spacing: -0.002em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Keep the footer at the bottom on short pages. */
body {
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

h1, h2, h3, h4 {
    margin: 0 0 var(--space-4);
    font-family: var(--font-display);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
    color: var(--color-ink);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); font-family: var(--font-body); font-weight: 600; }

p {
    margin: 0 0 var(--space-4);
    /* Stops a paragraph from ending on a single orphaned word. */
    text-wrap: pretty;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--color-terracotta);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--color-terracotta-dark);
}

ul, ol {
    margin: 0 0 var(--space-4);
    padding-left: var(--space-5);
}

li + li {
    margin-top: var(--space-1);
}

strong {
    font-weight: 600;
}

small {
    font-size: var(--text-sm);
}

img, picture, video, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

figure {
    margin: 0;
}

hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-10) 0;
}

blockquote {
    margin: 0;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* Inherit fonts rather than falling back to the browser's tiny default. */
button, input, select, textarea {
    font: inherit;
    color: inherit;
}

textarea {
    resize: vertical;
}

/* --- Focus ---------------------------------------------------------------
   A visible focus ring is the only way a keyboard user can tell where they are.
   :focus-visible so it appears for keyboards but not for mouse clicks. */

:focus-visible {
    outline: 2px solid var(--color-terracotta);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* --- Shared helpers ----------------------------------------------------- */

/* The icon sprite must never be painted — only referenced via <use>. */
.icon-sprite {
    display: none;
}

/* Visible only to screen readers — section labels, form hints, skip links. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Jumps a keyboard user past the navigation; hidden until focused. */
.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: calc(var(--z-header) + 1);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface-raised);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 500;
    transform: translateY(-200%);
    transition: transform var(--duration) var(--ease-out);
}

.skip-link:focus {
    transform: translateY(0);
}
