/* ============================================
   ANDY SWAN — V2
   Immersive, cinematic, confident
   ============================================ */

:root {
    --bg: #050508;
    --bg-elevated: #0a0a10;
    --bg-card: #0d0d16;

    --white: #f0f0f5;
    --gray-100: #c8c8d4;
    --gray-200: #8888a0;
    --gray-300: #555568;
    --gray-400: #333342;
    --gray-500: #1a1a24;

    --blue: #00b4ff;
    --cyan: #00e5c8;
    --pink: #ff2d7b;
    --violet: #8b5cf6;
    --btc: #f7931a;

    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-400) var(--bg);
    font-size: 16px;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--white);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

code {
    font-family: var(--mono);
    color: var(--blue);
    background: rgba(0, 180, 255, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

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

/* --- Three.js Scene --- */
#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#scene-container canvas {
    display: block;
}

/* --- Film Grain --- */
.grain {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    animation: grain 0.5s steps(1) infinite;
}

@keyframes grain {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -10%); }
    20% { transform: translate(-15%, 5%); }
    30% { transform: translate(7%, -25%); }
    40% { transform: translate(-5%, 25%); }
    50% { transform: translate(-15%, 10%); }
    60% { transform: translate(15%, 0%); }
    70% { transform: translate(0%, 15%); }
    80% { transform: translate(3%, 35%); }
    90% { transform: translate(-10%, 10%); }
    100% { transform: translate(0, 0); }
}

/* --- Navigation --- */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 48px;
    height: 72px;
    transition: background 0.5s ease, backdrop-filter 0.5s ease;
}

.nav.scrolled {
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.nav-wordmark {
    font-family: var(--mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.15em;
    transition: color 0.3s ease;
}

.nav-wordmark:hover {
    color: var(--btc);
}

.nav-links {
    display: flex;
    gap: 40px;
}

.nav-links a {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--gray-200);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: color 0.3s ease;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 1px;
    background: var(--blue);
    transition: width 0.4s var(--ease);
}

.nav-links a:hover { color: var(--white); }
.nav-links a:hover::after { width: 100%; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 24px;
    position: relative;
    z-index: 101;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 1.5px;
    background: var(--white);
    transition: all 0.3s ease;
    position: absolute;
    left: 0;
}

.nav-toggle span:first-child { top: 4px; }
.nav-toggle span:last-child { bottom: 4px; }

.nav-toggle.active span:first-child {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}
.nav-toggle.active span:last-child {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

.mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(5, 5, 8, 0.96);
    backdrop-filter: blur(30px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 48px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.mobile-nav.active {
    opacity: 1;
    pointer-events: all;
}

.mobile-nav a {
    font-family: var(--mono);
    font-size: 1.2rem;
    color: var(--gray-200);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.mobile-nav a:hover { color: var(--white); }

/* ====== HERO ====== */
.hero {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 48px;
}

.hero-inner {
    text-align: center;
    max-width: 1000px;
}

.hero-pre {
    font-family: var(--mono);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: var(--blue);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 32px;
    opacity: 0;
    animation: fade-in 1s 0.2s forwards;
}

.hero-name {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-bottom: 32px;
}

.hero-line {
    font-size: clamp(4.5rem, 15vw, 12rem);
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -0.04em;
    display: block;
    position: relative;
    opacity: 0;
    transform: translateY(60px);
    animation: hero-reveal 1s var(--ease) forwards;
}

.hero-line:nth-child(1) { animation-delay: 0.3s; }
.hero-line:nth-child(2) { animation-delay: 0.45s; }

/* Glitch on hover only */
.hero-line {
    transition: text-shadow 0.1s ease;
}

.hero-name:hover .hero-line {
    animation: hero-glitch 0.3s steps(2) infinite;
}

@keyframes hero-glitch {
    0% { text-shadow: 2px 0 var(--btc), -2px 0 var(--blue); }
    25% { text-shadow: -2px 0 var(--pink), 2px 0 var(--btc); }
    50% { text-shadow: 2px 2px var(--btc), -2px -2px var(--blue); }
    75% { text-shadow: -1px 0 var(--blue), 1px 0 var(--btc); }
    100% { text-shadow: 2px 0 var(--btc), -2px 0 var(--blue); }
}

@keyframes hero-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-sub {
    font-family: var(--mono);
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    color: var(--gray-200);
    min-height: 1.6em;
    opacity: 0;
    animation: fade-in 1s 0.8s forwards;
}

.hero-scroll {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fade-in 1s 1.5s forwards;
}

.hero-scroll-line {
    width: 1px;
    height: 48px;
    background: linear-gradient(180deg, var(--blue), transparent);
    animation: scroll-breathe 2.5s ease-in-out infinite;
}

@keyframes scroll-breathe {
    0%, 100% { opacity: 0.2; transform: scaleY(0.6); }
    50% { opacity: 1; transform: scaleY(1); }
}

/* ====== MARQUEE ====== */
.marquee {
    position: relative;
    z-index: 2;
    overflow: hidden;
    padding: 20px 0;
    border-top: 1px solid var(--gray-400);
    border-bottom: 1px solid var(--gray-400);
    background: var(--bg);
}

.marquee-track {
    display: flex;
    gap: 48px;
    white-space: nowrap;
    animation: marquee-scroll 40s linear infinite;
    width: max-content;
}

.marquee-track span {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--gray-200);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    flex-shrink: 0;
}

.marquee-track span::before {
    content: '◆';
    margin-right: 48px;
    color: var(--gray-400);
    font-size: 0.5em;
    vertical-align: middle;
}

.marquee-track .btc-accent {
    color: var(--btc);
}

.marquee-track .btc-accent::before {
    color: var(--btc);
}

@keyframes marquee-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ====== SECTIONS ====== */
.section {
    position: relative;
    z-index: 2;
    padding: 80px 48px;
}

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

.section-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.section-narrow {
    max-width: 720px;
}

.section-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--blue);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 32px;
}

.section-desc {
    font-size: 1.05rem;
    color: var(--gray-200);
    max-width: 550px;
    line-height: 1.7;
    margin-bottom: 40px;
}

/* ====== RESUME STRIP ====== */
.resume {
    position: relative;
    z-index: 2;
    background: var(--bg);
    border-bottom: 1px solid var(--gray-400);
}

.resume-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.resume-item {
    display: grid;
    grid-template-columns: 140px 140px 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 20px 48px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.3s ease;
    cursor: default;
    text-decoration: none;
    color: inherit;
}

a.resume-item {
    cursor: pointer;
}

a.resume-item:hover {
    background: rgba(0, 180, 255, 0.03);
}

.resume-role {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.resume-company {
    font-size: 1rem;
    font-weight: 600;
}

.resume-detail {
    font-size: 0.88rem;
    color: var(--gray-200);
}

.resume-arrow {
    font-family: var(--mono);
    color: var(--blue);
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 0.85rem;
}

a.resume-item:hover .resume-arrow {
    opacity: 1;
}

/* ====== LAB ====== */
.lab-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 40px;
}

.lab-intro {
    font-size: 1.05rem;
    color: var(--gray-200);
    line-height: 1.7;
    margin-top: 12px;
}

/* --- Featured / Latest Project Card --- */
.lab-featured {
    display: block;
    position: relative;
    background: var(--bg-card);
    border: 1px solid rgba(0, 180, 255, 0.15);
    border-radius: 16px;
    padding: 36px;
    margin-bottom: 32px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: all 0.4s var(--ease);
    overflow: hidden;
}

.lab-featured::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 180, 255, 0.04) 0%, rgba(139, 92, 246, 0.03) 50%, transparent 100%);
    opacity: 1;
    transition: opacity 0.4s ease;
}

