/* ================== 全局重置与基础设置 ================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
a { outline: none; text-decoration: none; }
body { font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif; overflow: hidden; }
body.unlocked { overflow: auto; }
body.modal-open { overflow: hidden !important; } /* 锁定底层滚动 */

/* ================== 启动屏与加载动画 ================== */
.intro-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background-color: #fdfbfb; z-index: 9999; 
    display: flex; justify-content: center; align-items: center; flex-direction: column;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}
.intro-screen.hidden { opacity: 0; visibility: hidden; }
.loader { width: 50px; height: 50px; border: 4px solid #e1edfc; border-top: 4px solid #6aa5e3; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.birthday-message { display: none; text-align: center; opacity: 0; transform: scale(0.9); transition: all 1s cubic-bezier(0.25, 1, 0.5, 1); }
.birthday-message.show { opacity: 1; transform: scale(1); }
.bday-zh { font-size: 3.5rem; color: #4a8cdb; font-weight: bold; margin-bottom: 15px; letter-spacing: 4px; }
.bday-en { font-size: 1.5rem; color: #888; letter-spacing: 6px; font-family: Arial, sans-serif; }

/* ================== 第一层：固定封面 ================== */
.cover {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh; z-index: 10;
    background: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)), url('../images/bg.jpg');
    background-size: cover; background-position: center; background-repeat: no-repeat; 
    display: flex; justify-content: center; align-items: center; text-align: center;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1); 
}
.cover.slide-up { transform: translateY(-100%); }
.cover-content h1 { font-size: 3.5rem; color: #333; margin-bottom: 15px; letter-spacing: 2px; }
.cover-content p { font-size: 1.2rem; color: #555; }
.scroll-arrow {
    position: absolute; bottom: 50px; width: 24px; height: 24px;
    border-bottom: 3px solid #5b9bd5; border-right: 3px solid #5b9bd5;
    transform: rotate(45deg); cursor: pointer; animation: bounce 2s infinite;
}
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0) rotate(45deg); }
    40% { transform: translateY(-15px) rotate(45deg); }
    60% { transform: translateY(-7px) rotate(45deg); }
}

