* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252525;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-bright: #ffffff;
    --text-muted: #d0d0d0;
    --accent: #4ade80;
    --border-subtle: rgba(74, 222, 128, 0.2);
    --border-bright: rgba(74, 222, 128, 0.4);
    --canvas-opacity: 0.06;
    --timeline-dot-border: #1e1e1e;
}

body.light-mode {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #2a2a2a;
    --text-secondary: #4a4a4a;
    --text-bright: #3a3a3a;
    --text-muted: #4a4a4a;
    --accent: #22c55e;
    --border-subtle: rgba(34, 197, 94, 0.3);
    --border-bright: rgba(34, 197, 94, 0.5);
    --canvas-opacity: 0.04;
    --timeline-dot-border: #ffffff;
}

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    padding: 0;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: var(--canvas-opacity);
    transition: opacity 0.3s ease;
}

/* Navigation */
.main-nav {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1000;
}

.nav-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0.5rem 0;
}

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

/* Theme Toggle Button */
#theme-toggle {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

#theme-toggle:hover {
    transform: scale(1.1);
}

#theme-toggle:focus {
    outline: none;
}

#theme-toggle svg {
    color: var(--text-primary);
    transition: opacity 0.3s ease;
}

@media (max-width: 640px) {
    .main-nav {
        top: 0.75rem;
        right: 0.75rem;
        gap: 0.75rem;
    }

    .nav-link {
        font-size: 0.75rem;
    }

    #theme-toggle {
        width: 32px;
        height: 32px;
    }

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

.content {
    max-width: 680px;
    width: 100%;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
    margin: 0 auto;
}

h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 500;
    margin-bottom: 2rem;
    color: var(--text-bright);
    letter-spacing: -0.02em;
}

.text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.text p {
    margin-bottom: 1.5rem;
}

.text p:last-child {
    margin-bottom: 0;
}

@keyframes static-effect {
    0% {
        transform: translate(0, 0);
        text-shadow: 0.5px 0 0 rgba(255, 255, 255, 0.1);
    }
    10% {
        transform: translate(-0.5px, 0.5px);
        text-shadow: -0.5px 0 0 rgba(255, 255, 255, 0.15);
    }
    20% {
        transform: translate(0.5px, -0.5px);
        text-shadow: 0.5px 0 0 rgba(255, 255, 255, 0.12);
    }
    30% {
        transform: translate(-0.5px, 0);
        text-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.08);
    }
    40% {
        transform: translate(0.5px, 0.5px);
        text-shadow: 0.5px 0 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        transform: translate(0, -0.5px);
        text-shadow: -0.5px 0 0 rgba(255, 255, 255, 0.13);
    }
    60% {
        transform: translate(-0.5px, 0.5px);
        text-shadow: 0.5px 0 0 rgba(255, 255, 255, 0.11);
    }
    70% {
        transform: translate(0.5px, 0);
        text-shadow: 0 -0.5px 0 rgba(255, 255, 255, 0.09);
    }
    80% {
        transform: translate(0, 0.5px);
        text-shadow: -0.5px 0 0 rgba(255, 255, 255, 0.14);
    }
    90% {
        transform: translate(-0.5px, -0.5px);
        text-shadow: 0.5px 0 0 rgba(255, 255, 255, 0.1);
    }
    100% {
        transform: translate(0, 0);
        text-shadow: 0.5px 0 0 rgba(255, 255, 255, 0.1);
    }
}

.clickable {
    cursor: pointer;
    position: relative;
    color: var(--text-muted);
    transition: color 0.3s ease;
    animation: static-effect 0.2s infinite;
    display: inline-block;
}

.clickable:hover {
    color: var(--text-bright);
}

.clickable::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.clickable:hover::after {
    transform: scaleX(1);
}

.hoverable {
    cursor: default;
    display: inline-block;
    color: var(--text-muted);
    transition: color 0.3s ease;
    white-space: pre;
}

.hoverable:hover {
    color: var(--text-bright);
}

.link {
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
    border-bottom: 1px solid transparent;
}

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

.link:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.institution-morph {
    color: var(--accent);
    position: relative;
}

.institution-morph::after {
    content: attr(data-full);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border: 1px solid var(--border-subtle);
    z-index: 100;
}

.institution-morph:hover::after {
    opacity: 1;
}

/* Timeline Section */
#timeline-section {
    position: relative;
    min-height: 100vh;
    padding: 4rem 2rem;
    z-index: 1;
}

#timeline-container {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

/* Timeline vertical line */
#timeline-container::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, transparent, var(--accent) 10%, var(--accent) 90%, transparent);
    transform: translateX(-50%);
    z-index: 1;
}

/* Timeline event */
.timeline-event {
    position: relative;
    margin-bottom: 4rem;
    display: flex;
    align-items: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-event.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Left side events */
.timeline-event.left {
    justify-content: flex-start;
}

.timeline-event.left .event-content {
    margin-right: calc(50% + 2rem);
    margin-left: 0;
    text-align: right;
}

/* Right side events */
.timeline-event.right {
    justify-content: flex-end;
}

.timeline-event.right .event-content {
    margin-left: calc(50% + 2rem);
    margin-right: 0;
    text-align: left;
}

/* Event dot on timeline */
.timeline-event::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: var(--accent);
    border: 2px solid var(--timeline-dot-border);
    border-radius: 50%;
    z-index: 2;
}

