:root {
    /* Dark Mode (Default) */
    --bg-color: #0f172a;
    --text-color: #f0f9ff;
    --text-muted: #94a3b8;
    --primary-accent: #0ea5e9;
    /* Sky 500 - Vibrant Tech Blue */
    --secondary-accent: #6366f1;
    /* Indigo - subtle purple depth */
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(14, 165, 233, 0.1);
    --card-bg: rgba(30, 41, 59, 0.5);
    --timeline-line: rgba(14, 165, 233, 0.3);
    --code-bg: #1e293b;
    --robot-color: #334155;
    --robot-wheel: #0f172a;
}

[data-theme="light"] {
    --bg-color: #f0f9ff;
    --text-color: #0c4a6e;
    --text-muted: #475569;
    --primary-accent: #0284c7;
    /* Sky 600 - Readable on light */
    --secondary-accent: #4f46e5;
    /* Indigo 600 */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(2, 132, 199, 0.1);
    --card-bg: rgba(255, 255, 255, 0.6);
    --timeline-line: rgba(2, 132, 199, 0.3);
    --code-bg: #e0f2fe;
    --robot-color: #94a3b8;
    --robot-wheel: #475569;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Scroll Progress Bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(to right, var(--primary-accent), var(--secondary-accent));
    z-index: 1001;
    transition: width 0.1s;
}

/* Canvas Background */
#robot-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at center, transparent 0%, transparent 100%);
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(transparent 20%, var(--bg-color) 90%);
    z-index: -1;
    pointer-events: none;
    transition: background 0.5s;
}

/* Glassmorphism Navigation */
.glass-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.5s, border-color 0.5s;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-color);
}

.highlight {
    color: var(--primary-accent);
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    margin-left: 2rem;
    font-weight: 500;
    transition: color 0.3s;
    font-size: 0.9rem;
}

.nav-links a:hover {
    color: var(--primary-accent);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.2rem;
    margin-left: 2rem;
    transition: transform 0.3s, color 0.3s;
    padding: 5px;
}

.theme-toggle:hover {
    transform: rotate(30deg);
    color: var(--primary-accent);
}

/* Sections */
.section {
    padding: 6rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    text-align: center;
    color: var(--text-color);
}

/* Hero Section */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 100vh;
    padding: 8rem 5% 4rem;
    max-width: 1200px;
    margin: 0 auto;
    gap: 2rem;
}

.hero-content {
    flex: 1;
}

.badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary-accent);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--primary-accent);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 4rem;
    line-height: 1.1;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

h2 {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.typing-text {
    border-right: 2px solid var(--primary-accent);
    white-space: nowrap;
    overflow: hidden;
    animation: blink 0.75s step-end infinite;
}

@keyframes blink {

    from,
    to {
        border-color: transparent
    }

    50% {
        border-color: var(--primary-accent)
    }
}

.gradient-text {
    background: linear-gradient(to right, var(--primary-accent), var(--secondary-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

p {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.social-links {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
}

.icon-link {
    font-size: 1.5rem;
    color: var(--text-color);
    transition: color 0.3s, transform 0.3s;
}

.icon-link:hover {
    color: var(--primary-accent);
    transform: translateY(-3px);
}

.cta-group {
    display: flex;
    gap: 1rem;
}

.primary-btn,
.secondary-btn {
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
    cursor: pointer;
}

.primary-btn {
    background: var(--text-color);
    color: var(--bg-color);
}

.secondary-btn {
    border: 1px solid var(--glass-border);
    color: var(--text-color);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.secondary-btn:hover {
    background: rgba(125, 125, 125, 0.1);
}

/* Skills Grid */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.skill-category {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    transition: transform 0.3s, background 0.3s;
}

.skill-category:hover {
    transform: translateY(-5px);
}

.skill-category h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-accent);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.skill-tag {
    font-size: 0.85rem;
    background: rgba(125, 125, 125, 0.1);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    color: var(--text-color);
    border: 1px solid var(--glass-border);
}

/* Timeline */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--timeline-line);
}

.timeline-item {
    padding-left: 3rem;
    position: relative;
    margin-bottom: 3rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 5px;
    width: 20px;
    height: 20px;
    background: var(--bg-color);
    border: 2px solid var(--primary-accent);
    border-radius: 50%;
    z-index: 1;
    transition: background 0.3s;
}

.timeline-date {
    font-size: 0.9rem;
    color: var(--primary-accent);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.timeline-content h3 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
    color: var(--text-color);
}

.timeline-content h4 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 400;
}

/* Education Grid */
.education-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.edu-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.edu-header h3 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
    color: var(--text-color);
}

.edu-date {
    font-size: 0.9rem;
    color: var(--secondary-accent);
}

.edu-detail {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Projects */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    transition: transform 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-accent);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header i {
    font-size: 1.5rem;
    color: var(--primary-accent);
}

.card-header h3 {
    color: var(--text-color);
}

.project-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: auto;
}

