/* ═══════════════════════════════════════════════
   Library lobby — the shelf of finished books

   Loaded after create.css, which owns the palette, .panel, .field, .ghost-btn and
   .primary-btn. Everything here is additive: the shelf, its cards, and the two sheets.
   ═══════════════════════════════════════════════ */

.studio { max-width: 1120px; }

.lobby-nav {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
}

.primary-btn.compact,
.ghost-btn.compact {
    width: auto;
    padding: 9px 16px;
    font-size: 14px;
}

/* .primary-btn is written for <button>; the lobby also hangs it on links. */
a.primary-btn {
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

/* ─────────── Status & empty ─────────── */
.shelf-status {
    margin: 0 0 18px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
}
.shelf-status[hidden] { display: none; }
.shelf-status.error { color: var(--coral-dark); }

.shelf-empty { text-align: center; }
.shelf-empty h2 { margin-bottom: 6px; }
.shelf-empty .panel-note { max-width: 420px; margin: 0 auto 18px; }
.shelf-empty .primary-btn { width: auto; padding: 11px 26px; }

/* ─────────── The shelf ─────────── */
.shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 20px;
}

.book {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 18px;
    background: var(--card);
    box-shadow: 0 10px 30px -20px var(--shadow);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.book:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px -20px var(--shadow);
}

/* Every cover occupies the same box no matter what was uploaded — a fixed height, the card's
   full width, and cover-fitting so a tall portrait scan and a wide landscape one both fill it
   instead of sitting letterboxed in the middle. The shelf reads as one even row of books; the
   drawing is still shown uncropped inside the player, which is where it matters. */
.book-cover {
    position: relative;
    /* One number, three ways, because .book is a flex column: a bare height is only a
       suggestion there and a tall blurb would squeeze the cover of that one card. */
    height: 288px;
    min-height: 288px;
    flex: 0 0 288px;
    overflow: hidden;
    background: var(--cream);
    border-bottom: 2px solid var(--line);
}

/* Absolutely positioned on purpose. Out of flow, the picture's own width and height cannot
   feed back into the card's layout at all — a 4000×600 banner and a 300×900 portrait both
   just fill this box. object-fit does the rest. */
.book-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* top-biased, because the interesting part of a book cover is rarely its bottom edge */
    object-fit: cover;
    object-position: center top;
    aspect-ratio: auto;
    display: block;
}
.book-cover .no-cover {
    display: grid;
    place-items: center;
    height: 100%;
    color: var(--muted);
    font-family: var(--font-title);
    font-size: 15px;
}

.book-pages {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 4px 11px;
    border-radius: 999px;
    background: rgba(74, 68, 65, 0.78);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.book-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 16px 18px 18px;
}
.book-body h2 {
    margin: 0;
    font-family: var(--font-title);
    font-size: 19px;
    font-weight: 600;
    line-height: 1.25;
}
.book-by {
    margin: 3px 0 0;
    color: var(--ink-soft);
    font-size: 13px;
}

.book-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 11px 0 0;
}
.chip {
    padding: 3px 10px;
    border: 2px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Three lines of page one, so every card in a row is the same height. */
.book-blurb {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 11px 0 0;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.6;
}

.book-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 16px;
}
.book-actions .primary-btn {
    flex: 1;
    width: auto;
    padding: 10px 14px;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
}
.book-actions .ghost-btn,
.book-actions .danger-btn { padding: 9px 14px; font-size: 13.5px; }

.danger-btn {
    flex-shrink: 0;
    border: 2px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.danger-btn:hover {
    border-color: var(--coral);
    background: var(--coral);
    color: #fff;
}

.book.busy { opacity: 0.55; pointer-events: none; }

/* ─────────── Sheets ─────────── */
.sheet {
    width: min(680px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: none;
    border-radius: 20px;
    background: var(--card);
    color: var(--ink);
    font-family: var(--font-body);
    box-shadow: 0 30px 70px -30px rgba(90, 60, 30, 0.5);
}
.sheet.narrow { width: min(420px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(74, 68, 65, 0.42); }
.sheet form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }

.sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 22px 0;
}
.sheet-head h2 {
    margin: 0 0 4px;
    font-family: var(--font-title);
    font-size: 21px;
    font-weight: 600;
}
.sheet-head .panel-note { margin: 0; }

.sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 22px;
}
.sheet-subhead {
    margin: 20px 0 10px;
    font-family: var(--font-title);
    font-size: 17px;
    font-weight: 600;
}

.edit-pages { display: grid; gap: 12px; }
.edit-page {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    border: 2px solid var(--line);
    border-radius: 14px;
}
.edit-page img {
    width: 54px;
    height: 54px;
    flex-shrink: 0;
    border-radius: 10px;
    object-fit: cover;
    background: var(--cream);
}
.edit-page .field { flex: 1; }
.edit-page textarea {
    width: 100%;
    min-height: 76px;
    resize: vertical;
}

.sheet-foot {
    padding: 14px 22px 20px;
    border-top: 2px solid var(--line);
}
.sheet-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.sheet-actions .primary-btn { width: auto; padding: 11px 24px; }
.sheet-foot .warn { margin: 0 0 12px; }

/* ─────────── Responsive ─────────── */
@media (max-width: 700px) {
    .studio-header { flex-direction: column; }
    .shelf { grid-template-columns: 1fr; }
    /* One card per row here, so the cover is as wide as the screen — a little shorter keeps
       it from pushing the title and buttons below the fold. All three properties again, or
       the min-height above wins and nothing changes. */
    .book-cover { height: 245px; min-height: 245px; flex: 0 0 245px; }
    .sheet-actions { flex-direction: column-reverse; }
    .sheet-actions button { width: 100%; }
}
