/* =================================================================
   Reset and Base Styles
   ================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #414961;
    --secondary-color: #34495e;
    --accent-color: #2679b1;
    --text-color: #5D688A;
    --text-light: #7f8ebb;
    --border-color: #e0e0e0;
    --background: #FFF2EF;
    --background-alt: #fffdfc;
    
    /* Sizing variables */
    --portrait-width: 250px;
    --portrait-height: 300px;
    --video-width: 300px;
    --max-content-width: 1000px;
}

body {
    font-family: 'Alan Sans', -apple-system, sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background: var(--background);
    letter-spacing: -0.02em;
    padding-bottom: 80px;
}

/* =================================================================
   Typography
   ================================================================= */
h1 {
    font-size: 2.4rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-weight: 600;
}

h2 {
    font-size: 1.5rem;
    margin: 1rem 0 0rem;
    color: var(--primary-color);
    font-weight: 600;
}

h3 {
    font-size: 1.3rem;
    margin: 0rem 0 0.5rem;
    color: var(--secondary-color);
    font-weight: 600;
}

p {
    margin-bottom: 0.5rem;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* =================================================================
   Layout Components
   ================================================================= */
.container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 2rem;
}

main {
    padding: 1rem 0;
    min-height: calc(100vh - 200px);
}

/* =================================================================
   Header and Navigation
   ================================================================= */
header {
    background: var(--background);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
}

.site-title:hover {
    text-decoration: none;
    color: var(--accent-color);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--accent-color);
    text-decoration: none;
}

/* Hamburger Menu */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--primary-color);
}

.hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 25px;
}

.hamburger span {
    display: block;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
    transition: all 0.3s;
}

.menu-toggle.active .hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.menu-toggle.active .hamburger span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* =================================================================
   Typewriter Effect
   ================================================================= */
.typewriter-container {
    display: inline-block;
}

#typewriter {
    color: var(--accent-color);
    font-weight: 600;
    border-right: 3px solid var(--accent-color);
    padding-right: 5px;
    animation: blink 0.7s step-end infinite;
    display: inline-block;
    min-width: 20px;
}

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--accent-color);
    }
}

/* =================================================================
   Bio Section
   ================================================================= */
.portrait {
    width: var(--portrait-width);
    height: var(--portrait-height);
    object-fit: cover;
}

.bio-section {
    margin: 1rem 0 1rem 0;
}

.bio-header {
    display: grid;
    grid-template-columns: var(--portrait-width) 1fr;
    gap: 2.5rem;
    margin-bottom: 1rem;
    align-items: start;
}

.bio-header .portrait {
    grid-row: 1 / 3;
    margin: 0;
}

.bio-header h1 {
    grid-column: 2;
    grid-row: 1;
    margin-top: -0.6rem;
    margin-bottom: 0;
}

.bio-paragraph {
    grid-column: 2;
    grid-row: 2;
    margin-top: -2rem;
}

/* =================================================================
   Research Section
   ================================================================= */
.research-section {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
    background: var(--background-alt);
    padding: 3rem;
    margin: 3rem 0;
}

.research-heading {
    flex-shrink: 0;
    width: 200px;
    margin: 0;
    padding-right: 2rem;
}

.research-interests {
    display: flex;
    gap: 1.5rem;
    flex: 1;
}

.research-card {
    flex: 1;
    background: var(--background);
    overflow: hidden;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.research-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.research-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.research-card h3 {
    padding: 1rem;
    margin: 0;
    font-size: 0.95rem;
    text-align: center;
    color: var(--secondary-color);
    line-height: 1.4;
}

/* =================================================================
   Video Sections
   ================================================================= */
.vertical-video-section {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
    margin: 3rem 0;
    background: var(--background-alt);
    padding: 2rem;
}

.video-side {
    flex-shrink: 0;
    width: var(--video-width);
}

.video-side video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.text-side {
    flex: 1;
}

.text-side h3 {
    margin-top: 0;
}

.video-showcase {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    margin: 3rem 0;
    padding: 2rem;
}

.vertical-video-center {
    flex-shrink: 0;
    max-width: var(--video-width);
}

.vertical-video-center video {
    width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.info-card {
    flex: 1;
    background: var(--background-alt);
    padding: 1.5rem;
    text-align: center;
}

.info-card h4 {
    margin: 0 0 0.5rem 0;
    color: var(--accent-color);
}

/* =================================================================
   Contact Links
   ================================================================= */
.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
    align-items: center;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-color);
    font-size: 1.5rem;
    transition: all 0.2s;
}

