/* =========================================================
   TECHPULSE — BASE / DESIGN SYSTEM
   "Signal Observatory" visual language

   Layers:
     1. Design tokens (dark default + light theme)
     2. Reset & base elements
     3. Typography & shared primitives
        (container, sections, kickers, buttons, chips)
     4. Glass & clay surface systems
     5. Status indicators, banners, a11y, responsive base
   ========================================================= */


/* =========================================================
   1. DESIGN TOKENS — DARK DEFAULT
   ========================================================= */

:root {
    color-scheme: dark;

    /* Surfaces — deep space navy, near-black */
    --bg: #04070d;
    --bg-soft: #070b14;
    --bg-deep: #02040a;
    --surface: #0c1220;
    --surface-hover: #111930;
    --surface-soft: #0a0f1b;
    --surface-raised: #131b2e;

    /* Glass system */
    --glass: rgba(13, 19, 33, 0.52);
    --glass-strong: rgba(15, 22, 38, 0.74);
    --glass-soft: rgba(17, 25, 42, 0.34);
    --glass-border: rgba(151, 170, 208, 0.13);
    --glass-border-strong: rgba(163, 182, 220, 0.22);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --glass-highlight-strong: rgba(255, 255, 255, 0.085);
    --glass-blur: 18px;

    /* Borders */
    --border: #1b2437;
    --border-soft: #151d2d;
    --border-strong: #2a3650;

    /* Text */
    --text: #e9eef8;
    --text-soft: #a9b4c9;
    --text-muted: #6d788d;
    --text-primary: #e9eef8;
    --text-secondary: #c4cddb;

    /* Accent system — luminous mint / electric indigo */
    --accent: #45e5c3;
    --accent-strong: #7ff2da;
    --accent-soft: rgba(69, 229, 195, 0.10);
    --accent-border: rgba(69, 229, 195, 0.30);
    --accent-glow: rgba(69, 229, 195, 0.42);

    --accent-2: #8b93ff;
    --accent-2-soft: rgba(139, 147, 255, 0.12);
    --accent-2-border: rgba(139, 147, 255, 0.32);
    --accent-3: #b78bff;
    --accent-3-soft: rgba(183, 139, 255, 0.12);

    /* Brand gradients */
    --gradient-brand:
        linear-gradient(
            100deg,
            #7ff2da 0%,
            #45e5c3 34%,
            #6fa0ff 68%,
            #a08bff 100%
        );

    --gradient-accent-fade:
        linear-gradient(
            180deg,
            rgba(69, 229, 195, 0.16),
            rgba(69, 229, 195, 0)
        );

    /* Semantics */
    --danger: #ff6b7d;
    --danger-soft: rgba(255, 107, 125, 0.09);
    --danger-border: rgba(255, 107, 125, 0.32);

    --warning: #f5b74e;
    --warning-soft: rgba(245, 183, 78, 0.09);
    --warning-border: rgba(245, 183, 78, 0.30);

    --success: #45e5c3;
    --info: #6ec3ff;

    /* Severity scale */
    --sev-critical: #ff5d73;
    --sev-high: #ff9e64;
    --sev-medium: #ffd166;
    --sev-low: #6ec3ff;
    --sev-none: #9aa8bd;
    --sev-unscored: #6d788d;

    /* Elevation */
    --shadow-sm:
        0 1px 2px rgba(1, 4, 10, 0.6);

    --shadow-md:
        0 10px 28px -10px rgba(1, 4, 10, 0.65);

    --shadow-lg:
        0 24px 60px -18px rgba(1, 4, 10, 0.8);

    /* Clay elevation — soft, volumetric, tactile */
    --clay-shadow:
        0 1px 0 rgba(255, 255, 255, 0.05) inset,
        0 -10px 24px -18px rgba(0, 0, 0, 0.7) inset,
        0 14px 34px -14px rgba(1, 4, 10, 0.72);

    --clay-shadow-hover:
        0 1px 0 rgba(255, 255, 255, 0.07) inset,
        0 -10px 24px -18px rgba(0, 0, 0, 0.7) inset,
        0 22px 48px -16px rgba(1, 4, 10, 0.85);

    --shadow-glow:
        0 0 0 1px var(--accent-border),
        0 10px 36px -10px var(--accent-glow);

    /* Typography */
    --font-display:
        'Space Grotesk',
        'Inter',
        system-ui,
        sans-serif;

    --font-main:
        'Inter',
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        sans-serif;

    --font-mono:
        'DM Mono',
        'SFMono-Regular',
        Menlo,
        Monaco,
        Consolas,
        monospace;

    /* Geometry */
    --container: 1180px;

    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    /* Z-index layers */
    --z-atmosphere: 0;
    --z-content: 1;
    --z-nav: 100;
    --z-mobile-nav: 110;
    --z-skip: 200;

    /* Motion */
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    --dur-fast: 160ms;
    --dur-med: 320ms;
    --dur-slow: 640ms;

    --transition:
        180ms var(--ease);
}


