:root {
    color-scheme: light;
    --bg: #ffffff;
    --text: #1f2328;
    --text-soft: #3d444d;
    --muted: #697179;
    --line: #e3e6e9;
    --link: #1d5b94;
    --link-hover: #0e3c66;
    --nav-bg: #23282d;
    --nav-text: #f3f5f6;
    --nav-muted: #a9b2ba;
    --nav-line: rgba(255, 255, 255, 0.16);
    --media-bg: #0f1113;
    --page: 860px;
    --wide: 1120px;
    --gutter: 20px;
    --label-column: 8.5rem;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #15181b;
    --text: #e3e6e9;
    --text-soft: #c3c9cf;
    --muted: #949da6;
    --line: #2c3136;
    --link: #8dbbe8;
    --link-hover: #bcd8f3;
    --nav-bg: #0e1012;
    --nav-text: #eef0f2;
    --nav-muted: #9aa3ab;
    --nav-line: rgba(255, 255, 255, 0.12);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
}

button {
    font: inherit;
    color: inherit;
}

img,
svg,
iframe {
    display: block;
}

img {
    max-width: 100%;
    height: auto;
}

[hidden] {
    display: none !important;
}

a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    color: var(--link-hover);
    text-decoration-color: currentColor;
}

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

h1,
h2,
h3 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    line-height: 1.25;
}

p {
    margin: 0 0 0.9rem;
}

strong {
    font-weight: 600;
}

.note {
    color: var(--muted);
    font-size: 0.9rem;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 8px;
    left: 8px;
    padding: 8px 14px;
    color: var(--nav-bg);
    background: var(--nav-text);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* Top bar */

.topbar {
    position: sticky;
    z-index: 50;
    top: 0;
    color: var(--nav-text);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-line);
}

.topbar-inner {
    display: flex;
    max-width: var(--wide);
    min-height: 54px;
    gap: 8px 24px;
    align-items: center;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.brand {
    color: var(--nav-text);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.brand:hover {
    color: var(--nav-text);
}

.site-nav {
    display: flex;
    align-self: stretch;
    gap: 2px;
}

.site-nav a {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: var(--nav-muted);
    font-size: 0.93rem;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: inset 0 -2px 0 transparent;
}

.site-nav a:hover {
    color: var(--nav-text);
}

.site-nav a[aria-current="page"] {
    color: var(--nav-text);
    box-shadow: inset 0 -2px 0 var(--nav-text);
}

.topbar-tools {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

.language-switcher {
    display: flex;
}

.lang-btn {
    min-width: 30px;
    min-height: 30px;
    padding: 2px 5px;
    border: 0;
    color: var(--nav-muted);
    background: none;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
}

.lang-btn:hover,
.lang-btn.active {
    color: var(--nav-text);
}

.lang-btn.active {
    text-decoration: underline;
    text-underline-offset: 0.3em;
}

.theme-toggle {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--nav-line);
    border-radius: 6px;
    color: var(--nav-muted);
    background: none;
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--nav-text);
}

.theme-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

[data-theme="light"] .theme-icon-sun,
[data-theme="dark"] .theme-icon-moon {
    display: none;
}

/* Page */

.page {
    max-width: var(--page);
    margin: 0 auto;
    padding: 44px var(--gutter) 24px;
}

.page:focus {
    outline: none;
}

.panel > h2 {
    margin-bottom: 1rem;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
}

.panel h3 {
    margin: 2.25rem 0 0.9rem;
    padding-top: 1.4rem;
    border-top: 1px solid var(--line);
    font-size: 1.15rem;
}

.panel > h2 + h3,
.panel > h2 + .page-links + h3 {
    margin-top: 1.25rem;
    padding-top: 0;
    border-top: 0;
}

/* Profile and news */

.profile {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 152px;
    gap: 36px;
    align-items: start;
}

.profile-photo {
    grid-column: 2;
    grid-row: 1;
    width: 152px;
    aspect-ratio: 1;
    border-radius: 4px;
    object-fit: cover;
}

.profile-text {
    grid-column: 1;
    grid-row: 1;
}

.profile h1 {
    margin-bottom: 0.15rem;
    font-size: 1.9rem;
    letter-spacing: -0.015em;
}

.profile-role {
    margin-bottom: 1.1rem;
    color: var(--muted);
}

.profile-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.1rem;
    margin: 1.1rem 0 0;
    font-size: 0.93rem;
}

