:root {
    --week-width: 12px;
    --bg-dark: #050505;
    --accent-primary: #a78bfa;
    /* Soft Purple */
    --accent-secondary: #3b82f6;
    /* Blue */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition-slow: 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    --transition-fast: 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    max-width: 100%;
}

*:not(html):not(body):not(.background-radial):not(.background-grid) {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

html {
    scroll-behavior: smooth;
    background-color: var(--bg-dark);
    overscroll-behavior: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    /* Use 100% instead of 100vw to avoid scrollbar-width offset */
    position: relative;
    overscroll-behavior: none;
}

/* Background Effects */
.background-radial {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(167, 139, 250, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
    z-index: -2;
}

.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
}

/* Layout */
header {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    padding: 1.5rem 5% !important;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2.5rem;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

nav a:hover {
    color: var(--text-main);
}

.nav-cta {
    background: var(--glass-bg);
    padding: 0.5rem 1.2rem;
    border-radius: 2rem;
    border: 1px solid var(--glass-border);
}

/* Hero Section */
#hero {
    min-height: 65vh;
    padding-top: 10rem;
    padding-bottom: 0;
    padding-left: 5% !important;
    padding-right: 5% !important;
    overflow: hidden;
    transition: none !important;
    /* Remove transition to prevent jump */
}

.hero-wrapper {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    align-items: center;
    gap: 3rem;
    width: 100%;
}

.hero-content,
.hero-visual {
    max-width: 100%;
    overflow: visible;
}

.hero-content h1 {
    max-width: 100%;
}

.badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(167, 139, 250, 0.1);
    color: var(--accent-primary);
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 6vw, 4.5rem);
    line-height: 1.1;
    font-weight: 700;
    margin-bottom: 2rem;
    max-width: 100%;
    overflow-wrap: break-word;
}

.gradient-text {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-sub {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin-bottom: 3rem;
    font-weight: 300;
}

.hero-actions {
    display: flex;
    gap: 1.5rem;
}

.btn {
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-dark);
}

.btn-secondary {
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    background: var(--glass-bg);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Glass Cards */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    backdrop-filter: blur(20px);
    padding: 2.5rem;
    box-shadow: var(--card-shadow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    /* Contain pseudo-glow */
}

.main-viz {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    /* Center alignment */
    position: relative;
    overflow: visible;
}

.main-viz::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(167, 139, 250, 0.1), transparent 50%);
    animation: rotate 10s linear infinite;
    pointer-events: none;
    clip-path: inset(0 round 1.5rem);
    /* Contain glow within card bounds to prevent overflow */
    z-index: -1;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 2rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #4ade80;
}

.status-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 10px #4ade80;
}

.viz-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
}

.velocity-chart {
    width: 100%;
    height: auto;
    overflow: visible;
}

.velocity-path {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-width 0.3s ease;
}

.velocity-path.python {
    stroke: var(--accent-primary);
}

.velocity-path.neo4j {
    stroke: var(--accent-secondary);
    opacity: 0.7;
}

.velocity-path.agents {
    stroke: #fbbf24;
    opacity: 0.5;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.python {
    background: var(--accent-primary);
}

.dot.neo4j {
    background: var(--accent-secondary);
}

.dot.agents {
    background: #fbbf24;
}

/* Hero Calendar */
.hero-calendar {
    padding: 1rem 10px;
    /* Safe padding for edges */
    overflow-x: visible;
    /* Prevent clipping of edges */
}

.hero-calendar {
    margin-top: 1.5rem;
}

.hero-calendar .calendar-months {
    display: block;
    /* Use block so absolute positioning works natively without flex squishing */
    width: 100%;
    margin-bottom: 0.3rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    min-height: 1.2rem;
    position: relative;
    /* Restored to contain absolute spans on desktop */
}

.hero-calendar .calendar-months span,
.hero-calendar .calendar-years span {
    white-space: nowrap;
    flex-shrink: 0;
}

.hero-calendar .calendar-years {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    /* Spacing below grid */
    font-size: 0.65rem;
    color: var(--text-muted);
    min-height: 1.2rem;
    position: relative;
}

.hero-calendar .calendar-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    align-items: center;
    position: relative;
    /* Bounds for year markers */
}