/* Event content card */
.event-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: calc(50% - 3rem);
    transition: all 0.3s ease;
    position: relative;
    z-index: 0;
}

.event-content:hover {
    border-color: var(--border-bright);
    transform: scale(1.02);
}

.event-date {
    font-size: 0.875rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.event-title {
    font-size: 1.125rem;
    color: var(--text-bright);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.event-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.event-type {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 0.25rem 0.75rem;
    margin-top: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 640px) {
    .content {
        padding: 1.5rem;
    }

    h1 {
        margin-bottom: 1.5rem;
    }

    .text {
        font-size: 1rem;
    }

    /* Mobile timeline - single column */
    #timeline-container::before {
        left: 2rem;
    }

    .timeline-event.left .event-content,
    .timeline-event.right .event-content {
        padding-left: 4rem;
        padding-right: 1rem;
        text-align: left;
        margin-left: 0;
        margin-right: 0;
    }

    .timeline-event::after {
        left: 2rem;
    }

    .event-content {
        max-width: 100%;
        width: 100%;
    }
}

/* Timeline end marker */
#timeline-end {
    position: relative;
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
}

#timeline-end::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 12px;
    height: 12px;
    background-color: var(--accent);
    border: 2px solid var(--timeline-dot-border);
    border-radius: 50%;
    transform: translateX(-50%);
}

#timeline-end.pulse::before {
    animation: pulse-dot 1s ease-out;
}

body:not(.light-mode) #timeline-end.pulse::before {
    animation: pulse-dot-dark 1s ease-out;
}

body.light-mode #timeline-end.pulse::before {
    animation: pulse-dot-light 1s ease-out;
}

@keyframes pulse-dot-dark {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }
    100% {
        box-shadow: 0 0 0 8px rgba(74, 222, 128, 0);
    }
}

@keyframes pulse-dot-light {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    100% {
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }
}

#current-time {
    font-size: 1rem;
    color: var(--accent);
    font-weight: 500;
    letter-spacing: 0.5px;
}

@media (max-width: 640px) {
    #timeline-end::before {
        left: 2rem;
    }
}

/* Projects Link on Main Page */
.projects-link {
    margin-top: 1rem;
}

.projects-link .link {
    font-size: 1rem;
}

/* Clickable Timeline Events */
.clickable-event {
    text-decoration: none;
    cursor: pointer;
}

.clickable-event:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}

/* Projects Page */
.projects-page {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 4rem 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.projects-header {
    margin-bottom: 3rem;
}

.projects-header h1 {
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 500;
    margin: 1rem 0;
    color: var(--text-bright);
}

.projects-intro {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.5rem;
    text-decoration: none;
    transition: all 0.3s ease;
    display: block;
}

.project-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
}

.project-card .project-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.project-card .project-date {
    font-size: 0.875rem;
    color: var(--accent);
    font-weight: 500;
}

.project-card .project-type {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-card .project-title {
    font-size: 1.125rem;
    color: var(--text-bright);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.project-card .project-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.project-card .project-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.project-card .keyword-tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 0.25rem 0.75rem;
    letter-spacing: 0.5px;
}

/* Project Detail Page */
.project-detail {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 4rem 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.project-nav {
    margin-bottom: 2rem;
}

.project-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 2rem;
}

.project-header {
    margin-bottom: 2rem;
}

.project-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.project-detail .project-date {
    font-size: 0.875rem;
    color: var(--accent);
    font-weight: 500;
}

.project-type-badge {
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 0.25rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-detail h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 500;
    color: var(--text-bright);
    margin: 0;
}

.project-body {
    margin-bottom: 2rem;
}

.project-body p {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1rem;
}

.project-pdf {
    margin-bottom: 2rem;
}

.project-pdf h2,
.project-links h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-bright);
    margin-bottom: 1rem;
}

.pdf-container {
    margin-bottom: 1rem;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.pdf-container iframe {
    display: block;
    border: none;
}

.pdf-download {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.pdf-download:hover {
    background: var(--accent);
    color: var(--bg-primary);
}

.project-links ul {
    list-style: none;
    padding: 0;
}

.project-links li {
    margin-bottom: 0.5rem;
}

.project-links a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.project-links a:hover {
    opacity: 0.8;
}

.external-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.external-link:hover {
    background: var(--accent);
    color: var(--bg-primary);
    opacity: 1;
}

@media (max-width: 640px) {
    .projects-page,
    .project-detail {
        padding: 3.5rem 1rem 2rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .project-content {
        padding: 1.5rem;
    }

    .pdf-container iframe {
        height: 400px;
    }
}

/* Footer */
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 2rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-secondary);
    transition: color 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-links a:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.footer-links svg {
    width: 20px;
    height: 20px;
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

@media (max-width: 640px) {
    .site-footer {
        padding: 2rem 1rem;
    }

    .footer-links {
        gap: 1rem;
    }
}
