:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-tertiary: #6c757d;
    --accent-primary: #357a52;  /* Improved contrast from #4a9b6e */
    --accent-secondary: #2c5f42; /* Improved contrast from #3d8159 */
    --accent-light: #e7f3ff;
    --border-color: #dee2e6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --nav-height: 60px;
    --focus-color: #0066cc;
    --focus-outline: 3px solid var(--focus-color);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-tertiary: #868e96;
    --accent-primary: #5fb380;
    --accent-secondary: #4a9b6e;
    --accent-light: #1a3a5c;
    --border-color: #404040;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --focus-color: #66b3ff;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Skip to main content link for keyboard users */
.skip-link {
    position: absolute;
    top: -100px;
    left: -100px;
    background: var(--accent-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1100;
    border-radius: 4px;
}

.skip-link:focus {
    top: 10px;
    left: 10px;
}

/* Focus styles for better keyboard navigation */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid var(--focus-color);
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Navigation */
nav.main-nav, /* More specific selector for main navigation */
body > nav { /* Alternative: direct child of body */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
    margin: 0;
    padding: 0;
}
/* Hide mobile-only items on desktop */
.mobile-only {
    display: none;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link:focus,
.nav-link.active {
    color: var(--accent-primary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link:focus::after,
.nav-link.active::after {
    width: 100%;
}


/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease, transform 0.3s ease;
    position: relative;
}

.theme-toggle:hover,
.theme-toggle:focus {
    background: var(--bg-secondary);
    transform: rotate(20deg);
}


/* Tooltip for theme toggle */
.theme-toggle-wrapper {
    position: relative;
}

.theme-tooltip {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
    box-shadow: var(--shadow-sm);
}

.theme-tooltip::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid var(--bg-tertiary);
}

.theme-toggle:hover + .theme-tooltip,
.theme-toggle:focus + .theme-tooltip {
    opacity: 1;
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    gap: 4px;
    border-radius: 4px;
    transition: background 0.3s;
}

.hamburger:focus {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
    background: var(--bg-secondary);
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Main Content */
main {
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 20px 3rem;
}

/* Hero Section */
.hero {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 20px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(120deg); }
    66% { transform: translate(-20px, 20px) rotate(240deg); }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    margin: 0 auto 2rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 3px solid var(--accent-primary);
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.hero .tagline {
    font-size: 1.25rem;
    font-style: italic;
    color: var(--text-tertiary);
    margin-bottom: 2rem;
}

.hero .intro {
    max-width: 700px;
    margin: 0 auto 2rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.contact-button {
    display: inline-flex;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow-md);
}

.contact-button:hover,
.contact-button:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* CV Section */
.section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

/* Special styling for Table of Contents */
.toc-section {
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
    border: 2px solid var(--accent-primary);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 12px rgba(53, 122, 82, 0.1);
}

[data-theme="dark"] .toc-section {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #2a4038 100%);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(95, 179, 128, 0.1);
}

.toc-heading {
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 1.2rem;
    color: var(--accent-primary);
    text-align: center;
}

.toc-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
    position: relative;
    padding-bottom: 1rem;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
}

h2 {
    font-size: 1.8rem;
    margin: 2rem 0 1.5rem;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
}

.job-item, .education-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.job-item:last-child, .education-item:last-child {
    border-bottom: none;
}

.company, .school {
    font-weight: 600;
    color: var(--text-primary);
}

.duration {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.location {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.description {
    margin-top: 1rem;
    color: var(--text-secondary);
}

.description ul {
    margin-left: 0;
    padding-left: 1.5rem;
}

/* Table of Contents Links */
.toc-link {
    background: white;
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    white-space: nowrap;
    position: relative;
    border: 1px solid rgba(53, 122, 82, 0.2);
    font-weight: 500;
}

[data-theme="dark"] .toc-link {
    background: var(--bg-tertiary);
    border-color: rgba(95, 179, 128, 0.2);
}

.toc-link svg {
    color: var(--accent-primary);
}

.toc-link:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(53, 122, 82, 0.2);
    border-color: var(--accent-primary);
}

.toc-link:hover svg {
    color: white;
}

.toc-link:focus {
    outline: 3px solid var(--focus-color);
    outline-offset: 2px;
}

/* Skills */
.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.skill-tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.skill-tag:hover {
    transform: translateY(-2px);
    background: var(--text-secondary);
    color: var(--bg-primary);
}

/* Languages */
.languages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.language-card {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
    transition: transform 0.2s ease;
}

.language-card:hover {
    transform: translateX(5px);
}

.language-name {
    font-weight: 600;
    color: var(--text-primary);
}

.language-level {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Legal Pages */
.legal-content {
    max-width: 800px;
    margin: 0 auto;
}

.legal-content h1 {
    margin-bottom: 2rem;
    text-align: center;
}

.legal-content h2 {
    margin-top: 3rem;
    margin-bottom: 1rem;
}

.legal-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.legal-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.legal-content ul {
    margin: 1rem 0 1rem 2rem;
}

.legal-content li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: var(--nav-height);
        left: -100%;
        width: 100%;
        height: calc(100vh - var(--nav-height));
        background: var(--bg-primary);
        flex-direction: column;
        padding: 2rem;
        gap: 1rem;
        transition: left 0.3s ease;
        border-top: 1px solid var(--border-color);
        z-index: 999;
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }
    /* Show mobile-only items on mobile */
    .mobile-only {
        display: block;
    }

    .hamburger {
        display: flex;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero .subtitle {
        font-size: 1.2rem;
    }

    .hero-image {
        width: 150px;
        height: 150px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .container {
        padding: 2rem 15px;
    }
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-tertiary);
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Mobile responsive footer */
@media (max-width: 768px) {
    footer .separator {
        display: none;
    }
    footer .links {
        display: block;
        margin-top: 0.5rem;
    }
}

/* External link button styling */
.external-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    color: var(--accent-primary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--accent-primary);
    transition: all 0.3s ease;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.external-link:hover,
.external-link:focus {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.external-link svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* Inline external link icon for subtle links (footer, credits, etc.) */
a.external-inline {
    text-decoration: none;
    color: inherit;
}

a.external-inline:hover {
    text-decoration: underline;
}

a.external-inline svg {
    width: 0.85em;
    height: 0.85em;
    fill: currentColor;
    vertical-align: baseline;
    margin-left: 0.2em;
}
