/* Global reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f5f5f3;
    --surface: #ffffff;
    --surface-soft: #f7f7f4;
    --text: #292524;
    --muted: #6b6660;
    --accent: #57534e;
    --accent-strong: #3a3633;
    --accent-soft: rgba(87, 83, 78, 0.10);
    --border: #e7e5e1;
    --shadow-sm: 0 2px 8px rgba(28, 25, 23, 0.05);
    --shadow-md: 0 10px 28px rgba(28, 25, 23, 0.08);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --content-width: 1080px;
}

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

body {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: linear-gradient(180deg, #fafaf8 0%, var(--bg) 300px);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

a:hover,
a:focus-visible {
    color: var(--accent-strong);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Layout */
.container {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: 2rem 1.25rem 3.25rem;
}

h1 {
    font-size: clamp(1.9rem, 2.8vw, 2.35rem);
    line-height: 1.25;
    margin-top: 0.5rem;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(1.35rem, 2vw, 1.7rem);
    line-height: 1.3;
    margin-bottom: 0.7rem;
    letter-spacing: -0.01em;
}

p,
li {
    font-size: 1.05rem;
}

/* Header and navigation */
.site-header {
    width: min(calc(100% - 2.5rem), var(--content-width));
    margin: 0 auto;
    margin-top: 0.8rem;
    padding: 0.55rem;
    background: color-mix(in srgb, var(--surface) 88%, white 12%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 30px rgba(28, 25, 23, 0.08);
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0.8rem;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.site-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.site-nav a {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 999px;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #f6f6f2 100%);
    box-shadow: 0 1px 2px rgba(28, 25, 23, 0.03);
}

.site-nav a:hover,
.site-nav a:focus-visible {
    color: var(--accent-strong);
    background: linear-gradient(180deg, #f8f8f6 0%, #efefea 100%);
    border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
    box-shadow: 0 4px 14px rgba(28, 25, 23, 0.10);
    transform: translateY(-1px);
}

.site-nav a.active {
    color: var(--accent-strong);
    background: linear-gradient(180deg, #f1f1ec 0%, #e8e8e2 100%);
    border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
    box-shadow: 0 4px 14px rgba(28, 25, 23, 0.10);
}

.site-nav a.active:hover,
.site-nav a.active:focus-visible {
    color: var(--accent-strong);
}

/* Footer */
.site-footer {
    width: min(100%, var(--content-width));
    margin: 0 auto 1rem;
    padding: 1rem 1.25rem;
    color: var(--muted);
    text-align: center;
    font-size: 0.95rem;
    border-top: 1px solid var(--border);
}

/* Shared cards */
.profile-card,
.item,
.pub-item,
.talk-item,
.about-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.item,
.pub-item,
.talk-item {
    padding: 1.15rem 1.25rem;
}

.item-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Home profile section */
.profile-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.25rem;
    align-items: center;
    margin-top: 0.85rem;
    margin-bottom: 1.75rem;
    padding: 1.35rem;
    box-shadow: var(--shadow-md);
}

.profile-card.no-image {
    grid-template-columns: 1fr;
}

.profile-info h1 {
    margin: 0 0 0.35rem;
}

.profile-affiliation {
    color: var(--muted);
    margin-bottom: 0.45rem;
}

.profile-contact,
.profile-links {
    font-size: 1rem;
}

/* Sections and timeline */
.home-section {
    margin-top: 1.8rem;
}

.home-section h2 {
    margin-bottom: 0.75rem;
}

.section-intro {
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
}

.timeline {
    list-style: none;
    display: grid;
    gap: 0.65rem;
}

.timeline li {
    display: grid;
    grid-template-columns: 8.5rem 1fr;
    column-gap: 0.7rem;
    align-items: start;
    padding: 0.4rem 0;
}

.timeline-date {
    color: var(--muted);
    width: 8.5rem;
    white-space: nowrap;
    font-weight: 600;
}

.timeline-text {
    min-width: 0;
}

/* Publication and talk details */
.pub-item,
.talk-item {
    margin-bottom: 1rem;
}

.pub-title,
.talk-title {
    font-size: 1.3rem;
    line-height: 1.35;
    margin-bottom: 0.25rem;
}

.talk-layout {
    display: grid;
    grid-template-columns: clamp(200px, 24vw, 280px) 1fr;
    gap: 1rem;
    align-items: center;
}

.talk-thumb-link {
    display: block;
    position: relative;
    width: 100%;
    max-width: 280px;
    aspect-ratio: 16 / 9;
    justify-self: start;
    border: 1px solid var(--border);
    overflow: hidden;
    background: #ffffff;
    touch-action: manipulation;
}

.talk-thumb-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
}

.talk-thumb-link:hover,
.talk-thumb-link:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.talk-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f6f6f3;
}

.pub-meta,
.talk-meta,
.item-meta {
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.pub-reference {
    margin-bottom: 0.55rem;
    color: var(--text);
}

.pub-award {
    margin-bottom: 0.45rem;
    font-weight: 600;
}

.pub-links,
.talk-links,
.item-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.pub-links a,
.talk-links a,
.item-links a,
.pub-pdf,
.pub-code,
.expand summary {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
}

.pub-links a:hover,
.talk-links a:hover,
.item-links a:hover,
.pub-pdf:hover,
.pub-code:hover,
.expand summary:hover {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.copy-bibtex-btn {
    margin-left: auto;
    white-space: nowrap;
}

/* Hide default summary marker */
.expand summary::-webkit-details-marker {
    display: none;
}

/* BibTeX section */
.bibtex-entry {
    position: relative;
    margin-top: 0.75rem;
    margin-bottom: 0.35rem;
    background: #1e1e1e;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    display: none;
    flex-basis: 100%;
}

.expand[open] + .bibtex-entry {
    display: block;
}

.citation-entry {
    background: #ffffff;
}

.bibtex-code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.45;
    padding: 0.9rem;
    margin: 0;
    color: #f5f5f5;
    white-space: pre;
    overflow-x: auto;
}

.bibtex-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.18rem 0.65rem;
    font-size: 0.82rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.35);
    color: #f5f5f5;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.bibtex-copy:hover,
.bibtex-copy:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.bibtex-entry-type {
    color: #ffcc66;
}

.bibtex-cite-key {
    color: #99c794;
}

.bibtex-field {
    color: #6699cc;
}

.bibtex-string {
    color: #c594c5;
}

.bibtex-number {
    color: #f99157;
}

/* About page */
.about-section {
    margin-bottom: 1rem;
    padding: 1.15rem 1.25rem;
}

.about-section p,
.about-section ul {
    font-size: 1.02rem;
}

.about-section ul {
    margin-left: 1.2rem;
    margin-top: 0.4rem;
}

.about-section li + li {
    margin-top: 0.25rem;
}

/* CV page */
.cv-header h2 {
    margin-bottom: 0.35rem;
}

.cv-header p + p {
    margin-top: 0.2rem;
}

/* Posters page */
.poster-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
    align-items: start;
}

.poster-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem;
}

.poster-link {
    display: block;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #f4f4f0;
}

.poster-link:hover,
.poster-link:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.poster-preview {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    border: none;
    background: #ffffff;
    pointer-events: none;
}

.poster-tile.landscape .poster-preview {
    aspect-ratio: 10 / 7;
}

.poster-meta {
    margin-top: 0.7rem;
}

.poster-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
}

.poster-venue {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Responsive rules */
@media (max-width: 860px) {
    .site-header {
        top: 0.45rem;
        margin-top: 0.45rem;
        border-radius: var(--radius-md);
    }

    .site-nav {
        width: 100%;
        gap: 0.42rem;
    }

    .poster-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .container {
        padding-top: 1.25rem;
    }

    .site-header {
        padding: 0.5rem;
    }

    .site-nav a {
        font-size: 0.9rem;
        padding: 0.4rem 0.7rem;
    }

    .profile-card {
        grid-template-columns: 1fr;
        justify-items: flex-start;
        padding: 1.1rem;
    }

    .timeline li {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .timeline-date {
        width: auto;
        white-space: normal;
    }

    .talk-layout {
        grid-template-columns: 1fr;
    }

    .copy-bibtex-btn {
        margin-left: 0;
    }
}