.hero-calendar .calendar-grid-wrapper {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.hero-calendar .calendar-days {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-right: 0.5rem;
    text-align: right;
    padding-top: calc(1.2rem + 0.3rem);
    /* Match month label height + margin */
}

.hero-calendar .calendar-days span {
    height: 10px;
    min-height: 10px;
    max-height: 10px;
    line-height: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    box-sizing: border-box;
    transform: translateY(-1px);
    /* micro-adjustment for optical baseline */
}

.hero-calendar .calendar-grid {
    display: flex;
    gap: 2px;
    position: relative;
    /* Required for child offsetLeft to be relative to grid */
    overflow: visible;
    /* Prevent any internal vertical scroll clipping */
}

.hero-calendar .calendar-week {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    /* Prevent weeks from collapsing to 0 width */
}

.hero-calendar .calendar-day {
    width: 10px;
    min-width: 10px;
    max-width: 10px;
    height: 10px;
    min-height: 10px;
    max-height: 10px;
    box-sizing: border-box;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.hero-calendar .calendar-day:hover {
    transform: scale(1.5);
    z-index: 10;
}

.hero-calendar .calendar-day.lvl-0 {
    background: rgba(255, 255, 255, 0.05);
}

.hero-calendar .calendar-day.lvl-1 {
    background: rgba(167, 139, 250, 0.3);
}

.hero-calendar .calendar-day.lvl-2 {
    background: rgba(167, 139, 250, 0.5);
}

.hero-calendar .calendar-day.lvl-3 {
    background: rgba(167, 139, 250, 0.7);
}

.hero-calendar .calendar-day.lvl-4 {
    background: var(--accent-primary);
}

/* Calendar Tooltip */
.calendar-tooltip {
    position: fixed;
    background: rgba(15, 15, 25, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    min-width: 220px;
    max-width: 300px;
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.calendar-tooltip.visible {
    opacity: 1;
}

.tooltip-header {
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-count {
    color: var(--accent-primary);
    font-size: 1.2rem;
    font-weight: 700;
}

.tooltip-projects {
    margin: 0.75rem 0;
}

.tooltip-project {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    color: var(--text-muted);
}

.tooltip-project span:first-child {
    color: var(--text-primary);
}

.tooltip-tech {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-tech-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.tooltip-tech-segment {
    height: 100%;
}

.tooltip-tech-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tooltip-tech-legend span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.tooltip-tech-legend i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* Full Width Activity Card */
.activity-card.full-width {
    grid-column: 1 / -1;
}

.activity-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* Inline Tech Distribution in Hero */
/* Inline Tech Distribution in Hero */
#full-tech-distribution,
.inline-tech-distribution {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns for better spacing */
    gap: 1rem 2rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    justify-content: center;
    justify-items: center;
    max-width: 500px;
    /* Tighter container for 2 columns */
    margin-left: auto;
    margin-right: auto;
}

#full-tech-distribution .dist-item,
.inline-tech-distribution .dist-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    justify-content: flex-start;
    white-space: nowrap;
    /* Prevent wrapping */
}

#full-tech-distribution .dist-item .lang-count,
.inline-tech-distribution .dist-item .lang-count {
    color: var(--accent-primary);
}

#full-tech-distribution .dist-item .lang-dot,
.inline-tech-distribution .dist-item .lang-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Projects Section */
section {
    padding: 6rem 5%;
    overflow: hidden;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 4rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.section-title .line {
    flex-grow: 1;
    height: 1px;
    background: var(--glass-border);
}

/* Section CTA - Contact button below portfolio sections */
.section-cta {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
    gap: 2rem;
    width: 100%;
}

.projects-grid .project-card {
    min-width: 0;
    width: 100%;
}

.project-card {
    transition: transform 0.4s ease, border-color 0.4s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Equal height cards */
}

.project-card:hover {
    transform: translateY(-10px);
}

.project-card.work:hover {
    border-color: var(--accent-work);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.2);
}

.project-card.personal:hover {
    border-color: var(--accent-personal);
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.2);
}

.glass-card[data-link]:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.2);
}

.glass-card.work[data-link]:hover {
    border-color: var(--accent-work);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.2);
}

.glass-card.personal[data-link]:hover {
    border-color: var(--accent-personal);
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.2);
}

.highlight {
    color: var(--accent-primary);
    font-weight: 700;
}

.highlight.work {
    color: var(--accent-work);
}

.highlight.personal {
    color: var(--accent-personal);
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
    min-height: 3.5rem;
    align-content: flex-start;
}

.project-tags::-webkit-scrollbar {
    display: none;
}

.project-tags span {
    font-size: 0.7rem;
    padding: 0 0.8rem;
    height: 1.6rem;
    border-radius: 1rem;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: normal;
    flex-shrink: 0;
}

.project-card h3 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    margin-bottom: 1rem;
    min-height: 4.5rem;
    display: flex;
    align-items: flex-start;
}

.project-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
    font-weight: 300;
    min-height: 7rem;
}

