:root {
    --primary-color: #2563eb;
    --secondary-color: #10b981;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #ffffff;
    --bg-section: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --max-width: 1200px;
}

* {
    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-dark);
    background-color: var(--bg-light);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
#navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: var(--bg-light);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* .nav-name is empty until the JSON loads and contributes no line box, so
       without this the bar grows and shifts the page down on first render */
    min-height: 64px;
}

.nav-name {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-dark);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.nav-toggle-bar {
    display: block;
    width: 24px;
    height: 2px;
    margin: 0 auto;
    background: var(--text-dark);
    transition: all 0.3s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

/* Hero Section */
.hero {
    padding-top: 100px;
    padding-bottom: 80px;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.hero-text h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.hero-text h2 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.hero-text p {
    font-size: 1.125rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* Wraps so three buttons cannot force a minimum width wider than the phone */
.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.social-link:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.hero-images {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-photo {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: none;
}

.profile-photo.active {
    display: block;
}

.photo-toggle {
    position: absolute;
    bottom: 20px;
    display: flex;
    gap: 10px;
}

.photo-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-light);
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.photo-btn.active {
    background: var(--bg-light);
    transform: scale(1.2);
}

/* Sections */
.section {
    padding: 80px 0;
}

.section:nth-child(even) {
    background-color: var(--bg-section);
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--text-dark);
}

/* Markdown fields (personal.bio, projects[].description). The global reset
   zeroes margins, so rendered block elements need their spacing back or
   multiple paragraphs run together as one block. */
.bio-text > * + *,
.project-description > * + * {
    margin-top: 1rem;
}

.bio-text ul,
.bio-text ol,
.project-description ul,
.project-description ol {
    padding-left: 1.5rem;
}

/* Markdown links use the palette instead of the browser default blue */
.bio-text a,
.project-description a,
.timeline-content a {
    color: var(--primary-color);
}

/* About Section */
.bio-text {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-light);
}

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

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: var(--border-color);
}

.timeline-item {
    display: flex;
    margin-bottom: 3rem;
    position: relative;
}

.timeline-item:nth-child(odd) {
    justify-content: flex-end;
    padding-right: calc(50% + 30px);
}

.timeline-item:nth-child(even) {
    padding-left: calc(50% + 30px);
}

.timeline-content {
    background: var(--bg-light);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    max-width: 400px;
    width: 100%;
}

.timeline-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.timeline-content h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.timeline-date {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.timeline-content ul {
    list-style: none;
    margin-bottom: 1rem;
}

.timeline-content li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

.timeline-content li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

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

.tech-tag {
    padding: 0.25rem 0.75rem;
    background: var(--bg-section);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-dark);
    /* A long tag ("Low-Level Memory Management") must break rather than
       push out of its card; flex items need min-width:0 to shrink at all */
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* Projects Grid */
/* min() keeps the 350px track from outgrowing a narrower container */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(350px, 100%), 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.project-title {
    font-size: 1.5rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.3s ease;
}

.project-title:hover {
    color: var(--primary-color);
}

.project-link-icon {
    color: var(--text-light);
    transition: color 0.3s ease;
}

.project-link-icon:hover {
    color: var(--primary-color);
}

.project-role {
    color: var(--secondary-color);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.project-date {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.project-description {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Skills Section */
.skills-container {
    max-width: 1200px;
    margin: 0 auto;
}

.skill-category {
    margin-bottom: 4rem;
}

.skill-category h3 {
    font-size: 1.75rem;
    margin-bottom: 2rem;
    color: var(--text-dark);
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

.skill-category h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Capped tracks, centered: a part-full last row stays under the centered
   category heading instead of hugging the left edge */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 170px));
    justify-content: center;
    gap: 1.25rem;
}

/* Rows stretch to the tallest card, so the flexible name row absorbs the
   slack and the badge and years line up across the whole row even when a
   name like "Linux Kernel" wraps */
.skill-card {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-rows: 1fr auto auto;
    justify-items: center;
}

.skill-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border-color);
    transition: all 0.3s ease;
}

