/*
 * zju.css — ZJU Huang Ling Group theme overrides
 * Complements the Stellar base stylesheet (main.css).
 *
 * Structure
 * ─────────
 * 1. Design tokens
 * 2. Preload safety net
 * 3. Header
 * 4. Navigation
 * 5. Footer
 * 6. Typography & links
 * 7. Responsive
 */


/* ── 1. Design Tokens ──────────────────────────────────────────────── */
:root {
    --zju-blue:       #003f88;
    --zju-light-blue: #005aab;
    --zju-gold:       #c8a04a;
    --white:          #ffffff;
}


/* ── 2. Preload Safety Net ─────────────────────────────────────────────
   Stellar adds "is-preload" to <body> and hides all #header.alt children
   with opacity:0 until main.js removes the class. If main.js fails to
   load, the header would remain invisible. This override ensures content
   is always visible regardless of script execution.
────────────────────────────────────────────────────────────────────── */
body.is-preload #header.alt > *,
body.is-preload #header.alt h1,
body.is-preload #header.alt p {
    opacity: 1 !important;
    transform: none !important;
}


/* ── 3. Header ─────────────────────────────────────────────────────── */
#header {
    background-color: var(--zju-blue) !important;
    padding: 2em 2em 2.5em !important;
    text-align: center;
}

/* Ensure all header text is white regardless of .alt state */
#header,
#header h1,
#header p,
#header * {
    color: var(--white) !important;
}

#header h1 {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 2.8em !important;
    font-weight: 600 !important;
    letter-spacing: 0.04em !important;
    line-height: 1.2;
    margin: 0 0 0.25em !important;
}

#header p {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1.15em !important;
    font-weight: 300;
    letter-spacing: 0.08em;
    opacity: 0.85;
    text-transform: uppercase;
    margin: 0 !important;
}

/* ZJU logo
   Plain <img class="zju-logo"> is used instead of <span class="logo">
   to avoid Stellar's preload transform (rotate + scale on .logo). */
.zju-logo {
    display: block;
    margin: 0 auto 1em;
    width: 82px;
    height: auto;
    object-fit: contain;
    /* Convert dark-ink PNG to white; remove if logo artwork is already white */
    filter: brightness(0) invert(1) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
}

/* Gold accent divider beneath the subtitle */
.header-divider {
    display: block;
    width: 48px;
    height: 2px;
    background: var(--zju-gold);
    border-radius: 2px;
    margin: 0.9em auto 0;
}


/* ── 4. Navigation ─────────────────────────────────────────────────── */
#nav > ul > li > a.active {
    color: var(--zju-blue);
    font-weight: 600;
}

.lang-toggle {
    cursor: pointer;
    font-weight: 600;
    color: var(--zju-blue) !important;
    user-select: none;
}


/* ── 5. Footer ─────────────────────────────────────────────────────── */
#footer {
    background-color: var(--zju-blue) !important;
}

#footer,
#footer * {
    color: rgba(255, 255, 255, 0.75) !important;
}


/* ── 6. Typography & Links ─────────────────────────────────────────── */
a {
    color: var(--zju-light-blue);
}

.button.primary {
    background-color: var(--zju-blue) !important;
    color: var(--white) !important;
}

.intro-link {
    display: inline-block;
    margin-top: 0.9em;
    font-weight: 600;
    text-decoration: underline;
}

.image.main img {
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    margin-bottom: 2em;
}


/* ── 7. Responsive ─────────────────────────────────────────────────── */
@media screen and (max-width: 736px) {
    #header       { padding: 3em 1em 2em !important; }
    .zju-logo     { width: 58px; }
    #header h1    { font-size: 1.7em !important; }
    #header p     { font-size: 0.95em; }
}
/* ── 8. 成员卡片对齐与排版优化 ─────────────────────────────────────── */
/* 确保同一行内的列等高对齐 */
.row {
    display: flex;
    flex-wrap: wrap;
}

/* 统一卡片内部布局 */
.member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%; /* 强制拉伸填满父级容器 */
    padding: 2em 1.5em;
    background: #fdfdfd;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