.project-meta {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem 2rem;
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
    margin-top: auto;
    /* Push footer to bottom */
    justify-content: center;
    overflow-x: visible;
    /* Allow wrap */
    flex-wrap: wrap;
    /* Ensure footer wraps on desktop */
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: 5.5rem;
    align-content: flex-start;
}

.project-meta::-webkit-scrollbar {
    display: none;
}

.highlight {
    color: var(--accent-primary);
}

/* Innovation Grid - Use same as projects-grid for consistency */
.innovation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
    gap: 2rem;
    width: 100%;
}

.innovation-grid .project-card {
    min-width: 0;
    width: 100%;
}

.innovation-grid h4 {
    font-family: var(--font-heading);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

/* Footer */
footer {
    padding: 4rem 10%;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    padding: 3rem;
}

.skill-group h5 {
    font-family: var(--font-heading);
    color: var(--accent-primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.skill-group p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Featured Project Cards */
.project-card.featured {
    border: 1px solid rgba(167, 139, 250, 0.3);
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.05) 0%, rgba(59, 130, 246, 0.03) 100%);
}

.project-card.featured:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 30px rgba(167, 139, 250, 0.25);
}

/* Highlight Tags */
.highlight-tag {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)) !important;
    color: white !important;
    border: none !important;
    font-weight: 600 !important;
}

/* Project Highlights */
.project-highlights {
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.project-highlights ul {
    list-style: none;
    padding: 0;
}

.project-highlights li {
    position: relative;
    padding-left: 1.2rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.project-highlights li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent-primary);
}

.project-highlights li strong {
    color: var(--text-main);
}

/* Contact Section */
.contact-container {
    text-align: center;
    padding: 4rem;
}

.contact-container p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* GitHub-Style Contribution Calendar */
.contribution-card {
    min-width: 100%;
}

.contribution-calendar {
    overflow-x: auto;
    padding: 1rem 0;
}

.calendar-months {
    display: flex;
    gap: 0;
    margin-left: 30px;
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.calendar-months span {
    flex: 1;
    text-align: left;
}

.calendar-grid-wrapper {
    display: flex;
    gap: 0.5rem;
}

.calendar-days {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-right: 0.5rem;
}

.calendar-days span {
    height: 12px;
    line-height: 12px;
}

.calendar-grid {
    display: flex;
    gap: 3px;
}

.calendar-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.calendar-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease;
}

.calendar-day:hover {
    transform: scale(1.3);
}

.calendar-day.lvl-0 {
    background: rgba(255, 255, 255, 0.05);
}

.calendar-day.lvl-1 {
    background: rgba(167, 139, 250, 0.3);
}

.calendar-day.lvl-2 {
    background: rgba(167, 139, 250, 0.5);
}

.calendar-day.lvl-3 {
    background: rgba(167, 139, 250, 0.7);
}

.calendar-day.lvl-4 {
    background: var(--accent-primary);
}

.heatmap-box.lvl-4 {
    background: var(--accent-primary);
}

.activity-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .activity-container {
        grid-template-columns: 2fr 1fr;
    }
}