#news-heading {
    margin-top: 2.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--line);
    font-size: 1.3rem;
}

.news-list,
.bib-list,
.cv-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.news-item {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1fr);
    gap: 1rem;
    padding: 1.1rem 0;
    border-top: 1px solid var(--line);
}

.news-item:first-child {
    border-top: 0;
    padding-top: 0.25rem;
}

.news-date {
    color: var(--muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.8;
}

.news-body {
    display: flow-root;
    min-width: 0;
}

.news-body > p:last-child {
    margin-bottom: 0;
}

.news-thumb {
    float: right;
    width: 176px;
    margin: 0.3rem 0 0.75rem 1.5rem;
    border-radius: 3px;
}

.news-thumbs {
    display: flex;
    float: right;
    gap: 6px;
    margin: 0.3rem 0 0.75rem 1.5rem;
}

.news-thumbs .news-thumb {
    float: none;
    margin: 0;
}

.news-thumb-tall {
    width: 96px;
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

/* CV and research topics */

.cv-list li,
.topics > div {
    display: grid;
    grid-template-columns: var(--label-column) minmax(0, 1fr);
    gap: 1rem;
    padding: 0.35rem 0;
}

.cv-when {
    color: var(--muted);
    font-size: 0.93rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.75;
}

.topics {
    margin: 1.25rem 0 0;
}

.topics dt {
    font-weight: 600;
}

.topics dd {
    margin: 0;
}

/* Figures, media and selected work */

.figure {
    margin: 1.75rem 0;
}

.figure-media {
    width: 100%;
    border-radius: 4px;
    background: var(--media-bg);
}

.figure figcaption {
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.video {
    margin: 0.9rem 0 0;
}

.video iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 4px;
    background: var(--media-bg);
}

/* Text beside a compact figure or video, stacked on narrow screens */

.media-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
    gap: 1.5rem;
    align-items: start;
    margin: 0 0 1.4rem;
}

.media-row > p,
.media-row .figure,
.media-row .video {
    margin: 0;
}

.media-row .figure figcaption {
    margin-top: 0.4rem;
    font-size: 0.82rem;
}

/* People I admire: a small image beside each name and description */

.admire-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 1.75rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}

.admire-list li {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 0.85rem;
    align-items: start;
}

.admire-thumb img {
    width: 56px;
    height: 56px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
    transition: border-color 0.15s ease;
}

.admire-thumb:hover img {
    border-color: var(--muted);
}

.admire-name {
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
}

.admire-name:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.admire-list p {
    margin: 0.2rem 0 0;
    color: var(--text-soft);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Research lines: two columns, stacked on narrow screens */

.research-lines {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
    margin: 1.75rem 0 0.5rem;
    padding-top: 1.4rem;
    border-top: 1px solid var(--line);
}

.research-line {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel .research-line h3 {
    margin: 0 0 0.8rem;
    padding-top: 0;
    border-top: 0;
}

.research-line .figure {
    margin: 0 0 0.9rem;
}

.research-line .figure-media {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.research-line > p:not(.item-links) {
    color: var(--text-soft);
    font-size: 0.95rem;
}

.research-line .item-links {
    margin-top: auto;
    padding-top: 0.1rem;
}

.work {
    padding-bottom: 1.5rem;
}

.work > p:first-child {
    margin-bottom: 0.25rem;
}

.item-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.1rem;
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
}

.page-links {
    margin: -0.25rem 0 0.5rem;
}

.see-also {
    margin-top: 0.5rem;
    color: var(--muted);
}

/* Publications */

.bib-list li {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.55rem 0;
    color: var(--text-soft);
}

.bib-list strong {
    color: var(--text);
}

.bib-label {
    color: var(--muted);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.95;
}

/* Demos */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.75rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.card {
    display: block;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
    text-decoration: none;
}

.card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    margin-bottom: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    object-fit: cover;
    background: #fff;
    transition: border-color 0.15s ease;
}

.card strong {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--link);
    font-size: 0.97rem;
    line-height: 1.35;
}

