/* === TOKENS (supplement to critical inline CSS) === */
/* @font-face, reset, :root, body base are in inline <style> for FOUC prevention */

body {
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

body::-webkit-scrollbar {
    width: 4px;
}

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

body::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 2px;
}

body::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

::selection {
    background: var(--highlight-selection);
    color: var(--text-1);
}

/* === ACCESSIBILITY === */

/* Skip link (visible only on focus) */
.skip-link {
    position: fixed;
    top: -100%;
    left: 16px;
    z-index: 999;
    padding: 8px 16px;
    background: var(--text-1);
    color: var(--bg);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.3;
    text-decoration: none;
    transition: top 0.2s var(--ease-quart);
}

.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:focus {
    top: 16px;
}

/* Focus indicators for keyboard navigation */
:focus-visible {
    outline: 1px dashed var(--text-2);
    outline-offset: 3px;
}

/* === PAGE GRID === */

/* --- PAGE GRID (base, always visible) --- */
.page-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle 1.5px at 0 0, rgba(255,255,255,0.08) 1.5px, transparent 1.5px),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 1px, transparent 1px, transparent 120px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 1px, transparent 1px, transparent 120px),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02) 1px, transparent 1px, transparent 24px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02) 1px, transparent 1px, transparent 24px);
    background-size: var(--grid-heartbeat, 120px) var(--grid-heartbeat, 120px), var(--grid-heartbeat, 120px) var(--grid-heartbeat, 120px), var(--grid-heartbeat, 120px) var(--grid-heartbeat, 120px), 24px 24px, 24px 24px;
}

/* --- PAGE GRID GLOW (mouse-reactive brightness boost) ---
   Refactored from a fullscreen fixed element with mouse-tracked mask
   to a 600px translated div with a static centered mask. The grid
   background is offset by negative cursor coords so the bright lines
   stay aligned with the dim base .page-grid underneath. */
