/* ===== Reset & Base Styles ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: var(--font-normal);
    font-size: var(--text-md);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--surface-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

::selection {
    background-color: var(--primary-200);
    color: var(--primary-900);
}

/* Spacing is set by components, not by elements */
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure) {
    margin: 0;
    padding: 0;
}

:where(ul, ol) {
    list-style: none;
}

/* ===== Typography: medium, tight and large headings ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: var(--font-medium);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    text-wrap: balance;
    overflow-wrap: break-word;  /* a long word never pushes the page wider than a narrow phone */
}

h1 {
    font-size: var(--text-4xl);
    letter-spacing: var(--tracking-tighter);
}

h2 {
    font-size: var(--text-3xl);
    letter-spacing: var(--tracking-tight);
}

h3 {
    font-size: var(--text-xl);
    line-height: var(--leading-snug);
    letter-spacing: var(--tracking-snug);
}

h4 {
    font-size: var(--text-lg);
    line-height: var(--leading-snug);
}

p {
    text-wrap: pretty;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-default);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* <picture> is only a format switch: the image itself is laid out by its parent.
   <source> must not become a flex or grid item of that parent. */
picture {
    display: contents;
}

picture > source {
    display: none;
}

:where(button) {
    font: inherit;
    cursor: pointer;
}

/* ===== Focus styles ===== */
:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--space-0-5);
}

/* ===== Reduced motion ===== */
@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;
    }
}