/* =========================================================
   1B. DESIGN TOKENS — LIGHT THEME
   ========================================================= */

:root[data-theme="light"] {
    color-scheme: light;

    --bg: #f2f5f9;
    --bg-soft: #eaeef5;
    --bg-deep: #e3e9f2;

    --surface: #ffffff;
    --surface-hover: #f3f6fb;
    --surface-soft: #f1f4f9;
    --surface-raised: #ffffff;

    --glass: rgba(255, 255, 255, 0.66);
    --glass-strong: rgba(255, 255, 255, 0.84);
    --glass-soft: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(24, 40, 71, 0.10);
    --glass-border-strong: rgba(24, 40, 71, 0.17);
    --glass-highlight: rgba(255, 255, 255, 0.9);
    --glass-highlight-strong: rgba(255, 255, 255, 1);
    --glass-blur: 16px;

    --border: #d4dce8;
    --border-soft: #dfe6ef;
    --border-strong: #b6c2d6;

    --text: #0d1524;
    --text-soft: #3d4a61;
    --text-muted: #67748c;
    --text-primary: #0d1524;
    --text-secondary: #2a3549;

    --accent: #0b8069;
    --accent-strong: #076a57;
    --accent-soft: rgba(11, 128, 105, 0.09);
    --accent-border: rgba(11, 128, 105, 0.32);
    --accent-glow: rgba(11, 128, 105, 0.28);

    --accent-2: #4f56e0;
    --accent-2-soft: rgba(79, 86, 224, 0.08);
    --accent-2-border: rgba(79, 86, 224, 0.28);
    --accent-3: #8a4fd0;
    --accent-3-soft: rgba(138, 79, 208, 0.08);

    --gradient-brand:
        linear-gradient(
            100deg,
            #076a57 0%,
            #0b8069 34%,
            #3552c9 68%,
            #7a3fc0 100%
        );

    --danger: #c9283a;
    --danger-soft: rgba(201, 40, 58, 0.07);
    --danger-border: rgba(201, 40, 58, 0.28);

    --warning: #9a6207;
    --warning-soft: rgba(154, 98, 7, 0.07);
    --warning-border: rgba(154, 98, 7, 0.28);

    --success: #0b8069;
    --info: #0b6aa8;

    --sev-critical: #d3223e;
    --sev-high: #d2622a;
    --sev-medium: #b3820e;
    --sev-low: #2273b8;
    --sev-none: #64748b;
    --sev-unscored: #67748c;

    --shadow-sm:
        0 1px 2px rgba(13, 21, 36, 0.06);

    --shadow-md:
        0 10px 28px -10px rgba(13, 21, 36, 0.14);

    --shadow-lg:
        0 24px 60px -18px rgba(13, 21, 36, 0.22);

    --clay-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 -8px 18px -14px rgba(24, 40, 71, 0.18) inset,
        0 12px 30px -14px rgba(24, 40, 71, 0.25);

    --clay-shadow-hover:
        0 1px 0 rgba(255, 255, 255, 1) inset,
        0 -8px 18px -14px rgba(24, 40, 71, 0.18) inset,
        0 20px 44px -16px rgba(24, 40, 71, 0.32);

    --shadow-glow:
        0 0 0 1px var(--accent-border),
        0 10px 32px -12px var(--accent-glow);
}


/* =========================================================
   2. RESET
   ========================================================= */

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

html {
    min-width: 320px;
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    min-height: 100vh;

    background: var(--bg);
    color: var(--text);

    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.6;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;

    /* Content sits above the fixed atmosphere layer. */
    position: relative;
    z-index: var(--z-content);
}

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

