/* ============================================================
   Style — Layout, Typography, Components
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

::selection {
    background-color: rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-text);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--color-scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--color-scrollbar-thumb);
    border-radius: 4px;
}

/* ---------- Container ---------- */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Scroll Progress Bar ---------- */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--gradient-primary);
    z-index: 10001;
    transition: width 0.1s linear;
}

/* ---------- Navigation ---------- */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: var(--color-nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--color-nav-shadow) 0 1px 3px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.nav-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-logo {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-text);
    text-decoration: none !important;
}

.nav-logo:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 8px;
}

.nav-links a {
    display: block;
    padding: 8px 16px;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-links a:hover {
    color: var(--color-primary);
    background-color: rgba(var(--color-primary-rgb), 0.08);
    text-decoration: none;
}

.nav-links a.active {
    color: var(--color-primary);
    background-color: rgba(var(--color-primary-rgb), 0.1);
}

.nav-actions {
    display: flex;
    gap: 4px;
}

/* Icon Button */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.icon-btn:hover {
    color: var(--color-primary);
    background-color: rgba(var(--color-primary-rgb), 0.08);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Hamburger */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    gap: 5px;
    padding: 0;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

.hamburger:hover {
    background-color: rgba(var(--color-primary-rgb), 0.08);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

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

.hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ---------- Theme Panel ---------- */
.theme-panel {
    position: fixed;
    top: 74px;
    right: 24px;
    width: 280px;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    z-index: 9999;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.theme-panel[hidden] {
    display: none;
}

.theme-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.theme-panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.theme-panel-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.color-input-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.color-input-group input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 32px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: transparent;
}

.color-input-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #ffffff;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: #ffffff;
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--color-border);
    color: var(--color-text-secondary);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.05);
    text-decoration: none;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.82rem;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    padding: 6px 12px;
    font-size: 0.82rem;
}

.btn-ghost:hover {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.08);
    text-decoration: none;
}

/* ---------- Section ---------- */
.section {
    padding: 80px 0;
    background-color: var(--color-bg);
    transition: background-color 0.3s ease;
}

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

.section-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 40px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 48px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* ---------- Hero ---------- */
#hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--gradient-hero);
    overflow: hidden;
    padding-top: 64px;
}

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 60px;
    align-items: center;
    position: relative;
    z-index: 1;
}

.hero-text {
    max-width: 560px;
}

.hero-greeting {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.hero-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 8px;
    min-height: 1.2em;
}

.hero-name .typing-cursor {
    display: inline-block;
    width: 3px;
    height: 0.85em;
    background: var(--color-primary);
    margin-left: 2px;
    vertical-align: baseline;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.hero-title {
    font-size: 1.3rem;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    font-weight: 400;
}

.hero-affiliation {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.hero-affiliation a {
    color: var(--color-text-muted);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.hero-affiliation a:hover {
    color: var(--color-primary);
}

.hero-social {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--color-text-secondary);
    background: rgba(var(--color-primary-rgb), 0.06);
    font-size: 1.2rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.social-link:hover {
    color: #ffffff;
    background: var(--gradient-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

/* Profile Photo */
.hero-photo {
    position: relative;
}

.profile-photo-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    padding: 4px;
    background: var(--gradient-primary);
    animation: glow-pulse 3s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.3),
                    0 0 40px rgba(var(--color-accent-rgb), 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(var(--color-primary-rgb), 0.5),
                    0 0 60px rgba(var(--color-accent-rgb), 0.2);
    }
}

.profile-photo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--color-bg);
}

/* ---------- About ---------- */
.about-content {
    font-size: 1.05rem;
    color: var(--color-text-secondary);
    line-height: 1.8;
    max-width: 720px;
}

.about-content a {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

/* ---------- News Timeline ---------- */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 7px;
    bottom: 8px;
    width: 2px;
    background: var(--color-timeline-line);
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    padding-bottom: 28px;
    padding-left: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-timeline-dot);
    border: 3px solid var(--color-bg);
    box-shadow: 0 0 0 2px var(--color-timeline-dot);
}

.timeline-date {
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.08);
    padding: 2px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
}

