:root {
    /* Dark Mode (Matte Starry) - Default */
    --bg-color: #0d0d11;
    /* Matte almost-black */
    --card-bg: rgba(255, 255, 255, 0.03);
    /* Subtle white overlay */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.15);
    --border-color: rgba(255, 255, 255, 0.08);

    --header-height-large: 100vh;
    --header-height-small: 80px;
    --transition-speed: 0.4s;
    /* Slightly faster for snappier feel */
    --container-width: 1200px;
}

body.light-mode {
    /* Morning Dawn (Bright) */
    --bg-color: #fff7ed;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --accent: #f59e0b;
    /* Sunny orange/gold */
    --accent-glow: rgba(245, 158, 11, 0.3);
    --border-color: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    /* Matte Starry Night */
    background-image:
        radial-gradient(1px 1px at 10% 10%, rgba(255, 255, 255, 0.8) 100%, transparent),
        radial-gradient(1px 1px at 20% 20%, rgba(255, 255, 255, 0.8) 100%, transparent),
        radial-gradient(1px 1px at 30% 70%, rgba(255, 255, 255, 0.6) 100%, transparent),
        radial-gradient(1px 1px at 60% 40%, rgba(255, 255, 255, 0.9) 100%, transparent),
        radial-gradient(1px 1px at 80% 10%, rgba(255, 255, 255, 0.7) 100%, transparent),
        radial-gradient(2px 2px at 50% 50%, rgba(255, 255, 255, 0.5) 100%, transparent),
        radial-gradient(circle at 50% 100%, #1a1a2e 0%, transparent 50%);
    /* Subtle bottom glow */
    background-size: 100% 100%;
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.5s, color 0.5s;
}

body.light-mode {
    /* Morning Dawn Gradient */
    background-image:
        linear-gradient(180deg, #ffedd5 0%, #e0f2fe 100%);
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
    z-index: 101;
    /* Above everything */
}

.theme-toggle:hover {
    background: var(--accent);
    color: #fff;
    transform: rotate(15deg);
}


a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #fff;
}

/* --- HEADER --- */
header {
    background-color: var(--bg-color);
    /* Fallback */
    /* Dynamic Background: Transparent at top, solid at bottom */
    /* We can interpolate the alpha channel using the variable, but standard CSS colors don't support calc in alpha easily without new syntax. 
       Workaround: Use an overlay or just a solid color that becomes visible. 
       Or better: Use backdrop filter mostly. */
    background-color: transparent;

    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;

    /* Dynamic Height based on Scroll */
    /* height = (1 - scroll) * (large - small) + small */
    /* But simplified: calculate height based on remaining space? 
       Actually: Height = 100vh - (100vh - 80px) * scroll 
    */
    --current-height: calc(100vh - (100vh - var(--header-height-small)) * var(--scroll));
    height: var(--current-height);

    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Remove transition on height for instant scroll-locking */
    transition: background-color 0.3s, box-shadow 0.3s, border-bottom 0.3s;

    will-change: height;
    overflow: hidden;
    /* Hide content as it shrinks */

    /* Border and Shadow appear as we scroll */
    border-bottom: 1px solid rgba(255, 255, 255, calc(var(--scroll) * 0.1));
    box-shadow: 0 4px 30px rgba(0, 0, 0, calc(var(--scroll) * 0.2));

    /* Add background opacity as we scroll */
    /* Using a pseudo-element for the background to control opacity */
}

/* Background overlay */
header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--bg-color);
    opacity: var(--scroll);
    /* 0 to 1 */
    z-index: -1;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

/* Light mode bg adjustment */
body.light-mode header::before {
    background-color: rgba(255, 255, 255, 0.95);
}

.header-content {
    width: 100%;
    max-width: var(--container-width);
    display: flex;
    /* Transformation from column (large) to row (small) 
       is hard to animate smoothly with variable. 
       Instead, keep it Flex Row always, but adjust positions/margins?
       Or, keep Column and just squish it?
       
       Let's try a hybrid approach:
       Flex-direction change is abrupt.
       We will keep it Row-ish but wrap?
       
       Actually, to match the "hero" look, it's centered column.
       To match "nav" look, it's spaced row.
       
       Let's use position absolute for moving parts or transforms.
    */
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    /* At scroll=0, we want it to look like it's in the center/column.
       We can achieve this by pushing elements with margins/transforms based on calc.
    */
    position: relative;
}

/* To simulate the Column -> Row transition smoothly:
   We will position the Profile Container.
   At scroll 0: Centered vertically and horizontally (or left aligned as per previous design).
   At scroll 1: Aligned left, vertically centered.
   
   Actually, previous design was:
   Large: Col, Left aligned, vertically centered.
   Small: Row, Space between.
*/

