/* ============================================================
   [ BASE // SUBSTRATE LAYER ]
   ------------------------------------------------------------
   UNIT / D-02 RESET + GLOBALS
   REV  / 2.7  SWISS INDUSTRIAL PRINT
   ------------------------------------------------------------
   Enforces: 90° corners, monospace default, uppercase chrome,
   paper grain, carbon-ink text.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Archivo+Black&family=Inter:wght@400;600;800;900&family=JetBrains+Mono:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500;700&family=Playfair+Display:wght@700&display=swap");

/* --- reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-radius: 0 !important;
}

html {
    font-size: 16px;
    scroll-behavior: auto;
    height: 100%;
    background: var(--sub-void);
}

body {
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--fg-phosphor);
    background-color: var(--sub-void);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    letter-spacing: var(--track-micro);
    text-transform: uppercase;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

/* PAPER GRAIN — unified physical print grain, darkens highlights via multiply */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.09;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    mix-blend-mode: multiply;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-macro);
    font-weight: var(--font-weight-black);
    letter-spacing: var(--track-macro);
    line-height: var(--line-height-tight);
    color: var(--fg-phosphor);
    margin: 0 0 var(--spacing-md) 0;
    text-transform: uppercase;
}

h1 { font-size: var(--font-size-4xl); line-height: 0.88; }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); letter-spacing: -0.02em; }
h5 { font-size: var(--font-size-lg); letter-spacing: 0; }
h6 {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--track-micro);
}

p {
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--fg-dim);
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    letter-spacing: var(--track-micro);
    text-transform: none;
}

a {
    color: var(--fg-phosphor);
    text-decoration: none;
    border-bottom: 1px solid var(--alert-red);
    transition: color var(--transition-fast), background var(--transition-fast);
}

a:hover {
    color: var(--on-accent);
    background: var(--alert-red);
}

/* semantic technical tags */
data, samp, kbd, output, var, code, pre, time {
    font-family: var(--font-mono);
    font-size: inherit;
    color: var(--fg-phosphor);
    letter-spacing: var(--track-micro);
    text-transform: uppercase;
}

kbd {
    border: 1px solid var(--sub-rule-hi);
    padding: 1px 6px;
    background: var(--sub-panel);
    font-size: var(--font-size-xs);
}

code {
    background: var(--sub-rack);
    border: 1px solid var(--sub-rule);
    padding: 2px 6px;
    color: var(--fg-phosphor);
    text-transform: none;
}

pre {
    background: var(--sub-rack);
    border: 1px solid var(--sub-rule);
    padding: var(--spacing-lg);
    overflow-x: auto;
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--fg-phosphor);
    text-transform: none;
    font-size: var(--font-size-sm);
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

/* hr = ruling line spanning container */
hr {
    border: 0;
    border-top: 1px solid var(--sub-rule);
    margin: var(--spacing-lg) 0;
}

/* lists */
ul, ol {
    margin: 0 0 var(--spacing-lg) 0;
    padding-left: var(--spacing-xl);
    color: var(--fg-dim);
    font-family: var(--font-mono);
    text-transform: none;
}

li {
    margin-bottom: var(--spacing-xs);
}

/* images — print-style contrast, softened for light substrate */
img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--sub-rule-hi);
    filter: grayscale(0.2) contrast(1.08);
}

/* --- focus --- */
:focus {
    outline: 2px solid var(--alert-red);
    outline-offset: 0;
}
:focus:not(:focus-visible) {
    outline: none;
}

/* --- selection --- */
::selection {
    background: var(--alert-red);
    color: var(--on-accent);
}

/* --- scrollbars (mechanical rails) --- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--sub-rack);
    border-left: 1px solid var(--sub-rule);
}
::-webkit-scrollbar-thumb {
    background: var(--fg-phosphor);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--alert-red);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.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;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* tactical text helpers */
.mono { font-family: var(--font-mono) !important; letter-spacing: var(--track-micro); }
.macro { font-family: var(--font-macro) !important; letter-spacing: var(--track-macro); font-weight: 900; text-transform: uppercase; }
.serif-degraded {
    font-family: var(--font-serif);
    font-weight: 700;
    filter: contrast(1.4) url("#dither");
    text-transform: none;
}
.upper { text-transform: uppercase; }
.track-wide { letter-spacing: 0.12em; }

.unit-tag {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.unit-tag::before { content: "[ "; color: var(--alert-red); }
.unit-tag::after  { content: " ]"; color: var(--alert-red); }

.alert-red { color: var(--alert-red) !important; }
.bg-alert-red { background: var(--alert-red) !important; color: var(--on-accent) !important; }

/* crosshair marker */
.crosshair {
    position: relative;
}
.crosshair::before {
    content: "+";
    position: absolute;
    color: var(--alert-red);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1;
}

/* warning stripe */
.warn-stripe {
    background: repeating-linear-gradient(
        -45deg,
        var(--alert-red) 0 10px,
        var(--sub-void) 10px 20px
    );
    height: 14px;
    width: 100%;
}

/* barcode */
.barcode {
    display: inline-block;
    background: repeating-linear-gradient(
        90deg,
        var(--fg-phosphor) 0 1px,
        transparent 1px 2px,
        var(--fg-phosphor) 2px 4px,
        transparent 4px 5px,
        var(--fg-phosphor) 5px 7px,
        transparent 7px 10px
    );
    height: 18px;
    min-width: 80px;
}

/* animations — kept but mechanical */
.animate-spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.animate-pulse { animation: pulse-hard 1.1s steps(2, end) infinite; }
@keyframes pulse-hard { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.35; } }

.animate-bounce { animation: none; }

@media (max-width: 768px) {
    html { font-size: 14px; }
    body { letter-spacing: 0.06em; }
    h1 { font-size: clamp(2.2rem, 10vw, 4rem); }
    h2 { font-size: var(--font-size-2xl); }
    h3 { font-size: var(--font-size-xl); }
}

@media (max-width: 480px) {
    html { font-size: 13px; }
}
