/* VARIABLES */
/* --- Color Definitions --- */
:root {
    /* Light Mode */
    --bg-main: #f4f4f9;
    --bg-header: whitesmoke;
    --bg-content: #f5f5f5;
    --text-homepage:whitesmoke;
    --text-main: #333333;
    --text-sidebar: rgb(16, 44, 147);
    --text-sidebar-hover: rgb(0, 55, 255);
    --link-color: rgb(35, 63, 166);
    --link-hover: #1d4ed8;
    --sidebar-background: linear-gradient(135deg, #E3F0FF, #CFE4FF);
    --pic-shadow:   
        4px 4px 12px hsla(0, 0%, 0%, 0.4),
        -6px -6px 8px hsla(0, 0%, 100%, 0.06);
    --sidebar-shadow: 0 0px 24px hsla(217, 54%, 53%, 0.18);
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-main: #121212;
    --bg-header: #1e1e1e;
    --bg-content: #181818;
    --text-main: whitesmoke;
    --text-sidebar: #94a3b8;
    --text-sidebar-hover: #60a5fa;
    --link-color: #93c5fd;
    --link-hover: hsl(210, 5%, 8%);
    --sidebar-background: linear-gradient(135deg, #2B3F73, #3D56A1);
    --pic-shadow:  
        4px 4px 12px hsla(0, 0%, 100%, 0.4),
        -3px -3px 4px hsla(0, 0%, 100%, 0.2);
    --sidebar-shadow: 0px 0px 30px hsla(228, 71%, 28%, 0.55);
}

[data-theme="dark"] .hamburgerlinks {
    background: var(--bg-header);
}

[data-theme="dark"] .hamburgerlinks li a {
    color: var(--text-main);
}

[data-theme="dark"] .hamburgerbutton .bar {
    background-color: var(--text-main);
}

@font-face {
  font-family: "kaiti";
  src: url("/assets/fonts/kaiti.ttf") format("truetype");
}

/* Global */

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    z-index: 1;
}

html {
    scroll-behavior:smooth;
}

.site-title {
    margin: 13px;
    color:var(--text-homepage);
}

.site-footer {
    color: var(--text-main);
    align-items: center;
}

.surnamecaps{
    text-transform: uppercase;
    font-size: 0.724em;
    font-weight: bold;
}

.post-nominal{
    font-size: 0.724em;
    font-weight: bold;

}

.aligned-list {
    list-style: none;
    padding-left: 0; 
}

.aligned-list li {
    display: flex; 
    align-items: flex-start;
    margin-bottom: 25px; 
    list-style-type: none;
    overflow: hidden; 
    position: relative; 
}

.content {
    padding-left: 20px;
    border-left: 1px solid;
}

.list-number {
    font-style: italic;
    margin-right: 10px; 
    flex-shrink: 0; 
    min-width: 1em; 
    padding-left: 2em;
}

/* Shared Components */

    /* Hamburger Button */

.hamburgerbutton {
    display: none;
    font-size: 1rem;
    background: none;
    border: none;
    color: var(--bg-main);
    cursor: pointer;
}

.hamburgerbutton .bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  background-color: var(--bg-main);
  transition: all 0.3s ease-in-out;
}

.hamburgerbutton:hover .bar {
    background-color: var(--bg-main);
}

.hamburgerbutton:hover .bar:nth-child(1) {
    transform: translateY(-2px); 
}

.hamburgerbutton:hover .bar:nth-child(3) {
    transform: translateY(2px); 
}

.hamburgerbutton .bar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#hamburgerbutton.active .bar:nth-child(2) { 
    opacity: 0; 
}

#hamburgerbutton.active .bar:nth-child(1) { 
    transform: translateY(8px) rotate(45deg); 
    background-color: var(--bg-main);
}

#hamburgerbutton.active .bar:nth-child(3) { 
    transform: translateY(-8px) rotate(-45deg); 
    background-color: var(--bg-main);
}

    /* Light/Dark Mode Button */

.theme-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-main);
    transition: transform 0.2s ease;
}

.theme-btn i {
    transition: filter 0.5s ease-in-out; 
}

