html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
    background: radial-gradient(circle, #ffffff 20%, #f5f5f5 60%, #e0e0e0 100%);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

:root {
    --bg-color: #f9f9f9;
    --text-color: #333;
    --primary-font: "Roboto", sans-serif;
    --secondary-font: "Roboto", sans-serif;
    --accent-bg: #eaeaea;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --header-width: 920px;
    --content-width: 900px;
    --portrait-size: 300px;
    --nav-height: 56px;
    --card-radius: 8px;
    --section-rule-opacity: 0.3;
    --media-shadow: 0 4px 10px var(--shadow-color);
    --surface-shadow: 0 2px 6px var(--shadow-color);
    --project-video-height: 300px;
    --carousel-video-width: 600px;
    --carousel-video-height: 350px;
    --carousel-video-gap: 20px;
    --mobile-carousel-video-width: 350px;
    --mobile-carousel-video-height: 200px;
}

body {
    margin: 0;
    font-family: var(--secondary-font);
    font-size: 1rem;
    line-height: 1.54;
    color: var(--text-color);
    background: radial-gradient(circle, #ffffff 20%, #f5f5f5 60%, #e0e0e0 100%);
    position: relative;
    isolation: isolate;
    padding: 2rem 2rem 0 2rem;
    min-height: 100vh;
}

.grain-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.15;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23noise)' opacity='0.7'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 180px 180px;
    mix-blend-mode: multiply;
    transform: translateZ(0);
    will-change: transform;
}

.site-nav,
header,
main {
    position: relative;
    z-index: 1;
}

body.subpage main {
    padding-top: 3rem;
    padding-bottom: 4rem;
}

body.subpage .publications {
    margin-top: 0;
    margin-bottom: 0;
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: flex-end;
    gap: 1.25rem;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 1rem 1rem 0 1rem;
    background: transparent;
}

.site-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.76rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.72;
    border-bottom: 1px solid transparent;
    padding-bottom: 0.2rem;
    transition:
        opacity 0.2s ease,
        border-color 0.2s ease;
}

.site-nav a:hover {
    opacity: 1;
    border-color: rgba(51, 51, 51, 0.45);
}

header {
    display: flex;
    align-items: center;
    gap: 3rem;
    padding: 2rem 1rem;
    max-width: var(--header-width);
    margin: 0 auto;
}

#home {
    min-height: calc(100dvh - var(--nav-height) - 9rem);
    padding: 0.75rem 1.5rem 0 0.5rem;
}

.project-description {
    margin-bottom: 2rem;
    font-size: 0.96rem;
    line-height: 1.48;
}

.image-container {
    flex: 0 0 auto;
}

.text-content {
    flex: 1;
    text-align: left;
}

header .portrait {
    width: var(--portrait-size);
    height: var(--portrait-size);
    border-radius: 50%;
    box-shadow: var(--media-shadow);
    object-fit: cover;
}

header h1 {
    margin-top: 0;
    text-align: left;
    font-family: "Averia Serif Libre", serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: 0.01em;
    margin-bottom: 0.75rem;
}

header .intro {
    text-align: left;
    margin: 1rem 0;
    font-size: 1rem;
    line-height: 1.5;
}

header .intro .intro-link {
    color: #5f9df6;
    text-decoration: none;
    transition: color 0.2s ease;
}

header .intro .intro-link:hover,
header .intro .intro-link:focus-visible {
    color: #397ee8;
}

header .links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: bold;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s;
}

header .links a .link-icon {
    font-size: 0.9em;
    margin-right: 0.12em;
}

header .links a:hover {
    border-color: var(--text-color);
}

main {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 2rem 0;
}

.project {
    width: 100%;
    margin: 5rem 0;
    text-align: left;
}

.project h2 {
    font-family: var(--primary-font);
    font-size: clamp(1.35rem, 2vw, 1.55rem);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.project h2::before,
.project h2::after {
    content: "";
    height: 1px;
    background-color: var(--text-color);
    flex: 1;
    opacity: 0.3;
}

.project .video-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
}

.project .video-pair {
    flex: 0 0 auto;
    height: var(--project-video-height);
    width: auto;
    max-width: 100%;
    object-fit: contain;
    background: #f6f6f6;
    border-radius: var(--card-radius);
    box-shadow: var(--media-shadow);
}

.project-image {
    display: block;
    width: min(100%, 880px);
    height: auto;
    aspect-ratio: 2500 / 982;
    max-width: 100%;
    margin: 0 auto 1rem auto;
    object-fit: contain;
    border-radius: var(--card-radius);
    box-shadow: var(--media-shadow);
}

.carousel-container {
    position: relative;
    left: 50%;
    width: 100vw;
    margin: 0 0 2rem 0;
    transform: translateX(-50%);
    overflow: hidden;
}

.carousel {
    width: 100%;
    overflow: hidden;
}

