/* ====================
   1. 全局变量与主题配置
==================== */
:root {
    --bg-color: #f7f7f7;
    --text-color: #333333;
    --title-color: #000000;
    --date-color: #999999;
    --line-color: #eaeaea;
    /* 修改这一行：使用 85% 透明度的白色 */
    --mask-bg: rgba(247, 247, 247, 0.85); 
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #cccccc;
    --title-color: #ffffff;
    --date-color: #777777;
    --line-color: #333333;
    /* 修改这一行：使用 85% 透明度的黑色 */
    --mask-bg: rgba(26, 26, 26, 0.85); 
}

/* ====================
   2. 基础排版
==================== */
/* 开启点击导航时的平滑滚动 */
html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    /* 核心修改：使用 vh 适配屏幕高度，保证内容少时不会挤在顶部，也不留多余白边 */
    padding: 8vh 20px; 
    min-height: 100vh; 
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transition: background-color 0.3s, color 0.3s; 
}

.header {
    width: 100%;
    max-width: 800px; 
    margin-bottom: 40px; /* 增加标题和时间轴的距离 */
    text-align: left; /* 强制左对齐，解决你截图里莫名居中的问题 */
}



.header h1 {
    font-size: 32px;
    margin-bottom: 5px;
}

.header p {
    color: var(--date-color);
    font-size: 14px;
}

/* ====================
   3. 时间轴主干
==================== */
.timeline {
    width: 100%;
    max-width: 800px;
    position: relative;
    padding-left: 20px; 
    text-align: left; /* 强制左对齐 */
}

/* 贯穿的垂直线 */
.timeline::before {
    content: '';
    position: absolute;
    top: 25px; /* 微调这个值，让线完美贴合第一年的节点 */
    bottom: 0;
    left: 0;
    width: 2px;
    background-color: var(--line-color);
}

/* 去掉时间轴最后一项的底部间距，收缩竖线尾巴 */
.timeline-item:last-child {
    margin-bottom: 0;
}

/* 冻结年份标题 (升级全宽毛玻璃) */
.year-marker {
    position: sticky;
    top: 10px;
    z-index: 10;
    
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); 
    border-radius: 8px; /* 圆角更柔和 */
    
    /* 核心修改：强制撑满整行宽度，形成一个完整的毛玻璃遮挡带 */
    width: calc(100% + 20px); 
    box-sizing: border-box;
    padding: 8px 15px 8px 20px; 
    margin: 40px 0 10px -20px; 
    
    background: var(--mask-bg); 
    display: block; 
    font-size: 28px; 
    font-weight: bold;
}

/* 冻结月份标题 (升级全宽毛玻璃) */
.month-marker {
    position: sticky;
    top: 60px; /* 配合上方年份的高度，往下稍微移动一点 */
    z-index: 9;
    
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); 
    border-radius: 8px;
    
    /* 核心修改：同样强制撑满整行宽度 */
    width: calc(100% + 20px);
    box-sizing: border-box;
    padding: 5px 15px 5px 20px; 
    margin: 0 0 20px -20px; 
    
    background: var(--mask-bg);
    display: block; 
    font-size: 18px;
    font-weight: bold;
    color: var(--date-color);
}

/* ====================
   4. 时间轴节点 (日记卡片)
==================== */
.timeline-item {
    position: relative;
    margin-bottom: 30px;
    padding-left: 20px;
}

/* 节点旁边的小红点 */
.timeline-item::before {
    content: '';
    position: absolute;
    left: -5px; 
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff4d4f; 
}

/* 带有照片的节点（交互样式） */
.timeline-item.has-photos {
    cursor: pointer; 
    transition: transform 0.2s; 
}

.timeline-item.has-photos:hover {
    transform: translateX(5px);
}

.item-content {
    display: flex;
    align-items: center;
    gap: 20px; 
}

.item-date {
    color: var(--date-color);
    font-size: 14px;
    min-width: 45px; 
}

/* 默认标题（无照片） */
.item-title {
    font-size: 16px;
    color: var(--title-color);
    transition: color 0.2s;
}

/* 带有照片的标题变蓝 */
.timeline-item.has-photos .item-title {
    color: #0066cc; 
}

.timeline-item.has-photos:hover .item-title {
    color: #004499;
}

/* ====================
   5. 主题切换器（胶囊按钮）
==================== */
/* 主题切换器（悬浮固定在右下角） */
.theme-switcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    display: flex;
    background: rgba(0, 0, 0, 0.05); 
    border-radius: 30px;
    padding: 5px;
    gap: 5px;
    backdrop-filter: blur(5px); /* 背景模糊效果 */
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    .theme-switcher {
        bottom: 20px;
        right: 20px;
    }
}

body.dark-mode .theme-switcher {
    background: rgba(255, 255, 255, 0.1);
}

