/* ------------------------------------------------------------------
   Shared site styles. Dark by default, light mode via body.light.
   ------------------------------------------------------------------ */

:root {
    --bg:        #0b0d12;
    --bg-soft:   #11141b;
    --surface:   #14181f;
    --surface-2: #1a1f28;
    --line:      #232936;
    --line-soft: #1b202a;
    --text:      #e8ebf1;
    --text-dim:  #9aa4b4;
    --text-mute: #6a7486;
    --accent:    #8aa2f7;
    --accent-2:  #62d9c4;
    --glow:      rgba(138, 162, 247, .16);
    --shadow:    0 1px 2px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.35);
    --radius:    12px;
    --maxw:      1240px;
    --pad-x:     max(18px, 3.2vw);
}

body.light {
    --bg:        #fbfbfa;
    --bg-soft:   #f3f4f2;
    --surface:   #ffffff;
    --surface-2: #f5f6f8;
    --line:      #e2e5ea;
    --line-soft: #edeff3;
    --text:      #16191f;
    --text-dim:  #525a68;
    --text-mute: #8a92a0;
    --accent:    #2f6f62;
    --accent-2:  #2f6f62;
    --glow:      rgba(47, 111, 98, .10);
    --shadow:    0 1px 2px rgba(16,24,40,.05), 0 10px 28px rgba(16,24,40,.07);
}

* { box-sizing: border-box; }
html {
    font-size: 18.5px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
    overflow-x: hidden;
}

/* a very soft light behind the top of the page */
body::before {
    content: '';
    position: fixed;
    inset: -20% -20% auto -20%;
    height: 70vh;
    background:
        radial-gradient(60% 60% at 22% 0%, var(--glow), transparent 70%),
        radial-gradient(45% 45% at 85% 5%, var(--glow), transparent 72%);
    pointer-events: none;
    z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
    font-family: 'Newsreader', Georgia, 'Times New Roman', serif;
    font-weight: 500;
    letter-spacing: -0.012em;
    color: var(--text);
    margin: 0;
}

/* ---------- nav ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px var(--pad-x);
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: saturate(170%) blur(14px);
    -webkit-backdrop-filter: saturate(170%) blur(14px);
    border-bottom: 1px solid var(--line-soft);
}

.nav .brand {
    font-family: 'Newsreader', Georgia, serif;
    font-size: 1rem;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--text);
    white-space: nowrap;
}
.nav .brand:hover { text-decoration: none; color: var(--accent); }

.nav-links {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-links a {
    color: var(--text-dim);
    font-size: .86rem;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 7px;
    white-space: nowrap;
    transition: color .2s ease, background-color .2s ease;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--text); }
.nav-links a.active::after {
    content: '';
    display: block;
    height: 1.5px;
    margin-top: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.theme-btn {
    margin-left: 4px;
    width: 30px;
    height: 30px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
    transition: color .2s ease, border-color .2s ease;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- layout ---------- */
.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 40px var(--pad-x) 28px;
}

.section { margin-top: 48px; }

.section-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 16px;
}
.section-head h2 { font-size: 1.4rem; }
.section-head .rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--line), transparent);
}

/* ---------- hero ---------- */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    column-gap: 34px;
    align-items: start;
}
.hero-head { grid-column: 1; grid-row: 1; }
.hero-body { grid-column: 1; grid-row: 2; }
/* the portrait spans both text rows and sits at their vertical middle */
.hero .portrait { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

.hero h1 {
    font-size: clamp(2rem, 4.4vw, 2.8rem);
    line-height: 1.08;
    margin-bottom: 6px;
    background: linear-gradient(175deg, var(--text) 30%, var(--text-dim));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero .role { color: var(--text-dim); font-size: .93rem; margin: 0 0 14px; }
.hero .role a { color: var(--text-dim); border-bottom: 1px solid var(--line); }
.hero .role a:hover { color: var(--accent); text-decoration: none; border-color: var(--accent); }

.hero p { color: var(--text-dim); margin: 0 0 14px; }
.hero p strong, .hero p b { color: var(--text); font-weight: 600; }

.hero .portrait img {
    width: 100%;
    border-radius: var(--radius);
    display: block;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.socials { display: flex; gap: 8px; margin: 0 0 18px; flex-wrap: wrap; }
.socials a {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text-dim);
    font-size: .92rem;
    transition: color .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.socials a:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px var(--glow);
    text-decoration: none;
}

/* ---------- interests ---------- */
/* plain flow (not grid/flex) so the lines wrap around the floated portrait */
.interests {
    list-style: none;
    padding: 0;
    margin: 6px 0 18px;
}
.interests li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 8px;
    color: var(--text-dim);
}
.interests li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: .66em;
    width: 5px;
    height: 5px;
    border-radius: 2px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.interests li b { color: var(--text); font-weight: 600; }

.callout {
    border: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    background: var(--surface);
    border-radius: 10px;
    padding: 15px 18px;
    color: var(--text-dim);
    font-size: .92rem;
}
.callout b { color: var(--text); }

/* ---------- news ---------- */
.news { max-height: 330px; overflow-y: auto; padding-right: 6px; }
.news ul { list-style: none; margin: 0; padding: 0; }
.news li {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 14px;
    padding: 9px 8px 9px 6px;
    border-radius: 8px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--text-dim);
    font-size: .91rem;
    transition: background-color .2s ease;
}
.news li:hover { background: var(--surface); }
.news li:last-child { border-bottom: none; }
.news li .when {
    color: var(--text-mute);
    font-variant-numeric: tabular-nums;
    font-size: .81rem;
    letter-spacing: .02em;
    padding-top: 2px;
    white-space: nowrap;
}
.news::-webkit-scrollbar { width: 7px; }
.news::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.news::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.news::-webkit-scrollbar-track { background: transparent; }

