/* Global Reset for better responsiveness */
*, *::before, *::after {
    box-sizing: border-box;
}

/* CSS Variables for Theming */
:root {
    --primary-color: #2185d6;
    --secondary-color: #28096b;
    --accent-color: #fdf906;
    --transition-duration: 0.6s;
    --background-dark: #111111;
    --background-light: #f5f5f5;
    --text-dark: #fff;
    --text-light: #000;
    /* Button borders */
    --button-border-dark: rgba(162, 162, 162, 0.5);
    --button-border-light: rgba(0, 0, 0, 0.5);
    /* Button Hover Backgrounds (The sliding effect) */
    --button-bg-hover-dark: rgba(220, 220, 220, 0.9); /* Light grey for dark mode hover */
    --button-bg-hover-light: rgba(0, 0, 0, 0.9); /* Black for light mode hover */
    /* Button Text Color on Hover */
    --button-text-hover-dark: #111; /* Black text on light grey background */
    --button-text-hover-light: #fff; /* White text on black background */
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Page Background Pattern */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-dark);
    background-image: linear-gradient(
        32deg,
        rgba(8, 8, 8, 0.74) 30px,
        transparent
    );
    background-size: 60px 60px;
    background-position: -5px -5px;
    color: var(--text-dark);
    text-align: center;
    transition: background-color var(--transition-duration) cubic-bezier(0.16, 1, 0.3, 1), color var(--transition-duration);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Ensure content doesn't touch edges on very small screens */
    padding-bottom: 40px; 
}

/* Light Mode */
.light-mode {
    background: var(--background-light);
    color: var(--text-light);
    background-image: none;
}

