/* 基础样式 */
:root {
    --primary-color: #2196f3;
    --secondary-color: #ff4081;
    --bg-color: #ffffff;
    --text-color: #2d2d2d;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --scrollbar-thumb: #c1c1c1;
    --bg-animation-speed: 40s;
    --transition-speed: 0.3s;
    --easing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --card-inset-shadow: inset 0 0 16px rgba(255,255,255,0.05);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --glass-bg: rgba(0, 0, 0, 0.8);
    --scrollbar-thumb: #4a4a4a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* 全局滚动条隐藏 */
html {
    overflow: auto; /* 确保允许滚动 */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* 启用惯性滚动 */
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-color);
    color: var(--text-color);
    transition: 
        background var(--transition-speed), 
        color var(--transition-speed);
    overflow-x: hidden;
    scrollbar-width: none;  /* Firefox 64+ */
    -ms-overflow-style: none;  /* IE 10+ */
    &::-webkit-scrollbar {
        display: none;  /* Chrome/Safari/Edge */
        width: 0;  /* 添加宽度0 */
    }
    overscroll-behavior: contain; /* 防止滚动穿透 */
    will-change: scroll-position;
    max-width: 100vw;
    overflow-x: hidden;
}

/* 动态背景 */
.dynamic-bg {
    position: fixed;
    width: 200vw;
    height: 200vh;
    left: -50vw;
    top: -50vh;
    z-index: -1;
    opacity: 0.15;
    filter: blur(80px);
    background: linear-gradient(
        45deg,
        var(--primary-color),
        var(--secondary-color)
    );
    animation: bgRotate var(--bg-animation-speed) linear infinite;
    will-change: transform;
}

@keyframes bgRotate {
    0% { transform: rotate(0deg) scale(1); }
    100% { transform: rotate(360deg) scale(1.1); }
}

/* 主题切换 */
.theme-toggle {
    margin-left: auto; /* 推到导航栏右侧 */
    position: relative; /* 移除fixed定位 */
    top: auto;
    right: auto;
    background: none;
    padding: 0;
    transform: scale(0.9);
}

.nav-bar {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1.2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    gap: 2rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding-right: 1.5rem; /* 给右侧留出空间 */
}

.nav-btn {
    background: none;
    border: 2px solid transparent;
    color: var(--text-color);
    padding: 0.6rem 1.2rem;
    border-radius: 2rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn.active,
.nav-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

/* 页面内容 */
.page {
    min-height: 100vh; /* 改为视口高度 */
    padding: 7rem 1.5rem 4rem; /* 增加底部padding */
    display: none;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
    overflow-y: hidden;
    scrollbar-width: none;
    &::-webkit-scrollbar {
        display: none;
    }
    scroll-snap-type: y proximity; /* 滚动吸附效果 */
    scroll-padding: 2rem;
    overflow-y: auto; /* 始终允许滚动 */
}

.page.active {
    display: block;
    overflow-y: auto; /* 确保激活页面可滚动 */
    scrollbar-color: var(--primary-color) transparent;
    scrollbar-width: thin;
}

/* 修改Webkit滚动条部分为 */
.page.active::-webkit-scrollbar {
    width: 0;  /* 改为0像素宽度 */
    background: transparent;
    display: none;  /* 确保隐藏 */
}

.page.active::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
    border: 2px solid var(--glass-bg);
    background-clip: padding-box;
}

.page.active::-webkit-scrollbar-track {
    background: var(--glass-bg);
    border-radius: 4px;
    margin: 2rem 0;
}

/* 添加滚动渐变效果 */
.page.active {
    mask-image: linear-gradient(
        to top, 
        transparent, 
        black 2rem, 
        black calc(100% - 2rem), 
        transparent
    );
    -webkit-mask-image: linear-gradient(
        to top, 
        transparent, 
        black 2rem, 
        black calc(100% - 2rem), 
        transparent
    );
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    text-align: center;
    margin-bottom: 3rem;
    font-size: 2.8rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 卡片系统 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.card {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.2), rgba(255, 64, 129, 0.15)); /* 使用悬停时的渐变色 */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.2rem;
    padding: 2rem;
    transition: 
        background 0.6s ease,
        transform 0.3s ease,
        box-shadow 0.3s ease;
    box-shadow: 
        var(--card-shadow),
        var(--card-inset-shadow);
    cursor: pointer;
    text-align: center;
    color: rgba(255, 255, 255, 0.9); /* 设置初始文字颜色 */
}