/* ---------- two column top: intro + news ---------- */
.top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 44px;
    align-items: stretch;
}

/* the news column stretches to the intro's height and scrolls inside it.
   Both children are absolute so the list's length never drives the row height. */
.side { position: relative; }
.side > .section-head { position: absolute; top: 0; left: 0; right: 0; }
.side > .news-side { position: absolute; top: 44px; left: 0; right: 0; bottom: 0; }
.top .hero { min-width: 0; }

.side .section-head { margin-bottom: 10px; }
.side .section-head h2 { font-size: 1.15rem; }

.news-side {
    max-height: none;
    overflow-y: auto;
    /* fade the clipped row at the bottom so the cut reads as "more below" */
    -webkit-mask-image: linear-gradient(180deg, #000 86%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 86%, transparent 100%);
    padding: 0;
}
.news-side li {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 10px 4px;
    font-size: .86rem;
}
.news-side li .when { font-size: .76rem; }
.news-side li:hover { background: transparent; }

.section-head .more {
    font-size: .84rem;
    font-weight: 500;
    color: var(--text-dim);
    white-space: nowrap;
}
.section-head .more:hover { color: var(--accent); text-decoration: none; }

@media (max-width: 980px) {
    .top { grid-template-columns: 1fr; gap: 30px; }
    .side > .section-head, .side > .news-side { position: static; }
    .news-side { overflow: visible; -webkit-mask-image: none; mask-image: none; }
}

.news-page { max-height: none; overflow: visible; padding-right: 0; }
.news-page li { grid-template-columns: 112px 1fr; padding: 12px 8px 12px 6px; }

/* ---------- publications ---------- */
.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.pub {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 21px;
    overflow: hidden;
    transition: border-color .22s ease, transform .22s ease, box-shadow .22s ease;
}
.pub::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    opacity: 0;
    transition: opacity .22s ease;
}
.pub:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.pub:hover::before { opacity: 1; }
.pub .title {
    font-family: 'Newsreader', Georgia, serif;
    font-size: 1.13rem;
    line-height: 1.32;
    margin-bottom: 5px;
}
.pub .authors { color: var(--text-dim); font-size: .88rem; margin-bottom: 9px; }
.pub .authors em { color: var(--text); font-style: normal; font-weight: 600; }
.pub .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .84rem; }
.pub .venue {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text-dim);
    font-weight: 600;
}
.pub .venue:hover { color: var(--accent); text-decoration: none; border-color: var(--accent); }
.pub .meta .sep { color: var(--text-mute); }

/* ---------- footer ---------- */
.footer {
    border-top: 1px solid var(--line-soft);
    margin-top: 48px;
    padding: 20px var(--pad-x) 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    color: var(--text-mute);
    font-size: .78rem;
    flex-wrap: wrap;
}
.footer a { color: var(--text-mute); }
.footer a:hover { color: var(--accent); }

/* the door to the personal page */
.footer .ig-link {
    margin-left: 8px;
    color: var(--text-mute);
    font-size: 1.05rem;
    vertical-align: -2px;
    text-decoration: none;
    transition: color .25s ease;
}
.footer .ig-link:hover { color: var(--accent); text-decoration: none; }

/* ---------- entrance ---------- */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.hero, .section, .pubs, .footer { animation: rise .5s ease both; }
.section { animation-delay: .07s; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
    .hero { grid-template-columns: minmax(0, 1fr) 190px; gap: 26px; }
}

@media (max-width: 620px) {
    /* name, role and links first, then the photo, then the bio */
    .hero { grid-template-columns: 1fr; row-gap: 24px; }
    .hero-head { grid-column: 1; grid-row: 1; }
    .hero .portrait { grid-column: 1; grid-row: 2; width: 70%; max-width: 240px; margin: 0 auto; }
    .hero-body { grid-column: 1; grid-row: 3; }
}

@media (max-width: 720px) {
    html { font-size: 17px; }
    .nav {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px var(--pad-x);
    }
    .nav .brand { font-size: .92rem; }
    .nav-links {
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1px;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .wrap { padding: 28px var(--pad-x) 22px; }
    .section { margin-top: 34px; }
    .news { max-height: none; overflow: visible; padding-right: 0; }
    .news li { grid-template-columns: 1fr; gap: 1px; padding: 9px 4px; }
    .footer { margin-top: 34px; font-size: .75rem; }
}

/* avoid a light/dark flash before theme.js runs */
html.pre-light { background: #fbfbfa; }
html:not(.pre-light) { background: #0b0d12; }
