/* ==========================================================================
   Mario Chacón-Falcón — personal academic site
   One stylesheet for every page. Colours are tokens on :root; dark mode
   follows the OS unless the visitor picks a theme with the toggle.
   ========================================================================== */

:root {
    --bg: #fbfaf7;
    --bg-elev: #ffffff;
    --bg-soft: #f3f1ec;
    --text: #1b1e23;
    --text-muted: #5a606b;
    --text-faint: #8a8f98;
    --border: #e5e1d8;
    --accent: #0b6e6b;
    --accent-strong: #08514f;
    --accent-soft: rgba(11, 110, 107, 0.09);
    --warn: #9a5b00;
    --warn-soft: rgba(196, 122, 0, 0.12);
    --violet: #5b4bc4;
    --violet-soft: rgba(91, 75, 196, 0.1);
    --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.05);

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --wrap: 880px;
    --radius: 10px;
    --header-h: 60px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111315;
        --bg-elev: #181b1e;
        --bg-soft: #1d2024;
        --text: #e7e5e0;
        --text-muted: #a4a9b1;
        --text-faint: #767c85;
        --border: #2b2f34;
        --accent: #5cc7bf;
        --accent-strong: #8ad9d2;
        --accent-soft: rgba(92, 199, 191, 0.12);
        --warn: #e8b25a;
        --warn-soft: rgba(232, 178, 90, 0.13);
        --violet: #a89cf2;
        --violet-soft: rgba(168, 156, 242, 0.13);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #111315;
    --bg-elev: #181b1e;
    --bg-soft: #1d2024;
    --text: #e7e5e0;
    --text-muted: #a4a9b1;
    --text-faint: #767c85;
    --border: #2b2f34;
    --accent: #5cc7bf;
    --accent-strong: #8ad9d2;
    --accent-soft: rgba(92, 199, 191, 0.12);
    --warn: #e8b25a;
    --warn-soft: rgba(232, 178, 90, 0.13);
    --violet: #a89cf2;
    --violet-soft: rgba(168, 156, 242, 0.13);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16.5px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1; }

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

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 3px;
    transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

h1, h2, h3, h4 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 0 0 .5em;
}

p { margin: 0 0 1em; }

em { font-style: italic; }

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

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

.skip-link {
    position: absolute; left: -9999px; top: 8px;
    background: var(--bg-elev); padding: 8px 12px; border-radius: 6px; z-index: 100;
}
.skip-link:focus { left: 12px; }

/* ---------- Header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header .wrap {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.12rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.brand:hover { color: var(--accent); }

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 6px;
}
.site-nav a:hover { color: var(--text); background: var(--bg-soft); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.header-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    width: 36px; height: 36px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    font-size: 1rem;
}
.icon-btn:hover { color: var(--text); background: var(--bg-soft); }

.menu-btn { display: none; }

@media (max-width: 760px) {
    .menu-btn { display: inline-grid; }
    .site-nav {
        position: absolute;
        top: var(--header-h);
        left: 0; right: 0;
        flex-direction: column;
        align-items: stretch;
        padding: 8px 16px 16px;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        display: none;
    }
    .site-nav.open { display: flex; }
    .site-nav a { padding: 10px 12px; font-size: 1rem; }
}

/* ---------- Page scaffolding ---------- */

.page-head {
    padding: 56px 0 8px;
}
.page-head h1 {
    font-size: clamp(2rem, 4vw, 2.6rem);
    margin-bottom: .25em;
}
.page-head .lede {
    color: var(--text-muted);
    font-size: 1.08rem;
    max-width: 640px;
}

.section { padding: 36px 0; }
.section + .section { border-top: 1px solid var(--border); }

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.section-title h2 { font-size: 1.55rem; margin: 0; }
.section-title a { font-size: .9rem; font-family: var(--font-sans); white-space: nowrap; }

.eyebrow {
    font-family: var(--font-mono);
    font-size: .74rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

/* ---------- Hero (home) ---------- */

.hero {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 44px;
    align-items: start;
    padding: 56px 0 40px;
}

.hero-photo img {
    width: 220px; height: 220px;
    object-fit: cover;
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.hero h1 {
    font-size: clamp(2.1rem, 4.5vw, 2.8rem);
    margin-bottom: .15em;
}
.hero .role {
    color: var(--text-muted);
    font-size: 1.02rem;
    margin-bottom: 1.2em;
}
.hero .role a { color: inherit; }
.hero .bio p { font-size: 1.04rem; }

.links-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 1.4em;
}

.chip-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elev);
    color: var(--text);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: border-color .15s, color .15s, background .15s;
}
.chip-link i { color: var(--text-muted); font-size: .95em; transition: color .15s; }
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.chip-link:hover i { color: var(--accent); }
.chip-link.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.chip-link.primary i { color: inherit; }
.chip-link.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--bg); }

@media (max-width: 680px) {
    .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 36px; }
    .hero-photo img { width: 150px; height: 150px; border-radius: 16px; }
}

