/* ===========================================================================
   base.css — reset plus bare-element defaults.
   Only element selectors and a handful of global utilities live here.
   Never put component styling in this file.
   Layer 2 of 4: tokens -> base -> components -> pages
   =========================================================================== */

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

* {
    margin: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + var(--space-5));
}

body {
    min-height: 100vh;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "ss01";
}

/* --- Headings -----------------------------------------------------------
   Serif display face, tight leading. Sizes come from the fluid scale so
   headings never need a media query.                                    */
h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
}

h1 {
    font-size: var(--text-3xl);
}
h2 {
    font-size: var(--text-2xl);
}
h3 {
    font-size: var(--text-lg);
}
h4 {
    font-size: var(--text-md);
}

p {
    text-wrap: pretty;
}

a {
    color: inherit;
    text-decoration: none;
}

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

ul,
ol {
    padding-left: 1.25em;
}

li::marker {
    color: var(--accent-line);
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

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

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

hr {
    height: var(--border-width);
    border: none;
    background: var(--border);
}

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

/* --- Focus ------------------------------------------------------------
   One visible focus treatment for the whole site. Never remove it.     */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
}

/* --- Layout primitives ------------------------------------------------ */

/* Horizontal gutter + max width. Used by nearly every top-level block. */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: clamp(1.125rem, 0.75rem + 2.5vw, 2.5rem);
}

/* Narrower measure for long-form reading (blog posts). */
.container--prose {
    max-width: var(--container-prose);
}

/* Standard vertical spacing for a page section. */
.section {
    padding-block: var(--section-gap);
}

.section--tight {
    padding-block: calc(var(--section-gap) * 0.55);
}

/* Stack: vertical flow with one gap value. */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.stack--sm {
    gap: var(--space-2);
}
.stack--lg {
    gap: var(--space-6);
}

/* Row: horizontal flow that wraps by default. */
.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

/* Visible only to assistive technology. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Skip link, revealed on keyboard focus. */
.skip-link {
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    z-index: calc(var(--z-header) + 10);
    padding: var(--space-2) var(--space-4);
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    transform: translateY(-200%);
    transition: transform var(--duration-fast) var(--ease-out);
}

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

/* --- Scroll reveal ----------------------------------------------------
   `reveal.js` adds .is-visible when the element enters the viewport.
   Elements stay visible if JS never runs (see the no-js guard below).  */
.reveal {
    opacity: 0;
    transform: translateY(1.25rem);
    transition: opacity var(--duration-slow) var(--ease-out),
        transform var(--duration-slow) var(--ease-out);
}

.reveal.is-visible {
    opacity: 1;
    transform: none;
}

html.no-js .reveal {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}