/* Top-right controls container */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Toggle Switch */
.switch {
    font-size: 17px;
    position: relative;
    display: inline-block;
    width: 3.5em;
    height: 2em;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    background-color: var(--primary-color);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: pointer;
    transition: all var(--transition-duration) cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-radius: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.slider::before {
    position: absolute;
    content: "";
    height: 1.4em;
    width: 1.4em;
    border-radius: 50%;
    left: 10%;
    bottom: 15%;
    box-shadow: inset 15px -4px 0px 15px var(--accent-color);
    background-color: var(--secondary-color);
    transition: all var(--transition-duration) cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-origin: center;
}

.clouds_stars {
    position: absolute;
    border-radius: 50%;
    height: 10px;
    width: 10px;
    left: 70%;
    bottom: 50%;
    background-color: #fff;
    transition: all var(--transition-duration) cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 1;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
}

.switch input:checked ~ .clouds_stars {
    transform: translateX(-20px) scale(0.5);
    opacity: 0.8;
    box-shadow: -7px 10px 0 #fff, 8px 15px 0 #fff, -17px 1px 0 #fff;
}

.switch input:checked + .slider {
    background-color: var(--secondary-color) !important;
}

.switch input:checked + .slider::before {
    transform: translateX(100%);
    box-shadow: inset 8px -4px 0 0 #fff;
}

/* Container Styling - Mobile First (Stacked) */
.container {
    width: 90%;
    max-width: 480px; /* Default narrow width for mobile */
    margin-top: 80px;
    margin-bottom: 40px;
    padding: 40px 30px;
    border-radius: 20px;
    transition: all var(--transition-duration) cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dark Mode Container Background */
body:not(.light-mode) .container {
    --s: 200px;
    --c1: #1d1d1d;
    --c2: #4e4f51;
    --c3: #3c3c3c;

    background: repeating-conic-gradient(
            from 30deg,
            #0000 0 120deg,
            var(--c3) 0 180deg
        )
        calc(0.5 * var(--s)) calc(0.5 * var(--s) * 0.577),
    repeating-conic-gradient(
        from 30deg,
        var(--c1) 0 60deg,
        var(--c2) 0 120deg,
        var(--c3) 0 180deg
    );
    background-size: var(--s) calc(var(--s) * 0.577);
    background-color: rgba(17, 17, 17, 0.85);
}

/* Light Mode Container Background */
.light-mode .container {
    --s: 82px;
    --c1: #b2b2b2;
    --c2: #ffffff;
    --c3: #d9d9d9;
    --_g: var(--c3) 0 120deg, #0000 0;
    
    background: conic-gradient(from -60deg at 50% calc(100% / 3), var(--_g)),
        conic-gradient(from 120deg at 50% calc(200% / 3), var(--_g)),
        conic-gradient(
            from 60deg at calc(200% / 3),
            var(--c3) 60deg,
            var(--c2) 0 120deg,
            #0000 0
        ),
        conic-gradient(from 180deg at calc(100% / 3), var(--c1) 60deg, var(--_g)),
        linear-gradient(
            90deg,
            var(--c1) calc(100% / 6),
            var(--c2) 0 50%,
            var(--c1) 0 calc(500% / 6),
            var(--c2) 0
        );
    background-size: calc(1.732 * var(--s)) var(--s);
    background-color: rgba(245, 245, 245, 0.9);
}

/* Profile Photo */
.profile-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

.light-mode .profile-photo {
    border-color: rgba(0, 0, 0, 0.1);
}

p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: inherit;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.4s forwards;
    margin-bottom: 30px;
    max-width: 100%;
    padding: 0 10px;
}

.social-links {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

/* Default Button Styles (Mobile) */
button {
    padding: 0.9em 1.5em;
    border: 2px solid var(--button-border-dark);
    position: relative;
    overflow: hidden;
    background-color: transparent;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
    font-family: inherit;
    color: var(--text-dark);
    cursor: pointer;
    width: 100%; 
    max-width: 100%; 
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0.6s) forwards;
    will-change: transform, color, border-color;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Animation Delays */
button:nth-child(1) { --delay: 0.6s; }
button:nth-child(2) { --delay: 0.7s; }
button:nth-child(3) { --delay: 0.8s; }
button:nth-child(4) { --delay: 0.9s; }
button:nth-child(5) { --delay: 1.0s; }

button::before {
    content: '';
    width: 0;
    height: 1000%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    background: var(--button-bg-hover-dark);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: block;
    z-index: -1;
}

button:hover::before {
    width: 120%;
}

button:hover {
    color: var(--button-text-hover-dark);
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0) scale(0.98);
}

/* Light Mode Button Styles */
.light-mode button {
    border-color: var(--button-border-light);
    color: var(--text-light);
}

.light-mode button::before {
    background: var(--button-bg-hover-light);
}

.light-mode button:hover {
    color: var(--button-text-hover-light);
}

/* Icon Styles */
.icon {
    width: 22px;
    height: 22px;
    margin-right: 12px;
    /* Added filter to transition for smooth color change */
    transition: transform 0.3s ease, filter 0.3s ease;
    flex-shrink: 0;
}

button:hover .icon {
    transform: scale(1.1) rotate(5deg);
}

/* --- GitHub Icon Specific Color Logic (The 2nd Button) --- */

/* 1. Dark Mode (Idle): Icon is White (Invert 1) */
.social-links button:nth-child(2) .icon {
    filter: invert(1);
}

/* 2. Dark Mode (Hover): Icon becomes Black (Invert 0) */
/* We need this because the dark mode hover background is light grey */
.social-links button:nth-child(2):hover .icon {
    filter: invert(0);
}

/* 3. Light Mode (Idle): Icon is Black (Invert 0) */
/* This overrides rule #1 */
.light-mode .social-links button:nth-child(2) .icon {
    filter: invert(0);
}

/* 4. Light Mode (Hover): Icon becomes White (Invert 1) */
/* This overrides rule #2 */
.light-mode .social-links button:nth-child(2):hover .icon {
    filter: invert(1);
}


/* Copyright Text */
.copyright {
    margin-top: 25px;
    padding-bottom: 0;
    font-size: 0.85rem;
    opacity: 0.6 !important;
    transform: none !important;
    animation: none !important;
    margin-bottom: 0;
    width: 100%; /* Ensure it spans full width in grid */
}

/* --- Responsive Media Queries --- */

/* DESKTOP MODE: Full Screen Grid Layout */
@media (min-width: 769px) {
    .container {
        max-width: 1000px; /* Expand to wide screen */
        padding: 50px;
        margin-top: 60px;
    }

    .social-links {
        flex-direction: row; /* Switch from column to row */
        flex-wrap: wrap; /* Allow items to wrap */
        justify-content: center; /* Center items */
        gap: 20px;
    }

    button {
        /* Buttons become cards in a grid */
        width: 300px; /* Fixed width for consistent look */
        max-width: none; /* Remove mobile limit */
        padding: 1.2em 1.5em; /* Slightly larger clickable area */
        font-size: 1.1rem;
    }

    .profile-photo {
        width: 160px;
        height: 160px;
    }
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .container {
        width: 92%;
        margin-top: 60px;
        padding: 25px 15px;
    }

    .profile-photo {
        width: 120px;
        height: 120px;
    }

    p {
        font-size: 1rem;
        margin-bottom: 25px;
    }

    button {
        font-size: 14px;
        padding: 0.8em 1.2em;
    }

    .icon {
        width: 18px;
        height: 18px;
        margin-right: 10px;
    }

    .top-controls {
        top: 15px;
        right: 15px;
    }
}