/* ============================================================
   Base: font faces, reset, typography, layout primitives.
   ============================================================ */

/* Self-hosted fonts (GDPR - no Google Fonts requests). Files live in
   /assets/fonts/; if any is missing the system stack covers the gap.
   NB: format() must be 'woff2' - 'woff2-variations' is not a valid value in
   the current CSS spec and strict browsers reject the whole src, silently
   loading no webfont at all. Browsers read variability from the file itself. */
@font-face {
    font-family: 'Hanken Grotesk';
    src: url('/assets/fonts/HankenGrotesk-Variable.woff2') format('woff2');
    font-weight: 100 900;           /* variable: wght axis 100–900 */
    font-display: optional;         /* headings: on a slow link keep the fallback rather than reflow late */
}
@font-face {
    font-family: 'Inter';
    src: url('/assets/fonts/Inter-Variable.woff2') format('woff2');
    font-weight: 100 900;           /* variable: wght axis 100–900 */
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/assets/fonts/JetBrainsMono-Variable.woff2') format('woff2');
    font-weight: 100 800;           /* variable: wght axis 100–800 */
    font-display: optional;         /* times and numbers: no late swap that moves every card */
}

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

* { margin: 0; }

/* The `hidden` attribute must actually hide.
   The UA stylesheet says `[hidden] { display: none }` - specificity (0,1,0),
   the same as any single class. So every `.btn { display: flex }` in this
   codebase silently beat it, and `<button class="btn" hidden>` rendered as
   normal. `!important` is correct here rather than lazy: `hidden` is a
   statement about the element's existence, not a style suggestion, and
   nothing should ever out-rank it. */
[hidden] { display: none !important; }

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

body {
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: 1.6;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

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

button { cursor: pointer; background: none; border: none; padding: 0; }

a { color: var(--c-action); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-h2); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-h3); font-weight: 600; }

p { text-wrap: pretty; }

::selection { background: var(--c-primary-tint); }

/* ---- Focus ---- */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--r-sm);
}

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

@media (max-width: 640px) {
    .container { padding-inline: 16px; }
}

/* ---- Text helpers ---- */
.text-gradient {
    background: var(--grad-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.text-soft { color: var(--c-text-soft); }
.text-faint { color: var(--c-text-faint); }

/* Spacing utilities: the same rhythm everywhere instead of ad-hoc inline
   margins that each page sizes differently. */
.m-0 { margin: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }

.mono {
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: 0.05em;
}

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Minimal pages (error screens) ---- */
.page-minimal {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--sp-6);
}

.error-page {
    text-align: center;
    max-width: 420px;
    animation: fade-up var(--t-slow) var(--ease-out);
}

.error-page__art { display: flex; justify-content: center; margin-bottom: var(--sp-5); }
.error-page__ring { animation: spin-slow 24s linear infinite; transform-origin: center; }
.error-page__title { margin-bottom: var(--sp-2); }
.error-page__text { color: var(--c-text-soft); margin-bottom: var(--sp-5); }

/* ---- Shared animations ---- */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pop-in {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes spin-slow {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    from { background-position: -400px 0; }
    to   { background-position: 400px 0; }
}

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

/* A word longer than the line it is on breaks rather than pushing the page
   sideways: a long e-mail address, a name pasted in from a spreadsheet, a
   link in a note. Block text only; a flex or grid child still needs its own
   min-width: 0 (see the phone sections of components.css and admin.css). */
body { overflow-wrap: break-word; }