.theme-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 16px;
    color: var(--date-color);
    transition: all 0.2s;
}

.theme-btn.active {
    background: var(--bg-color);
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ====================
   6. 后台表单样式 (admin.html 专属)
==================== */
.admin-form-container {
    width: 100%;
    max-width: 800px;
    background: var(--mask-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

label {
    font-size: 14px;
    color: var(--date-color);
    margin-bottom: 8px;
    font-weight: bold;
}

input, textarea {
    padding: 12px;
    border: 1px solid var(--line-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #0066cc;
}

textarea {
    resize: vertical;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 10px;
}

.submit-btn:hover {
    background-color: #004499;
}

.submit-btn:disabled {
    background-color: var(--date-color);
    cursor: not-allowed;
}

.status-msg {
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
    min-height: 20px;
}

/* ====================
   7. 登录界面样式
==================== */
.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--mask-bg);
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    text-align: center;
    margin-top: 50px;
}

.login-container h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--title-color);
}

.login-container input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-btn:hover {
    opacity: 0.8;
}

.hidden {
    display: none !important;
}

/* ====================
   8. 响应式布局 (适配手机和平板)
==================== */
@media (max-width: 768px) {
    body { padding: 4vh 15px; }
    
    .header h1 { font-size: 26px; }
    .year-marker { font-size: 24px; margin-top: 30px; }
    .month-marker { font-size: 16px; }
    .item-title { font-size: 15px; }
    
    .item-content { gap: 12px; } /* 缩小手机端日期和标题的间距 */
    .item-date { min-width: 40px; font-size: 13px; }
    .timeline-item { margin-bottom: 25px; }
    
    /* 手机端表单变成上下排列 */
    .form-row { flex-direction: column; gap: 0; }
}

/* ====================
   9. 照片墙弹窗 (Lightbox)
==================== */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* 半透明黑底，沉浸感强 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px); /* 背景模糊效果 */
}

.modal.hidden {
    display: none;
}

.modal-content {
    max-width: 90%;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    object-fit: contain; /* 保证图片完整显示不变形 */
}

/* 右上角关闭按钮 */
.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #ff4d4f;
}

/* 左右切换按钮 */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 30px;
    padding: 15px 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.3s;
}

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-nav.prev { left: 5%; }
.modal-nav.next { right: 5%; }

/* 图片底部提示文字 (第 1 / 3 张) */
#modal-caption {
    color: #ddd;
    margin-top: 15px;
    font-size: 15px;
    letter-spacing: 1px;
}

/* ====================
   10. 侧边导航栏
==================== */
.sidebar {
    position: fixed;
    left: 5%;
    top: 20%;
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar a {
    text-decoration: none;
    color: var(--date-color);
    transition: color 0.2s, transform 0.2s;
}

.sidebar a:hover {
    color: #0066cc;
    transform: translateX(5px);
}

.sidebar-year {
    font-weight: bold;
    font-size: 18px;
    color: var(--title-color) !important;
    margin-top: 10px;
}

.sidebar-month {
    font-size: 14px;
    padding-left: 15px;
}

/* 屏幕太窄时隐藏侧边栏，防止遮挡主体 */
@media (max-width: 1100px) {
    .sidebar { display: none; }
}

/* ====================
   11. 移动端专属交互 (侧边栏抽屉与紧凑胶囊)
==================== */

/* 移动端菜单按钮 (默认在电脑端隐藏) */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1002;
    background: var(--mask-bg);
    backdrop-filter: blur(5px);
    border: 1px solid var(--line-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* 虚化遮罩层 */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4); /* 半透明黑底 */
    backdrop-filter: blur(5px);           /* 核心：将背后的时间轴虚化 */
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.mobile-overlay.hidden {
    opacity: 0;
    pointer-events: none; /* 隐藏时不允许点击 */
}

@media (max-width: 1100px) {
    .mobile-menu-btn { 
        display: block; /* 屏幕变窄时显示按钮 */
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        right: -70%; /* 默认完全藏在屏幕右侧外 */
        left: auto;
        width: 60%;  /* 只占据 60% 的屏幕宽度 */
        height: 100vh;
        background-color: var(--bg-color);
        z-index: 1001;
        padding: 80px 20px 20px 30px; /* 顶部留出空间避开按钮 */
        box-shadow: -5px 0 20px rgba(0,0,0,0.15);
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* 平滑滑出动画 */
        display: flex; /* 覆盖原本的 display:none */
    }
    
    .sidebar.open {
        right: 0; /* 加了这个类名，侧边栏就会滑入屏幕 */
    }
}

@media (max-width: 768px) {
    /* 极致紧凑版主题切换器 */
    .theme-switcher {
        bottom: 15px;
        right: 15px;
        padding: 3px;
        gap: 2px;
    }
    
    .theme-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}