.theme-btn:hover i {
    filter: invert(100%); 
}

.sun-icon { display: none; }
.moon-icon { display: inline-block; }

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

[data-theme="light"] .moon-icon {
    display: inline-block;
}

[data-theme="dark"] .sun-icon {
    display: inline-block;
}

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

    /* Layout */

.main-wrapper {
    display: grid;
    grid-template-columns: clamp(180px, 25%, 240px) 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

    /* sidebar */

.sidebar {
    max-width: 300px;
    position: sticky;
    top: 20px;
    align-self: start;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    
    width: 100%;
    padding: 8px 0px 8px 8px;
    
    text-decoration: none;
    color: var(--link-color);
}

.sidebar ul li a i,
.sidebar ul li a img {
    width: 17px;
    flex-shrink: 0;
}

.sidebar ul li a:hover {
    color: var(--link-hover);
    font-style: italic;
    background: var(--sidebar-background);
    box-shadow: var(--sidebar-shadow);
    border-radius: 10px;
}

/* header */

.otherheader {
    background-color: #A3C1AD;
    color: white;
    padding: 10px;
    text-align: center;
}

.restnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

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

.restnav a {
    text-decoration: none;
    color: white;
}

/* index */

.homebody {
    display: flex;
    flex-direction: column;
    min-height: 100vh; 
    margin: 0;
}

.homebody .homeheader {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    padding: 10px;
    z-index: 10;
}

.homebody .cursor {
  display: inline-block;
  margin-left: 4px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.homebody .homeheaderlinks a {
    margin-left: 1.5rem;
    text-decoration: none;
    color:var(--text-homepage);
}

.homebody .homeheaderlinks a:hover {
    color:#94a3b8;
    background: var(--sidebar-background);
    box-shadow: 0px 0px 7px hsl(60, 100%, 40%);
    border-radius: 20px;
    padding: 9px;
}

.homebody .homefooter {
    color:var(--text-homepage);
    z-index: 10;
}

.homebody .homenav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.homebody .homepage-bg-grid {
    position: fixed; 
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    z-index: 2;
}

.homebody .bg-link {
    flex: 1;
    height: 100%;
    background-image: var(--img);
    background-size: cover;
    background-position: center;
    text-decoration: none;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    transition: flex 0.5s ease, filter 0.4s ease;
    filter: grayscale(20%); 
    position: relative;
    overflow: hidden;
}

.homebody .bg-link::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0); 
    transition: background 0.4s ease;
    z-index: 5;
}

.homebody .bg-link:hover {
    flex: 1.5;
    filter: grayscale(0%); 
}

.homebody .bg-link:hover::before {
    background: rgba(0, 0, 0, 0.8);
}

.homebody .bg-link span {
    color: cyan;
    font-size: 2rem;
    font-weight: bold;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 35% 0 0 5%;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.8);
    opacity: 0.2; 
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s ease, text-shadow 0.4s ease;
    z-index: 15;
}

.homebody .bg-link:hover span {
    opacity: 1;
    transform: scale(1);
    text-shadow: 2px 2px 20px rgba(255,255,0,1);
}

.homebody .bg-link.is-hovered {
    flex: 1.5;
    filter: grayscale(0%);
}
.homebody .bg-link.is-hovered::before {
    background: rgba(0, 0, 0, 0.8);
}
.homebody .bg-link.is-hovered span {
    opacity: 1;
    transform: scale(1);
    text-shadow: 2px 2px 20px rgba(255,255,0,1);
}

.homebody .scramble {
  transition: opacity 0.2s ease;
}

.homebody .bg-link:hover .scramble {
  opacity: 1;
}

.homebody .homemain {
    flex: 1; 
}

.homebody .hamburgerlinks {
  display: none;
  list-style: none;
  z-index: 1000;
}

.homebody .hamburgerlinks li {
  margin: 20px;
}

.homebody .hamburgerlinks li a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    display: block;
    padding: 8px 12px;
    transition: color 0.3s ease;
}

