/**
 * ReBatch Design System - Base Styles
 * Reset, body styles, typography, and overlays
 */

/* variables.css is linked before this file in base.njk (parallel fetch);
   no nested @import here, so the browser never serializes the token fetch. */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: var(--line-height-normal);
    overflow-x: hidden;
    font-size: var(--font-size-base);
}

/* Scanline overlay for subtle CRT effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: var(--z-scanline);
}

/* Pixel grid overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(245, 184, 0, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(245, 184, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: var(--z-overlay);
}

/* Typography */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--line-height-tight);
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

h1 { font-size: var(--font-size-5xl); }
h2 { font-size: var(--font-size-4xl); }
h3 { font-size: var(--font-size-3xl); }
h4 { font-size: var(--font-size-2xl); }

a {
    color: inherit;
    text-decoration: none;
}

/* Container */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* Section Labels */
.section-label {
    display: inline-block;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent-gold-text);
    margin-bottom: var(--space-lg);
    font-weight: 500;
    position: relative;
    padding-left: 1.5rem;
}

.section-label::before {
    content: '//';
    position: absolute;
    left: 0;
    color: var(--accent-gold-text);
}

/* Section Titles */
.section-title {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.section-title span,
.section-title em {
    color: var(--accent-gold-text);
}

.section-title em {
    font-style: italic;
}

/* Section Subtitles/Descriptions */
.section-subtitle,
.section-description {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-weight: 300;
    line-height: var(--line-height-relaxed);
    max-width: 700px;
}

/* Reveal Animation */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* Blink Animation */
@keyframes blink {
    50% { opacity: 0; }
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 0;
}

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

/* ── Accessibility ─────────────────────────────────────────────────────────
   Site-wide keyboard focus, skip link, and reduced-motion honoring. These were
   missing entirely; the terminal aesthetic pairs well with a sharp focus ring. */

/* Visible keyboard focus for interactive elements (mouse clicks stay clean). */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Skip-to-content: hidden until focused, then pinned top-left. */
.skip-link {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateY(-120%);
    z-index: var(--z-overlay);
    background: var(--accent-gold);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: transform var(--transition-fast);
}

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

main:focus {
    outline: none;
}

/* Honor prefers-reduced-motion for CSS animations/transitions and smooth scroll.
   The canvas scripts already check the media query in JS; this covers the rest
   (blink, deployment pulses/flows, .reveal, smooth anchor scrolling). */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}
