:root {
    /* Light Mode (Default - Retro/Western/Film) */
    --bg-primary: #f4ecd8;
    /* Vintage paper */
    --bg-secondary: #e8dfc5;
    /* Slightly darker paper */
    --bg-card: rgba(255, 255, 255, 0.8);
    /* Increased opacity for better contrast */
    --text-primary: #2c1810;
    /* Dark leather brown */
    --text-secondary: #5d4037;
    /* Lighter brown */
    --accent: #8b4513;
    /* Saddle Brown */
    --accent-hover: #a0522d;
    /* Sienna */
    --icon-color: #800000;
    /* Maroon/Rust for high visibility on light */
    --border: #d7ccc8;
    --sidebar-width: 280px;
    --transition: all 0.3s ease;
    --shadow: 4px 4px 0px rgba(44, 24, 16, 0.15);
}

body.dark-mode {
    /* Dark Mode (Noir/Western Night) */
    --bg-primary: #1a120b;
    /* Very dark brown/black */
    --bg-secondary: #2c1810;
    /* Dark leather */
    --bg-card: rgba(44, 24, 16, 0.8);
    /* Increased opacity */
    --text-primary: #eaddcf;
    /* Bone/Off-white */
    --text-secondary: #a68b7c;
    /* Muted earth tone */
    --accent: #cd853f;
    /* Peru/Gold */
    --accent-hover: #deb887;
    /* Burlywood */
    --icon-color: #ffb74d;
    /* Bright Amber for high visibility on dark */
    --border: #3e2723;
    --shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Courier Prime', 'Courier New', monospace;
    /* Typewriter style for retro feel */
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%239C92AC' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
}

h1,
h2,
h3,
h4 {
    font-family: 'Playfair Display', serif;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.profile-header {
    margin-bottom: 3rem;
    text-align: center;
}

.profile-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
    display: inline-block;
    position: relative;
    /* For typewriter overlay */
}

/* Typewriter Effect */
.typewriter::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background-color: var(--bg-secondary);
    border-left: 2px solid var(--accent);
    animation:
        typing 3s steps(18) forwards,
        blink-caret 0.75s step-end 6 forwards;
    /* Blink 6 times then stop and stay transparent */
}

@keyframes typing {
    to {
        width: 0;
    }
}

@keyframes blink-caret {

    from,
    to {
        border-left-color: transparent
    }

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

.subtitle {
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    color: var(--text-secondary);
    font-weight: 600;
    border: 1px solid transparent;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--bg-primary);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.nav-link i {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: auto;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    transition: var(--transition);
}

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

/* Main Content */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 4rem 6rem;
    /* Increased padding to fix "stuck to left" */
    max-width: 1400px;
    /* Allow more width on large screens */
}

.section {
    margin-bottom: 6rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.section-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
    border-bottom: 3px double var(--border);
    display: inline-block;
}

.section-title::after {
    display: none;
    /* Remove old underline */
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    /* Sharper corners for retro look */
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.bio-text {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: justify;
}

.bio-text strong {
    color: var(--accent);
    font-weight: 700;
}

.bio-text em {
    color: var(--text-primary);
    font-style: italic;
    text-decoration: underline;
    text-decoration-color: var(--accent);
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-left: 2px solid var(--border);
    padding-left: 2rem;
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: -6px;
    width: 10px;
    height: 10px;
    background-color: var(--accent);
    border-radius: 50%;
}

.timeline-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    top: 1.5rem;
    left: -2.6rem;
    /* Align with border */
    width: 12px;
    height: 2px;
    background-color: var(--border);
}

.timeline-item:hover {
    transform: translateX(5px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.timeline-header {
    margin-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
}

.timeline-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.company {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
}

.timeline-content p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.career-list {
    list-style-type: square;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    padding-left: 1.2rem;
}

/* Dark Mode Icon Fixes */
[data-theme="dark"] .nav-link i {
    color: var(--text-secondary);
    /* Ensure visibility in dark mode */
}

[data-theme="dark"] .nav-link:hover i,
[data-theme="dark"] .nav-link.active i {
    color: var(--accent);
}

[data-theme="dark"] .card-icon {
    color: var(--accent);
    opacity: 0.8;
}

[data-theme="dark"] .project-card:hover .card-icon {
    color: var(--accent-hover);
    opacity: 1;
}

/* Grid for Projects (Compact "Playbill" Style) */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    /* Tighter gap */
}

/* Project Card Animations */
.project-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 1.5rem;
    /* Increased padding */
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    overflow: hidden;

    /* Animation Initial State */
    opacity: 0;
    transform: translateY(30px);
}

.project-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
    background-color: var(--bg-primary);
    z-index: 1;
}

.card-icon {
    position: relative;
    /* Changed from absolute */
    top: auto;
    right: auto;
    background-color: transparent;
    color: var(--accent);
    /* Fully visible accent color */
    padding: 0;
    margin-bottom: 1rem;
    /* Space below icon */
    opacity: 1;
    /* Fully opaque */
    transform: none;
    /* Reset scale */
}

.card-icon i {
    width: 24px;
    height: 24px;
}

.project-card:hover .card-icon {
    color: var(--accent-hover);
    opacity: 1;
}

.project-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    padding-right: 0;
    /* No need for padding anymore */
    font-weight: 700;
}

.project-subtitle {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-style: italic;
}

.project-location {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--border);
    padding-top: 0.25rem;
    width: 100%;
}

.tag {
    margin-top: auto;
    background-color: transparent;
    border: 1px solid var(--border);
    padding: 0.1rem 0.5rem;
    border-radius: 2px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
}

/* Contact */
.contact-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.contact-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.contact-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.contact-item i {
    color: var(--accent);
    width: 20px;
    height: 20px;
}

