/* ============================================================
   Base — reset, body, background effects, accessibility,
   global typography defaults.
   ============================================================ */

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

* {
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-height) + 1rem);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.65;
    color: var(--text-secondary);
    background: var(--bg-base);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "ss01", "ss03";
    position: relative;
}

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

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

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

ul,
ol {
    list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

p {
    text-wrap: pretty;
}

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

button:focus-visible,
a:focus-visible {
    outline-offset: 4px;
}

/* Selection */
::selection {
    background: var(--glow-strong);
    color: var(--text-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-base);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-strong);
}

/* Background layers — fixed so they pan smoothly with scroll */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: var(--z-bg);
    pointer-events: none;
    background-image: linear-gradient(
            rgba(255, 255, 255, 0.025) 1px,
            transparent 1px
        ),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(
        ellipse 90% 60% at 50% 15%,
        #000 30%,
        transparent 80%
    );
    -webkit-mask-image: radial-gradient(
        ellipse 90% 60% at 50% 15%,
        #000 30%,
        transparent 80%
    );
}

.bg-glow {
    position: fixed;
    inset: 0;
    z-index: var(--z-bg);
    pointer-events: none;
    background:
        radial-gradient(
            circle 620px at 82% -10%,
            rgba(34, 211, 238, 0.12),
            transparent 60%
        ),
        radial-gradient(
            circle 720px at -5% 8%,
            rgba(59, 130, 246, 0.10),
            transparent 60%
        ),
        radial-gradient(
            circle 540px at 50% 110%,
            rgba(99, 102, 241, 0.08),
            transparent 60%
        );
}

.bg-noise {
    position: fixed;
    inset: 0;
    z-index: var(--z-bg);
    pointer-events: none;
    opacity: 0.025;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Content sits above the background */
.nav,
main,
footer {
    position: relative;
    z-index: var(--z-base);
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: var(--bg-base);
    font-weight: 600;
    border-radius: 0 0 var(--radius-md) 0;
    z-index: var(--z-overlay);
}
.skip-link:focus {
    left: 0;
}

/* Reduced motion */
@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;
    }
    .bg-glow,
    .bg-grid {
        display: none;
    }
}
