/* CSS Variables */
:root {
    --color-bg: #ffffff;
    --color-text: #111111;
    --color-text-muted: #666666;
    --color-border: #e5e5e5;
    --color-hover: #f5f5f5;
    --color-overlay: rgba(255, 255, 255, 0.95);
    
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 8rem;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
    font-family: var(--font-mono);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.85;
    font-size: 13px;
    letter-spacing: 0.04em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-y: scroll;
}

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

ul {
    list-style: none;
}

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

/* Focus States */
:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

/* Navigation */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--color-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    gap: var(--spacing-md);
}

.nav-link {
    font-size: 12px;
    color: #888888;
    transition: color var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-text);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--spacing-xl) + 60px) var(--spacing-md) var(--spacing-xl);
    min-height: 100vh;
}

.page-section {
    display: none;
    animation: fadeIn var(--transition-slow);
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    margin-bottom: calc(var(--spacing-lg) + 1rem);
}

.section-header h2 {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-sm);
}

/* About Section */
#about {
    position: relative;
}

.ascii-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.4;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.6) 25%, rgba(0,0,0,1) 100%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.6) 25%, rgba(0,0,0,1) 100%);
}

.about-header {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin-top: 10vh;
}

.tagline {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 300;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: var(--spacing-md);
}

.bio {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 400;
    line-height: 1.85;
    max-width: 65ch;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
}

.project-card {
    position: relative;
    aspect-ratio: 4/3;
    background: var(--color-hover);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--color-border);
}

.project-image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #f0f0f0, #e0e0e0);
    transition: transform var(--transition-slow);
}

.project-card:hover .project-image-placeholder {
    transform: scale(1.03);
}

.project-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.project-card:hover .project-overlay,
.project-card:focus-visible .project-overlay {
    opacity: 1;
}

.project-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--color-text-muted);
}

.project-title {
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0;
    margin-bottom: var(--spacing-xs);
}

.project-tags {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Timeline */
.timeline {
    max-width: 800px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) 0;
    border-bottom: 1px solid var(--color-border);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-dates {
    font-size: 12px;
    color: var(--color-text-muted);
}

.timeline-content h3 {
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: 0;
    margin-bottom: var(--spacing-xs);
}

.timeline-org {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

.timeline-bullets {
    list-style: disc;
    padding-left: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
    max-width: 65ch;
}

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

.timeline-links {
    font-size: 12px;
}

.timeline-links a {
    text-decoration: underline;
    text-underline-offset: 4px;
    color: var(--color-text);
}

/* Lab Grid */
.lab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-md);
}

.lab-card {
    aspect-ratio: 1;
    border: 1px solid var(--color-border);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.lab-card:hover {
    background: var(--color-hover);
}

.lab-title {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0;
}

.lab-icon {
    align-self: flex-end;
    color: var(--color-text-muted);
}

/* Modal / Panel */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-panel {
    width: 100%;
    max-width: 800px;
    height: 100%;
    background: var(--color-bg);
    border-left: 1px solid var(--color-border);
    box-shadow: -10px 0 40px rgba(0,0,0,0.05);
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    overflow-y: auto;
    position: relative;
}

.modal-overlay.active .modal-panel {
    transform: translateX(0);
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-hover);
    transition: background var(--transition-fast);
    z-index: 10;
}

.modal-close:hover {
    background: #e0e0e0;
}

.modal-content {
    padding: var(--spacing-xl) var(--spacing-lg) var(--spacing-lg);
}

/* Case Study Content */
.case-study-header {
    margin-bottom: var(--spacing-lg);
}

.case-study-title {
    font-size: clamp(2rem, 3vw, 3rem);
    font-weight: 300;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: var(--spacing-sm);
}

.case-study-meta {
    display: flex;
    gap: var(--spacing-md);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-md);
}

.case-study-section {
    margin-bottom: calc(var(--spacing-lg) + 1rem);
}

.case-study-section h4 {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

.case-study-section p {
    font-size: 13px;
    line-height: 1.85;
    color: var(--color-text);
    max-width: 65ch;
}

.demo-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--color-hover);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    margin-bottom: var(--spacing-lg);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 12.5px;
    }
    
    .nav-container {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .nav-links {
        width: 100%;
        justify-content: space-between;
    }
    
    .timeline-item {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }
    
    .modal-content {
        padding: var(--spacing-xl) var(--spacing-md) var(--spacing-md);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
