/**
 * NextForLab — element defaults, shared utilities and motion preferences.
 *
 * Single responsibility: page-level foundations. Named components live in
 * css/components.css; theme values in css/tokens.css, which must load first.
 */

/*
 * Fonts are self-hosted via css/fonts.css, which the page links before this
 * file — no @import here, since that would serialise the download behind this
 * stylesheet. Archivo 400/500/700/900 and JetBrains Mono 400/500 are shipped.
 */

/* ---------------------------------------------------------------- elements */

html {
    scroll-behavior: smooth;
    font-family: 'Archivo', ui-sans-serif, system-ui, sans-serif;
    /* iOS Safari inflates text when a phone is rotated to landscape unless this
       is pinned, which silently breaks every measured line length. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/*
 * Touch feedback on the site's own accent instead of the grey-blue box mobile
 * browsers paint by default. Kept visible rather than transparent: removing it
 * entirely leaves a tap feeling unacknowledged on a slow connection.
 */
a,
button,
[role='button'],
label,
summary {
    -webkit-tap-highlight-color: rgb(233 70 61 / 18%);
}

/* Breathing room above in-page anchor targets. */
[id] {
    scroll-margin-top: 24px;
}

body.modal-open {
    overflow: hidden;
}

hr {
    border-color: var(--hr-color);
    border-style: solid;
}

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

/* ------------------------------------------------------------ a11y basics */

/* One consistent, always-visible keyboard focus treatment. */
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: 60;
    padding: 12px 18px;
    background-color: var(--accent-500);
    color: var(--on-accent);
    font-weight: 500;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 8px;
}

/* -------------------------------------------------------------- utilities */

/*
 * Monospace micro-label — the small uppercase markers that caption every
 * section. The slash prefix is generated so the copy itself stays clean.
 */
.tag-label {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.tag-label::before {
    content: '// ';
    letter-spacing: normal;
}

/* 11px of wide-tracked monospace is legible on a desktop display and marginal
   on a phone held at arm's length, so the micro-labels step up one notch. */
@media (max-width: 767px) {
    .tag-label {
        font-size: 0.75rem;
        letter-spacing: 0.18em;
    }
}

.surface-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
}

/*
 * Decorative signal bars — short horizontal dashes that mark section seams.
 * Purely presentational; always paired with aria-hidden in the markup.
 */
.glitch-bars {
    display: flex;
    gap: 6px;
}

.glitch-bars i {
    height: 3px;
    background-color: var(--accent-500);
}

.glitch-bars i:nth-child(1) { width: 34px; }
.glitch-bars i:nth-child(2) { width: 12px; opacity: 0.75; }
.glitch-bars i:nth-child(3) { width: 52px; opacity: 0.5; }
.glitch-bars i:nth-child(4) { width: 8px; opacity: 0.3; }

/* Variant for placement on the accent field, where the bars go near-black. */
.glitch-bars--dark i {
    background-color: #140a06;
}

/* ------------------------------------------------------------- animations */

/*
 * Starting state for scroll reveals; scripts/reveal.js adds .is-visible.
 * With JavaScript off, the <noscript> style block in src/partials/head.html
 * forces these visible so the page is never left blank.
 */
.reveal-up {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-up.is-visible {
    opacity: 1;
    transform: none;
}

/* ------------------------------------------------------ motion and print */

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

    .reveal-up,
    .reveal-up.is-visible {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .marquee__track,
    .caret::after {
        animation: none;
    }

    .console {
        --console-tilt: 0deg;
        --console-scale: 1;
    }
}

@media print {
    header,
    footer,
    .glitch-bars {
        display: none;
    }
}
