/* ============================================================
   姻缘簿 · 古风样式 v2（沉浸式月老书房）
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow-x: hidden;
    font-family: "STKaiti", "KaiTi", "楷体", "Songti SC", "SimSun", serif;
    background: #1a1410;
    color: #d4c5a0;
}

/* 背景：书房墙+地面 */
body {
    background:
        radial-gradient(ellipse at 50% 20%, rgba(255, 200, 100, 0.1) 0%, transparent 50%),
        linear-gradient(180deg, #2a1f15 0%, #1a1410 60%, #0d0a07 100%);
    min-height: 100vh;
    position: relative;
}

/* ========== 背景书架场景 ========== */
.bg-room {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

/* 左右两侧的固定书架（装饰用） */
.bg-shelf {
    position: absolute;
    top: 80px;
    width: 180px;
    height: calc(100% - 200px);
}
.bg-shelf.left { left: -10px; }
.bg-shelf.right { right: -10px; }

/* 书架层板 */
.bg-shelf::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        /* 层板横线 */
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent calc(25% - 6px),
            #4a3018 calc(25% - 6px),
            #3a2818 25%,
            transparent 25%,
            transparent 50%
        ),
        /* 书架侧板 */
        linear-gradient(90deg, #3a2818 0%, transparent 8%, transparent 92%, #3a2818 100%);
}

/* 书架上的装饰书（随机排列的小色块） */
.bg-shelf .deco-book {
    position: absolute;
    bottom: 8px;
    width: 12px;
    border-radius: 2px 2px 0 0;
    box-shadow: inset 1px 0 2px rgba(0,0,0,0.3);
}

/* 中央主书架区域（可点击的姻缘簿放这里） */
.shelf-area {
    position: relative;
    z-index: 10;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 顶部标题 */
.top {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 50px 20px 10px;
}
.title {
    font-size: 60px;
    letter-spacing: 24px;
    color: #d4a94e;
    text-shadow:
        0 0 20px rgba(212, 169, 78, 0.4),
        0 0 60px rgba(212, 169, 78, 0.2);
    font-weight: normal;
}
.subtitle {
    margin-top: 12px;
    font-size: 18px;
    color: #8a7a5a;
    letter-spacing: 10px;
}

/* 搜索框（融入古风暗调） */
.search-box {
    margin-top: 25px;
    text-align: center;
}
.search-box input {
    width: 360px;
    max-width: 85%;
    padding: 12px 25px;
    border-radius: 4px;
    border: 1px solid #5a4a2a;
    background: rgba(40, 30, 18, 0.6);
    color: #c9b080;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    text-align: center;
    letter-spacing: 2px;
}
.search-box input::placeholder { color: #5a4a2a; }
.search-box input:focus {
    border-color: #8a6a3a;
    background: rgba(50, 38, 22, 0.8);
}

/* ========== 主书架 ========== */
.shelf {
    position: relative;
    max-width: 700px;
    margin: 30px auto;
    padding: 30px 20px 40px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
    min-height: 300px;
}

/* 书架层板 */
.shelf-board {
    position: absolute;
    left: 0; right: 0;
    height: 10px;
    background: linear-gradient(180deg, #6b4a2a 0%, #3a2818 100%);
    border-radius: 2px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,150,0.1);
}
.shelf-board.top { top: 0; }
.shelf-board.bottom { bottom: 0; }

/* 侧边板 */
.shelf::before, .shelf::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 12px;
    background: linear-gradient(90deg, #3a2818, #5a3e28, #3a2818);
    border-radius: 2px;
}
.shelf::before { left: 0; }
.shelf::after { right: 0; }

/* 单本姻缘簿 */
.book {
    width: 85px;
    height: 130px;
    background: linear-gradient(180deg, #7a5228 0%, #4a3018 100%);
    border-radius: 3px 8px 8px 3px;
    position: relative;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow:
        inset 3px 0 5px rgba(0,0,0,0.4),
        inset -2px 0 3px rgba(255,255,255,0.05),
        0 5px 10px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    padding: 12px 0;
    /* 发光效果 */
    animation: bookGlow 3s ease-in-out infinite;
}
@keyframes bookGlow {
    0%, 100% { box-shadow: inset 3px 0 5px rgba(0,0,0,0.4), 0 5px 10px rgba(0,0,0,0.5); }
    50% { box-shadow: inset 3px 0 5px rgba(0,0,0,0.4), 0 5px 20px rgba(212, 169, 110, 0.4); }
}
.book::before {
    content: '';
    position: absolute;
    left: 5px; top: 10px; bottom: 10px;
    width: 1px;
    background: rgba(0,0,0,0.4);
}
.book::after {
    content: '';
    position: absolute;
    right: 3px; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, rgba(0,0,0,0.2), rgba(0,0,0,0.4));
    border-radius: 0 3px 3px 0;
}
.book:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow:
        inset 3px 0 5px rgba(0,0,0,0.4),
        0 15px 25px rgba(212, 169, 110, 0.5);
    animation: none;
}
.book-title {
    font-size: 14px;
    color: #e8c87a;
    letter-spacing: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* 空书架提示 */
.shelf-empty {
    width: 100%;
    text-align: center;
    color: #6a5a3a;
    font-size: 16px;
    padding: 60px 0;
    letter-spacing: 4px;
}

/* 立姻缘簿按钮 */
.add-btn {
    position: relative;
    z-index: 10;
    display: block;
    margin: 30px auto;
    padding: 14px 50px;
    font-size: 20px;
    font-family: inherit;
    letter-spacing: 6px;
    color: #d4a94e;
    background: rgba(212, 169, 78, 0.05);
    border: 1px solid #8a6a3a;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}
.add-btn:hover {
    background: rgba(212, 169, 78, 0.15);
    box-shadow: 0 0 25px rgba(212, 169, 78, 0.3);
}

/* 底部落款 */
.footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 30px;
    color: #5a4a2a;
    font-size: 14px;
    letter-spacing: 6px;
}

/* ========== 浮尘 ========== */
.dust {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2;
}
.dust-particle {
    position: absolute;
    background: rgba(255, 220, 150, 0.5);
    border-radius: 50%;
    animation: float linear infinite;
}
@keyframes float {
    0%   { transform: translateY(100vh) translateX(0); opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translateY(-10vh) translateX(40px); opacity: 0; }
}

/* 暖光灯光斑 */
.lamp-glow {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 190, 100, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

/* ========== 翻页弹窗 ========== */
.book-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.4s;
}
.book-overlay.show { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.book-page {
    position: relative;
    max-width: 500px;
    width: 90%;
    animation: openBook 0.8s ease;
}
@keyframes openBook {
    from { transform: perspective(1200px) rotateY(-90deg); opacity: 0; }
    to   { transform: perspective(1200px) rotateY(0); opacity: 1; }
}

.close-page {
    position: absolute;
    top: -40px; right: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(212, 169, 110, 0.2);
    border: 1px solid #8a6a3a;
    color: #c9a96e;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
}

/* 宣纸 */
.paper {
    background:
        repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(139, 119, 87, 0.12) 28px, rgba(139, 119, 87, 0.12) 29px),
        linear-gradient(135deg, #f5f0e0 0%, #e8dcc0 50%, #d4c8a8 100%);
    border-radius: 4px;
    padding: 50px 40px;
    box-shadow:
        0 0 40px rgba(0,0,0,0.6),
        inset 0 0 80px rgba(139, 119, 87, 0.12);
    position: relative;
}
.paper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 8px;
    background: linear-gradient(180deg, rgba(139,119,87,0.25), transparent);
    border-radius: 4px 4px 0 0;
}
.paper::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 8px;
    background: linear-gradient(0deg, rgba(139,119,87,0.2), transparent);
    border-radius: 0 0 4px 4px;
}

.paper-inner {
    color: #3a2a1a;
    text-align: center;
    line-height: 2;
}
.paper-inner .doc-title {
    font-size: 28px;
    letter-spacing: 12px;
    margin-bottom: 30px;
    color: #5a3a1a;
}
.paper-inner .doc-body {
    font-size: 18px;
    text-align: left;
    padding: 0 20px;
    animation: fadeIn 2s;
}
.paper-inner .doc-body p { margin-bottom: 12px; }
.paper-inner .doc-date {
    margin-top: 30px;
    font-size: 16px;
    color: #6a4a2a;
    text-align: right;
}

/* ========== 新增表单弹窗 ========== */
.form-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.form-overlay.show { display: flex; }

.form-box {
    background: linear-gradient(135deg, #f5f0e0, #e8dcc0);
    border-radius: 6px;
    padding: 40px;
    width: 90%;
    max-width: 380px;
    color: #3a2a1a;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
}
.form-box h2 {
    text-align: center;
    font-size: 28px;
    letter-spacing: 8px;
    margin-bottom: 10px;
}
.form-tip {
    text-align: center;
    font-size: 14px;
    color: #8a6a4a;
    margin-bottom: 25px;
}
.form-box label {
    display: block;
    font-size: 15px;
    margin: 12px 0 6px;
    color: #5a3a1a;
}
.form-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #b09060;
    border-radius: 4px;
    background: #fffef5;
    font-size: 16px;
    font-family: inherit;
    color: #3a2a1a;
    outline: none;
}
.form-box input:focus {
    border-color: #8a6a3a;
    box-shadow: 0 0 8px rgba(138, 106, 58, 0.3);
}
.form-btns {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}
.form-btns button {
    flex: 1;
    padding: 12px;
    font-size: 18px;
    font-family: inherit;
    letter-spacing: 4px;
    border-radius: 4px;
    cursor: pointer;
}
.form-btns .cancel {
    background: transparent;
    border: 1px solid #8a6a3a;
    color: #5a3a1a;
}
.form-btns .confirm {
    background: #8a6a3a;
    border: none;
    color: #f5f0e0;
}

/* ========== 移动端适配 ========== */
@media (max-width: 600px) {
    .title { font-size: 42px; letter-spacing: 14px; }
    .bg-shelf { display: none; } /* 手机端隐藏两侧书架 */
    .book { width: 65px; height: 105px; }
    .book-title { font-size: 12px; letter-spacing: 2px; }
    .paper-inner .doc-title { font-size: 22px; letter-spacing: 8px; }
    .paper-inner .doc-body { font-size: 16px; }
    .lamp-glow { width: 300px; height: 300px; }
}
