/* css/style.css */

:root {
    --navy: #10263b;
    --navy-soft: #e8eef2;
    --red: #b32634;
    --red-dark: #8f1d29;
    --red-soft: #f7e9eb;
    --red-on-dark: #ff4545;

    --bg-main: #fcfbf8;
    --bg-alt: #faf8f3;
    --surface: #ffffff;
    --surface-muted: #f7f8f8;
    --text-main: var(--navy);
    --text-muted: #45596b;
    --text-light: #607485;
    --accent: var(--red);
    --accent-hover: var(--red-dark);
    --border: #d7dde1;
    --border-strong: #bcc7cf;
    
    --font-sans: 'Inter', Arial, sans-serif;
    
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--navy); }

::selection { background: var(--red-soft); color: var(--navy); }

:focus-visible { outline: 3px solid rgba(179, 38, 52, 0.28); outline-offset: 3px; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: var(--font-sans);
    color: var(--text-main);
    background-color: var(--bg-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

main { flex: 1 0 auto; }

.alt-bg { background-color: var(--bg-alt); }
.container { max-width: 1100px; margin: 0 auto; padding: 0 2rem; }
.section { padding: 6rem 0; }
.section-title { font-size: 2.5rem; margin-bottom: 3rem; color: var(--text-main); border-bottom: 2px solid var(--navy); padding-bottom: 1rem; }

/* Navbar */
.navbar { position: fixed; top: 0; width: 100%; background: rgba(16, 38, 59, 0.97); backdrop-filter: blur(8px); border-bottom: 2px solid var(--red); z-index: 1000; box-shadow: 0 3px 12px rgba(16, 38, 59, 0.18); }
.nav-content { max-width: 1100px; margin: 0 auto; padding: 1.2rem 2rem; display: flex; justify-content: space-between; align-items: center; }

/* Logo & Brand Name Container */
.nav-brand-wrapper { display: flex; align-items: center; gap: 0.8rem; text-decoration: none; }
.nav-logo { height: 32px; width: auto; object-fit: contain; display: none; } /* Hidden by default until fetched */
.nav-brand { font-family: var(--font-sans); font-size: 1.25rem; font-weight: 600; letter-spacing: 0.5px; color: var(--surface); }

.nav-links { display: flex; gap: 2rem; align-items: center; }
.nav-links a { position: relative; text-decoration: none; color: #dce5eb; font-size: 0.9rem; font-weight: 500; padding: 0.4rem 0; transition: color 0.2s; }
.nav-links a:hover, .nav-links a.active:hover { color: var(--red-on-dark); }
.nav-links a::after { content: ''; position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--red-on-dark); transform: scaleX(0); transform-origin: center; transition: transform 0.2s ease; }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.nav-links a.active { color: var(--surface); font-weight: 600; }
.navbar :focus-visible, .site-footer :focus-visible { outline-color: var(--red-on-dark); }

/* Home */
.home-main { background: var(--bg-main); }
.hero { position: relative; display: flex; align-items: center; min-height: 80vh; overflow: hidden; padding: 10rem 0 5.75rem; background: var(--bg-main); }
.hero::before { content: ''; position: absolute; top: 10%; right: -9rem; width: 28rem; height: 28rem; background: radial-gradient(circle, var(--navy-soft) 0%, rgba(232, 238, 242, 0) 70%); pointer-events: none; }
.hero-container { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); align-items: center; gap: clamp(3rem, 7vw, 6rem); width: 100%; }
.hero-text { min-width: 0; max-width: 650px; }
.hero-text h1 { display: flex; flex-wrap: nowrap; gap: 0.2em; margin-bottom: 1rem; color: var(--text-main); font-family: var(--font-sans); font-size: clamp(2.8rem, 5.1vw, 4.2rem); line-height: 1.02; letter-spacing: -0.025em; white-space: nowrap; }
.hero-given-name { color: #30485a; font-weight: 500; }
.hero-family-name { color: var(--text-main); font-weight: 700; white-space: nowrap; }
.hero-subtitle { margin-bottom: 0.3rem; color: var(--red); font-size: 1.2rem; font-weight: 700; }
.hero-company { color: #30485a; font-size: 1.03rem; font-weight: 500; }
.hero-bio { max-width: 640px; margin: 1.8rem 0 2rem; color: var(--text-muted); font-size: 1.02rem; line-height: 1.78; white-space: pre-line; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.home-action { display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem; min-height: 46px; padding: 0.72rem 1.05rem; border: 1px solid; border-radius: 6px; font-size: 0.9rem; font-weight: 700; text-decoration: none; transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s; }
.home-action svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.home-action-primary { background: var(--red); border-color: var(--red); color: var(--surface); }
.home-action-primary:hover { background: var(--red-dark); border-color: var(--red-dark); transform: translateY(-1px); }
.home-action-secondary { background: var(--surface); border-color: var(--navy); color: var(--navy); }
.home-action-secondary:hover { background: var(--navy); color: var(--surface); transform: translateY(-1px); }
.home-action:focus-visible, .footer-email:focus-visible, .footer-address:focus-visible, .footer-profile-link:focus-visible { outline: 3px solid var(--red-on-dark); outline-offset: 3px; }

.hero-visual { width: 100%; max-width: 390px; justify-self: end; }
.hero-image-wrapper { position: relative; }
.hero-image { position: relative; z-index: 1; display: block; width: 100%; aspect-ratio: 4 / 5; border: 3px solid rgba(16, 38, 59, 0.58); border-radius: 14px; object-fit: cover; object-position: 50% 68%; box-shadow: 0 20px 42px rgba(16, 38, 59, 0.18); }

.site-footer { scroll-margin-top: 76px; padding: 1.75rem 0; background: var(--navy); border-top: 3px solid var(--red); color: #dce5eb; }
.site-footer-layout { display: grid; grid-template-columns: minmax(245px, 1.15fr) minmax(250px, 1fr) minmax(285px, 0.9fr); align-items: center; gap: clamp(1.75rem, 4vw, 4rem); }
.footer-email, .footer-address, .footer-profile-link { min-width: 0; color: inherit; text-decoration: none; }
.footer-email, .footer-address { display: flex; align-items: center; gap: 0.8rem; }
.footer-email { width: fit-content; min-height: 48px; padding: 0.45rem 0.8rem 0.45rem 0.55rem; background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 6px; color: var(--surface); font-size: 0.98rem; font-weight: 400; transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
.footer-email:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 69, 69, 0.7); color: var(--red-on-dark); }
.footer-email svg { width: 36px; height: 36px; padding: 8px; background: rgba(255, 69, 69, 0.13); border-radius: 50%; }
.footer-address { width: fit-content; min-height: 48px; padding: 0.55rem 0.8rem; background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 6px; color: #dce5eb; font-size: 0.8rem; font-weight: 500; line-height: 1.45; transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
.footer-address:hover { background: rgba(255, 255, 255, 0.085); border-color: rgba(255, 69, 69, 0.65); color: var(--red-on-dark); }
.footer-address svg { width: 19px; height: 19px; }
.footer-address address { overflow-wrap: anywhere; font-style: normal; white-space: pre-line; }
.footer-profile-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.footer-profile-link { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 36px; padding: 0.42rem 0.55rem; background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 5px; color: var(--surface); font-size: 0.78rem; font-weight: 400; white-space: nowrap; transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
.footer-profile-link:hover { background: rgba(255, 255, 255, 0.085); border-color: rgba(255, 69, 69, 0.65); color: var(--red-on-dark); }
.site-footer svg { flex: 0 0 auto; fill: none; stroke: var(--red-on-dark); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.footer-profile-link svg { width: 16px; height: 16px; }
.footer-institution-link { justify-content: center; }
.footer-logo { display: block; width: auto; height: auto; object-fit: contain; }
.footer-logo-epfl { width: 54px; }
.footer-logo-sfi { width: 35px; }

/* Paper Cards */
.research-catalog { background: var(--bg-alt); }
.research-group + .research-group { margin-top: 5rem; }
.research-section-title { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; color: var(--navy); font-size: 2.15rem; line-height: 1.2; }
.research-section-title::after { content: ''; height: 1px; flex: 1; background: var(--border-strong); }

.papers-grid { display: flex; flex-direction: column; gap: 2rem; }
.paper-card { position: relative; display: flex; gap: 2.5rem; overflow: hidden; background: var(--surface); padding: 1.8rem 2.3rem; border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: 10px; box-shadow: 0 5px 14px rgba(16, 38, 59, 0.055); transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s; }
.paper-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(16, 38, 59, 0.1); border-color: var(--border-strong); border-left-color: var(--red); }
.paper-content { min-width: 0; flex: 1; }
.paper-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.paper-title { margin: 0; color: var(--text-main); font-family: var(--font-sans); font-size: 1.52rem; font-weight: 600; letter-spacing: -0.018em; line-height: 1.35; }
.paper-title-link { color: inherit; text-decoration: underline; text-decoration-color: transparent; text-decoration-thickness: 1px; text-underline-offset: 0.18em; transition: color 0.2s, text-decoration-color 0.2s; }
.paper-title-link:hover { color: var(--red-dark); text-decoration-color: currentColor; }
.paper-year { flex-shrink: 0; min-width: 3.5rem; padding: 0.3rem 0.65rem; background: var(--navy-soft); border-radius: 4px; color: var(--navy); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-align: center; }
.paper-authors { margin-top: 0.55rem; color: #30485a; font-size: 0.98rem; }
.paper-revision { display: block; width: fit-content; margin-top: 0.55rem; padding: 0.3rem 0.7rem; background: var(--red-soft); border: 1px solid var(--red); border-radius: 999px; color: var(--red); font-size: 0.8rem; font-weight: 700; line-height: 1.35; }
.paper-substatus { margin-top: 0.35rem; color: var(--red); font-size: 0.92rem; font-weight: 600; }
.paper-heading + .paper-substatus { margin-top: 0.7rem; }

.paper-links { display: flex; gap: 0.65rem; flex-wrap: wrap; }
.paper-link-btn { padding: 0.42rem 0.85rem; background: var(--surface); border: 1px solid var(--red); border-radius: 4px; color: var(--red); font-size: 0.82rem; font-weight: 700; text-decoration: none; transition: all 0.2s; }
.paper-link-btn:hover { background: var(--red); border-color: var(--red); color: var(--surface); }

.abstract-toggle { margin-top: 1.15rem; margin-bottom: 1rem; padding: 0.52rem 0.95rem; display: inline-flex; align-items: center; gap: 0.5rem; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 5px; color: var(--navy); cursor: pointer; font-family: inherit; font-size: 0.86rem; font-weight: 700; transition: all 0.2s; }
.abstract-toggle:hover { background: var(--red-soft); border-color: var(--border-strong); color: var(--accent-hover); }
.chevron { transition: transform 0.3s ease; stroke: currentColor; }
.abstract-toggle.open .chevron { transform: rotate(180deg); }

.paper-abstract { display: block; margin-bottom: 1.25rem; padding: 1.1rem 1.3rem; background: var(--surface-muted); border-left: 3px solid var(--navy); border-radius: 0 5px 5px 0; color: var(--text-muted); font-size: 0.94rem; line-height: 1.75; animation: fadeIn 0.3s ease; }
.paper-abstract[hidden] { display: none; }
.paper-abstract p { white-space: pre-line; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.paper-secondary-details { display: flex; flex-direction: column; gap: 0.55rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }
.paper-detail, .paper-areas { color: var(--text-muted); font-size: 0.86rem; line-height: 1.65; }
.paper-detail-label { display: inline-block; margin-right: 0.65rem; color: var(--navy); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.paper-areas { display: flex; align-items: center; gap: 0.65rem; }
.paper-areas .paper-detail-label { flex-shrink: 0; margin-right: 0; }
.paper-area-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.paper-area-tag { padding: 0.22rem 0.55rem; background: var(--navy-soft); border-radius: 3px; color: var(--text-muted); font-size: 0.78rem; font-weight: 500; }

.paper-mobile-actions, .paper-mobile-details { display: none; }
.paper-mobile-details-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.42rem 0.85rem; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 4px; color: var(--navy); cursor: pointer; font-family: inherit; font-size: 0.82rem; font-weight: 600; }
.paper-mobile-details-toggle:hover { background: var(--red-soft); border-color: var(--border-strong); color: var(--red-dark); }
.paper-mobile-details-toggle.open .chevron { transform: rotate(180deg); }

.paper-figure { width: 220px; height: auto; flex-shrink: 0; align-self: flex-start; border-radius: 8px; border: 1px solid var(--border); box-shadow: 0 4px 8px rgba(16, 38, 59, 0.08); }

/* Discussions */
.discussions-compact { padding: 3.5rem 0 4rem; background: var(--bg-main); }
.discussions-title { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.15rem; color: var(--navy); font-size: 1.65rem; }
.discussions-title::after { content: ''; height: 1px; flex: 1; background: var(--border-strong); }
.discussions-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 3rem; }
.discussion-item { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.disc-title { color: var(--text-main); font-family: var(--font-sans); font-size: 0.98rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; }
.disc-authors { margin-top: 0.15rem; color: var(--text-muted); font-size: 0.8rem; }
.disc-conference { margin-top: 0.2rem; color: var(--red); font-size: 0.78rem; font-weight: 700; line-height: 1.4; }

/* Interior pages */
.page-main { min-height: calc(100vh - 90px); }
.page-hero { padding: 7rem 0 2.5rem; background: linear-gradient(135deg, #1a3b57 0%, #24506e 100%); }
.page-hero h1 { font-size: 3.25rem; line-height: 1.1; margin-bottom: 1rem; }
.page-hero h1:last-child { margin-bottom: 0; }
.eyebrow { margin-bottom: 0.75rem; color: var(--accent); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.page-intro { max-width: 720px; color: var(--text-muted); font-size: 1.05rem; line-height: 1.8; }
.page-hero h1 { color: var(--surface); }
.page-hero .eyebrow { color: var(--red-on-dark); }
.page-hero .page-intro { color: #dce5eb; }
.empty-message { color: var(--text-muted); }

/* Error page */
.error-page { background: var(--bg-alt); }
.error-content { max-width: 720px; }
.error-content p { margin-bottom: 1.5rem; color: var(--text-muted); font-size: 1.05rem; line-height: 1.75; }
.error-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Teaching */
.teaching-page { background: var(--bg-alt); }
.teaching-content { max-width: 1100px; }
.teaching-section-title { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; color: var(--navy); font-size: 2.15rem; line-height: 1.2; }
.teaching-section-title::after { content: ''; height: 1px; flex: 1; background: var(--border-strong); }
.teaching-list { display: flex; flex-direction: column; gap: 0.75rem; list-style: none; }
.teaching-item { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: 1.15rem 1.35rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: 8px; box-shadow: 0 4px 12px rgba(16, 38, 59, 0.045); }
.teaching-course-details { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.45rem; min-width: 0; }
.teaching-course { color: var(--navy); font-size: 1rem; font-weight: 600; line-height: 1.4; }
.teaching-institution { color: var(--red); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; }
.teaching-years { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.35rem; flex-shrink: 0; }
.teaching-year { min-width: 3.15rem; padding: 0.22rem 0.48rem; background: var(--navy-soft); border-radius: 4px; color: var(--navy); font-size: 0.76rem; font-weight: 700; text-align: center; }

/* CV */
.cv-page { padding-top: 4rem; }
.cv-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }
.cv-toolbar { justify-content: flex-start; margin-bottom: 1.25rem; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 0.7rem 1rem; border: 1px solid var(--accent); border-radius: 6px; font-size: 0.9rem; font-weight: 600; text-decoration: none; transition: all 0.2s ease; }
.button-primary { background: var(--accent); color: var(--surface); }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-secondary { background: var(--surface); border-color: var(--navy); color: var(--navy); }
.button-secondary:hover { background: var(--navy); border-color: var(--navy); color: var(--surface); transform: translateY(-1px); }
.cv-frame-wrapper { overflow: hidden; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(16, 38, 59, 0.09); }
.cv-frame { display: block; width: 100%; height: 78vh; min-height: 640px; border: 0; background: var(--surface); }

/* Responsive */
@media (max-width: 900px) {
    .research-catalog.section { padding-top: 4rem; padding-bottom: 4rem; }
    .papers-grid { gap: 1.25rem; }
    .paper-card { flex-direction: column; gap: 1.25rem; padding: 1.25rem; }
    .paper-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.75rem; }
    .paper-title { font-size: 1.3rem; line-height: 1.35; }
    .paper-year { min-width: 3.25rem; padding: 0.24rem 0.5rem; }
    .paper-authors { margin-top: 0.45rem; font-size: 0.9rem; }
    .abstract-toggle, .paper-secondary-details { display: none; }
    .paper-mobile-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem; margin-top: 1rem; }
    .paper-mobile-actions .paper-links { gap: 0.55rem; }
    .paper-mobile-details:not([hidden]) { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 0.85rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
    .paper-mobile-abstract { color: var(--text-muted); font-size: 0.88rem; line-height: 1.65; }
    .paper-mobile-abstract .paper-detail-label { display: block; margin: 0 0 0.35rem; }
    .paper-mobile-details .paper-detail { font-size: 0.82rem; line-height: 1.55; }
    .paper-mobile-details .paper-areas { align-items: flex-start; flex-direction: column; gap: 0.4rem; font-size: 0.82rem; }
    .paper-figure { width: 100%; max-width: 300px; margin: 0 auto; }
}

@media (max-width: 768px) {
    .navbar { position: sticky; }
    .nav-content { flex-direction: column; gap: 0.75rem; padding: 0.85rem 1rem; }
    .nav-links { display: flex; gap: 1.5rem; }
    .hero { min-height: auto; padding: 4.5rem 0 5rem; }
    .hero::before { top: 42%; right: -13rem; }
    .hero-container { grid-template-columns: 1fr; gap: 3.5rem; }
    .hero-text { max-width: none; }
    .hero-visual { max-width: 340px; justify-self: center; }
    .discussions-list { grid-template-columns: 1fr; }
    .page-hero { padding: 2.75rem 0; }
    .page-hero h1 { font-size: 2.7rem; }
    .teaching-item { align-items: flex-start; flex-direction: column; gap: 0.7rem; }
    .teaching-years { justify-content: flex-start; }
    .cv-frame { min-height: 520px; height: 70vh; }
    .site-footer-layout { grid-template-columns: 1fr; gap: 1.15rem; }
    .footer-profile-links { grid-column: auto; }
}

@media (max-width: 480px) {
    .container { padding: 0 1.25rem; }
    .section { padding-top: 4rem; padding-bottom: 4rem; }
    .nav-links { width: 100%; justify-content: center; gap: 1.25rem; }
    .hero-text h1 { gap: 0.18em; font-size: clamp(2.1rem, 9.2vw, 2.65rem); }
    .hero-actions { flex-direction: column; }
    .home-action { width: 100%; }
    .hero-visual { max-width: 290px; }
    .site-footer { padding: 1.35rem 0; }
    .site-footer-layout { grid-template-columns: 1fr; gap: 1.15rem; }
    .footer-profile-links { grid-column: auto; }
    .paper-card { padding: 1.1rem; }
    .research-section-title { font-size: 1.85rem; }
    .research-group + .research-group { margin-top: 3.25rem; }
    .cv-actions { width: 100%; flex-direction: column; }
    .cv-frame { min-height: 440px; height: 65vh; }
}
