/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-family: 'Google Sans', 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    --max-width: 650px;
    --max-width-mobile: 480px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    --transition-fast: all 0.15s cubic-bezier(0.23, 1, 0.32, 1);
    --transition-spring: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --spacing-xs: 0.375rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1.25rem;
    --spacing-lg: 1.75rem;
    --spacing-xl: 2.5rem;
    --spacing-2xl: 3.5rem;
    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    background: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: -2;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(45deg, var(--tech-grid) 1px, transparent 1px),
        linear-gradient(-45deg, var(--tech-grid) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.4;
    animation: backgroundShift 20s ease-in-out infinite;
    z-index: -1;
}

/* Tech data flow particles */
.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, var(--accent-color), transparent),
        radial-gradient(2px 2px at 40px 70px, var(--accent-color), transparent),
        radial-gradient(1px 1px at 90px 40px, var(--accent-color), transparent),
        radial-gradient(1px 1px at 130px 80px, var(--accent-color), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    opacity: 0.1;
    /* animation: dataFlow 15s linear infinite; */ /* Disabled: Causes scroll position issues with viewport-based transforms */
    z-index: -1;
    pointer-events: none;
}

/* Container and layout */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-xs) var(--spacing-md);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Responsive container adjustments */
@media (max-width: 768px) {
    .container {
        max-width: var(--max-width-mobile);
        padding: var(--spacing-lg) var(--spacing-md);
    }
}

@media (min-width: 1440px) {
    .container {
        max-width: 800px;
        padding: var(--spacing-xl) var(--spacing-lg);
    }
}

.header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--spacing-xs);
    flex-shrink: 0;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Changed from center to prevent layout shifts when biography loads */
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 8px 0;
    overflow: visible;
}

.footer {
    text-align: center;
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.6;
    transition: var(--transition);
    flex-shrink: 0;
}

.footer:hover {
    opacity: 0.8;
}

/* Hero section */
.hero {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.hero:hover .profile-image {
    animation: float 6s ease-in-out infinite, glow 3s ease-in-out infinite;
}

.profile-container {
    margin-bottom: 4px;
}

.profile-image {
    width: clamp(100px, 15vw, 130px);
    height: clamp(100px, 15vw, 130px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
    box-shadow: var(--shadow-xl);
    transition: var(--transition);
    animation: float 6s ease-in-out infinite;
}

.profile-image:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-hover), 0 0 40px rgba(99, 102, 241, 0.4);
    animation: techGlow 2s ease-in-out infinite;
    filter: brightness(1.1) contrast(1.1);
}

.name {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--accent-color);
    letter-spacing: var(--letter-spacing-tight);
    line-height: 1.2;
    text-align: center;
    font-feature-settings: 'ss01', 'ss02';
    text-rendering: optimizeLegibility;
    white-space: nowrap;
    overflow: visible;
    max-width: 100%;
    display: block;
    width: 100%;
    min-height: 2.5rem;
}

.title {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 500;
    margin: 0 0 16px 0;
    color: var(--text-muted);
    letter-spacing: var(--letter-spacing-wide);
    line-height: 1.3;
    text-align: center;
    text-transform: uppercase;
    font-feature-settings: 'smcp';
}

.phd-notice {
    background: var(--accent-bg);
    backdrop-filter: blur(15px) saturate(200%);
    -webkit-backdrop-filter: blur(15px) saturate(200%);
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius-sm);
    padding: 4px var(--spacing-sm);
    margin: 2px auto;
    max-width: 350px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.2), 0 2px 8px rgba(99, 102, 241, 0.1);
    transition: var(--transition-fast);
    min-height: auto;
}

.phd-notice:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.25), 0 4px 12px rgba(99, 102, 241, 0.15);
}

.phd-icon {
    font-size: 0.9rem;
    color: var(--accent-color);
    flex-shrink: 0;
    transition: var(--transition);
    margin-right: 2px;
}

.phd-notice:hover .phd-icon {
    animation: iconPulse 0.6s ease-in-out;
    transform: scale(1.15);
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.8));
}

