:root {
    --bg-color: #e5e5e5;
    --book-bg: #ffffff;
    --active-bg: #38503d; 
    --text-black: #1a1a1a;
    --text-white: #ffffff;
    --font-stack: 'Josefin Sans', sans-serif; 
}

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

body {
    background-color: var(--bg-color);
    font-family: var(--font-stack);
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow: hidden;
}

header {
    margin-bottom: 30px;
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start;
    flex-shrink: 0;
}

h1 {
    text-transform: uppercase;
    font-size: 3.4rem; 
    letter-spacing: 1px; 
    font-weight: 800; 
    line-height: 1.1;
}

header p {
    font-size: 2.2rem;   
    font-weight: 300;
    opacity: 0.8;
}

.about-link {
    text-decoration: none;
    color: var(--text-black);
    font-size: 1.5rem;
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 2px solid var(--text-black);
}

/* --- 书架容器 --- */
#shelf-container {
    flex: 1;
    display: flex;
    align-items: flex-end; /* 底部对齐 */
    gap: 8px;
    width: 100%;
    padding-bottom: 20px;
}

/* --- 书本基础 --- */
.book {
    background-color: var(--book-bg);
    color: var(--text-black);
    position: relative;
    cursor: pointer;
    flex: 1; 
    transition: flex 0.6s cubic-bezier(0.25, 1, 0.5, 1), 
                background-color 0.4s;
    overflow: hidden;

}

/* --- 书脊视图 --- */
.spine-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 40px 5px 20px 5px;
    opacity: 1;
    transition: opacity 0.3s;
}

.vertical-info {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: flex;
    align-items: center;
    gap: 15px;
}

.spine-week { font-weight: 700; font-size: 2rem; }
.spine-title { font-size: 0.8rem; text-transform: uppercase; }

.barcode {
    height: 20px;
    width: 80%;
}

/* --- 展开视图 --- */
.expanded-view {
    position: absolute;
    inset: 0;
    padding: 40px; /* 减小内边距以适应高度不变的书 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s 0.1s;
    pointer-events: none;
}

.detail-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem); /* 字体大小根据容器自适应 */
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
    margin: 10px 0;
}

.detail-desc {
    font-size: 0.95rem;
    max-width: 80%;
    font-weight: 300;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 如果书太矮，自动省略多余文字 */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- 交互状态：仅宽度变大 --- */
@media screen and (min-width: 1025px) {
    .book:hover {
        flex: 8; 
        /* 注意：这里不再设置 height，它将保持 JS 赋予的随机高度 */
        background-color: var(--active-bg) !important;
        color: var(--text-white);
    }
    
    .book:hover .spine-view { opacity: 0; }
    .book:hover .expanded-view { 
        opacity: 1; 
        pointer-events: auto;
    }
}

/* 移动端逻辑通常需要撑满，所以保持现状 */
@media screen and (max-width: 1024px) {
    #shelf-container { flex-direction: column; height: auto; }
    .book { height: 80px !important; flex: none; width: 100%; margin-bottom: 8px; }
    .book.active { height: 280px !important; background-color: var(--active-bg); color: #fff; }
    .book.active .spine-view { opacity: 0; }
    .book.active .expanded-view { opacity: 1; }
}