.profile-container {
    display: flex;
    align-items: center;
    /* Gap shrinks */
    gap: calc(2rem - (1rem * var(--scroll)));
    transform-origin: left center;
    /* We don't need to change flex direction if we just hide the extra stuff */
    flex-direction: row;
}

/* Avatar Scaling */
.avatar {
    /* 120px to 45px */
    --size: calc(120px - (75px * var(--scroll)));
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    overflow: hidden;
    border: calc(4px - (2px * var(--scroll))) solid var(--accent);
    box-shadow: 0 0 calc(20px * (1 - var(--scroll))) var(--accent-glow);
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.name {
    /* 3rem to 1.5rem */
    font-size: calc(3rem - (1.5rem * var(--scroll)));
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: calc(0.5rem * (1 - var(--scroll)));
    white-space: nowrap;
}

/* Hide Contact links in small mode? Or scale them? 
   Let's keep them but fade them out/scale down if space is needed.
   User asked for "information is decreasing".
*/
.contact-links {
    display: flex;
    gap: 1.5rem;
    font-size: 1rem;
    /* Scale down slightly and move up closer to name */
    transform-origin: left top;
    transform: scale(calc(1 - (0.2 * var(--scroll)))) translateY(calc(var(--scroll) * -5px));
    opacity: 1;
    /* Keep visible */
}

/* Hero Text - The Intro Paragraph */
.hero-text {
    position: absolute;
    left: 0;
    /* Move it down from the Profile info */
    top: calc(50% + 80px);
    /* Initial position */
    transform: translateY(calc(var(--scroll) * -100px));
    /* Move up as we scroll */
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 800px;

    /* Fade out */
    opacity: calc(1 - (var(--scroll) * 1.5));
    pointer-events: none;
    /* Just text */
}

/* Scroll Button */
.scroll-down-btn {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.9rem;

    /* Fade out very fast as we scroll */
    opacity: calc(1 - (var(--scroll) * 4));

    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.scroll-down-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    color: var(--accent);
}

.scroll-down-btn .arrow {
    font-size: 1.2rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }

    60% {
        transform: translateY(-3px);
    }
}

/* When fully shrunk, hide elements properly to prevent clicks */
header.shrunk-state .hero-text,
header.shrunk-state .scroll-down-btn {
    visibility: hidden;
}


/* THEME TOGGLE POSITIONING */
/* It needs to move from top-right (absolute) to align with row in navbar?
   Currently it's absolute top 2rem right 2rem.
   In header 80px height, 2rem/2rem might is okay, but let's adjust.
*/
.theme-toggle {
    top: calc(2rem + (10px * var(--scroll)));
    /* Nudge it if needed */
    right: 2rem;
    /* Subtle scale on scroll */
    transform: scale(calc(1 - (0.2 * var(--scroll))));
    /* 1 -> 0.8 */
}

/* Keep the theme toggle vertically centered with the header
   once the header has finished shrinking */
header.shrunk-state .theme-toggle {
    top: 50%;
    transform: translateY(-50%) scale(0.8);
}

/* Spacer should reflect max height so content sits below the 100vh header initially */
.header-spacer {
    height: 100vh;
}


/* --- MAIN CONTENT --- */
.header-spacer {
    height: var(--header-height-large);
    transition: height var(--transition-speed);
}

.container {
    max-width: var(--container-width);
    margin: 4rem auto 2rem;
    padding: 0 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.large-card {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.icon {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.item {
    margin-bottom: 2rem;
}

.item:last-child {
    margin-bottom: 0;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.meta {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-style: italic;
}

/* Language Proficiency Styles */
.skill-row {
    margin-bottom: 1.2rem;
}

.skill-row:last-child {
    margin-bottom: 0;
}

.skill-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.prof-bar-bg {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.prof-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 3px;
}

/* Skills Tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.tags span {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tags span:hover {
    background-color: var(--accent);
    color: #fff;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #3b82f6);
}

/* --- FOOTER --- */
footer {
    margin-top: 2.5rem;
    padding: 1.5rem 0 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

footer p {
    margin: 0;
}

/* Responsive fixes */
@media (max-width: 768px) {
    .header-content {
        align-items: center;
        text-align: center;
        justify-content: center;
    }

    .profile-container {
        flex-direction: column;
        gap: 1.5rem;
    }

    .avatar {
        width: 150px;
        height: 150px;
    }

    .contact-links {
        justify-content: center;
        flex-wrap: wrap;
    }

    header.shrink .profile-container {
        flex-direction: row;
        gap: 1rem;
    }

    /* Keep header full screen on mobile too, but maybe adjust padding */
}