.card:hover {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.2), rgba(255, 64, 129, 0.15));
    transform: scale(1.02);
    box-shadow: 
        0 12px 24px rgba(33, 150, 243, 0.15),
        inset 0 0 24px rgba(255, 255, 255, 0.1);
    color: white; /* 悬停时文字颜色改为白色 */
}

.icon {
    font-size: 2.8rem;
    margin-bottom: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.4s ease;
}

.card h3 {
    color: rgba(255, 255, 255, 0.9);
    transition: color 0.4s ease;
}

.card p {
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.4s ease;
}

/* 表单样式 */
.contact-form {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border-radius: 1.2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    max-height: 80vh;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: y proximity; /* 滚动吸附效果 */
    scroll-padding: 2rem;
}

.form-group {
    margin-bottom: 1.8rem;
    transition: 
        transform var(--transition-speed) var(--easing-function),
        filter var(--transition-speed) var(--easing-function);
}

/* 输入框和文本区域的基本样式 */
input, 
textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1); /* 默认背景 */
    border: 2px solid transparent; /* 默认边框透明 */
    border-radius: 0.8rem;
    color: var(--text-color); /* 默认文字颜色 */
    transition: all var(--transition-speed) var(--easing-function);
    outline: none; /* 去掉默认的蓝色轮廓 */
}

/* 黑色模式下的输入框和文本区域样式 */
[data-theme="dark"] input, 
[data-theme="dark"] textarea {
    background: rgba(255, 255, 255, 0.2); /* 黑色模式下的背景 */
    border-color: var(--primary-color); /* 边框颜色 */
    color: #ffffff; /* 文字颜色 */
}

/* 输入框和文本区域聚焦时的样式 */
input:focus,
textarea:focus {
    border-color: var(--primary-color); /* 聚焦时的边框颜色 */
    background: rgba(255, 255, 255, 0.1); /* 保持背景颜色不变 */
}

/* 黑色模式下聚焦时的样式 */
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--secondary-color); /* 聚焦时的边框颜色 */
    background: rgba(255, 255, 255, 0.2); /* 保持背景颜色不变 */
}

textarea {
    resize: none;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

button[type="submit"] {
    background: linear-gradient(
        135deg,
        var(--primary-color),
        var(--secondary-color)
    );
    border: none;
    padding: 1.2rem 2.4rem;
    width: 100%;
    color: white;
    border-radius: 0.8rem;
    cursor: pointer;
    transition: 
        transform var(--transition-speed) var(--easing-function),
        filter var(--transition-speed) var(--easing-function);
}

button[type="submit"]:hover {
    transform: scale(1.01);
    box-shadow: 0 3px 12px rgba(33, 150, 243, 0.25);
}

/* 滚动条优化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

/* 统一滚动容器处理 */
.page,
.card-grid,
.contact-form {
    scroll-snap-type: y proximity; /* 滚动吸附效果 */
    scroll-padding: 2rem;
}

/* 统一处理Webkit内核的滚动条 */
.card-grid::-webkit-scrollbar,
.contact-form::-webkit-scrollbar {
    width: 8px; /* 设置滚动条宽度 */
    background: transparent; /* 背景透明 */
}

/* 滚动条轨道 */
.card-grid::-webkit-scrollbar-track,
.contact-form::-webkit-scrollbar-track {
    background: var(--bg-color); /* 设置轨道背景 */
}

/* 滚动条滑块 */
.card-grid::-webkit-scrollbar-thumb,
.contact-form::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb); /* 设置滑块颜色 */
    border-radius: 4px; /* 圆角 */
}