img {
    height: auto;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button,
a,
input,
textarea,
select {
    -webkit-tap-highlight-color: transparent;
}

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

ul,
ol {
    list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

[hidden] {
    display: none !important;
}

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


/* =========================================================
   THEME TRANSITION
   Applied transiently by the theme toggle.
   ========================================================= */

html.theme-transition,
html.theme-transition body,
html.theme-transition .site-header,
html.theme-transition .site-footer,
html.theme-transition .stat-card,
html.theme-transition .panel,
html.theme-transition .release-row,
html.theme-transition .opensource-card,
html.theme-transition .history-card,
html.theme-transition .tracked-project,
html.theme-transition .opensource-signal,
html.theme-transition .history-signal,
html.theme-transition .severity,
html.theme-transition .empty-state,
html.theme-transition .filter-group,
html.theme-transition .chip,
html.theme-transition .button,
html.theme-transition .archive-panel,
html.theme-transition .tech-item,
html.theme-transition .vulnerability-card {
    transition:
        background-color 320ms var(--ease),
        color 320ms var(--ease),
        border-color 320ms var(--ease),
        box-shadow 320ms var(--ease);
}


/* =========================================================
   SCROLLBAR
   ========================================================= */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-pill);
    border: 2px solid var(--bg);
}

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


/* Firefox */
html {
    scrollbar-color:
        var(--border-strong)
        var(--bg);
    scrollbar-width: thin;
}


/* =========================================================
   3. LAYOUT PRIMITIVES
   ========================================================= */

.container {
    width:
        min(
            calc(100% - 48px),
            var(--container)
        );

    margin-inline: auto;
}

.section {
    padding: 108px 0;

    position: relative;
}

.section-muted {
    background: var(--bg-soft);
}

.section-dark {
    background: var(--bg-deep);
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 32px;
    margin-bottom: 48px;
}

.section-heading h2 {
    font-family: var(--font-display);

    font-size:
        clamp(
            28px,
            3vw,
            40px
        );

    line-height: 1.08;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.section-heading p {
    max-width: 520px;

    color: var(--text-muted);

    font-size: 14px;
    line-height: 1.7;
}

.section-link {
    display: inline-flex;
    align-items: center;

    gap: 6px;

    color: var(--text-soft);

    font-size: 14px;
    font-weight: 600;

    white-space: nowrap;

    transition:
        color var(--transition),
        gap var(--transition);
}

.section-link::after {
    content: '→';

    transition:
        transform var(--transition);
}

.section-link:hover {
    color: var(--accent);
}

.section-link:hover::after {
    transform: translateX(3px);
}


/* =========================================================
   TYPOGRAPHY PRIMITIVES
   ========================================================= */

.section-kicker,
.eyebrow {
    display: inline-flex;
    align-items: center;

    gap: 10px;

    margin-bottom: 14px;

    color: var(--accent);

    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;

    letter-spacing: 0.18em;
    line-height: 1.4;

    text-transform: uppercase;
}

/* Signal dashes flanking the kicker text. */
.section-kicker::before,
.section-kicker::after {
    content: '';

    height: 1px;
    width: 18px;

    background:
        linear-gradient(
            90deg,
            transparent,
            var(--accent-border)
        );

    flex: 0 0 auto;
}

.section-kicker::after {
    background:
        linear-gradient(
            90deg,
            var(--accent-border),
            transparent
        );
}

.meta-label,
.stat-label,
.severity,
.project-rank {
    font-family: var(--font-mono);
}

time {
    font-family: var(--font-mono);
}

/* Gradient display text */
.text-gradient {
    background: var(--gradient-brand);

    -webkit-background-clip: text;
    background-clip: text;

    -webkit-text-fill-color: transparent;
    color: transparent;
}


/* =========================================================
   4. SURFACE SYSTEMS — GLASS & CLAY
   ========================================================= */

/* Glass: translucent, blurred, hairline border, top highlight.
   Communicates hierarchy — primary reading surfaces. */
.glass {
    position: relative;

    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);

    background:
        linear-gradient(
            165deg,
            var(--glass-highlight),
            rgba(255, 255, 255, 0) 38%
        ),
        var(--glass);

    -webkit-backdrop-filter:
        blur(var(--glass-blur));
    backdrop-filter:
        blur(var(--glass-blur));

    box-shadow: var(--shadow-md);
}

