:root {
    --bg: #f3f4f6;
    --text: #333;
    --card-bg: #ffffff;
    --header-bg1: #111827;
    --header-bg2: #1f2937;
    --accent: #38bdf8;
    --accent-dark: #0284c7;
    --muted: #6b7280;
    --shadow: rgba(0,0,0,0.1);
}
body.dark {
    --bg: #0f172a;
    --text: #e5e7eb;
    --card-bg: #1e293b;
    --header-bg1: #020617;
    --header-bg2: #0f172a;
    --muted: #94a3b8;
    --shadow: rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}
html {
    scroll-behavior: smooth;
}
body {
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Scroll progress bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    z-index: 999;
    transition: width 0.1s ease-out;
}

/* Theme toggle */
.theme-toggle {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 1000;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.25s ease, background 0.25s ease;
}
.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    background: rgba(255,255,255,0.3);
}

/* Header */
header {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--header-bg1), var(--header-bg2), var(--header-bg1));
    background-size: 200% 200%;
    animation: gradientShift 10s ease infinite;
    color: white;
    padding: 60px 20px;
    text-align: center;
}
#particles {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}
.header-content {
    position: relative;
    z-index: 1;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.profile-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #38bdf8;
    box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.15), 0 8px 20px rgba(0,0,0,0.35);
    margin-bottom: 18px;
    animation: floatPhoto 4s ease-in-out infinite, popIn 0.7s ease;
}
@keyframes floatPhoto {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.7); }
    to { opacity: 1; transform: scale(1); }
}

header h1 {
    animation: fadeInDown 0.8s ease 0.1s both;
}
header p {
    min-height: 1.4em;
    font-size: 1.05rem;
    color: #cbd5e1;
    animation: fadeInDown 0.8s ease 0.3s both;
}
.type-cursor {
    display: inline-block;
    margin-left: 2px;
    color: #38bdf8;
    animation: blink 0.9s steps(1) infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}

.resume-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 22px;
    background: var(--accent);
    color: #0f172a;
    font-weight: bold;
    text-decoration: none;
    border-radius: 30px;
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: fadeInDown 0.8s ease 0.5s both;
}
.resume-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(56, 189, 248, 0.5);
}

/* Navigation */
nav {
    background: var(--header-bg2);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background 0.3s ease;
}
.nav-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px;
}
nav a {
    position: relative;
    color: white;
    margin: 10px 15px;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.25s ease;
}
nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0%;
    height: 2px;
    background: #38bdf8;
    transition: width 0.25s ease;
}
nav a:hover {
    color: #38bdf8;
}
nav a:hover::after,
nav a.active-link::after {
    width: 100%;
}
nav a.active-link {
    color: #38bdf8;
}

/* Sections */
.container {
    max-width: 1000px;
    margin: auto;
    padding: 50px 20px;
}
h2 {
    margin-bottom: 8px;
    text-align: center;
    position: relative;
}
h2::after {
    content: '';
    display: block;
    width: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 3px;
    margin: 12px auto 20px;
    transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.25s;
}
.fade-section.visible h2::after {
    width: 60px;
}

/* Scroll reveal system — direction driven by data-anim on the section */
.fade-section {
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.fade-section[data-anim="up"]    { transform: translateY(36px); }
.fade-section[data-anim="left"]  { transform: translateX(-56px); }
.fade-section[data-anim="right"] { transform: translateX(56px); }
.fade-section[data-anim="zoom"]  { transform: scale(0.9); }
.fade-section.visible {
    opacity: 1;
    transform: none;
}

/* Staggered items within a section */
.stagger-item {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.25s ease;
}
.fade-section.visible .stagger-item {
    opacity: 1;
    transform: translateY(0);
}

/* Skill bars */
.skill-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.skill-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-weight: bold;
    font-size: 0.9rem;
}
.skill-pct {
    color: var(--accent-dark);
}
.skill-track {
    width: 100%;
    height: 12px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px var(--shadow);
}
.skill-fill {
    height: 100%;
    width: 0%;
    border-radius: 8px;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    transition: width 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Education */
.edu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.edu-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 8px var(--shadow);
    text-align: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}
.edu-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px var(--shadow);
}
.edu-card h3 {
    margin-bottom: 8px;
    color: var(--text);
}
.edu-meta {
    display: block;
    margin-top: 10px;
    color: var(--accent-dark);
    font-weight: bold;
    font-size: 0.9rem;
}

/* Experience — animated timeline */
.exp-card {
    position: relative;
    background: var(--card-bg);
    padding: 20px 20px 20px 28px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 8px var(--shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}

.exp-card:hover {
    transform: translateX(6px);
    box-shadow: 0 10px 22px var(--shadow);
}
.exp-head {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}
.exp-date {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: bold;
}
.exp-company {
    display: block;
    color: var(--accent-dark);
    font-weight: bold;
    margin: 4px 0 12px;
    font-size: 0.9rem;
}
.exp-card ul {
    padding-left: 20px;
}
.exp-card li {
    margin-bottom: 6px;
}

/* Projects */
.project-card {
    background: var(--card-bg);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 8px var(--shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}
.project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 26px var(--shadow);
}

/* Achievements & Certifications */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
    text-align: center;
}
.badge-card {
    background: var(--card-bg);
    padding: 16px 18px;
    border-radius: 6px;
    box-shadow: 0 2px 5px var(--shadow);
    font-size: 0.95rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}
.badge-card:hover {
    transform: scale(1.04);
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.2);
}
.badge-card .yr {
    display: inline-block;
    background: var(--header-bg1);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 8px;
    margin: 6px;
}

/* GitHub stats */
.github-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}
.github-stats img {
    max-width: 100%;
    border-radius: 8px;
}
.github-fallback {
    background: var(--card-bg);
    color: var(--muted);
    padding: 20px 24px;
    border-radius: 8px;
    box-shadow: 0 2px 5px var(--shadow);
    font-size: 0.9rem;
}
.github-fallback a {
    color: var(--accent-dark);
    font-weight: bold;
}

/* Contact */
#contact p {
    text-align: center;
    margin-bottom: 8px;
}
#contact a {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: bold;
}
#contact a:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    background: var(--header-bg1);
    color: white;
    text-align: center;
    padding: 20px;
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent);
    color: #0f172a;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease, visibility 0.3s;
    z-index: 998;
}
.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--accent-dark);
    color: white;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    header {
        padding: 50px 10px 30px;
    }
    .profile-photo {
        width: 110px;
        height: 110px;
    }
    .container {
        padding: 30px 15px;
    }
    nav a {
        display: block;
        margin: 8px 0;
    }
    .exp-head {
        flex-direction: column;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
