/* 1. Global Styles & Variables */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Playfair+Display:wght@500;700&display=swap');

:root {
    /* Color Palette */
    --primary-deep-indigo: #2C3E50; --secondary-teal-blue: #1ABC9C;
    --accent-warm-coral: #FF6F61; --background-soft-porcelain: #F8F9FA;
    --surface-mist-gray: #E5E8EB; --highlight-golden-amber: #F4C542;
    --text-charcoal-black: #212529; --text-slate-gray: #6C757D;
    
    /* Font Variables */
    --font-body: 'Inter', sans-serif;
    --font-heading: 'Playfair Display', serif;

    /* Color Assignments */
    --primary-color: var(--primary-deep-indigo); --background-color: var(--background-soft-porcelain);
    --text-color-dark: var(--text-charcoal-black); --text-color-light: var(--background-soft-porcelain);
    --accent-color: var(--accent-warm-coral); --accent-color-bright: #ff8a7a;
    --section-bg-alt: var(--surface-mist-gray); --panel-width: 165px; --panel-transition-speed: 0.3s;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    color: var(--text-color-dark);
    font-weight: 400;
    background-color: var(--background-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Palette */
body.dark-mode {
    --primary-color: #2C3E50;
    --background-color: #212529;
    --text-color-dark: #F8F9FA;
    --text-color-light: #212529;
    --accent-color: #FF6F61;
    --accent-color-bright: #ff8a7a;
    --section-bg-alt: #343a40;
    --surface-mist-gray: #495057;
}

/* 2. Dynamic Panel Styling */
.dynamic-panel {
    position: absolute; top: 0; left: 0; width: 100%; z-index: 1000;
    padding: 1.5rem 2rem;
    background-color: var(--primary-color);
    display: flex;
    justify-content: flex-start; 
    align-items: center;
    transition: all var(--panel-transition-speed) ease-in-out;
}
.panel-side-logo { display: none; }
.panel-side-logo img { width: 100%; height: auto; }

/* Menu wrapper for top state dropdown */
.menu-wrapper { position: relative; }
.menu-toggle {
    font-family: var(--font-body);
    background: none; border: none; color: var(--text-color-light); font-size: 1rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 0.5rem; letter-spacing: 1px;
    cursor: pointer;
}
.hamburger-icon span {
    display: block; width: 22px; height: 2px; background-color: var(--text-color-light); margin: 4px 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.menu-wrapper.menu-open .hamburger-icon span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-wrapper.menu-open .hamburger-icon span:nth-child(2) { opacity: 0; }
.menu-wrapper.menu-open .hamburger-icon span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.panel-nav {
    position: absolute; top: calc(100% + 15px); left: 0;
    background: var(--primary-color); border-radius: 5px;
    width: 200px; overflow: hidden; max-height: 0;
    transition: max-height 0.4s ease-in-out;
}
.menu-wrapper.menu-open .panel-nav { max-height: 300px; }
.panel-nav ul {
    list-style: none; display: flex; flex-direction: column;
    gap: 0.5rem; padding: 1rem;
}
.panel-nav li {
    opacity: 0;
}
.menu-wrapper.menu-open .panel-nav li {
    animation: slideInItem 0.4s ease forwards;
}
.menu-wrapper.menu-open .panel-nav li:nth-child(1) { animation-delay: 0.05s; }
.menu-wrapper.menu-open .panel-nav li:nth-child(2) { animation-delay: 0.1s; }
.menu-wrapper.menu-open .panel-nav li:nth-child(3) { animation-delay: 0.15s; }
.menu-wrapper.menu-open .panel-nav li:nth-child(4) { animation-delay: 0.2s; }
.menu-wrapper.menu-open .panel-nav li:nth-child(5) { animation-delay: 0.25s; }
.menu-wrapper.menu-open .panel-nav li:nth-child(6) { animation-delay: 0.3s; }

@keyframes slideInItem {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
.panel-nav a {
    color: var(--text-color-light); text-decoration: none; font-weight: 500;
    font-size: 1rem; transition: color 0.3s ease, background-color 0.3s ease;
    display: block; padding: 0.5rem; border-radius: 4px;
}
.panel-nav a:hover, .panel-nav a.active { color: var(--primary-deep-indigo); background-color: var(--accent-color-bright); }
body.dark-mode .panel-nav a:hover, body.dark-mode .panel-nav a.active { color: var(--text-charcoal-black); background-color: var(--accent-color); }

body.dark-mode .menu-toggle {
    color: var(--text-color-dark);
}

body.dark-mode .hamburger-icon span {
    background-color: var(--text-color-dark);
}

body.dark-mode .panel-nav a {
    color: var(--text-color-dark);
}

/* --- Scrolled State --- */
body.scrolled .dynamic-panel {
    position: fixed; width: var(--panel-width); height: 100vh;
    flex-direction: column; 
    justify-content: center;
    align-items: center; 
    padding: 2rem;
}
body.scrolled .panel-side-logo { display: none; }
body.scrolled .menu-toggle { display: none; }
body.scrolled .panel-nav {
    display: block; position: static; width: auto; padding: 0;
    border-radius: 0; max-height: none; background: none;
}
body.scrolled .panel-nav ul { flex-direction: column; align-items: center; gap: 1.5rem; padding: 0; }
body.scrolled .panel-nav li {
    opacity: 0;
    animation: slideInItem 0.5s ease forwards;
}
body.scrolled .panel-nav li:nth-child(1) { animation-delay: 0.1s; }
body.scrolled .panel-nav li:nth-child(2) { animation-delay: 0.2s; }
body.scrolled .panel-nav li:nth-child(3) { animation-delay: 0.3s; }
body.scrolled .panel-nav li:nth-child(4) { animation-delay: 0.4s; }
body.scrolled .panel-nav li:nth-child(5) { animation-delay: 0.5s; }
body.scrolled .panel-nav li:nth-child(6) { animation-delay: 0.6s; }

body.scrolled .panel-nav a { padding: 0; font-weight: 600; }
body.scrolled .panel-nav a:hover, body.scrolled .panel-nav a.active { color: var(--accent-color-bright); background-color: transparent; }

/* 3. Main Content Wrapper */
.content-wrapper { transition: margin-left var(--panel-transition-speed) ease-in-out; }
body.scrolled .content-wrapper { margin-left: var(--panel-width); }

/* 4. Hero & Content Sections */
.hero-section {
    height: 100vh; display: flex; flex-direction: column; justify-content: center;
    align-items: center; background-color: var(--background-color);
    position: relative; text-align: center;
    transition: background-color 0.3s ease;
}
h1, h2, h3 { transition: color 0.3s ease; }

/* UPDATED: Added position and z-index to fix overlapping text */
.hero-content {
    position: relative;
    z-index: 2; /* Ensures hero content is above the animation */
}

.hero-content h1 {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 7vw, 4.5rem); 
    font-weight: 700;
    line-height: 1; 
    margin-bottom: 2.5rem;
}
.hero-logo {
    max-height: 120px; 
    width: auto;
    margin-bottom: 2.5rem; 
}
.hero-greeting {
    font-size: 1rem; font-weight: 600; letter-spacing: 2px;
    color: var(--accent-color); 
    margin-bottom: 2.5rem;
}
.scroll-down-arrow {
    position: absolute; bottom: 2rem; width: 24px; height: 24px; animation: bounce 2s infinite;
}
.scroll-down-arrow::after {
    content: ''; display: block; width: 100%; height: 100%;
    border-bottom: 4px solid var(--text-color-dark);
    border-right: 4px solid var(--text-color-dark);
    transform: rotate(45deg);
    transition: border-color 0.3s ease;
}
@keyframes bounce { 0%, 20%, 50%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-20px); } 60% { transform: translateY(-10px); } }

/* 4.5 Hero Animation */
.hero-animation-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1; /* Sits behind the main hero content */
}
.phrase {
    position: absolute;
    opacity: 0;
    font-weight: 600;
    color: var(--text-color-dark);
    animation: fadeInOut 15s infinite;
    white-space: nowrap;
    transition: color 0.3s ease;
}
.animated-word-color {
    color: var(--accent-color);
}
@keyframes fadeInOut {
    0% { opacity: 0; transform: scale(0.95); }
    4% { opacity: 1; transform: scale(1); }
    16% { opacity: 1; transform: scale(1); }
    20% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 0; }
}