/* Hairline top edge — the "light catch" on glass edges. */
.glass::before {
    content: '';

    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;

    height: 1px;

    background:
        linear-gradient(
            90deg,
            transparent,
            var(--glass-highlight-strong),
            transparent
        );

    pointer-events: none;
}

/* Clay: soft, volumetric, tactile. Reserved for interactive
   and stat surfaces so hierarchy stays readable. */
.clay {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);

    background:
        linear-gradient(
            170deg,
            var(--glass-highlight),
            rgba(255, 255, 255, 0) 42%
        ),
        var(--surface);

    box-shadow: var(--clay-shadow);
}


/* =========================================================
   BUTTONS
   ========================================================= */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    min-height: 48px;
    padding: 0 26px;

    position: relative;

    border: 1px solid var(--accent-border);
    border-radius: var(--radius-pill);

    background: var(--accent-soft);
    color: var(--accent);

    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;

    overflow: hidden;

    transition:
        background-color var(--transition),
        border-color var(--transition),
        color var(--transition),
        transform var(--transition),
        box-shadow var(--transition);
}

/* Sheen sweep on hover */
.button::after {
    content: '';

    position: absolute;
    inset: 0;

    background:
        linear-gradient(
            115deg,
            transparent 30%,
            rgba(255, 255, 255, 0.12) 50%,
            transparent 70%
        );

    transform: translateX(-110%);

    transition:
        transform 640ms var(--ease);

    pointer-events: none;
}

.button:hover {
    background:
        color-mix(
            in srgb,
            var(--accent) 16%,
            transparent
        );

    border-color: var(--accent);

    color: var(--accent);

    transform: translateY(-2px);

    box-shadow: var(--shadow-glow);
}

.button:hover::after {
    transform: translateX(110%);
}

.button:active {
    transform: translateY(0);
}

.button--ghost {
    border-color: var(--border);
    background: var(--glass-soft);
    color: var(--text-soft);

    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.button--ghost:hover {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}


/* =========================================================
   CHIPS & BADGES
   ========================================================= */

.chip {
    display: inline-flex;
    align-items: center;

    gap: 7px;

    min-height: 27px;
    padding: 5px 13px;

    border: 1px solid var(--border);
    border-radius: var(--radius-pill);

    background: var(--glass-soft);

    color: var(--text-soft);

    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;

    letter-spacing: 0.08em;
    line-height: 1.2;

    text-transform: uppercase;

    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.chip--current {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--accent);

    box-shadow:
        0 0 18px -6px var(--accent-glow);
}

.chip--stale {
    border-color: var(--warning-border);
    background: var(--warning-soft);
    color: var(--warning);
}

.chip--future {
    border-color: var(--accent-2-border);
    background: var(--accent-2-soft);
    color: var(--accent-2);
}


/* =========================================================
   STATUS INDICATORS
   ========================================================= */

.status-dot {
    position: relative;

    display: inline-block;

    width: 8px;
    height: 8px;

    flex: 0 0 8px;

    border-radius: 50%;

    background: var(--accent);

    box-shadow:
        0 0 0 3px var(--accent-soft),
        0 0 12px var(--accent-glow);
}

.status-dot.is-live {
    background: var(--accent);

    box-shadow:
        0 0 0 3px var(--accent-soft),
        0 0 12px var(--accent-glow);
}

.status-dot.is-warning {
    background: var(--warning);

    box-shadow:
        0 0 0 3px var(--warning-soft),
        0 0 12px rgba(245, 183, 78, 0.45);
}

.status-dot.is-error {
    background: var(--danger);

    box-shadow:
        0 0 0 3px var(--danger-soft),
        0 0 12px rgba(255, 107, 125, 0.45);

    animation: none;
}

.status-dot.is-live::after,
.status-dot.is-warning::after {
    content: '';

    position: absolute;
    inset: -2px;

    border-radius: inherit;
}

.pulse {
    animation:
        techpulse-pulse
        2.4s
        var(--ease)
        infinite;
}

@keyframes techpulse-pulse {
    0% {
        box-shadow:
            0 0 0 0
            var(--accent-glow);
    }

    70% {
        box-shadow:
            0 0 0 9px
            rgba(69, 229, 195, 0);
    }

    100% {
        box-shadow:
            0 0 0 0
            rgba(69, 229, 195, 0);
    }
}


/* =========================================================
   ERROR BANNER
   ========================================================= */

.error-banner {
    display: flex;
    align-items: flex-start;

    gap: 12px;

    padding: 14px 18px;
    margin-bottom: 34px;

    border: 1px solid var(--warning-border);
    border-radius: var(--radius-md);

    background: var(--warning-soft);
    color: var(--text-soft);

    font-size: 13px;
    line-height: 1.55;
}

.error-banner strong {
    color: var(--warning);
}

.error-banner[hidden] {
    display: none !important;
}

.error-banner [data-error-detail] {
    display: block;

    margin-top: 2px;

    color: var(--text-muted);

    font-family: var(--font-mono);
    font-size: 11.5px;

    overflow-wrap: anywhere;
}


/* =========================================================
   SCROLL PROGRESS — thin luminous line, top of viewport
   ========================================================= */

.scroll-progress {
    position: fixed;

    top: 0;
    left: 0;

    z-index: calc(var(--z-nav) + 1);

    height: 2px;
    width: 100%;

    transform-origin: 0 50%;
    transform: scaleX(0);

    background: var(--gradient-brand);

    box-shadow:
        0 0 12px var(--accent-glow);

    pointer-events: none;
}


/* =========================================================
   CURSOR SPOTLIGHT — soft pointer-follow light
   (element added by app.js; hidden on touch/reduced motion)
   ========================================================= */

.cursor-spotlight {
    position: fixed;

    top: 0;
    left: 0;

    z-index: 2;

    width: 560px;
    height: 560px;

    border-radius: 50%;

    background:
        radial-gradient(
            circle at center,
            rgba(69, 229, 195, 0.055),
            rgba(111, 160, 255, 0.03) 42%,
            transparent 68%
        );

    transform: translate(-50%, -50%);

    pointer-events: none;

    opacity: 0;

    transition: opacity 600ms var(--ease);

    will-change: transform;
}

.cursor-spotlight.is-active {
    opacity: 1;
}

:root[data-theme="light"] .cursor-spotlight {
    background:
        radial-gradient(
            circle at center,
            rgba(11, 128, 105, 0.05),
            rgba(79, 86, 224, 0.025) 42%,
            transparent 68%
        );
}


/* =========================================================
   SKIP LINK — ACCESSIBILITY
   ========================================================= */

.skip-link {
    position: absolute;

    top: -48px;
    left: 16px;

    z-index: var(--z-skip);

    padding: 10px 16px;

    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);

    background: var(--accent);
    color: var(--bg);

    font-size: 13px;
    font-weight: 600;

    transition:
        top var(--transition);
}

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


