/**
 * 种草单 — 书架 / 影单墙
 */

body:has(.shelf-page) {
    background-color: #f5f2e9;
    background-image: url("../img/shelf_bg.jpg");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 100% 100%;
    background-attachment: fixed;
}

.shelf-page {
    --shelf-ink: var(--color-ink);
    --shelf-muted: var(--color-muted);
    --shelf-line: var(--color-line);
    --shelf-paper: var(--color-page);
    --shelf-wood: var(--color-primary);
    --shelf-accent: var(--color-primary);
    --shelf-book: var(--color-primary);
    --shelf-movie: var(--color-warning);
    --shelf-music: var(--color-success);
    font-family: var(--font-sans);
    color: var(--shelf-muted);
    background: transparent;
    min-height: calc(100vh - var(--site-header-h, 64px) - var(--site-footer-h, 74px));
    min-height: calc(100dvh - var(--site-header-h, 64px) - var(--site-footer-h, 74px));
    padding-bottom: 64px;
}

.shelf-brand {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--shelf-accent);
    margin: 0 0 8px;
}

.shelf-view-toggle .fa {
    margin-right: 4px;
}

@media (max-width: 991px) {
    .shelf-view-toggle {
        display: none !important;
    }
}

/* ---------- 3D 满宽舞台（仅 PC + 书架视图） ---------- */
.shelf-stage {
    display: none;
    position: relative;
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 520px;
    max-height: 780px;
    margin: 0;
    background:
        radial-gradient(ellipse 60% 50% at 50% 60%, rgba(195, 122, 103, 0.1), transparent 70%),
        linear-gradient(180deg, #efeae0 0%, #f7f3e8 55%, #f3efe6 100%);
    overflow: hidden;
}

.shelf-page.is-view-3d .shelf-stage {
    display: flex;
    align-items: stretch;
}

.shelf-page.is-view-3d .shelf-body {
    display: none;
}

.shelf-page.is-view-list .shelf-stage {
    display: none;
}

.shelf-page.is-view-list .shelf-body {
    display: block;
}

.shelf-stage-nav {
    flex: 0 0 108px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 14px 20px;
    background: linear-gradient(180deg, rgba(255, 252, 248, 0.92), rgba(247, 243, 232, 0.75));
    border-right: 1px solid rgba(229, 221, 210, 0.9);
    z-index: 3;
    overflow-y: auto;
}

.shelf-stage-nav-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shelf-stage-nav-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--shelf-muted);
    padding: 0 4px;
}

.shelf-stage-nav-btn {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--shelf-line);
    border-radius: 3px;
    background: var(--color-surface);
    color: var(--shelf-ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.shelf-stage-nav-btn:hover {
    border-color: var(--shelf-accent);
    color: var(--shelf-accent);
}

.shelf-stage-nav-btn.is-active {
    background: var(--shelf-accent);
    border-color: var(--shelf-accent);
    color: #fff;
}

.shelf-stage-nav-count {
    margin: auto 0 0;
    padding-top: 8px;
    font-size: 12px;
    color: var(--shelf-muted);
    text-align: center;
    border-top: 1px solid var(--shelf-line);
}

.shelf-stage-main {
    position: relative;
    flex: 1;
    min-width: 0;
}

.shelf-3d {
    position: absolute;
    inset: 0;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.shelf-3d:active {
    cursor: grabbing;
}

.shelf-3d-canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.shelf-3d.is-ready .shelf-3d-canvas {
    opacity: 1;
}

.shelf-3d-tip {
    position: absolute;
    left: 50%;
    bottom: 48px;
    transform: translateX(-50%) translateY(6px);
    max-width: min(90%, 420px);
    padding: 8px 16px;
    background: rgba(44, 36, 28, 0.9);
    color: #fff;
    font-size: 14px;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

.shelf-3d-tip.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.shelf-3d-empty {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    color: var(--shelf-muted);
    font-size: 15px;
    z-index: 2;
    pointer-events: none;
}

.shelf-3d.is-empty .shelf-3d-empty {
    display: flex;
}

.shelf-3d-fallback {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: var(--shelf-muted);
    font-size: 14px;
    background: rgba(247, 243, 232, 0.65);
    z-index: 2;
}

.shelf-3d.is-fallback .shelf-3d-canvas {
    display: none;
}

.shelf-3d.is-fallback .shelf-3d-fallback {
    display: flex;
}

.shelf-stage-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 16px;
    margin: 0;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--shelf-muted);
    pointer-events: none;
    z-index: 1;
    opacity: 0.75;
}

@media (max-width: 991px) {
    .shelf-stage {
        display: none !important;
    }

    .shelf-page .shelf-body {
        display: block !important;
    }
}

/* ---------- Hero（列表页与 resource 一致；详情页用 shelf-hero-detail） ---------- */
.shelf-hero {
    position: relative;
    padding: 56px 0 36px;
    text-align: center;
    background: transparent;
    margin-bottom: 0;
    overflow: visible;
}

.shelf-hero-detail {
    background:
        radial-gradient(ellipse 80% 60% at 10% 20%, rgba(195, 122, 103, 0.14), transparent 55%),
        radial-gradient(ellipse 70% 50% at 90% 80%, rgba(160, 160, 136, 0.22), transparent 50%),
        linear-gradient(165deg, #f7f3e8 0%, #efeae0 55%, #f3efe6 100%);
    padding: 56px 0 40px;
    margin-bottom: 28px;
    overflow: hidden;
    text-align: left;
}

.shelf-hero-detail::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--shelf-wood), var(--shelf-accent), transparent);
    opacity: 0.55;
}

