/* Basic Reset & Global Styles */
:root {
    --primary-bg-color: #ffffff; /* Light mode default */
    --secondary-bg-color: #f8f8f8;
    --text-color: #333;
    --heading-color: #1a1a1a;
    --accent-color: #007bff; /* A clean blue, inspired by tech/scientific themes */
    --link-hover-color: #0056b3;
    --border-color: #eee;
    --button-bg-color: #007bff;
    --button-text-color: #ffffff;
    --code-bg-color: #f0f0f0; /* For potential code snippets */
}

/* Optional: Dark Mode - You can add a toggle later or make it default */
/* @media (prefers-color-scheme: dark) {
    :root {
        --primary-bg-color: #1a1a1a;
        --secondary-bg-color: #2a2a2a;
        --text-color: #e0e0e0;
        --heading-color: #ffffff;
        --accent-color: #8ab4f8; 
        --link-hover-color: #6a9edb;
        --border-color: #333;
        --button-bg-color: #8ab4f8;
        --button-text-color: #1a1a1a;
        --code-bg-color: #3a3a3a;
    }
} */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Makes layout calculations easier */
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--primary-bg-color);
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition for dark mode */
    position: relative;
    overflow-x: hidden; /* Prevent horizontal scrolling from background animation */
}

/* Animated Penrose Tiling Background */
body::before {
    content: '';
    position: fixed;
    top: -100%;
    left: -100%;
    width: 300%;  /* Increased from 200% to provide more coverage */
    height: 300%; /* Increased from 200% to provide more coverage */
    background-image: url('../images/penrose-tiling.svg');
    background-size: 800px 800px; /* Zoomed in background pattern */
    background-repeat: repeat;
    opacity: 0.15;
    z-index: -1;
    animation: penroseFloat 20s linear infinite;
    pointer-events: none;
    transform: translate(var(--scroll-x, 0px), var(--scroll-y, 0px));
}

@keyframes penroseFloat {
    0% {
        transform: translate(var(--scroll-x, 0px), var(--scroll-y, 0px)) rotate(0deg);
    }
    100% {
        transform: translate(calc(var(--scroll-x, 0px) - 50px), calc(var(--scroll-y, 0px) - 50px)) rotate(2deg);
    }
}

/* Scroll-based parallax effect */
@media (prefers-reduced-motion: no-preference) {
    body::before {
        animation: penroseFloat 20s linear infinite;
    }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none;
        transform: translate(0, 0);
    }
}

.container {
    max-width: 1000px; /* Max width for content */
    margin: 0 auto; /* Center the container */
    padding: 0 20px; /* Padding on sides for smaller screens */
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'IBM Plex Sans', sans-serif;
    color: var(--heading-color);
    margin-bottom: 0.8em;
    font-weight: 600;
}

h1 { font-size: 2.8em; }
h2 { font-size: 2.2em; }
h3 { font-size: 1.8em; }
p { margin-bottom: 1em; }

a {
    color: var(--accent-color);
    text-decoration: none; /* No underline by default */
    transition: color 0.3s ease;
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline; /* Underline on hover for links */
}

/* Header & Navigation */
.site-header {
    background-color: var(--primary-bg-color);
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Subtle shadow */
    position: sticky; /* Keeps header at top on scroll */
    top: 0;
    z-index: 1000; /* Ensures it's above other content */
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allows wrapping on small screens */
}

.site-title {
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
}

.site-title a {
    color: var(--heading-color);
    text-decoration: none;
}

.site-nav ul {
    list-style: none;
    display: flex;
    gap: 25px; /* Space between nav items */
    align-items: center; /* Vertically center all items including the button */
}

.site-nav a {
    font-weight: 400;
    color: var(--text-color);
    padding: 5px 0;
    position: relative; /* For underline effect */
}

.site-nav a:hover {
    color: var(--link-hover-color);
    text-decoration: none; /* Remove default underline on hover */
}

/* Underline effect for nav links */
.site-nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--accent-color);
    transition: width 0.3s ease-in-out;
}

.site-nav a:hover::after {
    width: 100%;
}

/* Remove the special spacing for the last nav item (button) */
.site-nav li:last-child {
    margin-top: 0; /* Remove any special spacing */
}

/* Button style for CV */
.button {
    background-color: var(--button-bg-color);
    color: var(--button-text-color) !important; /* !important to override `a` tag color */
    padding: 10px 25px; /* Increased horizontal padding */
    min-width: 120px; /* Ensures minimum width for the button */
    text-align: center; /* Centers text within the button */
    border-radius: 5px;
    text-decoration: none;
    font-weight: 400;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: inline-block; /* Allows padding and margin */
}