/* =========================================================
   FOCUS STATES — ACCESSIBILITY
   ========================================================= */

:focus {
    outline: none;
}

:focus-visible {
    outline:
        2px solid
        var(--accent);

    outline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline:
        2px solid
        var(--accent);

    outline-offset: 3px;
    border-radius: 4px;
}


/* =========================================================
   DISABLED / INERT CONTROLS
   ========================================================= */

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}


/* =========================================================
   TEXT / INTERACTION SAFETY
   ========================================================= */

button,
a,
input,
textarea,
select {
    touch-action: manipulation;
}

code,
pre {
    font-family: var(--font-mono);
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

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

    .cursor-spotlight,
    .scroll-progress {
        display: none !important;
    }

}


/* Printing: reveal-gated content must always be visible, and fixed
   atmosphere layers must not repeat across printed pages. */
@media print {

    .reveal,
    .reveal-item {
        opacity: 1 !important;
        transform: none !important;
    }

    .tp-atmosphere,
    .cursor-spotlight,
    .scroll-progress,
    .site-header {
        display: none !important;
    }

}


/* =========================================================
   RESPONSIVE BASE
   ========================================================= */

@media (max-width: 768px) {

    .container {
        width:
            min(
                calc(100% - 32px),
                var(--container)
            );
    }

    .section {
        padding: 76px 0;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;

        gap: 14px;
        margin-bottom: 32px;
    }

    .section-link {
        white-space: normal;
    }

    .cursor-spotlight {
        display: none;
    }

}

@media (max-width: 480px) {

    .container {
        width:
            min(
                calc(100% - 24px),
                var(--container)
            );
    }

    .section {
        padding: 62px 0;
    }

    .section-heading h2 {
        font-size: 28px;
    }

    .button {
        min-height: 44px;
        padding-inline: 20px;
    }

}
