/* css/base.css
   Reset, font loading strategy, global typography, and accessibility primitives. */

/* Metric-compatible fallbacks: size-adjust keeps swapped web fonts from shifting
   layout, which is what protects the CLS = 0 budget. */
@font-face {
    font-family: 'Archivo Fallback';
    src: local('Arial');
    size-adjust: 99%;
    ascent-override: 89%;
    descent-override: 22%;
}

@font-face {
    font-family: 'Newsreader Fallback';
    src: local('Georgia');
    size-adjust: 96%;
    ascent-override: 90%;
    descent-override: 24%;
}

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

* {
    margin: 0;
}

html {
    scroll-padding-bottom: var(--dock-height);
}

/* Smooth anchor travel only for people who have not opted out of motion. */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Theme switch: the incoming theme grows from the toggle button (position set
   by theme.js as --theme-reveal-*) until it covers the viewport, instead of
   every element crossfading its own colors at once. Only the incoming snapshot
   animates — the outgoing one sits still underneath and is revealed through,
   so the circle reads as one theme "eating" into the other. Inert (no-op) in
   browsers without View Transitions support, and skipped entirely by theme.js
   under prefers-reduced-motion, so this rule never has to gate itself. */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-new(root) {
    clip-path: circle(0% at var(--theme-reveal-x, 50%) var(--theme-reveal-y, 50%));
    /* Linear, not --ease-out: the circle's covered area grows with the square of
       its radius, so an ease-out curve (tuned for quick 180ms hover states
       elsewhere) front-loads nearly all of the coverage into the first frames. */
    animation: theme-reveal 700ms linear forwards;
}

@keyframes theme-reveal {
    to {
        clip-path: circle(var(--theme-reveal-radius, 150%) at var(--theme-reveal-x, 50%) var(--theme-reveal-y, 50%));
    }
}

body {
    background-color: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition:
        background-color var(--dur-quick) var(--ease-out),
        color var(--dur-quick) var(--ease-out);
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 650;
    line-height: 1.05;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

p {
    max-width: 65ch;
}

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

a {
    color: inherit;
    text-decoration-color: var(--color-line);
    text-underline-offset: 0.2em;
    transition:
        color var(--dur-quick) var(--ease-out),
        text-decoration-color var(--dur-quick) var(--ease-out);
}

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

button {
    font: inherit;
    color: inherit;
}

/* One visible, consistent focus voice for every interactive element. */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

::selection {
    background-color: var(--color-accent);
    color: var(--color-on-accent);
}

.skip-link {
    position: fixed;
    inset: var(--space-3) auto auto var(--space-3);
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transform: translateY(-200%);
}

.skip-link:focus-visible {
    transform: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