@media (min-width: 1024px) {
    .phd-notice {
        max-width: 600px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .phd-icon {
        font-size: 1.2rem;
    }
}

.phd-text {
    font-size: clamp(0.7rem, 1.6vw, 0.8rem);
    color: var(--accent-text);
    margin: 0;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: var(--letter-spacing-wide);
    text-transform: uppercase;
    font-feature-settings: 'smcp';
    hyphens: none;
    word-break: keep-all;
    text-align: center;
}

@media (max-width: 400px) {
    .title {
        font-size: 0.8rem;
    }
    
    .phd-text {
        font-size: 0.65rem;
        letter-spacing: 0.01em;
    }
}

@media (min-width: 401px) and (max-width: 500px) {
    .phd-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Navigation */
.navigation {
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.nav-grid {
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.nav-link:nth-child(1) {
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

.nav-link:nth-child(2) {
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.nav-link:nth-child(3) {
    animation: fadeInUp 0.8s ease-out 0.3s both;
}

.nav-link:nth-child(4) {
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.nav-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .nav-grid {
        gap: var(--spacing-sm);
        flex-wrap: nowrap;
        max-width: 650px;
    }
    
    .nav-link {
        width: 120px;
        min-height: 75px;
    }
}

@media (max-width: 640px) {
    .nav-grid {
        max-width: 450px;
        gap: var(--spacing-xs);
    }
    
    .nav-link {
        width: 85px;
        min-height: 85px;
    }
    
    .nav-link span {
        font-size: 0.7rem;
        color: var(--text-color);
        font-weight: 600;
    }
    
    .nav-icon {
        font-size: 1.6rem;
    }
    
    .nav-icon i {
        width: 1.6rem;
        height: 1.6rem;
        line-height: 1.6rem;
    }
}

@media (max-width: 480px) {
    .nav-grid {
        max-width: 380px;
    }
    
    .nav-link {
        width: 70px;
        min-height: 80px;
        padding: 8px 4px;
    }
    
    .nav-icon {
        font-size: 1.4rem;
    }
    
    .nav-icon i {
        width: 1.4rem;
        height: 1.4rem;
        line-height: 1.4rem;
    }
    
    .nav-link span {
        font-size: 0.65rem;
        color: var(--text-color);
        font-weight: 600;
    }
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition-fast);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: visible;
    flex: none;
    width: 110px;
    min-height: 90px;
    height: auto;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

.nav-link:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--card-bg-hover);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
}

.nav-link:hover::before {
    opacity: 0.1;
}

@media (min-width: 768px) {
    .nav-link {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    .nav-link:hover {
        transform: translateY(-4px);
    }
}

.nav-icon {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    margin-bottom: 0;
    transition: var(--transition);
    flex-shrink: 0;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.8rem;
}

.nav-icon i {
    display: block;
    width: 1.8rem;
    height: 1.8rem;
    line-height: 1.8rem;
    text-align: center;
    transition: var(--transition);
    font-size: inherit;
}

.nav-link:hover .nav-icon {
    animation: iconPulse 0.4s ease-in-out;
    color: var(--accent-color);
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.6));
}

@media (min-width: 768px) {
    .nav-icon {
        font-size: 1.4rem;
    }
    
    .nav-icon i {
        width: 1.4rem;
        height: 1.4rem;
        line-height: 1.4rem;
    }
}

.nav-link span {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    font-weight: 500;
    text-align: center;
    line-height: 1.1;
    opacity: 1;
    color: var(--text-color);
    white-space: nowrap;
    overflow: visible;
    width: 100%;
    display: block;
    margin: 0;
    z-index: 10;
    position: relative;
}

@media (min-width: 768px) {
    .nav-link span {
        font-size: 0.85rem;
        color: var(--text-color);
    }
    
    .nav-link {
        min-height: 95px;
        width: 130px;
    }
    
    .nav-icon {
        font-size: 1.8rem;
        min-height: 2rem;
    }
    
    .nav-icon i {
        width: 2rem;
        height: 2rem;
        line-height: 2rem;
    }
}

@media (max-width: 480px) {
    .nav-link span {
        font-size: 0.65rem;
    }
}

/* Theme toggle */
.theme-toggle {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.theme-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-accent);
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

@media (min-width: 1024px) {
    .theme-toggle {
        width: 52px;
        height: 52px;
    }
}

.theme-toggle:hover {
    transform: scale(1.05) rotate(5deg);
    background: var(--card-bg-hover);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.theme-toggle:hover::before {
    opacity: 0.15;
}

.theme-icon {
    font-size: 1.2rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced Tech Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-6px);
    }
}

@keyframes techGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.2), 0 0 40px rgba(99, 102, 241, 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.4), 0 0 60px rgba(99, 102, 241, 0.2);
    }
}

@keyframes scanLine {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes dataFlow {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) scale(1);
    }
    90% {
        opacity: 1;
        transform: translateY(-10vh) scale(1);
    }
    100% {
        transform: translateY(-20vh) scale(0);
        opacity: 0;
    }
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.2);
    }
}

@keyframes backgroundShift {
    0% {
        background-position: 0% 0%;
    }
    50% {
        background-position: 100% 100%;
    }
    100% {
        background-position: 0% 0%;
    }
}

/* Enhanced Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: var(--spacing-sm) var(--spacing-xs);
        min-height: 100dvh;
    }
    
    .main {
        gap: var(--spacing-sm);
    }
    
    .nav-link {
        padding: var(--spacing-xs) 2px;
        min-height: 50px;
        width: 65px;
    }
    
    .phd-notice {
        padding: var(--spacing-xs);
        gap: var(--spacing-xs);
        margin: 2px auto;
    }
    
    .phd-icon {
        font-size: 0.9rem;
    }
    
    .name {
        font-size: clamp(1.5rem, 4vw, 2rem);
    }
}

@media (max-width: 320px) {
    .container {
        padding: var(--spacing-xs);
        min-height: 100svh;
    }
    
    .nav-grid {
        flex-wrap: wrap;
        gap: 2px;
    }
    
    .nav-link {
        padding: 4px 2px;
        min-height: 45px;
        width: 55px;
    }
    
    .name {
        font-size: 1.4rem;
    }
    
    .footer {
        display: none;
    }
}

/* Large desktop optimization */
@media (min-width: 1440px) {
    .hero {
        margin-bottom: var(--spacing-xl);
    }
    
    .name {
        margin-bottom: var(--spacing-xl);
    }
    
    .profile-container {
        margin-bottom: var(--spacing-xl);
    }
}

/* Performance optimizations */
.profile-image,
.nav-link,
.theme-toggle,
.phd-notice {
    will-change: transform;
    transform: translateZ(0);
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Modern CSS features */
@supports (backdrop-filter: blur(20px)) {
    .nav-link,
    .theme-toggle,
    .phd-notice {
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }
}

@supports (height: 100dvh) {
    .container {
        min-height: 100dvh;
    }
}

@supports (height: 100svh) {
    @media (max-width: 320px) {
        .container {
            min-height: 100svh;
        }
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        animation-delay: 0s !important;
    }
    
    html {
        scroll-behavior: auto;
    }
    
    .profile-image {
        animation: none !important;
    }
    
    body::after,
    .container::before {
        animation: none !important;
    }
}