/* ===========================================================
   base.css — modern reset, typography defaults, layout primitives,
   utilities, focus styles, reduced-motion guards
   =========================================================== */

/* ---- Reset ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--lh-base);
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
    transition: background-color var(--dur-base) var(--ease-smooth),
                color var(--dur-base) var(--ease-smooth);

    /* Persistent ultra-faint blueprint grid */
    background-image:
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
    background-size: 80px 80px;
    background-attachment: fixed;
}

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

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

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease-smooth),
                opacity var(--dur-fast) var(--ease-smooth);
}

ul, ol {
    list-style: none;
}

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

::selection {
    background: var(--selection-bg);
    color: var(--selection-fg);
}

/* ---- Typography defaults ---- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: var(--w-regular);
    font-variation-settings: "opsz" 144;
    color: var(--text);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
    text-wrap: balance;
}

h1 { font-size: var(--text-6xl); letter-spacing: var(--ls-display); line-height: var(--lh-display); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
    color: var(--text-mute);
    text-wrap: pretty;
    max-width: 70ch;
}

strong, b { font-weight: var(--w-semi); color: var(--text); }
em, i { font-style: italic; }

code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
    letter-spacing: var(--ls-mono);
}

/* ---- Focus styles ---- */
:focus { outline: none; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--r-sm);
}

/* ---- Layout primitives ---- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.container--narrow {
    max-width: var(--container-narrow);
}

.container--wide {
    max-width: var(--container-wide);
}

.section {
    padding-block: var(--section-y);
    position: relative;
}

.stack > * + * { margin-top: var(--s-4); }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-5 > * + * { margin-top: var(--s-5); }
.stack-6 > * + * { margin-top: var(--s-6); }
.stack-7 > * + * { margin-top: var(--s-7); }

/* ---- Utility helpers ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: var(--gutter);
    z-index: var(--z-skip);
    padding: 0.75rem 1.25rem;
    background: var(--accent);
    color: var(--ink);
    font-weight: var(--w-semi);
    border-radius: var(--r-sm);
    transition: top var(--dur-fast) var(--ease-smooth);
}

.skip-link:focus-visible {
    top: 0.75rem;
    outline-offset: 2px;
}

.mono {
    font-family: var(--font-mono);
    font-feature-settings: "tnum" 1, "ss01" 1;
    letter-spacing: var(--ls-mono);
}

.serif { font-family: var(--font-display); }
.sans  { font-family: var(--font-sans); }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: var(--w-medium);
    letter-spacing: var(--ls-wider);
    text-transform: uppercase;
    color: var(--text-mute);
}

.eyebrow::before {
    content: "";
    width: 1.75rem;
    height: 1px;
    background: var(--line-strong);
}

.eyebrow--accent { color: var(--accent); }
.eyebrow--accent::before { background: var(--accent); }

.eyebrow--no-rule::before { display: none; }

.text-mute      { color: var(--text-mute); }
.text-subtle    { color: var(--text-subtle); }
.text-accent    { color: var(--accent); }
.text-paper     { color: var(--text); }

/* ---- Section header pattern ---- */
.section-head {
    display: grid;
    grid-template-columns: max-content 1fr;
    align-items: end;
    gap: clamp(1.5rem, 3vw, 3rem);
    padding-bottom: var(--s-6);
    margin-bottom: clamp(2.5rem, 6vw, 5rem);
    border-bottom: 1px solid var(--line);
}

.section-head__index {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-subtle);
    letter-spacing: var(--ls-wide);
}

.section-head__title {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: var(--w-regular);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
    color: var(--text);
    text-wrap: balance;
}

.section-head__title em {
    font-style: italic;
    color: var(--accent);
    font-variation-settings: "opsz" 144, "SOFT" 50;
}

.section-head__lead {
    margin-top: var(--s-3);
    font-size: var(--text-lg);
    color: var(--text-mute);
    max-width: 60ch;
    line-height: var(--lh-snug);
}

@media (max-width: 720px) {
    .section-head {
        grid-template-columns: 1fr;
        gap: var(--s-3);
    }
}

/* ---- Reveal animation states (set by JS) ---- */
[data-reveal] {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity var(--dur-slow) var(--ease-out),
                transform var(--dur-slow) var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
    will-change: opacity, transform;
}

[data-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Reduced motion: kill non-essential motion globally ---- */
@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;
    }
    [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ---- Mobile padding tweaks ---- */
@media (max-width: 600px) {
    body { background-size: 56px 56px; }
}