/* 更新所有transition属性 */
.card,
button,
.form-group {
    transition: 
        transform var(--transition-speed) var(--easing-function),
        filter var(--transition-speed) var(--easing-function);
}

/* 修改footer样式 */
footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    margin-top: auto; /* 改为弹性布局自动边距 */
    position: static; /* 移除固定定位 */
    width: 100%;
    font-size: 0.9rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* 添加新的背景样式 */
.interactive-bg {
    pointer-events: none; /* 允许穿透点击 */
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: -1;
    overflow: hidden;
}

.light-trail {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, 
        rgba(33, 150, 243, 0.3) 0%,
        rgba(255, 64, 129, 0.2) 50%,
        transparent 70%);
    filter: blur(60px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.particle-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
}

/* 添加滚动视差效果 */
@media (prefers-reduced-motion: no-preference) {
    .card {
        transition: 
            transform 0.6s cubic-bezier(0.23, 1, 0.32, 1),
            box-shadow 0.4s,
            opacity 0.4s,
            transform 0.6s var(--easing-function);
    }
}

/* 调整main容器 */
main {
    min-height: calc(100vh - 120px); /* 留出页脚空间 */
    padding-bottom: 2rem; /* 底部内边距 */
}

/* 添加打印样式 */
@media print {
    .nav-bar, .interactive-bg, footer { display: none; }
    .page { display: block !important; opacity: 1; }
}

#physics-container {
    height: 120px;
    margin-bottom: 2rem;
    position: relative; 
    z-index: 1; /* 确保可交互 */
}

#gu-element {
    position: absolute;
    font-size: 4rem;
    cursor: grab;
    user-select: none;
    transition: 
        transform 0.1s ease-out; /* Smooth transition during dragging */
    will-change: transform;
}

#gu-element:active {
    cursor: grabbing;
    opacity: 0.8; /* Slightly reduce opacity when dragging */
}

/* 添加卡片碰撞效果 */
.card--colliding {
    transform: translateY(-10px) rotateZ(3deg) !important;
    background: rgba(255, 64, 129, 0.1) !important;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* 新增留言列表样式 */
.comments-list {
    margin-top: 2rem;
    max-height: 300px; /* 限制最大高度 */
    overflow-y: auto; /* 允许滚动 */
    background: var(--glass-bg);
    border-radius: 1.2rem;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.comment-item {
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.comment-item:last-child {
    border-bottom: none; /* 最后一条留言不显示底部边框 */
}

.comment-item .comment-author {
    font-weight: bold;
}

.comment-item .comment-message {
    margin-top: 0.3rem;
}

/* 提示弹窗样式 */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px; /* 弹窗之间的间距 */
}

.toast {
    background-color: rgba(33, 150, 243, 0.9); /* 背景颜色 */
    color: white; /* 文字颜色 */
    padding: 15px 20px; /* 内边距 */
    border-radius: 8px; /* 圆角 */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* 阴影效果 */
    opacity: 0; /* 初始透明度 */
    transition: opacity 0.5s ease, transform 0.5s ease; /* 过渡效果 */
}

.toast.show {
    opacity: 1; /* 显示时的透明度 */
    transform: translateY(0); /* 显示时的位移 */
}

.toast.hide {
    opacity: 0; /* 隐藏时的透明度 */
    transform: translateY(-20px); /* 隐藏时的位移 */
}

/* 留言列表标题样式 */
.comments-title {
    font-size: 1.5rem; /* 字体大小 */
    font-weight: bold; /* 字体加粗 */
    margin-bottom: 1rem; /* 底部间距 */
    color: var(--text-color); /* 文字颜色 */
}

@media (max-width: 768px) {
    body {
        overflow: hidden; /* 禁用页面滚动 */
    }
    .page {
        padding: 5rem 1rem 2rem; /* 减少padding以适应小屏幕 */
    }
    .card-grid {
        grid-template-columns: 1fr; /* 单列布局 */
    }
    .contact-form {
        padding: 1.5rem; /* 减少padding以适应小屏幕 */
    }
    .comments-list {
        max-height: 200px; /* 减少最大高度以适应小屏幕 */
    }
}