.shelf-hero-title {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: clamp(1.75rem, 3.5vw, 2.35rem);
    color: var(--shelf-ink);
    margin: 0 0 10px;
    line-height: 1.2;
}

.shelf-hero-desc {
    max-width: 36em;
    margin: 0 0 20px;
    font-size: 1.05rem;
}

.shelf-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

@keyframes shelfFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.shelf-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--shelf-ink);
    color: #fff !important;
    border: none;
    border-radius: 2px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, border-color 0.2s, color 0.2s;
}
.shelf-btn:hover { background: var(--shelf-accent); color: #fff !important; transform: translateY(-1px); }
.shelf-btn-ghost {
    background: transparent;
    color: var(--shelf-ink) !important;
    border: 1px solid var(--shelf-line);
}
.shelf-btn-ghost:hover { border-color: var(--shelf-accent); color: var(--shelf-accent) !important; background: transparent; }
.shelf-btn-sm { padding: 6px 14px; font-size: 0.9rem; }
.shelf-btn-primary { background: var(--shelf-accent); }
.shelf-btn-primary:hover { background: var(--color-primary-hover); }

.shelf-body {
    padding-top: 28px;
}

/* 覆盖 community.css 对 shelf-toolbar / shelf-tab 的全局 chips 样式 */
.shelf-page .shelf-toolbar.shelf-filter {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 20px;
    margin: 0 0 28px !important;
    padding: 14px 16px !important;
    background: var(--color-surface) !important;
    border: 1px solid var(--shelf-line) !important;
    border-radius: 4px !important;
    box-shadow: none !important;
}

.shelf-page .shelf-filter-groups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    min-width: 0;
}

.shelf-page .shelf-tabs {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 0 !important;
    background: transparent !important;
}

.shelf-page .shelf-tabs-sort {
    padding-left: 14px;
    border-left: 1px solid var(--shelf-line);
}

.shelf-page .shelf-tab {
    position: static !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    min-width: 52px;
    padding: 6px 14px !important;
    border: 1px solid var(--shelf-line) !important;
    border-radius: 3px !important;
    background: #fff !important;
    color: var(--shelf-ink) !important;
    text-decoration: none !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    box-shadow: none !important;
    transition: border-color 0.2s, color 0.2s, background 0.2s !important;
}

.shelf-page .shelf-tab::after {
    display: none !important;
    content: none !important;
}

.shelf-page .shelf-tab:hover {
    border-color: var(--shelf-accent) !important;
    color: var(--shelf-accent) !important;
    background: var(--color-primary-soft) !important;
}

.shelf-page .shelf-tab.is-active {
    border-color: var(--shelf-accent) !important;
    background: var(--shelf-accent) !important;
    color: #fff !important;
}

.shelf-tabs-inline { margin-bottom: 20px; }

.shelf-sort a {
    margin-right: 12px;
    color: var(--shelf-muted) !important;
    text-decoration: none !important;
    font-size: 0.9rem;
}
.shelf-sort a.is-active { color: var(--shelf-accent) !important; font-weight: 600; }

.shelf-page .shelf-search {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: center;
}
.shelf-page .shelf-search input {
    border: 1px solid var(--shelf-line);
    padding: 7px 12px;
    min-width: 180px;
    background: #fff;
    border-radius: 3px;
}