.page-grid-glow {
    position: fixed;
    left: 0;
    top: 0;
    width: 600px;
    height: 600px;
    z-index: 0;
    pointer-events: none;
    transform: translate3d(calc(var(--mx, -9999px) - 300px), calc(var(--my, -9999px) - 300px), 0);
    background-image:
        radial-gradient(circle 1.5px at 0 0, rgba(255,255,255,0.2) 1.5px, transparent 1.5px),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.25), rgba(255,255,255,0.25) 1px, transparent 1px, transparent 120px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.25), rgba(255,255,255,0.25) 1px, transparent 1px, transparent 120px),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.10), rgba(255,255,255,0.10) 1px, transparent 1px, transparent 24px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.10), rgba(255,255,255,0.10) 1px, transparent 1px, transparent 24px);
    background-size: var(--grid-heartbeat, 120px) var(--grid-heartbeat, 120px), var(--grid-heartbeat, 120px) var(--grid-heartbeat, 120px), var(--grid-heartbeat, 120px) var(--grid-heartbeat, 120px), 24px 24px, 24px 24px;
    /* Offset the grid by the inverse cursor position so lines register with the base grid. */
    background-position:
        calc(var(--mx, 0px) * -1 + 300px) calc(var(--my, 0px) * -1 + 300px),
        calc(var(--mx, 0px) * -1 + 300px) calc(var(--my, 0px) * -1 + 300px),
        calc(var(--mx, 0px) * -1 + 300px) calc(var(--my, 0px) * -1 + 300px),
        calc(var(--mx, 0px) * -1 + 300px) calc(var(--my, 0px) * -1 + 300px),
        calc(var(--mx, 0px) * -1 + 300px) calc(var(--my, 0px) * -1 + 300px);
    -webkit-mask-image: radial-gradient(circle 300px at 50% 50%, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    mask-image: radial-gradient(circle 300px at 50% 50%, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    transition: opacity 0.4s var(--ease-quart);
}

body.hero-hovered .page-grid-glow {
    width: 300px;
    height: 300px;
    transform: translate3d(calc(var(--mx, -9999px) - 150px), calc(var(--my, -9999px) - 150px), 0);
    background-position:
        calc(var(--mx, 0px) * -1 + 150px) calc(var(--my, 0px) * -1 + 150px),
        calc(var(--mx, 0px) * -1 + 150px) calc(var(--my, 0px) * -1 + 150px),
        calc(var(--mx, 0px) * -1 + 150px) calc(var(--my, 0px) * -1 + 150px),
        calc(var(--mx, 0px) * -1 + 150px) calc(var(--my, 0px) * -1 + 150px),
        calc(var(--mx, 0px) * -1 + 150px) calc(var(--my, 0px) * -1 + 150px);
    -webkit-mask-image: radial-gradient(circle 150px at 50% 50%, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    mask-image: radial-gradient(circle 150px at 50% 50%, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}

@media not all and (hover: hover) {
    .page-grid-glow { display: none; }
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .page-grid, .page-grid-glow {
        background-image:
            radial-gradient(circle 1px at 0 0, rgba(255,255,255,0.06) 1px, transparent 1px),
            repeating-linear-gradient(0deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 1px, transparent 1px, transparent 96px),
            repeating-linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 1px, transparent 1px, transparent 96px);
        background-size: 96px 96px, 96px 96px, 96px 96px;
    }
}

/* === LAYOUT === */

/* --- CURSOR 3D --- */
@media (hover: hover) and (min-width: 769px) {
    /* The OS cursor is the fail-safe. js/cursor-boot.js adds .cursor-ready only
       once a custom pointer is confirmed visible (3D first frame, or the SVG
       fallback). If WebGL init throws, the GLB 404s, the CDN is blocked, or the
       module stalls, this class never lands and the OS cursor stays. */
    html.cursor-ready *,
    html.cursor-ready *::before,
    html.cursor-ready *::after {
        cursor: none !important;
    }

    #cursor3d,
    #cursor3d-fallback {
        position: fixed;
        top: 0;
        left: 0;
        width: 120px;
        height: 120px;
        pointer-events: none;
        z-index: 10000;
        /* mix-blend-mode removed, caused cursor to vanish over dark overlays like cookie banner */
        transform: translate(calc(var(--mx, -100px) - 60px), calc(var(--my, -100px) - 60px));
    }

    #cursor3d-fallback {
        width: 48px;
        height: 48px;
        transform: translate(calc(var(--mx, -100px) - 24px), calc(var(--my, -100px) - 24px));
    }
}
@media not all and (hover: hover), (max-width: 768px) {
    #cursor3d,
    #cursor3d-fallback { display: none; }
}

/* Firefox keeps the OS cursor: cursor-boot.js returns before marking ready, so
   .cursor-ready never lands and the rule above never applies. The old
   @-moz-document override is redundant now and was removed. */

/* --- LAYOUT --- */

.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
}

section {
    border-bottom: 1px solid var(--line);
    padding: 80px 0;
}

section:last-of-type {
    border-bottom: none;
}

/* --- Responsive --- */

/* Tablet (769-1024px) */
@media (max-width: 1024px) {
    .page {
        padding: 0 24px;
    }

    section {
        padding: 60px 0;
    }
}

/* Mobile (<=768px) */
@media (max-width: 768px) {
    .page {
        padding: 0 16px;
    }

    section {
        padding: 48px 0;
    }
}

/* Small mobile (<=400px) */
@media (max-width: 400px) {
    .page {
        padding: 0 12px;
    }
}

/* === REVEAL ANIMATION === */

.reveal {
    opacity: 1;
    transform: none;
    transition: opacity 0.8s var(--ease-expo),
                transform 0.8s var(--ease-expo);
}

.reveal.reveal-ready { opacity: 0; transform: translateY(24px); }

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* === WAVE LOADER === */

.wave-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 48px 0;
}

.wave-loader-bar {
    width: 2px;
    height: 20px;
    background: var(--text-3);
    opacity: 0.4;
    animation: waveScale 0.8s var(--ease-quart) infinite alternate;
}

.wave-loader-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-loader-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-loader-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-loader-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveScale {
    0%   { transform: scaleY(0.3); }
    100% { transform: scaleY(1); }
}