.phrase-1 { top: 25%; left: 15%; font-size: clamp(1rem, 2.5vw, 1.5rem); animation-delay: 0s; }
.phrase-2 { top: 70%; right: 18%; font-size: clamp(1.2rem, 3vw, 1.8rem); animation-delay: 3s; }
.phrase-3 { top: 20%; right: 10%; font-size: clamp(1.5rem, 4vw, 2.2rem); animation-delay: 6s; }
.phrase-4 { top: 75%; left: 20%; font-size: clamp(1.1rem, 2.8vw, 1.6rem); animation-delay: 9s; }
.phrase-5 { top: 50%; right: 15%; font-size: clamp(1rem, 2.5vw, 1.5rem); animation-delay: 12s; }


/* 5. Generic Content Styles */
.content-section { padding: 5rem 2rem; transition: background-color 0.3s ease; }
#about, #skills { background-color: var(--background-color); }
#experience, #publications, #contact { background-color: var(--section-bg-alt); }
.container { max-width: 960px; margin: 0 auto; }
h2 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2.5rem; margin-bottom: 2rem; text-align: center;
}
h3 {
    font-family: var(--font-heading);
    font-weight: 700;
}
.contact-info {
    text-align: center;
    color: var(--text-slate-gray);
    margin-bottom: 2.5rem;
    font-size: 0.9rem;
}
.contact-info strong {
    color: var(--text-charcoal-black);
}
body.dark-mode .contact-info strong { color: var(--text-color-dark); }
.contact-info a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}
.contact-info a:hover { text-decoration: underline; }