.lab-featured:hover {
    border-color: rgba(0, 180, 255, 0.35);
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3), 0 0 30px rgba(0, 180, 255, 0.06);
}

.lab-featured-badge {
    position: relative;
    z-index: 1;
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--bg);
    background: var(--blue);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.lab-featured-body {
    position: relative;
    z-index: 1;
}

.lab-featured-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.lab-featured-desc {
    font-size: 0.95rem;
    color: var(--gray-200);
    line-height: 1.7;
    max-width: 600px;
    margin-bottom: 20px;
}

.lab-featured-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lab-featured-tags span {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--gray-200);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 12px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.lab-featured-cta {
    position: absolute;
    bottom: 36px;
    right: 36px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--blue);
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.4s var(--ease);
}

.lab-featured:hover .lab-featured-cta {
    opacity: 1;
    transform: translateX(0);
}

.lab-list {
    border-top: 1px solid var(--gray-400);
}

.lab-item {
    display: grid;
    grid-template-columns: 40px 1fr 2fr auto auto;
    align-items: center;
    gap: 24px;
    padding: 24px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.lab-item:hover {
    background: rgba(0, 180, 255, 0.03);
    padding-left: 16px;
    padding-right: 16px;
    margin-left: -16px;
    margin-right: -16px;
    border-radius: 8px;
}

.lab-item-num {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--gray-400);
}