.card-ref {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    font-style: italic;
}

.card:hover {
    color: var(--muted);
}

.card:hover img {
    border-color: var(--muted);
}

.card:hover strong {
    color: var(--link-hover);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* Difficulty of a mini-game, next to its title */
.difficulty {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.5;
    text-transform: uppercase;
    vertical-align: 0.12em;
}

.difficulty.easy {
    color: #17784f;
    background: rgba(27, 158, 111, 0.13);
}

.difficulty.medium {
    color: #8a5a00;
    background: rgba(201, 133, 0, 0.15);
}

.difficulty.hard {
    color: #b23434;
    background: rgba(214, 69, 69, 0.13);
}

[data-theme="dark"] .difficulty.easy {
    color: #5fd3a3;
    background: rgba(60, 194, 143, 0.16);
}

[data-theme="dark"] .difficulty.medium {
    color: #f0bf5a;
    background: rgba(224, 165, 38, 0.16);
}

[data-theme="dark"] .difficulty.hard {
    color: #f08a8a;
    background: rgba(230, 103, 103, 0.16);
}

/* Footer */

.site-footer {
    display: flex;
    width: min(calc(100% - 2 * var(--gutter)), calc(var(--page) - 2 * var(--gutter)));
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin: 2rem auto 0;
    padding: 1.25rem 0 2.25rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
}

.site-footer p {
    margin: 0;
}

.back-to-top {
    padding: 0;
    border: 0;
    color: var(--link);
    background: none;
    cursor: pointer;
}

.back-to-top:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Responsive */

@media (max-width: 960px) {
    .topbar-inner {
        flex-wrap: wrap;
        padding-top: 8px;
    }

    .site-nav {
        order: 3;
        width: calc(100% + 2 * var(--gutter));
        margin: 0 calc(-1 * var(--gutter));
        padding: 0 calc(var(--gutter) - 10px);
        overflow-x: auto;
        border-top: 1px solid var(--nav-line);
        scrollbar-width: none;
    }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .site-nav a {
        min-height: 42px;
    }
}

@media (max-width: 640px) {
    :root {
        --gutter: 16px;
    }

    body {
        font-size: 15.5px;
    }

    .site-nav a {
        padding: 0 8px;
        font-size: 0.9rem;
    }

    .page {
        padding-top: 28px;
    }

    .profile {
        display: flow-root;
    }

    .profile-photo {
        float: right;
        width: 92px;
        margin: 0.2rem 0 0.75rem 1rem;
    }

    .profile h1 {
        font-size: 1.55rem;
    }

    .news-item {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.2rem;
    }

    .news-thumb {
        width: 40%;
        margin-left: 1rem;
    }

    .news-thumbs {
        margin-left: 1rem;
    }

    .news-thumb-tall {
        width: 72px;
    }

    .cv-list li,
    .topics > div {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding: 0.45rem 0;
    }
}

@media (max-width: 720px) {
    .research-lines {
        grid-template-columns: minmax(0, 1fr);
        gap: 2.25rem;
    }

    .media-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.9rem;
    }

    .admire-list {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Keeps the six English tabs within a 390 px phone screen */
@media (max-width: 420px) {
    .site-nav a {
        padding: 0 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

@media print {
    :root,
    [data-theme="dark"] {
        --bg: #fff;
        --text: #111;
        --text-soft: #222;
        --muted: #555;
        --line: #ccc;
        --link: #111;
        --link-hover: #111;
    }

    body {
        font-size: 10pt;
    }

    .topbar,
    .site-footer,
    .video,
    #panel-demos,
    #panel-misc {
        display: none !important;
    }

    .page {
        max-width: none;
        padding: 0;
    }

    .panel[hidden] {
        display: block !important;
    }

    .panel + .panel {
        margin-top: 1.5rem;
        padding-top: 1rem;
        border-top: 1px solid #aaa;
    }

    .news-item,
    .bib-list li,
    .cv-list li {
        break-inside: avoid;
    }
}