.button:hover {
    background-color: var(--link-hover-color);
    transform: translateY(-2px); /* Slight lift effect */
    text-decoration: none;
}

/* Main Content - Hero Section */
.main-content {
    padding: 60px 20px; /* Top/bottom padding */
    min-height: calc(100vh - 180px); /* Adjust to ensure footer is at bottom */
}

.hero {
    display: flex;
    flex-direction: column; /* Stack image and bio on small screens */
    align-items: center;
    text-align: center;
    gap: 40px; /* Space between image and bio */
}

.hero-image {
    flex-shrink: 0; /* Prevents image from shrinking */
    width: 200px; /* Fixed width for the image container */
    height: 200px; /* Fixed height for the image container */
    border-radius: 50%; /* Makes the image circular */
    overflow: hidden; /* Hides parts of image outside the circle */
    border: 4px solid var(--accent-color); /* Border around the image */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures the image covers the circle without distortion */
    display: block; /* Removes extra space below image */
}

.hero-bio {
    max-width: 700px;
}

.hero-bio h2 {
    font-size: 2.5em;
    margin-bottom: 15px;
    color: var(--heading-color);
    text-align: center; /* Keep the heading centered */
}

.hero-bio p {
    font-size: 1.1em;
    margin-bottom: 1.2em;
    text-align: justify; /* Make paragraph text aligned flat on both edges */
    hyphens: auto; /* Optional: adds hyphens for better justification */
}

.hero-bio a {
    font-weight: 600; /* Make internal links stand out */
}

.social-links {
    margin-top: 25px;
    font-size: 1.1em;
    font-family: 'Roboto Mono', monospace; /* Monospace for links */
}

.social-links a {
    margin: 0 10px;
    color: var(--text-color); /* Default text color for social links */
}

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

/* General Section Styling for Research, Projects, Interests */
.section-content {
    padding: 40px 0;
    border-bottom: 1px solid var(--border-color);
}

.section-content:last-child {
    border-bottom: none; /* No border for the last section */
}

.section-content h2 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.5em;
    position: relative;
    padding-bottom: 15px;
}

.section-content h2::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--accent-color);
    border-radius: 2px;
}

.item-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Responsive grid */
    gap: 30px;
    margin-top: 30px;
}

.item-card {
    background-color: var(--secondary-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.item-card h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
    color: var(--heading-color);
}

.item-card p {
    font-size: 0.95em;
    margin-bottom: 15px;
}

/* Abstract Image Styling for Research Section */
.abstract-image {
    width: auto; /* Let the width adjust naturally to the image */
    max-width: 80%; /* Increased maximum width constraint */
    height: 150px;
    margin: 15px auto 20px auto; /* Center the image container */
    border-radius: 6px;
    background-color: transparent; /* Keep transparent background */
    display: flex;
    align-items: center;
    justify-content: center;
}

.abstract-image img {
    height: 120px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.abstract-image:hover img {
    transform: scale(1.05);
}

.item-card .tags {
    font-size: 0.85em;
    color: #666;
    margin-top: 10px;
    font-family: 'Roboto Mono', monospace;
}
.item-card .tags span {
    background-color: var(--code-bg-color);
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 5px;
    display: inline-block;
    margin-bottom: 5px;
}

/* Footer */
.site-footer {
    background-color: var(--secondary-bg-color);
    color: #777;
    text-align: center;
    padding: 30px 0;
    font-size: 0.9em;
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        text-align: center;
    }

    .site-nav ul {
        margin-top: 15px;
        flex-direction: column; /* Stack nav items vertically */
        gap: 15px;
    }
    
    .site-nav li:last-child {
        margin-top: 10px; /* Keep space for the button on mobile only */
    }

    .site-title {
        margin-bottom: 10px;
    }

    .hero {
        flex-direction: column;
        padding: 40px 0;
    }

    .hero-bio h2 {
        font-size: 2em;
    }

    .main-content {
        padding: 40px 15px;
    }

    .item-list {
        grid-template-columns: 1fr; /* Single column on small screens */
    }

    .section-content h2 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 2.2em; }
    h2 { font-size: 1.8em; }
    h3 { font-size: 1.4em; }

    .site-nav ul {
        gap: 10px;
    }

    .button {
        padding: 8px 15px;
        font-size: 0.9em;
    }

    .hero-image {
        width: 150px;
        height: 150px;
    }

    .hero-bio p {
        font-size: 1em;
    }
}