/* ==========================================================================
   Design System & Global Variables
   ========================================================================== */
:root {
    /* Color Palette - "Ezyang's Blog" Dark Scheme */
    --bg: #000000;
    --card-bg: rgba(15, 20, 30, 0.45);
    /* Subtle translucent background for cards */
    --card-border: rgba(91, 196, 245, 0.1);
    /* Subtle sky-blue boundary */
    --accent: #86d4f9;
    /* Luminous sky blue accent */
    --accent-glow: #9bd6f9;
    /* Lighter sky blue for highlights */
    --text-primary: #dcdcdc;
    /* Soft readable light gray text */
    --text-secondary: #6da6ce;
    /* Slate-blueish secondary text */
    --link: #5bc4f5;
    /* Primary link color */
    --link-hover: #a5e3ff;
    /* Hover link color */
}

/* ==========================================================================
   Light Mode Override — only bg & text flip, all blues stay identical
   ========================================================================== */
body.light-mode {
    --bg: #f4f1eb;
    /* Warm cream — easier on eyes than pure white */
    --card-bg: rgba(255, 252, 245, 0.80);
    --card-border: rgba(91, 196, 245, 0.18);
    --text-primary: #1a1a2e;
    /* Near-black for body text */
    --text-secondary: #4a7fa8;
    /* Slightly deeper blue-gray for secondary text */
    /* All accent / link blues intentionally unchanged */
}

/* Canvas background tint in light mode */
body.light-mode #fishCanvas {
    background: transparent;
}

/* ==========================================================================
   Theme Toggle Button
   ========================================================================== */
#theme-toggle {
    position: fixed;
    top: 24px;
    right: 28px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50px;
    padding: 12px 22px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.18);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    user-select: none;
}

#theme-toggle:hover {
    border-color: rgba(91, 196, 245, 0.35);
    box-shadow: 0 4px 20px rgba(91, 196, 245, 0.12);
}

/* The pill track */
.toggle-track {
    width: 60px;
    height: 32px;
    border-radius: 16px;
    background: rgba(91, 196, 245, 0.18);
    border: 1px solid rgba(91, 196, 245, 0.3);
    position: relative;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

body.light-mode .toggle-track {
    background: rgba(91, 196, 245, 0.35);
}

/* The sliding thumb */
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 8px rgba(91, 196, 245, 0.6);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.light-mode .toggle-thumb {
    transform: translateX(28px);
}

/* The sun/moon icon label */
.toggle-icon {
    font-size: 24px;
    line-height: 1;
    transition: opacity 0.2s ease;
}

/* ==========================================================================
   Base Elements
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    color: var(--text-primary);
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: 25px;
    font-weight: 200;
    line-height: 1.8;
    overflow-x: hidden;
    /* Prevent horizontal scrolling */
}

/* All main content sits above the canvas background */
body>*:not(canvas) {
    position: relative;
    z-index: 1;
}

/* Link Aesthetics */
a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: rgba(84, 158, 255, 0.3);
    text-underline-offset: 4px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
    text-decoration-color: var(--link-hover);
}

/* ==========================================================================
   Layout System
   ========================================================================== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 60px 24px;
}

/* Glassmorphism Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* Safari support */
    padding: 52px 56px;
    margin-bottom: 40px;
    box-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.2);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    border-color: rgba(84, 158, 255, 0.25);
    box-shadow: 0 8px 32px 0 rgba(84, 158, 255, 0.05);
}

/* Typography Headings */
h1 {
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: clamp(80px, 10vw, 120px);
    font-weight: 400;
    color: var(--accent);
    line-height: 1.2;
    margin-bottom: 8px;
}

h2 {
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: 29px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(84, 158, 255, 0.15);
    padding-bottom: 8px;
}

/* ==========================================================================
   Header Section Styles
   ========================================================================== */
#header-section {
    text-align: center;
    margin-bottom: 56px;
    padding-bottom: 20px;
}


.header-email {
    font-size: 25px;
    margin-bottom: 16px;
}

.header-email a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.header-email a:hover {
    color: var(--accent);
    text-decoration: underline;
}


.header-links {
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: 27px;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    /* Add this line for mobile wrapping */
}

.header-links a {
    color: var(--text-secondary);
    /* Softer color by default */
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s ease;
}

.header-links a:hover {
    color: var(--accent);
    /* Sky blue on hover */
    text-decoration: underline;
}

/* ==========================================================================
   Bio Section Styles
   ========================================================================== */
.bio-content {
    display: flex;
    gap: 48px;
    align-items: stretch;
    /* Photo column grows to match text height */
}

.bio-photo {
    flex-shrink: 0;
    width: 280px;
    /* height is determined by the text column via align-items: stretch */
}

.bio-photo img {
    width: 100%;
    height: 100%;
    /* Fill the full stretched height */
    object-fit: cover;
    /* Portrait crop — face stays centered */
    object-position: center top;
    /* Bias toward face/top of image */
    border-radius: 12px;
    border: 1px solid var(--card-border);
    box-shadow: 0 0 24px rgba(91, 196, 245, 0.15);
    display: block;
}

.bio-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 700px) {
    .bio-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .bio-photo {
        width: 240px;
        margin-bottom: 8px;
    }
}

/* ==========================================================================
   Footer Section Styles
   ========================================================================== */
#footer-section {
    text-align: center;
    margin-top: 48px;
    padding: 24px 0;
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: 13px;
    color: var(--text-secondary);
    border-top: 1px solid rgba(91, 196, 245, 0.08);
}

#footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
}

#footer-section a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ==========================================================================
   Background Canvas Setup
   ========================================================================== */
#fishCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    /* Let mouse clicks pass through to the links below */
}

/* ==========================================================================
   Projects Section Styles (Updated Layout)
   ========================================================================== */
.project-item {
    display: flex;
    gap: 40px;
    margin-bottom: 56px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(91, 196, 245, 0.08);
}

.project-item:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Left side media box (for images/gifs) */
.project-media {
    flex-shrink: 0;
    width: 240px;
    height: 200px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.project-media img,
.project-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Never crop — show full figure */
    border-radius: 4px;
}

.project-media-placeholder {
    font-size: 32px;
    color: rgba(91, 196, 245, 0.2);
}

/* Right side content details */
.project-details {
    flex-grow: 1;
}

.project-header {
    margin-bottom: 8px;
}

.project-title {
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.3;
}

.project-authors {
    font-size: 22px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Sky-blue highlight for your name in papers */
.project-authors strong {
    color: var(--accent-glow);
    font-weight: 700;
}

.project-description {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 14px;
}

/* Links row with Flexbox spacing */
.project-links {
    font-family: 'Gentium Book Plus', 'Gentium Book Basic', Georgia, serif;
    font-size: 24px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 14px;
    /* Clear horizontal gap between links and dots */
}

.project-links a {
    color: var(--link);
    text-decoration: none;
}

.project-links a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.project-links .separator {
    color: rgba(91, 196, 245, 0.25);
    /* Subtle color for the dots */
}

/* Responsive formatting for mobile layout */
@media (max-width: 600px) {
    .project-item {
        flex-direction: column;
        gap: 16px;
    }

    .project-media {
        width: 100%;
        height: 200px;
    }
}