.project-tech {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

.project-tech span {
    font-size: 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-accent);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

/* Code Block */
.hero-visual {
    flex: 1;
    display: flex;
    justify-content: center;
}

.code-block {
    background: var(--code-bg);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 450px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transition: background 0.5s;
}

.code-header {
    display: flex;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background: #ef4444;
}

.dot.yellow {
    background: #f59e0b;
}

.dot.green {
    background: #22c55e;
}

pre {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.keyword {
    color: var(--secondary-accent);
}

.string {
    color: var(--primary-accent);
}

.comment {
    color: var(--text-muted);
    opacity: 0.7;
}

.function {
    color: #60a5fa;
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 5%;
    background: var(--bg-color);
    border-top: 1px solid var(--glass-border);
    transition: background 0.5s;
}

.contact-info {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Back To Top Button */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-accent);
    color: #fff;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#back-to-top.visible {
    opacity: 1;
    pointer-events: all;
}

#back-to-top:hover {
    transform: translateY(-5px);
}

/* Scroll Animations */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .glass-nav {
        padding: 1rem 5%;
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        margin-left: 0;
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-links a {
        margin-left: 0;
        font-size: 0.85rem;
    }

    .theme-toggle {
        margin-left: 0;
    }

    .hero {
        flex-direction: column;
        text-align: center;
        padding-top: 10rem;
        /* Increased top padding to account for taller nav */
        padding-bottom: 2rem;
    }

    .hero-content {
        order: 1;
        /* Ensure text comes first on mobile slightly, usually okay but keeping order */
    }

    .hero-visual {
        order: 2;
        width: 100%;
    }

    h1 {
        font-size: 2.5rem;
        /* Resize heavy fonts */
    }

    .section {
        padding: 3rem 5%;
    }

    .section-title {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

    .timeline::before {
        left: 20px;
    }

    .timeline-item {
        padding-left: 3rem;
    }

    .social-links,
    .cta-group {
        justify-content: center;
    }

    .projects-grid,
    .education-grid,
    .skills-grid {
        grid-template-columns: 1fr;
        /* Force single column on smaller tablets/large phones */
    }

    .code-block {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    .nav-links a {
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 5px;
    }
}

/* --- New Features --- */

/* 3D Tilt Effect Base */
.tilt-card {
    transform-style: preserve-3d;
    transform: perspective(1000px);
    transition: transform 0.1s;
    /* Faster for mouse tracking */
}

/* System Widget */
.system-widget {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--primary-accent);
    padding: 0.8rem;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--primary-accent);
    backdrop-filter: blur(5px);
    z-index: 1000;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 150px;
}

.widget-header {
    border-bottom: 1px dashed var(--glass-border);
    padding-bottom: 2px;
    margin-bottom: 2px;
    font-weight: 700;
}

.status-row {
    display: flex;
    justify-content: space-between;
}

.blink {
    animation: blink-anim 2s infinite;
}

@keyframes blink-anim {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* --- Even More Features --- */

/* Custom Cursor */
body {
    cursor: crosshair;
    /* Fallback */
}

/* Glitch Effect */
.glitch {
    position: relative;
    color: var(--text-color);
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 #ff00c1;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim-1 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 #00fff9;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim-2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% {
        clip: rect(20px, 9999px, 11px, 0);
    }

    20% {
        clip: rect(68px, 9999px, 86px, 0);
    }

    40% {
        clip: rect(10px, 9999px, 96px, 0);
    }

    60% {
        clip: rect(52px, 9999px, 12px, 0);
    }

    80% {
        clip: rect(27px, 9999px, 73px, 0);
    }

    100% {
        clip: rect(72px, 9999px, 35px, 0);
    }
}

@keyframes glitch-anim-2 {
    0% {
        clip: rect(12px, 9999px, 63px, 0);
    }

    20% {
        clip: rect(84px, 9999px, 5px, 0);
    }

    40% {
        clip: rect(28px, 9999px, 20px, 0);
    }

    60% {
        clip: rect(3px, 9999px, 47px, 0);
    }

    80% {
        clip: rect(69px, 9999px, 97px, 0);
    }

    100% {
        clip: rect(43px, 9999px, 54px, 0);
    }
}

/* --- Click Particles --- */
.click-particle {
    position: fixed;
    pointer-events: none;
    background: var(--primary-accent);
    border-radius: 50%;
    animation: fade-out 1s forwards;
    z-index: 9999;
}

@keyframes fade-out {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0);
    }
}

/* --- Active Nav Link --- */
.nav-links a.active {
    color: var(--primary-accent);
    position: relative;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-accent);
    box-shadow: 0 0 10px var(--primary-accent);
}