.timeline-text {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* ---------- Publications ---------- */
.pub-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.pub-search-wrapper {
    position: relative;
    max-width: 400px;
}

.pub-search-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

#pub-search {
    width: 100%;
    padding: 10px 16px 10px 40px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--color-text);
    background: var(--color-bg-tertiary);
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#pub-search::placeholder {
    color: var(--color-text-muted);
}

#pub-search:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.12);
}

.pub-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 6px 16px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    border: 1.5px solid var(--color-border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.filter-pill.active {
    background: rgba(var(--color-primary-rgb), 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.filter-pill:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Publication Card */
.pub-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pub-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 24px;
    transition: box-shadow 0.3s ease, transform 0.2s ease, border-color 0.3s ease;
}

.pub-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: rgba(var(--color-primary-rgb), 0.2);
    transform: translateY(-2px);
}

.pub-card[hidden] {
    display: none;
}

.pub-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.pub-venue-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #ffffff;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 3px;
    letter-spacing: 0.02em;
}

.pub-venue-badge.conference { background: var(--color-badge-conference); }
.pub-venue-badge.journal { background: var(--color-badge-journal); }
.pub-venue-badge.preprint { background: var(--color-badge-preprint); }

.pub-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
}

.pub-authors {
    font-size: 0.88rem;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    line-height: 1.5;
}

.pub-authors .highlight {
    color: var(--color-primary);
    font-weight: 600;
}

.pub-venue {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
    margin-bottom: 14px;
}

.pub-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.pub-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.pub-link-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.06);
    text-decoration: none;
}

.pub-link-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* BibTeX */
.bibtex-wrapper {
    margin-top: 14px;
}

.bibtex-content {
    display: none;
    margin-top: 10px;
    position: relative;
}

.bibtex-content.open {
    display: block;
}

.bibtex-content pre {
    background: var(--color-bibtex-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 16px;
    padding-right: 48px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
    overflow-x: auto;
    white-space: pre;
}

.bibtex-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bibtex-copy-btn:hover {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
}

.bibtex-copy-btn.copied {
    color: #059669;
}

.pub-no-results {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    padding: 40px 0;
}

/* ---------- CV Section ---------- */
.cv-download {
    margin-bottom: 40px;
}

.cv-subsection {
    margin-bottom: 40px;
}

.cv-subsection:last-child {
    margin-bottom: 0;
}

.cv-subsection-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cv-subsection-title i {
    color: var(--color-primary);
    font-size: 1.1rem;
}

.cv-entry {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.cv-entry:last-child {
    border-bottom: none;
}

.cv-entry-main {
    flex: 1;
}

.cv-entry-role {
    font-weight: 600;
    color: var(--color-text);
    font-size: 1rem;
    margin-bottom: 2px;
}

.cv-entry-org {
    color: var(--color-primary);
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.cv-entry-desc {
    color: var(--color-text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.cv-entry-period {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 24px;
    margin-top: 2px;
}

/* ---------- Footer ---------- */
#footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    padding: 40px 0;
    transition: background-color 0.3s ease;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.footer-social {
    display: flex;
    gap: 12px;
}

.footer-social .social-link {
    width: 38px;
    height: 38px;
    font-size: 1rem;
}

.footer-text {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.footer-text a {
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.footer-text a:hover {
    color: var(--color-primary);
}

/* ---------- Scroll to Top ---------- */
.scroll-top-btn {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: #ffffff;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.scroll-top-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

/* ---------- Scroll Reveal ---------- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }

    .profile-photo-wrapper {
        animation: none;
    }

    .hero-name .typing-cursor {
        animation: none;
        opacity: 1;
    }
}

/* ---------- Print ---------- */
@media print {
    #navbar,
    #scroll-progress,
    #particle-canvas,
    .scroll-top-btn,
    .theme-panel,
    .nav-actions,
    .pub-controls,
    .pub-link-btn,
    .bibtex-wrapper,
    .hero-social,
    .cv-download {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    .section {
        padding: 20px 0;
        break-inside: avoid;
    }

    #hero {
        min-height: auto;
        padding: 20px 0;
    }

    .hero-content {
        grid-template-columns: 1fr;
    }

    .hero-photo {
        display: none;
    }

    .pub-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}