/* ---------- 列表卡片（优化） ---------- */
.shelf-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
}

.shelf-card {
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    color: inherit !important;
    background: var(--color-surface);
    border: 1px solid var(--shelf-line);
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    animation: shelfFadeUp 0.55s ease both;
    box-shadow: 0 1px 2px rgba(44, 36, 28, 0.04);
}
.shelf-card:nth-child(2) { animation-delay: 0.04s; }
.shelf-card:nth-child(3) { animation-delay: 0.08s; }
.shelf-card:nth-child(4) { animation-delay: 0.12s; }
.shelf-card:nth-child(5) { animation-delay: 0.16s; }
.shelf-card:hover {
    transform: translateY(-5px);
    border-color: rgba(195, 122, 103, 0.35);
    box-shadow: 0 12px 28px rgba(44, 36, 28, 0.1);
}

.shelf-card-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    background-color: #e8e4d8;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.shelf-card-cover.is-empty {
    background-image:
        linear-gradient(145deg, rgba(255,252,248,0.35), transparent 55%),
        linear-gradient(160deg, #e6e4d8 0%, #d4cfc0 100%);
}
.shelf-card-book .shelf-card-cover.is-empty {
    background-image:
        linear-gradient(145deg, rgba(243, 230, 220, 0.7), transparent 60%),
        linear-gradient(160deg, #e8d5cc 0%, #c37a67 120%);
}
.shelf-card-movie .shelf-card-cover.is-empty {
    background-image:
        linear-gradient(145deg, rgba(255, 236, 210, 0.65), transparent 60%),
        linear-gradient(160deg, #ead2b0 0%, #d4893a 120%);
}
.shelf-card-music .shelf-card-cover.is-empty {
    background-image:
        linear-gradient(145deg, rgba(230, 240, 225, 0.65), transparent 60%),
        linear-gradient(160deg, #d5e0d0 0%, #7d9b76 120%);
}

.shelf-card-book { border-top: 3px solid var(--shelf-book); }
.shelf-card-movie { border-top: 3px solid var(--shelf-movie); }
.shelf-card-music { border-top: 3px solid var(--shelf-music); }

.shelf-type-badge {
    position: absolute;
    left: 10px;
    top: 10px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    background: rgba(44, 36, 28, 0.78);
    color: #fff;
    border-radius: 2px;
    backdrop-filter: blur(4px);
}
.shelf-card-book .shelf-type-badge { background: rgba(195, 122, 103, 0.92); }
.shelf-card-movie .shelf-type-badge { background: rgba(212, 137, 58, 0.92); }
.shelf-card-music .shelf-type-badge { background: rgba(125, 155, 118, 0.92); }

.shelf-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 14px 16px;
    flex: 1;
}
.shelf-card-title {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    color: var(--shelf-ink);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.shelf-card-meta {
    margin: 0;
    font-size: 13px;
    color: var(--shelf-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
}
.shelf-card-count {
    color: var(--shelf-ink);
    font-weight: 500;
}
.shelf-card-author::before {
    content: '·';
    margin-right: 10px;
    color: var(--shelf-line);
}
.shelf-card-stats {
    margin: auto 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--shelf-line);
    font-size: 12px;
    color: var(--shelf-muted);
    display: flex;
    gap: 12px;
}
.shelf-card-stats .fa {
    margin-right: 3px;
    opacity: 0.7;
}

.shelf-empty {
    text-align: center;
    padding: 64px 20px;
    color: var(--shelf-muted);
    border: 1px dashed var(--shelf-line);
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
}

.shelf-pager { margin-top: 32px; text-align: center; }

/* Detail */
.shelf-hero-detail { padding-bottom: 48px; }
.shelf-detail-head {
    display: flex;
    gap: 32px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.shelf-detail-cover {
    width: 160px;
    aspect-ratio: 2 / 3;
    flex-shrink: 0;
    background: linear-gradient(145deg, #d8e4e0, #c5d4cf);
    background-size: cover;
    background-position: center;
    box-shadow: 6px 10px 28px rgba(26, 47, 42, 0.18);
    animation: shelfFadeUp 0.6s ease both;
}
.shelf-detail-info { flex: 1; min-width: 220px; }
.shelf-meta-line { margin: 0 0 16px; }
.shelf-meta-line a { color: var(--shelf-accent); }
.shelf-private-tag {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.75rem;
    background: rgba(26, 47, 42, 0.1);
    border-radius: 2px;
}
.shelf-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.shelf-engage {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0 0 32px;
    padding: 14px 0;
    border-bottom: 1px solid var(--shelf-line);
}
.shelf-engage-btn {
    border: 1px solid var(--shelf-line);
    background: #fff;
    padding: 8px 14px;
    border-radius: 2px;
    color: var(--shelf-ink);
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.shelf-engage-btn em {
    font-style: normal;
    font-size: 0.85rem;
    margin-left: 4px;
    color: var(--shelf-muted);
}
.shelf-engage-btn:hover, .shelf-engage-btn.is-on {
    border-color: var(--shelf-accent);
    color: var(--shelf-accent);
    background: var(--color-primary-soft);
}
.shelf-engage-btn.is-on i.fa-heart { color: #c0392b; }
.shelf-engage-count { margin-left: auto; font-size: 0.9rem; }

.shelf-item-wall {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.shelf-item {
    display: flex;
    gap: 20px;
    padding: 22px 0;
    border-bottom: 1px solid var(--shelf-line);
    animation: shelfFadeUp 0.5s ease both;
}
.shelf-item-cover {
    position: relative;
    width: 72px;
    flex-shrink: 0;
    aspect-ratio: 2 / 3;
    background: linear-gradient(145deg, #e0e8e4, #cfdad5);
    background-size: cover;
    background-position: center;
    box-shadow: 2px 4px 12px rgba(26, 47, 42, 0.1);
}
.shelf-item-index {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    line-height: 22px;
    text-align: center;
    background: var(--shelf-ink);
    color: #fff;
}
.shelf-item-title {
    font-family: var(--font-sans);
    font-size: 1.35rem;
    margin: 0 0 4px;
    color: var(--shelf-ink);
}
.shelf-item-title a { color: inherit !important; text-decoration: none !important; }
.shelf-item-title a:hover { color: var(--shelf-accent) !important; }
.shelf-item-creator { margin: 0 0 6px; font-size: 0.92rem; }
.shelf-item-note {
    margin: 0 0 6px;
    font-style: italic;
    color: var(--shelf-ink);
    opacity: 0.85;
    border-left: 2px solid var(--shelf-wood);
    padding-left: 12px;
}
.shelf-item-meta { margin: 0; font-size: 0.82rem; }

.shelf-section-title {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    color: var(--shelf-ink);
    margin: 40px 0 16px;
}

.shelf-comment {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--shelf-line);
}
.shelf-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #e8efed;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.shelf-comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
.shelf-comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.shelf-comment-head time { font-size: 0.8rem; color: var(--shelf-muted); }
.shelf-comment-form textarea {
    width: 100%;
    border: 1px solid var(--shelf-line);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 2px;
    resize: vertical;
}
.shelf-comment-empty, .shelf-comment-login { padding: 20px 0; color: var(--shelf-muted); }

/* Member manage */
.shelf-mine-list { margin-top: 8px; }
.shelf-mine-row {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--shelf-line);
}
.shelf-mine-cover {
    width: 56px;
    height: 84px;
    flex-shrink: 0;
    background: #d8e4e0 center/cover;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.08);
}
.shelf-mine-info { flex: 1; min-width: 0; }
.shelf-mine-info h3 { margin: 0 0 6px; font-size: 1.1rem; }
.shelf-mine-info h3 a { color: var(--shelf-ink); }
.shelf-mine-ops { white-space: nowrap; }

.shelf-item-manage { list-style: none; margin: 0; padding: 0; }
.shelf-item-manage-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--shelf-line);
}
.shelf-item-manage-cover {
    width: 40px;
    height: 60px;
    background: #d8e4e0 center/cover;
    flex-shrink: 0;
}
.shelf-item-manage-body { flex: 1; min-width: 0; }
.shelf-item-note-sm { margin: 4px 0 0; font-size: 0.85rem; color: var(--shelf-muted); }
.shelf-item-manage-ops { white-space: nowrap; }
.shelf-parse-box { margin-bottom: 24px; }

@media (max-width: 767px) {
    .shelf-hero { padding: 36px 0 28px; }
    .shelf-detail-cover { width: 120px; }
    .shelf-search { margin-left: 0; width: 100%; }
    .shelf-search input { flex: 1; min-width: 0; }
    .shelf-mine-row, .shelf-item-manage-row { flex-wrap: wrap; }
    .shelf-engage-count { margin-left: 0; width: 100%; }
    .shelf-wall {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
    .shelf-card-body { padding: 10px 10px 12px; }
    .shelf-card-title { font-size: 14px; }
}