.homebody .hamburgerlinks li a:hover {
    color: purple;
    background-color: #f8f8f8;
    border-radius: 20px;
}

/* publications */

.page-publications .generallinks {
    color: var(--link-color);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.page-publications .generallinks:hover {
    color: var(--link-hover);
}

.page-publications .publication-content {
    flex: 1;
    min-width: 0; 
}

.page-publications .publication-content .title {
    display: block; 
    margin-bottom: 5px;
}

.page-publications .publication-content .details {
    display: block;
    margin-bottom: 5px;
    line-height: 1.4; 
}

.page-publications .publication-content .art-container {
    display: block;
    margin-top: 10px; 
}

.page-publications .publication-content .chinese {
    font-family: "kaiti", sans-serif;
    display: block;
    font-weight: bolder;
    margin-top: -2px; 
    margin-bottom: 3px; 
}

.page-publications .publication-group {
    display: block;
    transition: max-height 0.5s ease-out, opacity 0.5s ease-out;
    overflow: hidden;
}

.page-publications .publication-group.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.page-publications .subsection-separator {
    font-size: 20px; 
    font-weight: bold; 
    color: var(--text-main);
    margin-top: 0.5em; 
    margin-bottom: 0.5em; 
}

.page-publications .subsection-separator.collapsed-header {
    cursor: pointer;
    user-select: none; 
    position: relative;
    padding-left: 25px;
    padding-right: 10px; 
}
.page-publications .subsection-separator.collapsed-header:hover{
    font-style: italic;
    text-shadow: var(--pic-shadow);
}

.page-publications .subsection-separator.collapsed-header::after {
    content: '+'; 
    position: absolute;
    left: 10px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.page-publications .subsection-separator.collapsed-header.active::after {
    content: '-'; 
}

.page-publications .video-container {
    width: 100%;       
    aspect-ratio: 16 / 9;
}

.page-publications .video-container iframe {
    width: 100%;
    height: 100%;
}

.page-publications .year-separator {
    font-size: 18px; 
    font-weight: bold; 
    margin-top: 0.5em; 
    margin-bottom: 1em;
}

.page-publications .year-separator.collapsed-header {
    cursor: pointer;
    user-select: none; 
    position: relative;
    padding-left: 25px;
    padding-right: 10px; 
}

.page-publications .year-separator.collapsed-header:hover{
    font-style: italic;
    text-shadow: var(--pic-shadow);
}

.page-publications .year-separator.collapsed-header::after {
    content: '+'; 
    position: absolute;
    left: 10px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.page-publications .year-separator.collapsed-header.active::after {
    content: '-'; 
}

/* course */

.page-course .course-content {
    flex: 1;
    min-width: 0; 
}

.page-course .course-content .title {
    display: block; 
    margin-bottom: 5px;
}

.page-course .course-content .details {
    display: block;
    margin-bottom: 5px;
    line-height: 1.4; 
}

.page-course .course-content .university {
    display: block;
    margin-bottom: 5px;
    line-height: 1.4; 
}

.page-course .course-year {
    font-size: 20px; 
    font-weight: bold; 
    margin-top: 0.5em; 
    margin-bottom: 1em;
}

.page-course .course-year.collapsed-header {
    cursor: pointer;
    user-select: none; 
    position: relative;
    padding-left: 25px;
    padding-right: 10px; 
}

.page-course .course-year.collapsed-header::after {
    content: '+'; 
    position: absolute;
    left: 10px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.page-course .course-year.collapsed-header.active::after {
    content: '-'; 
}

/* cover art */

.page-coverarts .cover-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-top: 20px;
}

.page-coverarts .publication-card {
    background: var(--bg-main);
    border-radius: 16px;
    padding: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.page-coverarts .publication-card:hover {
    transform: translateY(-4px);
    background: var(--bg-content);
    box-shadow: var(--pic-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;

}

.page-coverarts .publication-card a {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 12px;

    height: 100%;
    text-decoration: none;
    color: var(--text-main);
}

.page-coverarts .card-year {
    font-weight: bold;
    font-size: 1.25rem;
    opacity: 0.8;
}

.page-coverarts .card-title {
    line-height: 1.4;
}

.page-coverarts .card-image {
    height: 260px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.page-coverarts .card-image img {
    max-height: 90%;
    width: auto;
    max-width: 100%;
    object-fit: cover;
    margin: 5px;
    border-radius: 8px;
    align-self: start;
    box-shadow: var(--pic-shadow);
}

/* research */

.page-research #initial-img {
    max-width: 800px; 
    width: 100%; 
    height: auto; 
    display: block; 
    margin: 0 auto 15px auto;
    border-radius: 20px;
    box-shadow: var(--pic-shadow);
}

.page-research .longpara{
    text-indent: 30px;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* --- Base Scroll and Sticky Setup --- */
.page-research .scroll-container {
    height: 600vh; 
}

.page-research .sticky-wrapper {
    position: relative;
}

.page-research .sticky-content {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    z-index: 10;
    display: flex;
    transition: all 1.2s ease-in-out; 
    flex-direction: row; 
}

.page-research #sticky-container {
    position: sticky;
    height: 100vh;
    max-height: 850px;  
    min-height: 500px; 
    transition: transform 0.6s ease-in-out, left 0.6s ease-in-out;
}

.page-research #image-display {
    flex: 4; /* Share width with #text-column (6) */
    max-width: 100%;
    order: 1;
    position: relative;
    margin: 20px;
    height: 95%;
    transform: translateX(0%);
    transition: transform 1.2s ease-in-out, opacity 1.2s ease-in-out;
    z-index: 1;
    border-radius: 30px;
    overflow: hidden;
    box-shadow: var(--pic-shadow);
}

.page-research #text-column {
    flex: 6; /* Share width with #image-display (6) */
    order: 2;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
    color: var(--text-main);
    text-align: left;
    overflow-y: hidden;
    min-height: 200px;
    transform: translateX(0%);
    transition: transform 1.2s ease-in-out;
    z-index: 2;
}

.page-research #text-overlay {
    opacity: 1; 
    transform: translateY(0); 
    transition: opacity 1.2s ease-in-out, transform 1.2s ease-in-out;
    overflow-y: auto;
    max-height: 90%; 
    padding-right: 15px; 
    width: 100%; 
}

.page-research #text-overlay.fading-out {
    opacity: 0;
    transform: translateY(0px); 
}

.page-research #image-display img {
    position: absolute;
    width: 100%;
    height: 100%; 
    object-fit: cover;
    object-position: center center;
    opacity: 0;
    transform: scale(1); 
    filter: blur(0px);
    transition: opacity 1.2s ease-in-out, 
                transform 1.2s ease-in-out, 
                filter 1.2s ease-in-out; 
    will-change: transform, opacity, filter;
}

