/* ==========================================================================
   Base: design tokens, reset, element defaults, focus
   ========================================================================== */

:root {
    /* Primary: navy for headings, header and footer */
    --primary-900: #10233d;
    --primary-800: #173257;
    --primary-700: #1d4e89;
    --primary-600: #2160a8;
    --primary-100: #e7eef8;

    /* Accent: copper, for links on light backgrounds and key numbers */
    --accent-600: #9a4a14;
    --accent-500: #b35a1d;
    --accent-100: #f8ece2;

    /* Resistor body tan, used on the drawing and soft highlights */
    --tan-300: #e6cf9f;
    --tan-100: #f6efe0;

    /* Surface and border */
    --surface-0: #ffffff;
    --surface-50: #f7f8fa;
    --surface-100: #eef1f5;
    --border-200: #d9dee6;
    --border-300: #c2c9d4;

    /* Ink: body text */
    --ink-900: #151a22;
    --ink-700: #364152;
    --ink-500: #586374;

    /* Feedback */
    --error-600: #b3261e;
    --error-100: #fdecea;

    /* Text on dark backgrounds */
    --on-dark: #eef3fa;
    --on-dark-muted: #b9c6d8;

    --primary-900-rgb: 16 35 61;

    --maxw: 72rem;
    --maxw-narrow: 46rem;
    --gutter: 1rem;
    --radius: 0.375rem;
    --radius-lg: 0.75rem;

    --shadow-sm: 0 1px 2px rgb(var(--primary-900-rgb) / 0.08);
    --shadow-md: 0 8px 24px rgb(var(--primary-900-rgb) / 0.08);

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    --focus-ring: 3px solid var(--primary-600);
    --focus-ring-on-dark: 3px solid #9cc3ff;
}

@media (min-width: 48rem) {
    :root {
        --gutter: 1.5rem;
    }
}

/* Reset ------------------------------------------------------------------ */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd,
fieldset {
    margin: 0;
}

fieldset {
    padding: 0;
    border: 0;
    min-width: 0;
}

ul[role="list"],
ol[role="list"] {
    list-style: none;
    margin: 0;
    padding: 0;
}

img,
svg {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Element defaults ------------------------------------------------------- */

body {
    background: var(--surface-0);
    color: var(--ink-700);
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.65;
}

h1,
h2,
h3,
h4 {
    color: var(--ink-900);
    line-height: 1.2;
    text-wrap: balance;
}

h1 {
    font-size: clamp(1.85rem, 1.4rem + 2vw, 2.75rem);
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(1.35rem, 1.2rem + 0.8vw, 1.75rem);
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.15rem;
}

a {
    color: var(--primary-700);
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--primary-900);
}

code,
kbd {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

/* Focus ------------------------------------------------------------------ */

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}
