/* Display font */
@font-face {
    font-family: 'GageEXO';
    src: url('/fonts/GageEXO-Regular.woff2') format('woff2');
    font-display: swap;
}

/* IBM Plex Sans (variable) */
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('/fonts/IBM Plex Sans Var-Roman.woff2') format('woff2');
    font-weight: 100 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('/fonts/IBM Plex Sans Var-Italic.woff2') format('woff2');
    font-weight: 100 700;
    font-style: italic;
    font-display: swap;
}

/* IBM Plex Mono */
@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('/fonts/IBMPlexMono-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* =========================================================
   DESIGN TOKENS
   ========================================================= */
:root {
    --bg-deep: #030510;
    --bg: #060916;
    --bg-surface: #0a1028;
    --border: #1a2848;

    --text-primary: #d2ddf0;
    --text-dim: #8098c0;
    --text-faint: #506a98;
    --text-bright: #f0f4fc;

    --accent: #4a9eff;
    --accent-bright: #7ec8ff;
    --accent-rgb: 74, 158, 255;

    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Type scale — 4 sizes + display */
    --heading: 1.25rem;
    --body: 1rem;
    --small: 0.85rem;
    --xs: 0.75rem;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;

    --max-width: 900px;

    --bulge-strength: 0.14;
    --bulge-radius-x: 760;
    --bulge-radius-y: 520;
    --bulge-edge-pull-x: 28;
    --bulge-edge-pull-y: 6;
    --bulge-scale-center: 1.018;
    --bulge-tilt: 0.42;
}

/* =========================================================
   RESET & BASE
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 20px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.65;
    color: var(--text-primary);
    background: var(--bg);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Phosphor glow + chromatic fringe on all text */
    text-shadow:
        0 0 0.2em rgba(var(--accent-rgb), 0.08),
        1px 1px rgba(255, 0, 255, 0.2),
        -1px -1px rgba(0, 255, 255, 0.16);
    transition: text-shadow 0.15s ease, background-color 0.4s ease;
}

/* =========================================================
   TEXTURE: FILM GRAIN
   256x256 noise tile with subtle color variation (slight
   per-channel offsets for a film-stock feel, not pure gray).
   Generated once by JS at bottom of page.
   ========================================================= */
#grain-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.10;
    mix-blend-mode: overlay;
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* =========================================================
   TEXTURE: SCANLINES
   RGB-fringe variant — alternating cyan/purple tint lines
   with a dark bar, referencing CRT phosphor rows.
   Sits above grain so it isn't washed out.
   ========================================================= */
#scanlines {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: repeating-linear-gradient(to bottom,
            rgba(120, 200, 220, 0.035) 0px,
            rgba(255, 255, 255, 0.02) 1px,
            rgba(160, 100, 200, 0.025) 2px,
            rgba(0, 0, 0, 0.18) 3px,
            transparent 4px);
}

/* =========================================================
   TEXTURE: PHOSPHOR DOT MASK
   Two overlapping RGB stripe grids (horizontal + vertical)
   with overlay blending simulate the subpixel phosphor
   structure visible on real CRT screens under magnification.
   ========================================================= */
#phosphor-mask {
    position: fixed;
    inset: 0;
    z-index: 9997;
    pointer-events: none;
}

/* Horizontal RGB phosphor stripes only */
#phosphor-mask::before {
    content: '';
    position: absolute;
    inset: 0;
    mix-blend-mode: overlay;
    opacity: 0.55;
    background: repeating-linear-gradient(to bottom,
            rgba(218, 49, 49, 0.15) 0px,
            rgba(112, 159, 115, 0.15) 2px,
            rgba(40, 129, 206, 0.15) 4px);
}

/* =========================================================
   LAYOUT
   ========================================================= */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

section {
    padding: var(--space-xl) 0;
}

/* =========================================================
   NAV
   ========================================================= */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0.7rem 0;
}

.site-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-family: 'GageEXO', sans-serif;
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    font-feature-settings: 'ss01' 1;
    transform: scaleX(1.2);
    transform-origin: left center;
    line-height: 1;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s, text-shadow 0.2s;
    animation: fade-down 0.6s cubic-bezier(0.16, 1, 0.3, 1) 1.6s both;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    list-style: none;
}

