/* CSS Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

margin,
padding {
    margin: 0;
    padding: 0;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

/* Design Tokens */
:root {
    --color-bg: #F9F7F4;
    --color-text: #1A1A1A;
    --color-text-muted: #555555;
    --color-primary: #0D7377;
    --color-accent: #E8A838;
    --color-border: rgba(26, 26, 26, 0.1);
    --color-card-bg: rgba(255, 255, 255, 0.4);

    --font-heading: 'Fraunces', serif;
    --font-body: 'Inter', sans-serif;

    --space-sm: 1rem;
    --space-md: 2.5rem;
    --space-lg: 5rem;
    --space-xl: 10rem;

    --transition-fast: 200ms ease;
    --transition-slow: 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Base Styles */
html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: 400;
    line-height: 1.2;
    color: var(--color-text);
}

a {
    color: var(--color-text);
    text-decoration: none;
    transition: color var(--transition-fast);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.site-header {
    padding: 2rem 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: linear-gradient(to bottom, var(--color-bg) 70%, transparent);
}

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

.logo {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.main-nav {
    display: flex;
    gap: 2rem;
}

.main-nav a {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.main-nav a:hover {
    color: var(--color-text);
}

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

.section-header {
    margin-bottom: var(--space-lg);
    max-width: 600px;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
}

.section-header p {
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

/* Hero */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    padding-top: 5rem;
    overflow: hidden;
}

.hero-headline {
    font-size: clamp(3rem, 6vw, 5.5rem);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
    max-width: 900px;
}

.hero-tagline {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    max-width: 500px;
}

.hero-graphic {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 50%;
    color: var(--color-primary);
    z-index: -1;
    opacity: 0.08;
    overflow: hidden;
}

/* CTA Buttons */
.cta-primary,
.cta-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.cta-primary {
    background-color: var(--color-primary);
    color: #FFF;
    padding: 1rem 2rem;
    border-radius: 4px;
}

.cta-primary:hover {
    background-color: var(--color-text);
    color: var(--color-accent);
}

.cta-secondary {
    background: #1A1A1A;
    color: #F9F7F4;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.cta-secondary:hover {
    background-color: var(--color-primary);
    color: #F9F7F4;
}

/* Apps Grid */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 3rem;
}

.app-card {
    background-color: #FFFFFF;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
    transition: transform 250ms ease, box-shadow 250ms ease, border-top 250ms ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-top: 2px solid transparent;
}

.app-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    border-top: 2px solid var(--color-primary);
}

.app-card-icon {
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--color-bg);
    border-radius: 12px;
}

.app-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.app-title {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.app-desc {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
    flex-grow: 1;
}

/* About */
.about {
    background-color: #1A1A1A;
    color: #F9F7F4;
    position: relative;
    overflow: hidden;
}

#grain-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0.035;
    z-index: 9998;
}

.about-container {
    max-width: 800px;
    text-align: left;
    position: relative;
    z-index: 2;
}

.about-content h2 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #F9F7F4;
    border-left: 4px solid var(--color-accent);
    padding-left: 1.5rem;
}

.about-content p {
    font-size: 1.25rem;
    color: rgba(249, 247, 244, 0.8);
    max-width: 600px;
    margin: 0;
}

/* Lab Notebook */
.notebook {
    background-color: var(--color-bg);
}

.notebook-container {
    max-width: 800px;
    margin: 0 auto;
}

.timeline-wrapper {
    position: relative;
}

.timeline-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 80px;
    background: linear-gradient(to bottom, transparent, #F9F7F4);
    pointer-events: none;
    z-index: 999;
}

.timeline-scroll {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 1rem;
}

.timeline-scroll::-webkit-scrollbar {
    width: 4px;
}

.timeline-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.timeline {
    display: flex;
    flex-direction: column;
    padding-top: 2rem;
    padding-bottom: 80px;
}

.timeline-entry {
    display: grid;
    grid-template-columns: 100px 30px 1fr;
    gap: 1.5rem;
    position: relative;
    padding-bottom: 3.5rem;
}

.timeline-entry:last-child {
    padding-bottom: 0;
}

.timeline-date {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
    text-align: right;
    padding-top: 0.4rem;
    /* optical alignment */
}

/* The vertical line container */
.timeline-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Dot */
.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--color-primary);
    margin-top: 0.45rem;
    /* Optical alignment with text */
    z-index: 2;
}

/* Vertical line connecting dots */
.timeline-entry:not(:last-child) .timeline-center::after {
    content: '';
    position: absolute;
    top: 1rem;
    bottom: -3.5rem;
    /* extend through padding */
    width: 2px;
    background-color: var(--color-primary);
    opacity: 0.2;
    z-index: 1;
}

.timeline-content {
    padding-bottom: 0.5rem;
}

.timeline-title {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.timeline-desc {
    font-weight: 300;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

/* Contact */
.contact-container {
    text-align: center;
    max-width: 600px;
}

.contact h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.contact p {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin-bottom: 3rem;
}

.contact-email {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.25rem;
}

.contact-email:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Footer */
.site-footer {
    padding: 3rem 0;
    border-top: 1px solid var(--color-border);
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Hero Word Reveal */
.word-wrapper {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
}

.word {
    display: inline-block;
    transform: translateY(110%);
    animation: reveal-word 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes reveal-word {
    0% {
        transform: translateY(110%);
    }

    100% {
        transform: translateY(0);
    }
}

/* Cursor Glow */
#cursor-glow {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    background: radial-gradient(circle at center, rgba(13, 115, 119, 0.35) 0%, transparent 70%);
    z-index: 9999;
    mix-blend-mode: screen;
    will-change: transform, opacity;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    #cursor-glow {
        display: none !important;
    }
}

/* Animations */
.fade-in-section {
    opacity: 0;
    transform: translateY(20px);
    visibility: hidden;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
    will-change: opacity, visibility;
}

.fade-in-section.is-visible {
    opacity: 1;
    transform: none;
    visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --space-xl: 6rem;
    }

    .hero-headline {
        font-size: 3rem;
    }

    .hero-graphic {
        display: none;
    }

    .contact-email {
        font-size: 1.5rem;
    }

    .about-content h2 {
        font-size: 2.2rem;
    }

    .timeline-entry {
        grid-template-columns: 80px 20px 1fr;
        gap: 0.75rem;
    }
}