/* 强制统一照片尺寸，避免大小不一导致错位 */
.member-card img {
    width: 180px;
    height: 200px;
    object-fit: cover; /* 保证图片不变形，自动裁剪 */
    object-position: center 20%; /* 新增：调整裁剪焦点。15%表示重心偏上，适合大部分半身照 */
    border-radius: 50%; /* 圆形头像。如果想要方形，可改为 border-radius: 10px; */
    margin-bottom: 1.5em;
    border: 3px solid var(--white);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* 文本结构微调 */
.member-card h4 {
    margin-bottom: 0.5em;
    text-align: center;
}

.member-card p {
    margin: 0;
    text-align: center;
    flex-grow: 1; /* 占据剩余空间，将底部内容对齐 */
}


/* ── 9. PI 卡片专属蓝色特效 ───────────────────────────────────────── */
.pi-link {
    text-decoration: none; /* 移除 a 标签默认下划线 */
    display: block;
    height: 100%;
}

/* 顶部增加一条浙大蓝的强调线 */
.pi-link .member-card {
    border-top: 4px solid var(--zju-blue);
    background: #ffffff;
}

/* PI 名字应用浙大蓝渐变效果 */
.pi-link .member-card h4 {
    background: linear-gradient(135deg, var(--zju-blue) 0%, var(--zju-light-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    font-size: 1.3em;
}
/* ── 10. PI 个人主页专属排版 (PI Profile Layout) ───────────────── */
/* 左右分栏布局 */
.pi-header {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 3em;
    margin-bottom: 3em;
    padding-bottom: 2.5em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.pi-header img {
    width: 260px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 63, 136, 0.15);
    border: 4px solid var(--white);
    flex-shrink: 0; /* 防止照片被挤压变形 */
}

.pi-info {
    flex-grow: 1;
}

.pi-name-title {
    margin-bottom: 1.5em;
}

/* 教授姓名：浙大蓝渐变色 */
.pi-info h2 {
    font-size: 2.6em;
    font-weight: 700;
    margin-bottom: 0.2em;
    background: linear-gradient(135deg, var(--zju-blue) 0%, #3a7bd5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 教授头衔：蓝底胶囊状标签 */
.pi-info .pi-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--zju-blue);
    display: inline-block;
    padding: 0.3em 1em;
    background: rgba(0, 63, 136, 0.08);
    border-radius: 50px; /* 胶囊形状 */
    letter-spacing: 0.05em;
}

/* 简介正文排版 */
.pi-info .bio-text {
    font-size: 1.05em;
    line-height: 1.8;
    color: #444;
    text-align: justify;
    margin-bottom: 1em;
}

/* 灰色小卡片存放联系方式 */
.contact-box {
    margin-top: 2em;
    padding: 1.2em 1.5em;
    background: #f4f7f9;
    border-left: 4px solid var(--zju-blue);
    border-radius: 0 8px 8px 0;
    font-size: 0.95em;
    line-height: 1.8;
    color: #333;
}

.contact-box strong {
    color: var(--zju-blue);
    margin-right: 0.5em;
}

/* ── 11. 荣誉列表优化 ───────────────── */
.cv-section h3 {
    color: var(--zju-blue);
    border-bottom: 2px solid var(--zju-gold);
    display: inline-block;
    padding-bottom: 0.2em;
    margin-bottom: 1em;
    font-weight: 600;
}

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

.honors-list li {
    position: relative;
    padding-left: 1.5em;
    margin-bottom: 0.8em;
    line-height: 1.6;
    color: #555;
}

/* 使用金色四角星作为列表前缀符号 */
.honors-list li::before {
    content: "✦";
    position: absolute;
    left: 0;
    color: var(--zju-gold);
}

/* 手机端适配：改为上下布局 */
@media screen and (max-width: 850px) {
    .pi-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 2em;
    }
    .pi-info .bio-text {
        text-align: left;
    }
    .contact-box {
        text-align: left;
    }
}
/* ── 12. 返回顶部悬浮按钮 (Back to Top Button) ───────────────── */
#back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    background-color: var(--zju-blue);
    color: var(--white);
    border: none;
    border-radius: 50%; /* 圆形按钮 */
    box-shadow: 0 4px 10px rgba(0, 63, 136, 0.3);
    font-size: 1.2em;
    cursor: pointer;
    z-index: 10000; /* 确保悬浮在所有元素之上 */

    /* 默认隐藏 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px); /* 隐藏时稍微靠下 */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;

    /* 让内部的箭头图标居中 */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 触发显示时的状态 */
#back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 鼠标悬浮特效 */
#back-to-top:hover {
    background-color: var(--zju-light-blue);
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 63, 136, 0.4);
}

/* 手机端适配：缩小按钮并调整边距 */
@media screen and (max-width: 736px) {
    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 1em;
    }
}
/* ── 13. 手机端导航栏横向滑动适配 ──────────────────────────────────── */
@media screen and (max-width: 980px) {
    /* 强制显示被模板隐藏的导航栏 */
    #nav {
        display: block !important; 
        overflow-x: auto; /* 允许横向滚动 */
        white-space: nowrap; /* 强制所有菜单项在一行显示，不换行 */
        -webkit-overflow-scrolling: touch; /* 开启 iOS 丝滑滚动特效 */
        background-color: #ffffff; /* 确保背景色正常 */
        padding: 0.5em 1em;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        
        /* 隐藏滚动条但保留滚动功能 (美化外观) */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    /* 针对 Webkit 浏览器 (Chrome/Safari) 隐藏滚动条 */
    #nav::-webkit-scrollbar {
        display: none;
    }

    /* 将原本可能堆叠的 <ul> 改为弹性盒子，横向排列 */
    #nav ul {
        display: flex !important;
        flex-wrap: nowrap;
        margin: 0;
        padding: 0;
        border: none !important; /* 移除可能的边框 */
    }

    #nav ul li {
        display: inline-block;
        flex-shrink: 0; /* 防止文字被挤压换行 */
        padding: 0;
        border: none !important;
    }

    #nav ul li a {
        display: block;
        padding: 0.5em 1em;
        font-size: 0.9em;
    }

    /* 隐藏模板可能残留的汉堡菜单按钮（如果存在的话） */
    #titleBar, a[href="#navPanel"] {
        display: none !important;
    }
}