/* ==========================================================================
   base.css — Reset, typography, layout primitives, motion
   ========================================================================== */

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 2rem);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    letter-spacing: var(--tracking-normal);
    font-synthesis-weight: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color var(--dur-base) var(--ease-out);
}

/* A faint line grid that drifts slower than the page (parallax). It is
   structure, not light: no glow, no halo. `--scroll-shift` is set by JS. */
body::before {
    content: "";
    position: fixed;
    inset: -25% 0;
    background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
    background-size: 76px 76px;
    transform: translate3d(0, var(--scroll-shift, 0px), 0);
    pointer-events: none;
    z-index: -1;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
    mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}

/* A field of soft blobs that drift across the page, then merge and pull
   apart like liquid (an SVG goo filter does the merging). Monochrome and
   faint: it is texture, not decoration. The markup is injected by JS. */
.liquid {
    position: fixed;
    inset: -12%;
    z-index: -2;
    overflow: hidden;
    opacity: 0.08;
    pointer-events: none;
    filter: url("#liquid-goo");
}

.liquid > span {
    position: absolute;
    display: block;
    width: min(30vw, 300px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--blob);
    will-change: transform;
    animation: liquid-move 24s ease-in-out infinite alternate;
}

.liquid > span:nth-child(1) {
    left: 2%;
    top: 4%;
    width: min(30vw, 300px);
    --tx: 30vw;
    --ty: 26vh;
    --sx: 1.3;
    animation-duration: 19s;
    animation-delay: -3s;
}

.liquid > span:nth-child(2) {
    left: 40%;
    top: -10%;
    width: min(24vw, 240px);
    --tx: 34vw;
    --ty: 36vh;
    --sx: 0.75;
    animation-duration: 25s;
    animation-delay: -9s;
}

.liquid > span:nth-child(3) {
    left: 68%;
    top: 26%;
    width: min(32vw, 320px);
    --tx: -26vw;
    --ty: -22vh;
    --sx: 1.2;
    animation-duration: 22s;
    animation-delay: -14s;
}

.liquid > span:nth-child(4) {
    left: 4%;
    top: 58%;
    width: min(26vw, 260px);
    --tx: 46vw;
    --ty: -30vh;
    --sx: 0.8;
    animation-duration: 28s;
    animation-delay: -6s;
}

.liquid > span:nth-child(5) {
    left: 48%;
    top: 72%;
    width: min(36vw, 360px);
    --tx: -20vw;
    --ty: 24vh;
    --sx: 1.35;
    animation-duration: 23s;
    animation-delay: -18s;
}

@keyframes liquid-move {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }

    50% {
        transform: translate3d(var(--tx), var(--ty), 0) scale(var(--sx));
    }

    100% {
        transform: translate3d(calc(var(--tx) * -0.6), calc(var(--ty) * -0.5), 0) scale(1.1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .liquid {
        display: none;
    }
}

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

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

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

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

ul,
ol {
    list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: var(--lh-snug);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

strong {
    font-weight: 600;
    color: var(--text);
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding: 0.1em 0.35em;
    border-radius: 5px;
    background: var(--glass-strong);
}

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

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

@supports (scrollbar-color: auto) {
    html {
        scrollbar-color: var(--glass-border-hover) transparent;
    }
}

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border-hover);
    border-radius: var(--radius-pill);
    border: 3px solid transparent;
    background-clip: content-box;
}

/* ==========================================================================
   Layout
   ========================================================================== */

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

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

main {
    flex: 1 0 auto;
}

.section {
    padding-block: var(--space-section);
}

.section--tight {
    padding-block: clamp(3rem, 7vw, 5rem);
}

.grid {
    display: grid;
    gap: var(--space-md);
}

.cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs);
}

/* ==========================================================================
   Typography helpers
   ========================================================================== */

.eyebrow {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 400;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-faint);
}

.section__head {
    max-width: 58ch;
    margin-bottom: var(--space-xl);
}

.section__head--center {
    margin-inline: auto;
    text-align: center;
}

.section__title {
    font-size: var(--fs-h2);
    margin-top: var(--space-sm);
    text-wrap: balance;
}

.section__lead {
    margin-top: var(--space-sm);
    max-width: 56ch;
    color: var(--text-muted);
    font-size: var(--fs-md);
}

.text-muted {
    color: var(--text-muted);
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.skip-link {
    position: absolute;
    top: var(--space-2xs);
    left: var(--space-2xs);
    z-index: var(--z-top);
    padding: 0.7rem 1.1rem;
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transform: translateY(-200%);
    transition: transform var(--dur-base) var(--ease-out);
}

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

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

/* ==========================================================================
   Scroll reveal
   ========================================================================== */

html:not(.no-js) .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
}

html:not(.no-js) .reveal.is-visible {
    opacity: 1;
    transform: none;
}

/* ==========================================================================
   Keyframes
   ========================================================================== */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

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

@keyframes appear {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 var(--accent-line);
    }
    50% {
        box-shadow: 0 0 0 6px transparent;
    }
}

@keyframes blink {
    0%,
    50% {
        opacity: 1;
    }
    50.01%,
    100% {
        opacity: 0;
    }
}

@keyframes fill {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* ==========================================================================
   Motion preferences
   ========================================================================== */

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

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

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

@media print {
    .header,
    .footer,
    .back-to-top,
    .theme-toggle {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }
}