.page-research #image-display img.active {
    opacity: 1;
    filter: blur(0px);
}

.page-research #image-display img.zoom-out-blur {
    opacity: 0;
    transform: translateY(-7.5%) scale(3); 
    filter: blur(10px);
}

.page-research .sticky-content.image-right #image-display {
    order: 2; 
}

.page-research .sticky-content.image-right #text-column {
    order: 1; 
}

.page-research .slide-out-left #image-display {
    transform: translateX(-120%);
}

.page-research .slide-out-left #text-column {
    transform: translateX(120%);
}

.page-research .slide-out-right #image-display {
    transform: translateX(300%);
}

.page-research .slide-out-right #text-column {
    transform: translateX(-300%);
}

.page-research .pre-enter-left #image-display {
    transform: translateX(120%);
}

.page-research .pre-enter-left #text-column {
    transform: translateX(-120%);
}

.page-research .pre-enter-right #image-display {
    transform: translateX(-300%);
}

.page-research .pre-enter-right #text-column {
    transform: translateX(300%);
}

.page-research .trigger-section {
    height: 100vh;
    background: transparent;
    position: relative;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}

.page-research .totop {
    display:block;
    position:fixed;
    right:50px;
    bottom:20px;
    z-index: 9999;
    animation: bottom-up linear, opacity linear;
    animation-timeline: scroll();
}