.card {
    background: var(--background-color);
    border-left: 5px solid var(--accent-color);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    border-radius: 0 5px 5px 0;
    text-align: left;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}
.card:hover {
    transform: translateX(10px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.07);
}
.card-subtitle {
    font-weight: 600;
    color: var(--text-charcoal-black);
}
body.dark-mode .card-subtitle {
    color: var(--text-color-dark);
}
.card ul { padding-left: 20px; margin-top: 1rem; }
.card-date { color: var(--text-slate-gray); font-weight: 500; }
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin-top: 2rem; }
.skill-item { background: #fff; border: 1px solid #ddd; border-radius: 5px; padding: 1rem; text-align: center; font-weight: 600; transition: background-color 0.3s ease, border-color 0.3s ease; }
body.dark-mode .skill-item { background-color: var(--surface-mist-gray); border-color: var(--primary-color); }
.cert-grid { display: flex; flex-wrap: wrap; gap: 2rem; align-items: center; justify-content: center; margin-top: 3rem; }

/* 6. Publications Section Styles */
.publication-item {
    background: var(--background-color);
    border-left: 5px solid var(--accent-color);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    border-radius: 0 5px 5px 0;
    text-align: left;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}
.publication-link { display: block; text-decoration: none; }
.publication-link:hover .publication-item {
    transform: translateX(10px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.07);
}
.publication-item h3 {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-color-dark);
}
.publication-item .publication-source {
    font-style: italic;
    color: var(--text-slate-gray);
}

/* 7. Footer Styles with Social Icons */
footer { text-align: center; }
footer h2 { color: var(--text-color-dark); }
.social-links { margin-top: 2rem; display: flex; justify-content: center; gap: 1.5rem; }
.social-links a, .social-icon-btn { text-decoration: none; display: flex; align-items: center; justify-content: center; transition: transform 0.2s ease; }
.social-links a:hover, .social-icon-btn:hover { transform: translateY(-5px); }
.social-icon { width: 40px; height: 40px; object-fit: contain; }
body.dark-mode .social-icon { filter: invert(1) brightness(1.5) contrast(1.2); }
.copyright { color: var(--text-slate-gray); margin-top: 2rem; }