.contact-item h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.contact-item p {
    font-size: 0.9rem;
    font-weight: 600;
}

.contact-item a {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
}

.contact-item a:hover {
    color: var(--accent);
    border-bottom-style: solid;
}

/* Filters & Load More */
.filter-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
    background-color: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    width: 100%;
}

.btn-primary {
    background-color: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.75rem 2rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary:hover {
    background-color: var(--accent);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-primary i {
    width: 18px;
    height: 18px;
}

.project-card.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 1024px) {
    .content {
        padding: 4rem 3rem;
    }

    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        /* Changed from fixed to relative for mobile flow */
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
        box-shadow: none;
    }



    .content {
        margin-left: 0;
        padding: 2rem 1.5rem;
        width: 100%;
    }

    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        /* Wrap items to next line */
        justify-content: center;
        /* Center items */
        overflow-x: visible;
        /* Remove scroll */
        padding-bottom: 0;
        gap: 0.8rem;
    }

    .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .sidebar-footer {
        display: none;
    }

    .theme-toggle {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        margin: 0;
    }

    .section-title {
        font-size: 1.75rem;
    }
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--accent);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    transform: translateY(20px);
    z-index: 1000;
    box-shadow: var(--shadow);
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    background-color: var(--text-primary);
    transform: translateY(-5px);
}

/* Map Section */
#global-map {
    margin-bottom: 4rem;
}

#map {
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Print Styles - Dedicated Resume Layout */
@media print {
    @page {
        margin: 0;
        size: A4;
    }

    /* Hide EVERYTHING from the main site */
    body>*:not(#print-cv) {
        display: none !important;
    }

    /* Reset Body */
    html,
    body {
        background: #fff !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        font-family: 'Poppins', sans-serif !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Show and Style the Print CV */
    #print-cv {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        background: #fff;
    }

    .resume-container {
        display: grid !important;
        grid-template-columns: 28% 72% !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100vh;
    }

    /* --- LEFT COLUMN --- */
    .resume-left {
        background-color: #f0f0f0 !important;
        padding: 2rem 1.5rem !important;
        color: #333 !important;
    }

    .profile-section {
        text-align: center;
        margin-bottom: 2rem;
    }

    .resume-name {
        font-size: 18pt !important;
        font-weight: 700 !important;
        color: #000 !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.2 !important;
    }

    .resume-role {
        font-size: 10pt !important;
        color: #555 !important;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .resume-section {
        margin-bottom: 2rem !important;
    }

    .resume-title {
        font-size: 11pt !important;
        text-transform: uppercase;
        letter-spacing: 1px;
        font-weight: 600 !important;
        color: #000 !important;
        margin-bottom: 1rem !important;
        border-bottom: 1px solid #ccc !important;
        padding-bottom: 0.2rem !important;
    }

    /* Contact List */
    .contact-list {
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .contact-list li {
        display: flex !important;
        align-items: center !important;
        margin-bottom: 0.8rem !important;
        font-size: 9pt !important;
        color: #444 !important;
    }

    .contact-list .icon {
        margin-right: 0.8rem !important;
        color: #000 !important;
        display: flex !important;
        align-items: center !important;
    }

    .contact-list .icon i {
        width: 14px !important;
        height: 14px !important;
    }

    /* Education */
    .education-item {
        margin-bottom: 1rem !important;
    }

    .education-item h4 {
        font-size: 10pt !important;
        font-weight: 600 !important;
        margin: 0 !important;
        color: #000 !important;
    }

    .education-item p {
        font-size: 9pt !important;
        margin: 0 !important;
        color: #444 !important;
    }

    .school-sub {
        font-style: italic !important;
        font-size: 8.5pt !important;
        color: #666 !important;
    }

    /* Skills/Languages */
    .skills-list {
        list-style: none !important;
        padding: 0 !important;
    }

    .skills-list li {
        font-size: 9pt !important;
        margin-bottom: 0.4rem !important;
        position: relative !important;
        padding-left: 1rem !important;
    }

    .skills-list li::before {
        content: "•";
        position: absolute;
        left: 0;
        color: #000;
    }

    /* --- RIGHT COLUMN --- */
    .resume-right {
        padding: 3rem 2rem !important;
        background-color: #fff !important;
    }

    .resume-text {
        font-size: 9.5pt !important;
        line-height: 1.6 !important;
        color: #444 !important;
        text-align: justify !important;
    }

    /* Experience Items */
    .experience-item {
        display: grid !important;
        grid-template-columns: 80px 1fr !important;
        margin-bottom: 1rem !important;
        align-items: baseline !important;
    }

    .exp-date {
        font-size: 9pt !important;
        font-weight: 600 !important;
        color: #333 !important;
    }

    .exp-content h4 {
        font-size: 10pt !important;
        font-weight: 700 !important;
        margin: 0 !important;
        color: #000 !important;
    }

    .exp-content p {
        font-size: 9.5pt !important;
        margin: 0 !important;
        color: #555 !important;
        font-style: italic !important;
    }

    /* Credits Grid */
    .credits-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem 2rem !important;
    }

    .credit-item {
        break-inside: avoid;
    }

    .credit-item h4 {
        font-size: 10pt !important;
        font-weight: 700 !important;
        margin: 0 !important;
        color: #000 !important;
    }

    .credit-item p {
        font-size: 9pt !important;
        margin: 0 !important;
        font-style: italic !important;
        color: #444 !important;
    }

    .credit-loc {
        display: block !important;
        font-size: 8pt !important;
        text-transform: uppercase;
        color: #777 !important;
        margin-top: 0.1rem !important;
    }
}