.carousel.is-static {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.carousel.is-static .carousel-track {
    width: max-content;
    animation: none;
    padding: 0 1rem;
}

.carousel.is-static .carousel-group {
    gap: 1rem;
}

.carousel-track {
    display: flex;
    align-items: center;
    width: max-content;
    animation: scroll 80s linear infinite;
    will-change: transform;
}

.carousel-group {
    display: flex;
    align-items: center;
}

@keyframes scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(calc(-1 * var(--carousel-distance, 0px)));
    }
}

.carousel-video {
    width: var(--carousel-video-width);
    height: var(--carousel-video-height);
    margin: 0 calc(var(--carousel-video-gap) / 2);
    flex-shrink: 0;
    scroll-snap-align: center;
    object-fit: fill;
    background: #f6f6f6;
    border-radius: var(--card-radius);
    box-shadow: var(--media-shadow);
    transition: opacity 0.2s ease;
}

.carousel-video:not(.is-ready),
.project .video-pair:not(.is-ready) {
    opacity: 0.96;
}

.caption {
    font-size: 0.88rem;
    color: #999;
    max-width: 900px;
    margin: 0;
    line-height: 1.38;
    text-align: center;
}

@media screen and (max-width: 700px) {
    html,
    body {
        background: radial-gradient(circle at top, #ffffff 14%, #fdfdfd 60%, #f7f7f7 100%);
    }

    body {
        padding: 1rem 1rem 0 1rem;
        font-size: 1.02rem;
        line-height: 1.5;
    }

    .grain-layer {
        display: none;
    }

    .site-nav {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.85rem 1rem;
        padding-top: 0.85rem;
        margin-bottom: 1.5rem;
    }

    .site-nav a {
        font-size: 0.82rem;
        letter-spacing: 0.08em;
    }

    header {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 1.5rem;
    }

    #home {
        min-height: calc(100dvh - var(--nav-height) - 7rem);
        padding-top: 0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    header .portrait {
        width: min(300px, 72vw);
        height: min(300px, 72vw);
    }

    .text-content {
        text-align: center;
    }

    header h1 {
        text-align: center;
        font-size: clamp(2.35rem, 8vw, 2.8rem);
    }

    header .intro {
        text-align: left;
        padding: 0;
    }

    .project-description,
    .authors,
    .publication p {
        font-size: 1rem;
        line-height: 1.48;
    }

    .project h2 {
        font-size: clamp(1.3rem, 5vw, 1.5rem);
        gap: 0.75rem;
    }

    .caption {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .project-image {
        width: 100%;
        height: auto;
        max-width: 100%;
    }

    .project-2A .video-row {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .project .video-pair {
        width: 100%;
        height: auto;
        max-height: 300px;
    }

    .carousel-video {
        height: var(--mobile-carousel-video-height);
        width: var(--mobile-carousel-video-width);
    }

    .carousel.is-static .carousel-track {
        padding: 0 0.5rem 0.5rem 0.5rem;
    }

    .hide-on-mobile {
        display: none;
    }

    .publication {
        padding: 1rem;
    }

    .carousel-container::before {
        background: linear-gradient(to right, #ffffff, transparent 35%, transparent 65%, #ffffff);
    }

}

@media screen and (max-width: 480px) {
    body {
        padding: 0.9rem 0.9rem 0;
    }

    .site-nav {
        gap: 0.75rem 0.9rem;
    }

    .site-nav a {
        font-size: 0.8rem;
    }

    .project h2::before,
    .project h2::after {
        max-width: 2.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .carousel-track {
        animation: none;
    }
}

.carousel-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #f9f9f9, transparent 40%, transparent 60%, #f9f9f9);
    pointer-events: none;
    z-index: 1;
}

.section-heading {
    text-align: center;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.title-separator {
    width: 140px;
    margin: 0.8rem auto 3rem auto;
    border: none;
    border-top: 2px solid var(--text-color);
    opacity: var(--section-rule-opacity);
}

.authors {
    margin: 0.5rem 0 2.5rem 0;
    color: #666;
    font-size: 0.96rem;
    line-height: 1.5;
    text-align: center;
}

.publications {
    max-width: var(--content-width);
    margin: 4rem auto;
}

.publication-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.publication {
    background: rgba(255, 255, 255, 0.5);
    padding: 1.5rem;
    border-radius: var(--card-radius);
    box-shadow: var(--surface-shadow);
}

.publication p {
    margin: 0;
    line-height: 1.55;
    font-size: 0.96rem;
}

.publication a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(51, 51, 51, 0.25);
    transition: border-color 0.2s ease;
}

.publication a:hover {
    border-color: rgba(51, 51, 51, 0.7);
}

.site-nav a.active,
.site-nav a[aria-current="page"] {
    opacity: 1;
    border-color: rgba(51, 51, 51, 0.45);
}