/* 8. Dark Mode Toggle Switch */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    margin-left: auto;
}
.dark-mode-toggle:hover label::after {
    transform: translateY(-2px);
}
.dark-mode-toggle input {
    display: none;
}
.dark-mode-toggle label {
    cursor: pointer;
    width: 60px;
    height: 30px;
    background-color: var(--text-slate-gray);
    border-radius: 30px;
    position: relative;
    transition: background-color 0.3s ease;
}
.dark-mode-toggle label::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--background-soft-porcelain);
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232C3E50'%3E%3Cpath d='M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12Zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM11 1h2v3h-2V1Zm0 19h2v3h-2v-3ZM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93ZM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121Zm2.121-14.85-1.414 1.415L19.778 7.05l1.414-1.414-2.121-2.121ZM4.222 16.95l-1.414 1.414 2.121 2.121 1.414-1.414-2.121-2.121ZM1 11v2h3v-2H1Zm19 0v2h3v-2h-3Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px;
}
.dark-mode-toggle input:checked + label {
    background-color: var(--text-slate-gray);
}
.dark-mode-toggle input:checked + label::after {
    transform: translateX(30px);
    background-color: var(--primary-deep-indigo);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath stroke='%23F8F9FA' stroke-width='1' d='M17.51 3.07C15.93 2.38 14 2 12 2 6.48 2 2 6.48 2 12s4.48 10 10 10c2.21 0 4.21-.59 6-1.58-.93-.46-1.78-1.07-2.52-1.78-1.12-1.08-1.95-2.42-2.42-3.95-.53-1.69-.53-3.6 0-5.29.47-1.53 1.3-2.87 2.42-3.95.74-.71 1.59-1.32 2.52-1.78z'/%3E%3C/svg%3E");
}
.dark-mode-toggle:hover input:checked + label::after {
    transform: translateY(-2px) translateX(30px);
}
body.scrolled .dark-mode-toggle {
    display: none;
}

/* 9. Share Button Styles */
.share-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.social-icon-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}
.share-nav {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    border-radius: 5px;
    width: 150px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.4s ease-in-out;
}
.share-menu-wrapper.share-menu-open .share-nav {
    max-height: 100px;
}
.share-nav ul {
    list-style: none;
    padding: 0.5rem;
}
.share-nav li {
    opacity: 0;
}
.share-menu-wrapper.share-menu-open .share-nav li {
    animation: slideInItem 0.4s ease forwards;
}
.share-nav button {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-color-light);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.3s, background-color 0.3s;
}
.share-nav button:hover {
    color: var(--primary-deep-indigo);
    background-color: var(--accent-color-bright);
}
body.dark-mode .share-nav button:hover {
    color: var(--text-charcoal-black);
    background-color: var(--accent-color);
}

/* 10. Responsive Design (Media Queries) */
@media (max-width: 768px) {
    /* --- Always-on-top Navbar for Mobile --- */
    .dynamic-panel {
        position: fixed; /* Keep navbar fixed at the top on mobile */
        justify-content: space-between; /* Space between menu and toggle */
    }
    body.scrolled .dynamic-panel {
        position: fixed;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-between; /* Keep space-between on scroll */
        align-items: center;
        padding: 1.5rem 1.5rem;
    }
    body.scrolled .panel-nav {
        display: none;
    }
    body.scrolled .menu-toggle {
        display: flex;
    }
    body.scrolled .content-wrapper {
        margin-left: 0;
    }
    .content-wrapper {
        padding-top: 80px; /* Adjust this value to match your nav bar height */
    }
    
    /* UPDATED: Ensure dark mode toggle is always visible on mobile */
    body.scrolled .dark-mode-toggle {
        display: flex;
    }


    /* --- Reposition Animated Phrases on Mobile --- */
    .phrase {
        font-size: clamp(0.9rem, 3.5vw, 1.2rem);
    }
    .phrase-1 { top: 20%; left: 5%; }
    .phrase-2 { top: 78%; right: 5%; }
    .phrase-3 { top: 20%; right: 8%; }
    .phrase-4 { top: 82%; left: 8%; }
    .phrase-5 { top: 70%; right: 10%; }

    /* --- Ensure Scroll Arrow is Visible --- */
    .scroll-down-arrow {
        bottom: 5.6rem; /* UPDATED: Moved arrow up to be more visible */
    }

    /* --- General Mobile Adjustments --- */
    .hero-content h1 { font-size: clamp(2rem, 10vw, 3.5rem); }
    .hero-logo { max-height: 100px; }
    .content-section { padding: 4rem 1.5rem; }
    .dynamic-panel { padding: 1rem 1.5rem; }
    .panel-nav {
        /* Reposition dropdown to the right on mobile */
        left: 0;
        right: auto;
    }
}