.skill-card.expert::before {
    background: var(--secondary-color);
}

.skill-card.proficient::before {
    background: var(--primary-color);
}

.skill-card.familiar::before {
    background: #9ca3af;
}

.skill-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.skill-card.expert:hover {
    border-color: var(--secondary-color);
    background: linear-gradient(to bottom, rgba(16, 185, 129, 0.05), var(--bg-light));
}

.skill-card.proficient:hover {
    border-color: var(--primary-color);
    background: linear-gradient(to bottom, rgba(37, 99, 235, 0.05), var(--bg-light));
}

.skill-card.familiar:hover {
    border-color: #9ca3af;
    background: linear-gradient(to bottom, rgba(156, 163, 175, 0.05), var(--bg-light));
}

.skill-name {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    align-self: start;
}

.skill-level-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.skill-level-badge.expert {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.skill-level-badge.proficient {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.skill-level-badge.familiar {
    background: rgba(156, 163, 175, 0.1);
    color: #6b7280;
}

.skill-years {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

.skill-years-number {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-dark);
}


/* Education & Certifications */
.edu-cert-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    max-width: 1000px;
    margin: 0 auto;
}

.edu-cert-container.no-certifications {
    grid-template-columns: 1fr;
}

.edu-cert-container.no-certifications .certification-section {
    display: none;
}

/* The section title is already "Education" in this state, so the column
   subheading would just repeat it */
.edu-cert-container.no-certifications .education-section h3 {
    display: none;
}

.education-section h3,
.certification-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.edu-item,
.cert-item {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.edu-item h4,
.cert-item h4 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.edu-institution,
.cert-issuer {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.edu-date,
.cert-date {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.edu-details {
    color: var(--text-light);
    font-style: italic;
}

/* Contact Section */
/* Flex with a gap rather than inline-block margins: a centered inline item's
   side margins still count toward the page width and pushed a few pixels of
   horizontal scroll onto narrow phones */
.contact-info {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    text-align: center;
}

.contact-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 1rem 2rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.contact-item:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Footer */
footer {
    background: var(--text-dark);
    color: var(--bg-light);
    padding: 2rem 0;
    text-align: center;
}

/* Data loading errors */
.load-error {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    padding: 1rem 20px;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    color: #78350f;
    font-size: 0.9375rem;
    text-align: center;
}

.load-error code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-container {
        flex-wrap: wrap;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        gap: 0;
        width: 100%;
        margin-top: 0.5rem;
    }

    /* In landscape the open list is taller than the screen, and a fixed
       navbar cannot be scrolled, so the last links become unreachable */
    .nav-links.open {
        display: flex;
        max-height: calc(100vh - 8rem);
        max-height: calc(100dvh - 8rem);
        overflow-y: auto;
    }

    .nav-links li {
        border-top: 1px solid var(--bg-section);
    }

    .nav-link {
        display: block;
        padding: 0.875rem 0;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    /* .hero-content centers its text, but flex children need telling */
    .hero-links {
        justify-content: center;
    }

    .hero-text h1 {
        font-size: 2rem;
    }
    
    /* Cards stack on one side here, so nothing connects to the rail and it
       reads as a stray rule; its indent also costs about a fifth of the
       card's text width on a phone. The cards' own spacing does the grouping. */
    .timeline::before {
        display: none;
    }

    .timeline-item,
    .timeline-item:nth-child(odd),
    .timeline-item:nth-child(even) {
        justify-content: flex-start;
        padding-left: 0;
        padding-right: 0;
    }

    .timeline-content {
        max-width: none;
    }

    .edu-cert-container,
    .edu-cert-container.no-certifications {
        grid-template-columns: 1fr;
    }
    
    .skills-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .skills-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }
    
    .skill-card {
        padding: 1rem 0.5rem;
    }
    
    .skill-name {
        font-size: 1rem;
    }
    
    .skill-years-number {
        font-size: 1.125rem;
    }
}