@keyframes bottom-up {
    to {
        bottom: 70px;
    }
}

@keyframes opacity {
    0% {
        opacity: 0;
    }
    16%, 100% {
        opacity: 100%;
    }
}

.page-research .totop .btn {
    color: var(--text-main);
    animation: bounce 1s infinite;

}

@keyframes bounce {
    0%, 100% {transform: translateY(0);}
    50% {transform: translateY(-30px);}
}

/* about */

.page-about .flex-rows {
    display: flex;
    align-items: flex-start;
}

.page-about .textwithimg{
    flex:2;
    text-indent: 30px;
    line-height: 1.5;
    margin-bottom: 10px;
}

.page-about .imgwithtext{
    flex:1;
}

.page-about .imgwithtext img {
    max-width: 90px;
    width: 100%; 
    height: auto; 
    display: block; 
    margin: 0 auto;
}

/* contact */


/* Responsive design for smaller screens */
@media (max-width: 1024px) {
    /* global */

    .main-wrapper {
        grid-template-columns: 1fr;
        margin-top: 0;
    }

    .content {
        padding-left: 0;
        padding-top: 0;
        border-left: none;
    }

    .hamburgerbutton {
        display: block;
        z-index: 1000;
    }

    .site-title{
        font-size: 1.7em;
    }

    /* header */

    .restnav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    /* sidebar */

    .sidebar {
        max-width: none;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 1s ease-in-out, opacity 0.7s ease;
        position: static;
    }

    .sidebar.active{
        max-height: none;
        opacity: 1;
        padding-bottom: 20px;
        border-bottom: 1px solid #ccc;
        overflow: visible;
    }   
     

    /* index */

    .homebody {
        overflow-y: auto;
        height: auto;
        overflow-x: hidden;
        width: 100%;
    }

    .homebody .homeheaderlinks {
        display: none;
    }

    .homebody .homeheader {
        position: absolute; 
        top: 0;
        left: 0;
        width: 100%;
        box-sizing: border-box;
        background: transparent; 
        z-index: 10;
    }

    .homebody .hamburgerlinks {
        display: flex; 
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 60px;
        right: 2rem;
        width: auto;
        background: var(--bg-content);
        color: var(--text-main);
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        border-radius: 8px;
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        transition: all 0.7s ease-in-out;
        z-index: 1000;
    }

    .homebody .hamburgerlinks.active {
        max-height: 500px;
        opacity: 1;
        padding: 1rem;
    }

    .homebody .hamburgerlinks li{
        text-decoration: none;
        margin:10px 0;
        text-align: right;
    }

    .homebody .homepage-bg-grid {
        display: flex;
        position: relative;
        flex-direction: column; 
        min-height:2048px;
    }

    .homebody .homefooter {
        position: relative;
        background: rgba(0, 0, 0, 0.9); 
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .homebody .bg-link:hover::before {
        background: rgba(0, 0, 0, 0);
    }

    .homebody .bg-link.is-hovered {
        flex: 1.2;
        filter: grayscale(0%); 
    }

    .homebody .bg-link span {
        padding: 8rem 0 0 1rem;
    }

    /* publications */

    .page-publications #image-display {
        border-radius: 10px;
    }

    /* course */
    /* cover art */

    .page-coverarts .cover-grid {
        grid-template-columns: 1fr;
    }

    .page-coverarts .card-image{
        height:auto;
    }

    /* research */

    .page-research .sticky-content {
        flex-direction: column;
    }

    .page-research .slide-out-right #image-display {
        transform: translateX(120%);    
    }
    .page-research .slide-out-right #text-column {
        transform: translateX(-120%);
    }
    .page-research .pre-enter-right #image-display {
        transform: translateX(-120%);
    }
    .page-research .pre-enter-right #text-column {
        transform: translateX(120%);
    }

    .page-research .totop {
        right:10px;
    }
    
    /* about */

    .page-about .flex-rows {
        flex-direction: column; 
    }

    .page-about .textwithimg {
        flex: 1; 
    }

    .page-about .imgwithtext {
        display: none;
    }

    /* contact */
    
}
