/* ==========================================================================
   Gapminder-Style CV Visualization — Style System
   Inspired by Hans Rosling's Gapminder aesthetic (mid-2010s)
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --color-bg: #fafafa;
    --color-text: #1a1a2e;
    --color-text-muted: #555;
    --color-accent: #e377c2;
    --color-grid: #e0e0e0;
    --color-simulation: #1f77b4;
    --color-plm: #2ca02c;
    --color-iot: #ff7f0e;
    --color-data: #9467bd;
    --color-dataproducts: #d62728;
    --color-dataai: #e377c2;
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --ease-gapminder: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-duration: 800ms;
    --section-max-width: 1100px;
    --section-padding: 4rem 2rem;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-display);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- Section Layout --- */
.section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--section-padding);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms var(--ease-gapminder),
                transform 600ms var(--ease-gapminder);
}

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

.section--career,
.section--skills {
    display: block;
    padding-top: 5rem;
    padding-bottom: 2rem;
}

.section--career .section__content,
.section--skills .section__content {
    position: sticky;
    top: 4.5rem;
    max-width: var(--section-max-width);
    max-height: calc(100vh - 6rem);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.section__content {
    width: 100%;
    max-width: var(--section-max-width);
    margin: 0 auto;
}

.section--career,
.section--domains,
.section--skills,
.section--impact,
.section--achievements {
    scroll-margin-top: 60px;
    padding-top: 5rem;
}

.section__title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.section__description {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    max-width: 600px;
}

/* --- Hero Section --- */
.section--hero {
    opacity: 1;
    transform: none;
    background: linear-gradient(135deg, #fafafa 0%, #f0e6f6 50%, #e6f0fa 100%);
    text-align: center;
    flex-direction: column;
}

.hero__name {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--color-dataai), var(--color-data));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 1s var(--ease-gapminder) forwards;
}

.hero__title {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 600;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
    animation: fadeInUp 1s var(--ease-gapminder) 0.2s both;
}

.hero__subtitle {
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--color-text-muted);
    margin-top: 1rem;
    font-style: italic;
    animation: fadeInUp 1s var(--ease-gapminder) 0.4s both;
}

.hero__scroll-hint {
    position: absolute;
    bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    animation: bounce 2s infinite 2s;
}

/* --- Chart Container --- */
.chart-container {
    width: 100%;
    min-height: 400px;
    position: relative;
}

.section--skills .chart-container {
    min-height: 0;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.section--skills .chart-container svg {
    max-height: 100%;
}

.section--skills {
    min-height: 140vh;
    padding: 3rem 2rem;
}

.section--career {
    min-height: 200vh;
}

.skills-layout {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
    min-height: 0;
}

.chart-container svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* --- Timeline Slider --- */
.timeline-slider {
    margin-top: 2rem;
    text-align: center;
}

.timeline-slider label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-slider input[type="range"] {
    width: 100%;
    max-width: 700px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-grid);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.timeline-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-dataai);
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: grab;
    transition: transform 0.15s ease;
}

.timeline-slider input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    max-width: 700px;
    margin: 0.5rem auto 0;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* --- Skills Era Buttons --- */
.skills-era-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.era-btn {
    padding: 0.5rem 1.2rem;
    border: 2px solid var(--color-grid);
    border-radius: 2rem;
    background: white;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.era-btn:hover {
    border-color: var(--color-dataai);
    color: var(--color-dataai);
}

.era-btn[aria-pressed="true"] {
    background: var(--color-dataai);
    border-color: var(--color-dataai);
    color: white;
}

/* --- Metrics Grid --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.metric-card {
    text-align: center;
    padding: 2rem 1rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    transition: transform 0.3s var(--ease-gapminder);
}

.metric-card:hover {
    transform: translateY(-4px);
}

.metric-number {
    display: block;
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--color-dataai);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.metric-number--text {
    font-size: 1.8rem;
}

.metric-label {
    display: block;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.metric-card--highlight {
    background: linear-gradient(135deg, #fef3f8, #f3f0fe);
}

/* --- Achievements --- */
.achievements-list {
    position: relative;
    padding-left: 3rem;
}

.achievements-list::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--color-simulation), var(--color-plm), var(--color-iot), var(--color-data), var(--color-dataai));
    border-radius: 2px;
}

.achievement-item {
    position: relative;
    margin-bottom: 2rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s var(--ease-gapminder), transform 0.6s var(--ease-gapminder);
}

.achievement-item.visible {
    opacity: 1;
    transform: translateX(0);
}

.achievement-item::before {
    content: '';
    position: absolute;
    left: -2.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-dataai);
    border: 3px solid var(--color-bg);
    box-shadow: 0 0 0 2px var(--color-dataai);
}

.achievement-year {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-dataai);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.achievement-text {
    font-size: 1rem;
    margin-top: 0.25rem;
}

/* --- Footer --- */
.section--footer {
    min-height: auto;
    padding: 3rem 2rem;
    background: var(--color-text);
    color: white;
    opacity: 1;
    transform: none;
}

.section--footer .section__content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer__info a {
    color: var(--color-accent);
    text-decoration: none;
}

.footer__info a:hover {
    text-decoration: underline;
}

.footer__info p {
    margin-bottom: 0.25rem;
}

.footer__credit {
    font-size: 0.8rem;
    opacity: 0.6;
}

/* --- D3 Chart Styles --- */
.bubble-label {
    font-size: 11px;
    font-weight: 600;
    fill: var(--color-text);
    pointer-events: none;
    text-anchor: middle;
}

.axis text {
    font-size: 12px;
    fill: var(--color-text-muted);
}

.axis line,
.axis path {
    stroke: var(--color-grid);
}

.grid line {
    stroke: var(--color-grid);
    stroke-dasharray: 2 4;
    stroke-opacity: 0.5;
}

.tooltip {
    position: absolute;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
    max-width: 250px;
}

.tooltip.active {
    opacity: 1;
}

.tooltip__role {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.tooltip__company {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.tooltip__dates {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --section-padding: 3rem 1.5rem;
    }

    .section__title {
        font-size: 2rem;
    }

    .chart-container {
        min-height: 280px;
    }

    .section--career {
        min-height: 150vh;
    }

    .section--skills {
        min-height: 120vh;
        padding: 2rem 1.5rem;
    }

    .section--skills .section__content {
        position: sticky;
        top: 4.5rem;
        max-height: calc(100vh - 6rem);
    }

    .skills-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .skills-era-selector {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

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

    .section--skills .chart-container {
        min-height: 280px;
        max-height: 350px;
    }

    .section--domains {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .section--domains .section__title,
    .section--domains .section__description {
        padding-left: 1rem;
    }

    .section--domains .chart-container {
        min-height: 250px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .metric-number {
        font-size: 2.5rem;
    }

    .section--footer .section__content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .hero__name {
        font-size: 2.5rem;
    }

    .section--career {
        min-height: 120vh;
    }

    .chart-container {
        min-height: 220px;
    }

    .section--skills .chart-container {
        min-height: 240px;
        max-height: 300px;
    }

    .section__description {
        font-size: 0.95rem;
    }
}