.contact-link:hover {
    color: var(--accent-color);
    text-decoration: none;
    transform: translateY(-2px);
}

.contact-link i {
    font-size: 2rem;
}

/* =================================================================
   Content Elements (Lists, Code, Media)
   ================================================================= */
main ul {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
    list-style-type: "- ";
}

main ul li {
    margin-bottom: 0;
}

main ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

main ol li {
    margin-bottom: 1rem;
}

main img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem 0;
    border-radius: 4px;
}

main video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem 0;
    border-radius: 4px;
}

code {
    background: var(--background-alt);
    padding: 0.2rem 0.4rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

pre {
    background: var(--background-alt);
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

pre code {
    background: none;
    padding: 0;
}

.github-link {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    font-weight: 600;
    margin: 1rem 0;
    transition: all 0.2s;
}

.github-link:hover {
    background: var(--secondary-color);
    text-decoration: none;
    transform: translateY(-2px);
}

/* =================================================================
   Footer
   ================================================================= */
footer {
    background: var(--background);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 0;
    color: var(--text-light);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 90;
}

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

footer p {
    margin: 0;
}

footer .contact-links {
    margin: 0;
}

/* =================================================================
   Responsive Design
   ================================================================= */
@media (max-width: 768px) {
    /* Typography */
    h1 {
        font-size: 1.7rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    /* Layout */
    .container,
    .nav-container {
        padding: 0 1rem;
    }

    /* Navigation */
    .nav-container {
        flex-direction: row-reverse;
        justify-content: space-between;
        position: relative;
    }

    .menu-toggle {
        display: block;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--background);
        flex-direction: column;
        padding: 0;
        border-bottom: 1px solid var(--border-color);
        gap: 0.5rem;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: all 0.3s ease;
    }

    .nav-links.active {
        max-height: 500px;
        opacity: 1;
        padding: 1rem;
    }

    .nav-links li {
        width: 100%;
        text-align: center;
    }

    .nav-links a {
        display: block;
        padding: 0.5rem;
    }

    /* Bio Section */
    .bio-header {
        display: grid;
        grid-template-columns: 110px 1fr;
        grid-template-rows: auto auto;
        gap: 1rem;
        align-items: end;
    }

    .bio-header .portrait {
        grid-column: 1;
        grid-row: 1;
        width: 120px;
        height: 160px;
    }

    .bio-header h1 {
        grid-column: 2;
        grid-row: 1;
        font-size: 1.6rem;
        line-height: 1.3;
        margin-bottom: 0;
        align-self: end;
    }

    .typewriter-container {
        display: block;
        margin-top: 0.3rem;
    }

    .bio-paragraph {
        grid-column: 1 / -1;
        grid-row: 2;
        margin: 0;
        margin-top: 1rem;
    }

    /* Research Section */
    .research-section {
        flex-direction: column;
        padding: 2rem 1.5rem;
    }

    .research-heading {
        width: 100%;
        padding-right: 0;
        margin-bottom: 1rem;
        text-align: center;
    }

    .research-interests {
        flex-direction: column;
    }

    .research-card img {
        height: 120px;
    }

    /* Video Sections */
    .vertical-video-section {
        margin-bottom: 2rem;
    }

    .vertical-video-section,
    .video-showcase {
        flex-direction: column;
        align-items: center;
    }
    
    .video-side,
    .vertical-video-center {
        width: 75%;
        max-width: var(--video-width);
        margin-top: -1.5rem;
    }

    .vertical-video-section .text-side {
        margin-top: -3rem;
    }

    /* Contact Links */
    .contact-links {
        flex-direction: column;
    }

    .contact-link {
        width: 100%;
        justify-content: center;
    }

    /* Footer */
    footer .container {
        flex-direction: column-reverse;
        gap: 1rem;
        align-items: center;
    }

    footer p {
        text-align: center;
    }

    footer .contact-links {
        width: 100%;
        flex-direction: row;
        justify-content: space-evenly;
        gap: 1rem;
    }

    footer .contact-link {
        width: auto;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container,
    .nav-container {
        padding: 0 1rem;
    }

    h1 {
        font-size: 1.7rem;
    }

    .portrait {
        width: 150px;
        height: 200px;
    }
}