.lab-item-name {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.lab-item-desc {
    font-size: 0.88rem;
    color: var(--gray-200);
}

.lab-item-tag {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.lab-item-tag.live {
    color: var(--cyan);
    background: rgba(0, 229, 200, 0.08);
}

.lab-item-arrow {
    color: var(--blue);
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.3s var(--ease);
    display: flex;
}

.lab-item:hover .lab-item-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ====== TERMINAL ====== */
.terminal {
    max-width: 750px;
    margin: 0 auto;
    background: var(--bg);
    border: 1px solid var(--gray-400);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.terminal-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--gray-400);
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.terminal-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.terminal-dots span:nth-child(1) { background: #ff5f57; }
.terminal-dots span:nth-child(2) { background: #ffbd2e; }
.terminal-dots span:nth-child(3) { background: #28c840; }

.terminal-title {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--gray-300);
}

.terminal-body {
    padding: 24px;
    min-height: 320px;
    max-height: 480px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.8;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-400) transparent;
}

.terminal-body::-webkit-scrollbar { width: 4px; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 2px; }

.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.prompt {
    color: var(--blue);
    user-select: none;
}

#terminal-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--white);
    font-family: var(--mono);
    font-size: 0.82rem;
    outline: none;
    caret-color: var(--blue);
}

#terminal-input::placeholder {
    color: var(--gray-400);
}

.t-line {
    margin-bottom: 1px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.t-cmd { color: var(--white); }
.t-cmd .cmd-val { color: var(--blue); }
.t-blue { color: var(--blue); }
.t-cyan { color: var(--cyan); }
.t-pink { color: var(--pink); }
.t-violet { color: var(--violet); }
.t-btc { color: var(--btc); }
.t-muted { color: var(--gray-300); }
.t-dim { color: var(--gray-400); }
.t-bold { font-weight: 700; }
.t-head { color: var(--blue); font-weight: 700; margin-top: 8px; }

/* ====== CONNECT / X FEATURED ====== */
.connect-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 64px;
    align-items: start;
}

.x-intro {
    font-size: 1.05rem;
    color: var(--gray-200);
    line-height: 1.7;
    margin-bottom: 24px;
    margin-top: 12px;
}

.x-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    background: var(--white);
    color: var(--bg);
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 100px;
    transition: all 0.3s var(--ease);
    margin-bottom: 32px;
}

.x-follow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 255, 255, 0.15);
}

.x-logo {
    font-size: 1.1rem;
    font-weight: 800;
}

.x-embed {
    border: 1px solid var(--gray-400);
    border-radius: 12px;
    overflow: hidden;
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-400) transparent;
}

.x-embed::-webkit-scrollbar { width: 4px; }
.x-embed::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 2px; }

.connect-side {
    padding-top: 0;
}

.connect-links-stacked {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-400);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 32px;
}

.connect-link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.3s ease;
}

.connect-link-row:last-child {
    border-bottom: none;
}

.connect-link-row:hover {
    background: rgba(0, 180, 255, 0.03);
}

.connect-link-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.connect-link-handle {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--gray-200);
}

.connect-cta {
    font-size: 1rem;
    color: var(--gray-200);
    line-height: 1.6;
}

/* ====== FOOTER ====== */
.footer {
    position: relative;
    z-index: 2;
    padding: 32px 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--gray-400);
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--gray-300);
}

/* ====== ANIMATIONS ====== */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.reveal-up {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

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

/* Stagger */
.reveal-up:nth-child(1) { transition-delay: 0s; }
.reveal-up:nth-child(2) { transition-delay: 0.08s; }
.reveal-up:nth-child(3) { transition-delay: 0.16s; }
.reveal-up:nth-child(4) { transition-delay: 0.24s; }
.reveal-up:nth-child(5) { transition-delay: 0.32s; }
.reveal-up:nth-child(6) { transition-delay: 0.40s; }

/* ====== RESPONSIVE ====== */
@media (max-width: 900px) {
    .resume-item {
        grid-template-columns: 100px 1fr auto;
        padding: 16px 32px;
    }
    .resume-detail {
        display: none;
    }
    .lab-featured { padding: 28px; }
    .lab-featured-title { font-size: 1.4rem; }
    .lab-featured-cta { position: static; opacity: 1; transform: none; margin-top: 16px; }
    .lab-item {
        grid-template-columns: 1fr auto auto;
        gap: 16px;
    }
    .lab-item-num,
    .lab-item-desc {
        display: none;
    }
    .connect-layout {
        grid-template-columns: 1fr;
        gap: 48px;
    }
}

@media (max-width: 768px) {
    .nav { padding: 0 24px; }
    .nav-links { display: none; }
    .nav-toggle { display: block; }
    .mobile-nav { display: flex; }

    .hero { padding: 0 24px; }
    .section { padding: 64px 24px; }

    .resume-item {
        padding: 14px 24px;
    }

    .footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .hero-line {
        font-size: 3.5rem;
    }
}

/* ====== MATRIX RAIN ====== */
.matrix-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.matrix-overlay.active {
    opacity: 1;
}

.matrix-overlay canvas {
    width: 100%;
    height: 100%;
}
