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

body {
    background: #fdfdfd;
    color: #222;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    max-width: 840px;
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* === Selection === */
::selection {
    background: #1a1f4e;
    color: #fff;
}

/* === Typography === */
h1 {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.3;
    color: #1a1f4e;
    border-bottom: 3px solid #1a1f4e;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    clear: both;
    background: none;
}

#news h2 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #e5e5e5;
}

#news h2:first-of-type {
    margin-top: 0;
}

p {
    margin-bottom: 1rem;
}

p:last-child {
    margin-bottom: 0;
}

/* === Links === */
a, a:visited, a:active {
    color: #1a1f4e;
    text-decoration: underline;
    text-decoration-color: #c5c9e0;
    text-underline-offset: 3px;
    transition: all 0.2s ease;
}

a:hover {
    text-decoration-color: #1a1f4e;
    color: #0f1435;
}

a:focus-visible {
    outline: 2px solid #1a1f4e;
    outline-offset: 3px;
    border-radius: 2px;
}

h1 a, h1 a:visited, h1 a:active, h1 a:hover {
    color: #1a1f4e;
    text-decoration: none;
}

/* === Sections === */
#intro, #contact, #news, #publications, #phdthesis {
    background: none;
    margin-top: 4rem;
    padding: 0;
}

#intro {
    margin-top: 0;
}

#intro h1 {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: -0.025em;
    line-height: 1.2;
    border-bottom: none;
    margin-bottom: 1.5rem;
}

#intro > p:first-of-type {
    font-size: 1.0625rem;
    color: #1a1a1a;
}

/* === Images === */
.inset {
    float: left;
    margin: 0.3rem 1.5rem 1rem 0;
    border-radius: 4px;
    max-width: 180px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.inset:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

a img { border: none; }

img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
}

#news img {
    max-width: 320px;
    margin: 0.8rem 0.5rem 0.8rem 0;
    display: inline-block;
    vertical-align: top;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

#news img:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* === Contact === */
#contact {
    background: #f8f9fc;
    border: 1px solid #dde1f0;
    border-radius: 6px;
    padding: 1.5rem 2rem;
    line-height: 1.75;
    transition: border-color 0.3s ease;
}

#contact:hover {
    border-color: #c5c9e0;
}

/* === Publications === */
#publications ul {
    list-style: none;
    padding: 0;
    border-top: 2px solid #e8e8e8;
    padding-top: 0.5rem;
}

#publications li {
    padding: 0.6rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    line-height: 1.55;
    transition: background 0.2s ease;
}

#publications li:last-child {
    border-bottom: none;
}

#publications li:hover {
    background: #fafbfd;
}

#publications li strong {
    display: block;
    color: #0f1435;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 0.15rem;
}

#publications a {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* === PhD Thesis === */
#phdthesis {
    border-top: 1px solid #e8e8e8;
    padding-top: 4rem;
}

#phdthesis .inset {
    max-width: 140px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border-radius: 3px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

#phdthesis .inset:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transform: translateY(-3px);
}

/* === Utilities === */
.clearer { clear: both; }

/* === Print === */
@media print {
    body {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.5;
        background: #fff;
        padding: 0;
    }

    #news img, #phdthesis .inset {
        max-width: 50%;
        page-break-inside: avoid;
    }

    a {
        color: #000;
        text-decoration: none;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* === Responsive: Tablet === */
@media (max-width: 768px) {
    body {
        padding: 2rem 1.5rem 4rem;
        font-size: 15px;
    }

    #intro h1 {
        font-size: 1.75rem;
    }

    .inset {
        max-width: 160px;
    }
}

/* === Responsive: Mobile === */
@media (max-width: 600px) {
    body {
        padding: 1.25rem 1rem 2.5rem;
        font-size: 15px;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Reduce section gaps on small screens */
    #intro, #contact, #news, #publications, #phdthesis {
        margin-top: 2.5rem;
    }

    h1 {
        font-size: 1.15rem;
        margin-bottom: 1rem;
    }

    #intro h1 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }

    /* Portrait centered and slightly larger */
    .inset {
        float: none;
        display: block;
        max-width: 200px;
        margin: 0 auto 1.25rem;
    }

    /* All images stack full-width */
    #news img {
        max-width: 100%;
        display: block;
        margin: 0.5rem 0;
    }

    /* Contact card tighter on mobile */
    #contact {
        padding: 1rem 1.25rem;
        font-size: 0.9rem;
        line-height: 1.7;
        border-radius: 4px;
    }

    /* Contact heading inside card */
    #contact h1 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    /* News dates smaller */
    #news h2 {
        margin-top: 2rem;
        font-size: 0.75rem;
    }

    /* Publications even more compact on mobile */
    #publications li {
        padding: 0.5rem 0;
        font-size: 0.85rem;
    }

    #publications li strong {
        font-size: 0.88rem;
    }

    /* Thesis section */
    #phdthesis {
        padding-top: 2.5rem;
    }

    #phdthesis .inset {
        max-width: 120px;
    }

    /* Long URLs must break */
    a {
        word-break: break-all;
    }

    /* But not short link text */
    a:not([href^="http"]) {
        word-break: normal;
    }

    /* Reduce bottom padding on paragraphs */
    p {
        margin-bottom: 0.75rem;
    }
}
