/* CSS Variables for Theme Colors */
:root {
    /* Light Theme */
    --bg-color-body: #f8fafc; /* Very light background */
    --bg-card: #ffffff; /* White card background */
    --text-color-primary: #1a202c; /* Dark text */
    --text-color-secondary: #4a5568; /* Medium text */
    --border-color: #e2e8f0;
    --gradient-from: #a78bfa; /* Violet 400 */
    --gradient-to: #6366f1; /* Indigo 500 */
    --button-gradient-from: #3b82f6; /* Blue 500 */
    --button-gradient-to: #7e22ce; /* Purple 800 */
    --button-hover-gradient-from: #2563eb; /* Blue 600 */
    --button-hover-gradient-to: #6b21a8; /* Purple 900 */
    --toggle-bg: #f3f4f6;
    --toggle-text: #1f2937;
}

/* Dark Theme */
html[data-theme="dark"] {
    --bg-color-body: #0f172a; /* Dark blue-gray for body */
    --bg-card: #1e293b; /* Even darker card background */
    --text-color-primary: #f8fafc; /* Lightest text */
    --text-color-secondary: #cbd5e0; /* Light text */
    --border-color: #475569;
    --gradient-from: #1e293b; /* Dark gradient start */
    --gradient-to: #2d3748; /* Dark gradient end */
    --button-gradient-from: #6366f1; /* Indigo 500 */
    --button-gradient-to: #8b5cf6; /* Violet 500 */
    --button-hover-gradient-from: #4f46e5; /* Indigo 600 */
    --button-hover-gradient-to: #7c3aed; /* Violet 600 */
    --toggle-bg: #374151;
    --toggle-text: #f8fafc;

    /* --- Specific Text Color Overrides for Dark Mode --- */
    /* Apply primary text color to all default gray shades used by Tailwind */
    .text-gray-50, .text-gray-100, .text-gray-200, .text-gray-300,
    .text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700,
    .text-gray-800, .text-gray-900 {
        color: var(--text-color-primary) !important;
    }

    /* Override specific colored texts to ensure they are visible in dark mode */
    .text-purple-700 {
        color: var(--heading-color) !important; /* Ensure these are readable */
    }
    .text-indigo-600 {
        color: var(--link-color) !important; /* Ensure links are visible */
    }

    /* Ensure list bullets adapt to the secondary text color */
    ul li::marker {
        color: var(--text-color-secondary);
    }

    /* Specific overrides for text elements that might inherit black */
    h1, h2, h3, p, span, li, a {
        color: var(--text-color-primary); /* Default to primary for all */
    }
    /* Re-apply more specific rules with !important if needed based on structure */
    .portfolio-section p, .experience-card p, .project-card p,
    .education-card p, .certifications li {
        color: var(--text-color-secondary) !important;
    }
    .portfolio-section h2, .experience-card h3, .project-card h3,
    .education-card h3, .certifications li span {
        color: var(--text-color-primary) !important;
    }
    /* Ensure footer text is readable */
    footer p {
        color: var(--text-color-secondary) !important;
    }
}


/* General Body and Font Styles */
body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color-primary); /* Use primary text color variable */
    line-height: 1.6;
    scroll-behavior: smooth;
    overflow-x: hidden;
    background-color: var(--bg-color-body); /* Use body background color variable */
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition for theme change */
}

/* Custom Background Gradient for a modern feel */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--gradient-from) 0%, var(--gradient-to) 100%);
    opacity: 0.6;
    z-index: 0;
    filter: blur(100px); /* Soft blur effect */
    pointer-events: none;
    transition: background 0.5s ease, opacity 0.5s ease;
}

/* Main Content Container */
.container {
    background-color: var(--bg-card); /* Use card background color variable */
    border-radius: 1.5rem; /* More rounded corners */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); /* Stronger, modern shadow */
    padding: 3rem; /* Increased padding */
    margin-top: 3rem;
    margin-bottom: 3rem;
    position: relative; /* For z-index to work against background-gradient */
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Section Headings - modern and prominent */
.section-heading {
    font-family: 'Poppins', sans-serif; /* Different font for headings */
    display: flex;
    align-items: center;
    border-bottom: 3px solid var(--heading-border); /* Use heading border color variable */
    padding-bottom: 0.75rem;
    margin-bottom: 2.5rem; /* More space below headings */
    font-size: 2.5rem; /* Larger heading */
    font-weight: 700; /* Bold */
    color: var(--heading-color); /* Use heading color variable */
    letter-spacing: -0.03em; /* Tighter letter spacing */
    transition: color 0.3s ease, border-color 0.3s ease;
}

.section-heading svg {
    color: var(--heading-color); /* Match icon color to heading */
    flex-shrink: 0;
    transition: color 0.3s ease;
}

/* Card Styling for sections */
.portfolio-section {
    background-color: var(--bg-card); /* Use card background color variable */
    border-radius: 1.25rem; /* More rounded */
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* Enhanced shadow */
    padding: 2.5rem; /* Increased padding */
    margin-bottom: 3rem; /* More space between sections */
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Smooth transition for hover and scroll */
    /* Initial state for JS animation */
    opacity: 0;
    transform: translateY(30px);
}