/* Mobile Adjustments */
@media (max-width: 1024px) {

    /* Ensure all elements fit within viewport */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    h1 {
        font-size: 2.5rem;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Hide weekday labels at tablet widths to prevent overlap with year marker */
    .hero-calendar .calendar-days {
        display: none !important;
    }

    /* Remove the left margin that was accounting for the now-hidden weekday labels */
    /* Center the months container to match the centered grid */
    .hero-calendar {
        margin-top: 1.5rem;
    }

    .hero-calendar .calendar-months {
        margin: 0 auto !important;
        text-align: center !important;
        font-size: 0.6rem;
    }

    #hero {
        padding-top: 8rem;
        padding-bottom: 0;
        padding-left: 5% !important;
        padding-right: 5% !important;
    }

    .hero-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
        width: 100%;
        max-width: 100%;
    }

    .hero-content,
    .hero-visual {
        width: 100%;
        max-width: 100%;
    }

    .hero-sub {
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }

    .hero-actions {
        justify-content: center;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .hero-actions .btn {
        flex: 1 1 auto;
        min-width: 140px;
        max-width: 200px;
    }

    .main-viz {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 1rem;
    }

    .hero-calendar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .calendar-grid-wrapper {
        width: 100% !important;
        min-width: 0 !important;
        overflow-x: auto;
    }

    .viz-stats {
        gap: 1.5rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .stat-value {
        font-size: 2rem;
    }

    section {
        padding: 4rem 5%;
        max-width: 100%;
    }

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

    .projects-grid,
    .innovation-grid {
        justify-content: center;
    }

    .projects-grid .project-card,
    .innovation-grid .project-card {
        flex: 0 0 100%;
        max-width: 100%;
        min-width: 0;
    }

    .skills-container {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem 5%;
    }

    nav ul {
        gap: 1rem;
    }

    nav a {
        font-size: 0.8rem;
    }

    .nav-cta {
        padding: 0.4rem 0.8rem;
    }

    h1 {
        font-size: 2.5rem;
        width: 100%;
        max-width: 100%;
        word-break: break-word;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.8rem;
    }

    .hero-sub {
        font-size: 1rem;
        max-width: 100%;
    }

    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }

    .glass-card {
        padding: 1.5rem;
    }

    .project-card h3 {
        font-size: 1.4rem;
    }

    .project-card p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

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

    .project-tags span {
        font-size: 0.65rem;
        padding: 0.25rem 0.6rem;
    }

    .project-highlights li {
        font-size: 0.85rem;
    }

    .project-meta {
        flex-wrap: wrap;
        gap: 1rem;
        font-size: 0.8rem;
    }

    #full-tech-distribution,
    .inline-tech-distribution {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .contact-container {
        padding: 2rem;
    }

    .contact-container p {
        font-size: 1rem;
    }

    .contact-links {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .hero-actions .btn {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 0.8rem 1.5rem;
    }

    nav ul {
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .viz-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .viz-stats {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .main-viz {
        padding: 1rem;
    }

    #full-tech-distribution .dist-item,
    .inline-tech-distribution .dist-item {
        white-space: nowrap;
        line-height: 1.2;
    }

    .hero-calendar {
        margin-bottom: 0;
        width: 100%;
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        overflow-x: hidden;
        padding: 0;
    }

    .hero-calendar .calendar-main {
        max-width: 100%;
    }

    .hero-calendar .calendar-grid-wrapper {
        justify-content: center;
        overflow: visible;
        /* Prevent scrollbars while ensuring content is not clipped */
        width: 100%;
        max-width: 100%;
    }

    /* Target a larger legible square size for mobile */
    .hero-calendar {
        --week-width: 14px;
        margin-top: 1.5rem;
    }

    .hero-calendar .calendar-day {
        width: 12px;
        height: 12px;
        border-radius: 2px;
    }

    /* Hide weekday labels on mobile to save horizontal space for the scrolling grid */
    .hero-calendar .calendar-days {
        display: none !important;
    }

    .hero-calendar .calendar-months {
        margin-bottom: 4px;
        font-size: 0.55rem;
        width: max-content;
        /* scale with the scrolling grid */
    }

    .hero-calendar .calendar-grid,
    .hero-calendar .calendar-week {
        gap: 3px;
    }

    @media (max-width: 500px) {
        .hero-calendar {
            margin-top: 1rem;
            overflow-x: auto;
            max-width: 100%;
            padding-bottom: 0.5rem;
            /* Space for scrollbar */
            -webkit-overflow-scrolling: touch;
        }

        .hero-calendar .calendar-grid,
        .hero-calendar .calendar-week {
            gap: 1px;
            /* Minimal gap to ensure 52 weeks fit in ~350-400px */
        }

        .hero-calendar .calendar-day {
            width: 5px !important;
            height: 5px !important;
            border-radius: 1px;
        }

        .hero-calendar .calendar-day {
            /* Robust scaling for mobile to fit ~54 weeks. Max 10px, min 3px. */
            width: clamp(3px, calc(100vw / 65), 10px) !important;
            height: clamp(3px, calc(100vw / 65), 10px) !important;
            border-radius: 1px;
        }

        .hero-calendar .calendar-months,
        .hero-calendar .calendar-years {
            font-size: 0.45rem !important;
            /* Prevent overlap due to squished columns */
        }

        #full-tech-distribution svg,
        .inline-tech-distribution svg {
            width: 80% !important;
            /* Scale down pie chart proportionally on mobile */
            height: auto !important;
            margin: 0 auto;
            display: block;
        }

        #full-tech-distribution,
        .inline-tech-distribution {
            margin-top: 0.5rem;
            padding-top: 0.5rem;
            gap: 0.5rem;
        }
    }

    .skills-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    footer {
        padding: 2rem 5%;
    }
}

/* Extra small screens - hide nav items except Contact */
@media (max-width: 600px) {

    /* Navigation - show only Contact */
    nav li:not(:last-child) {
        display: none;
    }

    nav ul {
        gap: 0;
    }

    /* Hero heading - smaller font */
    h1 {
        font-size: 1.5rem;
        line-height: 1.2;
    }

    #hero {
        padding-top: 6rem;
        padding-left: 5% !important;
        padding-right: 5% !important;
    }

    .hero-sub {
        font-size: 0.85rem;
    }

    /* Stack buttons vertically */
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        min-width: 0;
        text-align: center;
        flex: none;
        margin: 0;
        /* Reset any margins */
    }

    /* Calendar - ensure it scrolls horizontally */
    .main-viz {
        padding: 0.75rem;
        max-width: 100%;
        overflow: hidden !important;
        /* Force containment on small screens */
    }

    /* Removed forced scroll/width to allow fluid scaling */

    .viz-header {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        text-align: center;
        margin-bottom: 1rem;
    }

    .viz-stats {
        flex-direction: row !important;
        /* Force horizontal metrics */
        justify-content: space-around;
        align-items: flex-start;
        width: 100%;
        gap: 0;
        padding-top: 1rem;
        border-top: 1px solid var(--glass-border);
        margin-bottom: 1rem;
    }

    .stat {
        flex: 1;
        text-align: center;
        padding: 0 4px;
    }

    .stat-label {
        font-size: 0.6rem;
        letter-spacing: 0;
        margin-bottom: 0.25rem;
        white-space: nowrap;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .hero-calendar {
        margin-top: 1.5rem;
    }

    .hero-calendar .calendar-months {
        font-size: 0.45rem;
    }

    /* Removed hardcoded size to allowed fluid calc from 768px query to work */
}

/* --- PORTRAIT PDF OPTIMIZATION & PRINT STYLES --- */
@media print {
    @page {
        size: A4 portrait;
        margin: 1.5cm;
    }

    :root {
        --bg-dark: #fbf9f1;
        /* Premium Light Beige for PDF */
        --text-main: #1e293b;
        --text-muted: #4b5563;
        --glass-bg: #ffffff;
        --glass-border: #e2e8f0;
        --accent-primary: #7c3aed;
        --accent-secondary: #2563eb;
    }

    body {
        background-color: #fbf9f1 !important;
        color: #1e293b !important;
        width: 100%;
    }

    .background-radial,
    .background-grid,
    header,
    header *,
    nav,
    nav *,
    .hero-actions,
    .section-cta,
    footer,
    #chart-tooltip,
    #calendar-tooltip {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    main {
        padding: 0 !important;
    }

    section {
        padding: 1.5rem 0 !important;
        page-break-inside: avoid;
        margin-bottom: 2rem !important;
        border-bottom: 1px solid #f3f4f6;
    }

    #hero {
        padding-top: 0 !important;
        min-height: auto !important;
    }

    .hero-wrapper {
        display: block !important;
    }

    .hero-content h1 {
        font-size: 3rem !important;
        margin-bottom: 0.5rem !important;
    }

    .hero-sub {
        font-size: 1.2rem !important;
        margin-bottom: 1.5rem !important;
    }

    .glass-card {
        background: #ffffff !important;
        border: 1px solid #e5e7eb !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        padding: 1.5rem !important;
        border-radius: 0.5rem !important;
    }

    .projects-grid,
    .innovation-grid {
        display: block !important;
        /* Stack for portrait A4 width */
    }

    .project-card {
        margin-bottom: 1.5rem !important;
        page-break-inside: avoid;
    }

    .project-card h3 {
        font-size: 1.5rem !important;
        min-height: auto !important;
        margin-bottom: 0.5rem !important;
    }

    .project-card p {
        font-size: 1rem !important;
        min-height: auto !important;
        margin-bottom: 1rem !important;
    }

    .project-tags {
        min-height: auto !important;
        margin-bottom: 1rem !important;
    }

    .project-meta {
        min-height: auto !important;
        padding-top: 0.75rem !important;
    }

    .gradient-text {
        background: none !important;
        -webkit-text-fill-color: initial !important;
        color: #7c3aed !important;
    }

    /* Contribution Calendar for PDF */
    .hero-calendar .calendar-day {
        border: 1px solid #e5e7eb !important;
    }

    .hero-calendar .calendar-day.lvl-0 {
        background: #f9fafb !important;
    }

    .hero-calendar .calendar-day.lvl-1 {
        background: #ddd6fe !important;
    }

    .hero-calendar .calendar-day.lvl-2 {
        background: #c4b5fd !important;
    }

    .hero-calendar .calendar-day.lvl-3 {
        background: #a78bfa !important;
    }

    .hero-calendar .calendar-day.lvl-4 {
        background: #7c3aed !important;
    }
}