/* ================== 生日祝贺信区 ================== */
.birthday-letter-section { padding: 80px 20px 40px; background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%); position: relative; z-index: 1; }
.letter-paper { max-width: 700px; margin: 0 auto; padding: 50px 40px; background: #fffaf0; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.06); color: #555; line-height: 2; }
.letter-title { color: #4a8cdb; text-align: center; margin-bottom: 30px; font-weight: normal; }
.letter-paper p { text-indent: 2em; margin-bottom: 15px; }
.letter-signature { text-align: right; margin-top: 40px; font-style: italic; color: #888; }

/* ================== 第二层：时间轴目录 ================== */
.timeline-section { min-height: auto; padding: 60px 20px 80px; background: linear-gradient(180deg, #f4f9ff 0%, #d6eaff 100%); position: relative; z-index: 1; overflow-x: hidden; }
.timeline-section h2 { text-align: center; margin-bottom: 50px; color: #333; font-size: 2rem; }
.timeline { max-width: 900px; margin: 0 auto; position: relative; }
.timeline::after { content: ''; position: absolute; width: 4px; background-color: #6aa5e3; top: 0; bottom: 0; left: 20px; border-radius: 2px; }
.timeline-item { margin-bottom: 40px; position: relative; width: 100%; padding-left: 50px; padding-right: 15px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease; }
.timeline-item.visible { opacity: 1; transform: translateY(0); }
.timeline-item::before { content: ''; position: absolute; width: 16px; height: 16px; background-color: #6aa5e3; border-radius: 50%; border: 4px solid #fff; top: 15px; left: 10px; z-index: 1; }
.timeline-date { font-size: 1.1rem; font-weight: bold; color: #4a8cdb; margin-bottom: 8px; }
.timeline-content { background: #ffffff; padding: 20px; border-radius: 8px; color: #555; line-height: 1.6; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); cursor: pointer; transition: transform 0.3s; }
.timeline-content:hover { transform: scale(1.02); }

@media screen and (min-width: 768px) {
    .timeline::after { left: 50%; transform: translateX(-50%); }
    .timeline { overflow: hidden; }
    .timeline-item { width: 50%; clear: both; margin-bottom: 120px; }
    .timeline-item:nth-child(odd) { float: left; padding-left: 0; padding-right: 45px; }
    .timeline-item:nth-child(odd)::before { left: auto; right: -10px; }
    .timeline-item:nth-child(even) { float: right; padding-left: 45px; padding-right: 0; margin-top: -80px; }
    .timeline-item:nth-child(even)::before { left: -10px; }
}

/* ================== 照片墙基础样式 ================== */
.photo-wall-section { padding: 60px 20px 100px; background: linear-gradient(180deg, #d6eaff 0%, #fdfbfb 100%); position: relative; z-index: 1; }
.photo-wall-section h2 { text-align: center; margin-bottom: 50px; color: #333; font-size: 2rem; }
.photo-container { max-width: 800px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; padding: 20px; }

.photo-item {
    background: #fff; padding: 12px 12px 30px 12px; box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    cursor: pointer; width: 240px; position: relative; z-index: 5;
    transform: rotate(var(--r)) translate(var(--x), var(--y));
    transition: transform 0.4s ease-out, box-shadow 0.4s ease-out; 
}
.photo-item:hover { transform: scale(1.1) rotate(0deg) translate(0, 0) !important; box-shadow: 0 15px 30px rgba(0,0,0,0.2); z-index: 10; }
.photo-item img { width: 100%; height: 200px; object-fit: cover; border-radius: 2px; }
.photo-caption { text-align: center; margin-top: 15px; color: #666; font-size: 0.95rem; }
.photo-item .expanded-story { display: none; } 

/* ================== 独立全局照片弹窗 ================== */
.photo-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 2000; 
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0.4s ease;
}
.photo-modal.active { opacity: 1; visibility: visible; }

.photo-modal-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); cursor: pointer;
}

.photo-modal-content {
    position: relative; background: #fff; z-index: 1; width: 90%; max-width: 450px; max-height: 85vh;
    border-radius: 16px; padding: 30px 20px; display: flex; flex-direction: column; align-items: center;
    overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.3); overscroll-behavior: contain; 
    transform: scale(0.85); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.photo-modal.active .photo-modal-content { transform: scale(1); }

.photo-modal-content img { max-width: 100%; max-height: 45vh; height: auto; object-fit: cover; border-radius: 8px; margin-bottom: 20px; }
.photo-modal-content p { width: 100%; text-align: left; color: #444; line-height: 1.8; font-size: 1.05rem; padding: 0 10px; }

/* ================== 居中一句话页脚 ================== */
.main-footer { background-color: #fdfbfb; text-align: center; padding: 40px 20px 80px; color: #888; font-size: 1rem; letter-spacing: 3px; }

/* ================== AI 聊天弹窗样式 ================== */
.chat-fab {
    position: fixed; bottom: 30px; right: 30px; background-color: #4a8cdb; color: white;
    border: none; border-radius: 30px; padding: 12px 24px; font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(74, 140, 219, 0.4); cursor: pointer; z-index: 9; 
    transition: transform 0.3s, box-shadow 0.3s;
}
.chat-fab:hover { transform: translateY(-5px); box-shadow: 0 6px 20px rgba(74, 140, 219, 0.6); }

.chat-modal {
    position: fixed; bottom: 90px; right: 30px; width: 350px; height: 500px;
    background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; z-index: 100; overflow: hidden;
    transition: opacity 0.3s, transform 0.3s; transform-origin: bottom right;
}
.chat-modal.hidden { opacity: 0; transform: scale(0.8); pointer-events: none; }

.chat-header { background: linear-gradient(135deg, #6aa5e3, #4a8cdb); color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center; }
.chat-title { font-weight: bold; }
.chat-actions { display: flex; gap: 8px; align-items: center; }
.chat-actions button { background: rgba(255, 255, 255, 0.2); border: none; color: white; font-size: 0.95rem; width: 28px; height: 28px; display: flex; justify-content: center; align-items: center; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; }
.chat-actions button:hover { background: rgba(255, 255, 255, 0.35); transform: translateY(-1px); }

#chatModal.chat-modal-fullscreen .chat-actions button, .chat-actions button:has(i + text), #chatExportBtn:has(:not(:only-child)) { width: auto; padding: 0 12px; }

.chat-body { flex: 1; padding: 15px; background: #fdfbfb; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; overscroll-behavior: contain; }
.chat-msg { max-width: 80%; padding: 10px 15px; border-radius: 15px; line-height: 1.5; font-size: 0.95rem; word-wrap: break-word; }
.msg-user { align-self: flex-end; background: #e1edfc; color: #333; border-bottom-right-radius: 2px; }
.msg-ai { align-self: flex-start; background: #fff; color: #444; border: 1px solid #eee; border-bottom-left-radius: 2px; }

.chat-footer { padding: 10px; background: #fff; border-top: 1px solid #eee; display: flex; gap: 10px; }
.chat-footer textarea { flex: 1; height: 40px; border: 1px solid #ccc; border-radius: 20px; padding: 10px 15px; resize: none; outline: none; font-family: inherit; }
.chat-footer button { background: #4a8cdb; color: white; border: none; border-radius: 20px; padding: 0 20px; cursor: pointer; }

/* ================== Markdown 文本排版美化 ================== */
.chat-msg p { margin-bottom: 8px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { padding-left: 20px; margin-bottom: 8px; }
.chat-msg li { margin-bottom: 4px; }
.chat-msg strong { color: #222; font-weight: bold; }
.chat-msg pre { background-color: #f1f5f9; padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.chat-msg code { font-family: Consolas, Monaco, monospace; background-color: rgba(0,0,0,0.05); padding: 2px 4px; border-radius: 4px; font-size: 0.9em; }

/* ================== 响应式适配 (手机端自动精简) ================== */
@media (max-width: 600px) {
    .hide-on-mobile { display: none; }
    .chat-fab { width: 50px; height: 50px; padding: 0; display: flex; justify-content: center; align-items: center; border-radius: 50%; }
    #chatExportBtn { width: 32px !important; height: 32px !important; padding: 0 !important; }
}
