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

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

button {
    font: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

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

ul,
ol {
    list-style: none;
}

/* ─── DESIGN TOKENS (LIGHT THEME DEFAULT) ─────────────────────────── */
:root {
    --font-serif: "Crimson Pro", Georgia, serif;
    --font-sans: "Inter", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", monospace;

    --bg-base: #f5f4ef;
    --bg-card: #ffffff;
    --bg-alt: #ebeae4;
    --bg-glow: rgba(190, 18, 60, 0.05);

    --fg-base: #111215;
    --fg-muted: #4e5159;
    --fg-subtle: #7d828f;

    --primary: #be123c;
    --primary-hover: #9f1239;
    --accent: #10b981;

    --border: rgba(17, 18, 21, 0.08);
    --border-strong: rgba(17, 18, 21, 0.15);

    --grid-color: rgba(17, 18, 21, 0.08);
    --grid-size: 40px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.03);

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 16px;
    --radius-circle: 9999px;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── DARK THEME OVERRIDES ────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-base: #0b0c0e;
    --bg-card: #121316;
    --bg-alt: #17191c;
    --bg-glow: rgba(225, 29, 72, 0.03);

    --fg-base: #e2e4e9;
    --fg-muted: #9fa4b0;
    --fg-subtle: #676b75;

    --primary: #e11d48;
    --primary-hover: #be123c;
    --accent: #10b981;

    --border: rgba(226, 228, 233, 0.07);
    --border-strong: rgba(226, 228, 233, 0.15);
    --grid-color: rgba(226, 228, 233, 0.065);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ─── TYPOGRAPHY & BODY ───────────────────────────────────────────── */
html {
    scroll-behavior: smooth;
    font-size: 16px;
    background-color: var(--bg-base);
    transition: background-color var(--transition-base);
}

body {
    font-family: var(--font-sans);
    color: var(--fg-base);
    line-height: 1.625;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: color var(--transition-base);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 1) 20%, rgba(0, 0, 0, 0) 78%);
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 1) 20%, rgba(0, 0, 0, 0) 78%);
    pointer-events: none;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    z-index: 9999;
    transition: top var(--transition-fast);
}

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

/* ─── HEADER & NAVIGATION ─────────────────────────────────────────── */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background-color: rgba(245, 244, 239, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

[data-theme="dark"] .site-header {
    background-color: rgba(11, 12, 14, 0.85);
}

.site-header.scrolled {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(17, 18, 21, 0.12);
}

[data-theme="dark"] .site-header.scrolled {
    background-color: rgba(11, 12, 14, 0.8);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(225, 29, 72, 0.2);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 18px;
    transition: opacity var(--transition-fast);
}

.brand-link:hover {
    opacity: 0.8;
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    border: 1px solid var(--border);
    color: var(--fg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    color: var(--fg-base);
    background-color: var(--border);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }
html:not([data-theme="dark"]) .icon-sun { display: none; }
html:not([data-theme="dark"]) .icon-moon { display: block; }

/* ─── MAIN LAYOUT ─────────────────────────────────────────────────── */
main {
    flex: 1;
    padding-top: 72px;
}

/* ─── HERO / MASTHEAD ─────────────────────────────────────────────── */
.masthead {
    padding: 32px 24px 64px;
    text-align: center;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

@media (min-width: 768px) {
    .masthead {
        padding: 48px 24px 80px;
    }
}

.masthead::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -40%);
    width: 500px;
    height: 300px;
    background: radial-gradient(ellipse, rgba(190, 18, 60, 0.1) 0%, transparent 70%);
    filter: blur(60px);
    pointer-events: none;
    z-index: -1;
}

.masthead h1 {
    font-family: var(--font-serif);
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--fg-base) 40%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="dark"] .masthead h1 {
    background: linear-gradient(135deg, var(--fg-base) 60%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dek {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--fg-muted);
    max-width: 48ch;
    margin: 0 auto;
    line-height: 1.6;
}

/* ─── PROJECTS SECTION ────────────────────────────────────────────── */
.projects {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 24px 100px;
}

@media (min-width: 768px) {
    .projects {
        padding-bottom: 140px;
    }
}

.lab-description {
    font-size: 16px;
    color: var(--fg-muted);
    line-height: 1.65;
    max-width: 60ch;
    margin: 0 auto 36px;
    text-align: center;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
    opacity: 0.7;
    margin-bottom: 20px;
}

.project-list {
    display: grid;
    gap: 16px;
}

/* ─── PROJECT CARDS ───────────────────────────────────────────────── */
.project-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 32px 40px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition:
        transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        border-color 0.3s ease,
        box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        background-color var(--transition-base);
}

.project-link:hover {
    transform: translateY(-6px);
    border-color: var(--primary);
    box-shadow: 0 16px 36px rgba(190, 18, 60, 0.08), 0 0 1px var(--primary);
}

[data-theme="dark"] .project-link:hover {
    box-shadow: 0 16px 48px rgba(225, 29, 72, 0.15), 0 0 1px var(--primary);
}

.project-link:hover .project-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

.project-text {
    min-width: 0;
}

.project-name {
    font-family: var(--font-serif);
    font-size: clamp(1.75rem, 3.5vw, 2.25rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
    transition: color var(--transition-fast);
}

.project-link:hover .project-name {
    color: var(--primary);
}

.project-tagline {
    font-size: 15px;
    color: var(--fg-muted);
    line-height: 1.55;
    max-width: 52ch;
}

.project-arrow {
    font-size: 1.5rem;
    color: var(--fg-subtle);
    flex-shrink: 0;
    transition: transform var(--transition-base), color var(--transition-fast);
}

/* ─── FOOTER ──────────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 40px 24px;
    background-color: var(--bg-base);
    transition: background-color var(--transition-base), border-color var(--transition-base);
}

.site-footer small {
    display: block;
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    color: var(--fg-subtle);
    font-size: 13px;
}

/* ─── HERO CANVAS VISUALIZER ─────────────────────────────────────── */
.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;
}

.hero-viz {
    width: 100%;
    max-width: 720px;
    margin: 0 auto 24px;
}

.hero-viz canvas {
    display: block;
    width: 100%;
    aspect-ratio: 5 / 2;
    cursor: crosshair;
}

/* ─── SCROLL REVEAL ANIMATIONS ────────────────────────────────────── */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

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

.reveal:nth-child(2) { transition-delay: 0.1s; }
.reveal:nth-child(3) { transition-delay: 0.2s; }
.reveal:nth-child(4) { transition-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ─── MOBILE ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .project-link {
        padding: 24px;
        align-items: flex-start;
    }

    .project-arrow {
        margin-top: 4px;
    }
}