.portfolio-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Skill Badges - larger and more distinct */
.skill-badge {
    background-color: var(--skill-badge-bg); /* Use skill badge background color variable */
    color: var(--skill-badge-text); /* Use skill badge text color variable */
    padding: 0.5rem 1.25rem;
    border-radius: 9999px; /* Pill shape */
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.4rem;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.skill-badge:hover {
    background-color: var(--skill-badge-hover-bg); /* Use skill badge hover background color variable */
    transform: translateY(-2px); /* Slight lift on hover */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Smaller Skill Badges for project cards */
.skill-badge-sm {
    background-color: var(--skill-badge-sm-bg); /* Use small skill badge background color variable */
    color: var(--skill-badge-sm-text); /* Use small skill badge text color variable */
    padding: 0.3rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    margin: 0.2rem;
    transition: background-color 0.2s ease;
}

.skill-badge-sm:hover {
    background-color: var(--skill-badge-sm-hover-bg); /* Use small skill badge hover background color variable */
}


/* Link Styling - modern and consistent */
a {
    color: var(--link-color); /* Use link color variable */
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--link-hover-color); /* Use link hover color variable */
    text-decoration: underline;
}

/* Specific Card Styles for sub-sections (Experience, Education) */
.experience-card, .education-card, .skill-category-card {
    background-color: var(--bg-card-light); /* Use light card background color variable */
    border-left: 6px solid var(--heading-border); /* Using heading border color */
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    transition: all 0.3s ease-in-out, background-color 0.3s ease, border-color 0.3s ease;
}

.experience-card:hover, .education-card:hover, .skill-category-card:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 12px -4px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.06);
}

/* Project Card Specific Styles - Grid Layout */
.project-card {
    background-color: var(--bg-card); /* Use card background color variable */
    border-radius: 1rem;
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease-in-out;
    border: 1px solid var(--border-color); /* Use border color variable */
    overflow: hidden;
}

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px -8px rgba(0, 0, 0, 0.25), 0 6px 10px -4px rgba(0, 0, 0, 0.1);
    border-color: var(--link-color); /* Use link color variable for hover border */
}

.project-link {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    color: var(--link-color); /* Use link color variable */
    transition: color 0.3s ease;
}

.project-link:hover {
    color: var(--link-hover-color); /* Use link hover color variable */
}

/* Header Specific Styles */
header {
    background: linear-gradient(135deg, var(--header-gradient-from) 0%, var(--header-gradient-to) 100%);
    transition: background 0.3s ease;
}

header h1 {
    color: var(--header-text-dark);
}

header p {
    color: var(--header-text-light);
}

header a, header span {
    color: var(--header-text-light);
}

header a:hover {
    color: var(--header-icon-hover);
}

/* Theme Toggle Button */
#theme-toggle {
    background-color: var(--toggle-bg); /* Use toggle background color variable */
    transition: background-color 0.3s ease;
}

#theme-toggle svg {
    color: var(--toggle-text); /* Use toggle text color variable */
    transition: color 0.3s ease;
}

/* Header Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-down { animation: fadeInDown 0.8s ease-out forwards; }
.animate-fade-in-left { animation: fadeInLeft 0.8s ease-out 0.2s forwards; opacity: 0; }
.animate-fade-in-right { animation: fadeInRight 0.8s ease-out 0.4s forwards; opacity: 0; }
.animate-fade-in-up { animation: fadeInUp 0.8s ease-out 0.6s forwards; opacity: 0; }

/* Image specific styles */
.project-image {
    width: 100%;
    height: 200px; /* Fixed height for consistency */
    object-fit: cover; /* Ensures image covers area without distortion */
    border-bottom-left-radius: 0; /* Remove rounded corners at the bottom where it meets content */
    border-bottom-right-radius: 0;
}

/* Profile image specific styles */
header .items-center img { /* More specific selector for profile image */
    object-fit: cover; /* Ensure cover for circular images */
}

/* Fallback styling for images that fail to load */
img[onerror] {
    background-size: contain; /* Ensure background image covers */
    background-repeat: no-repeat;
    background-position: center;
    border: 1px dashed var(--border-color); /* Dashed border for missing image */
    color: var(--text-color-secondary); /* Text color for missing image alt text */
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    box-sizing: border-box; /* Include padding in dimensions */
}

/* To show alt text as visible text for broken images */
.broken-image-fallback::before {
    content: attr(alt); /* Display alt text */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word; /* Break long words */
    padding: 5px;
    box-sizing: border-box;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem;
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
        border-radius: 1rem;
    }
    .section-heading {
        font-size: 2rem; /* Adjusted for mobile */
        margin-bottom: 1.5rem;
    }
    header h1 {
        font-size: 3.5rem; /* Adjusted for mobile */
    }
    header p {
        font-size: 1.25rem;
    }
    header .flex {
        flex-direction: column; /* Stack contact info vertically */
        gap: 0.75rem;
        align-items: flex-start; /* Align to left on small screens */
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .portfolio-section {
        padding: 1.5rem;
        margin-bottom: 2rem;
        border-radius: 1rem;
    }
    .project-card, .experience-card, .education-card, .skill-category-card {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
        border-radius: 0.75rem;
    }
    .skill-badge {
        font-size: 0.85rem;
        padding: 0.4rem 1rem;
    }
    .education-card {
        flex-direction: column; /* Stack image and text vertically */
        align-items: center;
        text-align: center;
    }
    /* Specific adjustments for smaller images in education/certs on mobile */
    .education-card img {
        width: 60px; /* Smaller size on mobile */
        height: 60px;
    }
    .certifications li img {
        width: 30px; /* Smaller size on mobile */
        height: 30px;
        margin-right: 0.5rem; /* Adjust margin */
    }
}

/* Certifications list item image alignment */
.certifications li img {
    flex-shrink: 0; /* Prevent image from shrinking */
    object-fit: contain; /* Maintain aspect ratio */
    vertical-align: middle; /* Align image vertically with text baseline */
    display: inline-block; /* Ensure proper vertical-align behavior */
}
/* Ensure the text within the list item aligns as well */
.certifications li span, .certifications li a {
    vertical-align: middle;
}

@media (min-width: 768px) {
    .header .flex {
        flex-direction: row;
        align-items: center;
    }
}