/* ---------- Research themes ---------- */

.themes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
@media (max-width: 640px) { .themes { grid-template-columns: 1fr; } }

.theme {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.theme h3 {
    font-size: 1.12rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: .4em;
}
.glyph {
    flex: none;
    width: 30px; height: 30px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .85rem;
}
.theme p { color: var(--text-muted); font-size: .95rem; margin: 0; }

/* ---------- News ---------- */

.news { list-style: none; margin: 0; padding: 0; }
.news li {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.news li:last-child { border-bottom: 0; }
.news time {
    font-family: var(--font-mono);
    font-size: .8rem;
    color: var(--text-faint);
    padding-top: 3px;
    white-space: nowrap;
}
.news p { margin: 0; }
.news .kind {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 1px 7px;
    border-radius: 4px;
    margin-right: 6px;
    background: var(--bg-soft);
    color: var(--text-muted);
    vertical-align: 1px;
}
@media (max-width: 520px) {
    .news li { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Publications ---------- */

.pub-group + .pub-group { margin-top: 36px; }
.pub-group > h2 {
    font-size: 1.2rem;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.pub {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}
.pub:last-child { border-bottom: 0; }
.pub .year {
    font-family: var(--font-mono);
    font-size: .82rem;
    color: var(--text-faint);
    padding-top: 4px;
}
.pub-title {
    font-family: var(--font-serif);
    font-size: 1.14rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 .25em;
}
.pub-title a { color: var(--text); text-decoration: none; }
.pub-title a:hover { color: var(--accent); text-decoration: underline; }
.pub-authors { color: var(--text-muted); font-size: .94rem; margin: 0; }
.pub-authors .me { color: var(--text); font-weight: 600; }
.pub-venue { font-size: .94rem; margin: .15em 0 0; }
.pub-venue em { color: var(--text); }
.pub-tldr { font-size: .94rem; color: var(--text-muted); margin: .5em 0 0; }

.status {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: 2px;
    font-family: var(--font-sans);
}
.status.review { background: var(--warn-soft); color: var(--warn); }
.status.accepted { background: var(--accent-soft); color: var(--accent); }
.status.prep { background: var(--violet-soft); color: var(--violet); }

.pub-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: .7em;
    align-items: center;
}
.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elev);
    color: var(--text-muted);
    font: 500 .8rem/1.6 var(--font-sans);
    text-decoration: none;
    cursor: pointer;
}
.btn-sm:hover { color: var(--accent); border-color: var(--accent); }
.btn-sm i { font-size: .9em; }

details.more { margin-top: .6em; }
details.more > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elev);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; font-family: var(--font-mono); }
details.more[open] > summary::before { content: "–"; }
details.more > summary:hover { color: var(--accent); border-color: var(--accent); }
details.more .more-body {
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--bg-soft);
    border-radius: 8px;
    font-size: .93rem;
    color: var(--text-muted);
}

.inline-details { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.inline-details details.more { margin-top: 0; }
.inline-details details.more[open] { flex-basis: 100%; }

pre.bibtex {
    margin: 0;
    font-family: var(--font-mono);
    font-size: .78rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}
.copy-row { display: flex; justify-content: flex-end; margin-top: 8px; }

@media (max-width: 520px) {
    .pub { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Generic timeline entries (talks, CV) ---------- */

.entries { list-style: none; margin: 0; padding: 0; }
.entry {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.entry:last-child { border-bottom: 0; }
.entry .when {
    font-family: var(--font-mono);
    font-size: .8rem;
    color: var(--text-faint);
    padding-top: 3px;
}
.entry h3 {
    font-family: var(--font-serif);
    font-size: 1.08rem;
    margin: 0 0 .15em;
}
.entry .where { color: var(--text-muted); font-size: .93rem; margin: 0; }
.entry .note { font-size: .93rem; margin: .4em 0 0; }
.entry ul.points { margin: .4em 0 0; padding-left: 1.1em; font-size: .94rem; color: var(--text-muted); }
.entry ul.points li { margin-bottom: .2em; }
.entry .pub-actions { margin-top: .55em; }

.type-tag {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 2px;
}

@media (max-width: 560px) {
    .entry { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Misc ---------- */

.callout {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    font-size: .93rem;
    color: var(--text-muted);
}
.callout img { width: 52px; height: 52px; flex: none; }
.callout p { margin: 0; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    background: var(--text);
    color: var(--bg);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: .88rem;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */

.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 48px;
    padding: 28px 0 36px;
    font-size: .85rem;
    color: var(--text-faint);
}
.site-footer .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.site-footer .funding {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 480px;
}
.site-footer .funding img { width: 40px; height: 40px; flex: none; }
.site-footer a { color: var(--text-muted); }

@media print {
    .site-header, .site-footer, .pub-actions, details.more { display: none !important; }
    body { background: #fff; color: #000; }
}
