/**
 * Library book covers: spine + face, full-bleed image vs inset + title, or title-only placeholder.
 */
.library-book-cover {
    position: relative;
    width: 160px;
    height: 220px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        0 2px 4px rgba(15, 23, 42, 0.06),
        0 8px 24px rgba(15, 23, 42, 0.08);
}

.library-book-book {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
}

/* Default spine if no inline style (e.g. old markup); JS sets per-book HSL gradient from book id */
.library-book-spine {
    flex: 0 0 11px;
    width: 11px;
    background: linear-gradient(
        90deg,
        #1a2332 0%,
        #2c3a4f 45%,
        #243044 100%
    );
    box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.2);
}

html.dark-mode .library-book-spine:not([style]) {
    background: linear-gradient(90deg, #0d1117 0%, #21262d 50%, #161b22 100%);
}

.library-book-face {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(165deg, #fdfcfa 0%, #ebe4d8 55%, #e2d9cc 100%);
    border: 1px solid rgba(30, 42, 59, 0.12);
    border-left: none;
    border-radius: 0 9px 9px 0;
}

html.dark-mode .library-book-face {
    background: linear-gradient(165deg, #21262d 0%, #161b22 100%);
    border-color: var(--border);
}

/* Title-only (no cover image) */
.library-book-book--placeholder .library-book-face {
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
}

.library-book-title-on-cover {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    text-align: center;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
    line-clamp: 6;
    overflow: hidden;
    text-wrap: balance;
    max-height: 100%;
}

html.dark-mode .library-book-title-on-cover {
    color: var(--text);
}

/* Artwork area (image) */
.library-book-cover-art {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.library-book-cover-art--full {
    padding: 0;
}

.library-book-cover-art--full img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.library-book-cover-art--inset {
    padding: 8px 8px 6px;
    justify-content: center;
    gap: 4px;
}

.library-book-cover-art--inset img {
    position: relative;
    max-width: 92%;
    max-height: 58%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

html.dark-mode .library-book-cover-art--inset img {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.library-book-cover-inset-title {
    display: none;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    color: var(--text);
    padding: 0 6px;
    max-width: 100%;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.library-book-cover-art--inset .library-book-cover-inset-title {
    display: -webkit-box;
}

.library-book-cover-art--full .library-book-cover-inset-title {
    display: none !important;
}

/* Legacy fallback node (hidden unless error path uses it) */
.library-book-cover .library-book-cover-fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
    background: var(--surface-2);
}

/* —— Project folder tiles (library “Projects” row) —— */
.library-book-cover.project-folder-cover {
    --project-hue: 210;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(
        168deg,
        hsl(var(--project-hue), 42%, 97%) 0%,
        hsl(var(--project-hue), 36%, 90%) 48%,
        hsl(var(--project-hue), 32%, 84%) 100%
    );
    border: 1px solid hsla(var(--project-hue), 38%, 72%, 0.55);
    box-shadow:
        0 2px 4px rgba(15, 23, 42, 0.05),
        0 10px 28px hsla(var(--project-hue), 40%, 50%, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.library-book-cover.project-folder-cover:not(.project-folder-cover--cta) {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

html.dark-mode .library-book-cover.project-folder-cover:not(.project-folder-cover--cta) {
    background: linear-gradient(
        168deg,
        hsl(var(--project-hue), 22%, 22%) 0%,
        hsl(var(--project-hue), 18%, 16%) 100%
    );
    border-color: hsla(var(--project-hue), 28%, 42%, 0.65);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.project-folder-cover__tab {
    flex: 0 0 auto;
    width: 46%;
    max-width: 88px;
    height: 13px;
    margin: 11px 0 0 14px;
    border-radius: 7px 7px 0 0;
    background: linear-gradient(
        180deg,
        hsla(var(--project-hue), 48%, 88%, 0.95) 0%,
        hsla(var(--project-hue), 42%, 78%, 0.9) 100%
    );
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

html.dark-mode .project-folder-cover__tab {
    background: linear-gradient(
        180deg,
        hsla(var(--project-hue), 25%, 34%, 0.95) 0%,
        hsla(var(--project-hue), 22%, 26%, 0.9) 100%
    );
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.project-folder-cover__sheet {
    flex: 1;
    min-height: 0;
    margin: 0 9px 11px;
    border-radius: 0 10px 10px 10px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.72) 0%,
        rgba(255, 255, 255, 0.38) 100%
    );
    border: 1px solid hsla(var(--project-hue), 35%, 70%, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

html.dark-mode .project-folder-cover__sheet {
    background: linear-gradient(
        180deg,
        hsla(var(--project-hue), 16%, 28%, 0.95) 0%,
        hsla(var(--project-hue), 14%, 20%, 0.85) 100%
    );
    border-color: hsla(var(--project-hue), 22%, 38%, 0.5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.project-folder-cover__papers {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 72%;
    height: 38px;
    pointer-events: none;
}

.project-folder-cover__papers span {
    position: absolute;
    left: 0;
    right: 0;
    height: 8px;
    border-radius: 2px;
    background: hsla(var(--project-hue), 40%, 55%, 0.14);
    border: 1px solid hsla(var(--project-hue), 35%, 50%, 0.12);
}

.project-folder-cover__papers span:nth-child(1) {
    top: 0;
    transform: rotate(-2deg);
    opacity: 0.85;
}

.project-folder-cover__papers span:nth-child(2) {
    top: 11px;
    transform: rotate(1.2deg);
    opacity: 0.65;
}

.project-folder-cover__papers span:nth-child(3) {
    top: 22px;
    transform: rotate(-0.8deg);
    opacity: 0.45;
}

html.dark-mode .project-folder-cover__papers span {
    background: hsla(var(--project-hue), 20%, 50%, 0.2);
    border-color: hsla(var(--project-hue), 18%, 40%, 0.25);
}

.project-folder-cover__glyph {
    position: relative;
    z-index: 1;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 46px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    color: hsl(var(--project-hue), 38%, 36%);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
    margin-top: 18px;
}

html.dark-mode .project-folder-cover__glyph {
    color: hsl(var(--project-hue), 28%, 78%);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

/* “New project” placeholder — paper beige like library book faces */
.library-book-cover.project-folder-cover--cta {
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 12px;
    background: linear-gradient(165deg, #fdfcfa 0%, #ebe4d8 55%, #e2d9cc 100%);
    border: 1px dashed var(--border);
    box-shadow:
        0 2px 4px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

html.dark-mode .library-book-cover.project-folder-cover--cta {
    background: linear-gradient(165deg, #21262d 0%, #161b22 100%);
    border-color: var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.project-folder-cover__cta-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.35);
    color: var(--text-muted);
    border: 1px solid rgba(30, 42, 59, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

html.dark-mode .project-folder-cover__cta-ring {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-color: var(--border);
    box-shadow: none;
}

.project-folder-cover__cta-ring svg {
    width: 26px;
    height: 26px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.project-folder-cover__cta-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.library-book-card:has(.project-folder-cover:not(.project-folder-cover--cta)):hover .project-folder-cover {
    transform: translateY(-3px);
    box-shadow:
        0 4px 8px rgba(15, 23, 42, 0.08),
        0 14px 32px hsla(var(--project-hue), 45%, 50%, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

html.dark-mode .library-book-card:has(.project-folder-cover:not(.project-folder-cover--cta)):hover .project-folder-cover {
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