.nav-links a {
    font-family: var(--font-body);
    font-size: var(--body);
    color: var(--text-dim);
    text-decoration: none;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color 0.2s;
    animation: fade-down 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.nav-links li:nth-child(1) a { animation-delay: 1.75s; }
.nav-links li:nth-child(2) a { animation-delay: 1.9s; }

.nav-links a:visited,
.footer-link:visited {
    color: var(--text-dim);
    text-decoration: none;
}

.footer-link {
    font-family: var(--font-body);
    font-size: var(--small);
    color: var(--text-dim);
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: color 0.2s;
}

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

.nav-links a:hover {
    color: var(--accent-bright);
}

/* =========================================================
   SECTION LABELS
   ========================================================= */
.section-label {
    font-family: var(--font-mono);
    font-size: var(--heading);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(1.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-down {
    from {
        opacity: 0;
        transform: translateY(-0.6rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
    flex: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100vh;
    padding-top: 5rem;
    position: relative;
}

.hero-name {
    font-family: 'GageEXO', sans-serif;
    font-size: clamp(4.5rem, 12vw, 8rem);
    font-weight: 400;
    line-height: 1.1;
    color: var(--text-bright);
    margin-bottom: var(--space-sm);
    animation: fade-up 1.6s cubic-bezier(0.16, 1, 0.3, 1) both;
    text-shadow:
        0 0 60px rgba(var(--accent-rgb), 0.2),
        0 0 120px rgba(var(--accent-rgb), 0.06),
        2px 1px rgba(255, 0, 255, 0.3),
        -2px -1px rgba(0, 255, 255, 0.25);
    transition: text-shadow 0.15s ease;
}

.hero-role {
    font-family: var(--font-body);
    font-size: var(--heading);
    font-weight: 500;
    color: var(--accent);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.02em;
}

.hero-tagline {
    font-size: var(--body);
    font-weight: 300;
    color: var(--text-dim);
    line-height: 1.6;
}

.alt-a {
    font-feature-settings: 'ss01' 1;
}

/* =========================================================
   OPHAN
   ========================================================= */
@keyframes ophan-fade-in {
    from { opacity: 0; }
    to   { opacity: 0.1; }
}

#ophan {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    opacity: 0.1;
    pointer-events: none;
    animation: ophan-fade-in 2s ease 1.4s both;
}

.hero .container {
    position: relative;
    z-index: 1;
}

/* =========================================================
   ABOUT
   ========================================================= */
.about-text {
    font-size: var(--body);
    color: var(--text-primary);
    line-height: 1.7;
}

.about-text strong {
    color: var(--text-bright);
    font-weight: 500;
}

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
    padding: 2rem 0;
    margin-top: var(--space-xl);
    position: relative;
    z-index: 1;
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.footer-text {
    font-family: var(--font-body);
    font-size: var(--small);
    color: var(--text-faint);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cc-link {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    text-decoration: none;
    color: var(--text-faint);
    filter: drop-shadow(1px 1px rgba(255, 0, 255, 0.2))
            drop-shadow(-1px -1px rgba(0, 255, 255, 0.16));
    transition: color 0.2s, filter 0.15s;
}

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

.cc-icon {
    display: inline-block;
    width: 26px;
    height: 26px;
    background-color: currentColor;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
}

.cc-icon--cc {
    mask-image: url('/cc-icon.svg');
    -webkit-mask-image: url('/cc-icon.svg');
}

.cc-icon--by {
    mask-image: url('/by-icon.svg');
    -webkit-mask-image: url('/by-icon.svg');
}

/* =========================================================
   CRT TOGGLE SWITCH
   ========================================================= */
.crt-toggle {
    display: flex;
    align-items: center;
    gap: 0.5em;
    cursor: pointer;
    animation: fade-down 0.6s cubic-bezier(0.16, 1, 0.3, 1) 2.05s both;
}

.crt-toggle-icon {
    color: var(--text-faint);
    transition: color 0.2s, filter 0.15s;
}

.crt-toggle:hover .crt-toggle-icon {
    color: var(--accent);
    filter: drop-shadow(-2px 0 rgba(255, 50, 50, 0.5)) drop-shadow(2px 0 rgba(50, 50, 255, 0.5));
}

/* Hide the actual checkbox */
.crt-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Checked state — TV on */
.tv-screen {
    fill: transparent;
    transition: fill 0.3s, filter 0.3s;
}

.crt-toggle input:checked ~ .crt-toggle-icon .tv-screen {
    fill: currentColor;
    filter: drop-shadow(0 0 4px currentColor);
}

.crt-toggle input:checked ~ .crt-toggle-icon {
    color: var(--text-dim);
}

/* =========================================================
   CRT BULGE
   ========================================================= */
[data-bulge] {
    transform-origin: center center;
    will-change: transform, filter;
}

body.bulge-toggling [data-bulge] {
    transition: transform 0.22s ease, filter 0.22s ease;
}

/* When texture is off, overlays + chromatic effects fade */
.texture-off #grain-overlay,
.texture-off #scanlines,
.texture-off #phosphor-mask {
    opacity: 0;
}

.texture-off {
    text-shadow: none;
    /* Restore lighter background when CRT is off */
    --bg: #0b1022;
    --bg-deep: #070b14;
    --bg-surface: #101830;
}

.texture-off .hero-name {
    text-shadow: none;
}

.texture-off .cc-link {
    filter: none;
}

#grain-overlay,
#scanlines,
#phosphor-mask {
    transition: opacity 0.4s ease;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 680px) {
    .nav-links {
        gap: var(--space-sm);
    }

    .nav-links a {
        font-size: 0.7rem;
    }
}
