/* Books — covers on a shelf, shared by About and /books. */

.books-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 48px 24px;
    list-style: none;
}
@media (max-width: 559px) {
    .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 20px; }
}

.book__link { display: flex; flex-direction: column; gap: 20px; color: inherit; }

/* A paperback seen from the front: the spine's crease on the left, the
   page block peeking out on the right, and a soft shadow on the shelf. */
.book__cover {
    position: relative;
    isolation: isolate;
    display: block;
    width: min(100%, 112px);
    aspect-ratio: 2 / 3;
    border-radius: 2px 3px 3px 2px;
    background: var(--surface);
    box-shadow: 0 14px 16px -14px rgb(0 0 0 / 0.45), 0 1px 2px rgb(0 0 0 / 0.08);
    transition: translate 260ms cubic-bezier(0.33, 1, 0.68, 1), box-shadow 260ms ease;
}
.book__cover img,
.book__cover .image-skeleton { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* Out of flow, so a tall picture cannot stretch the 2:3 board. */
.book__cover > :is(img, .image-skeleton, .book__blank) { position: absolute; inset: 0; }
.book__cover::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    background: linear-gradient(90deg, rgb(0 0 0 / 0.2), rgb(255 255 255 / 0.14) 2px, rgb(0 0 0 / 0.06) 5px, transparent 9px);
    pointer-events: none;
}
.book__cover::after {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    right: -5px;
    z-index: -1;
    width: 6px;
    border-radius: 0 2px 2px 0;
    background: repeating-linear-gradient(90deg, #f3eee2 0 1px, #ddd6c6 1px 2px);
}
.skeleton.book__cover::after { display: none; }
.book__link:is(:hover, :focus-visible) .book__cover {
    translate: 0 -4px;
    box-shadow: 0 20px 18px -14px rgb(0 0 0 / 0.4), 0 1px 2px rgb(0 0 0 / 0.08);
}

/* No picture on Goodreads: the title set on a plain board. */
.book__blank {
    display: flex;
    align-items: flex-end;
    padding: 12px 10px 12px 14px;
    border-radius: inherit;
    background: linear-gradient(160deg, #3b3a36, #1f1e1b);
    color: #f3eee2;
    font-size: 12px;
    line-height: 1.3;
}

.book__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.book__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
}
.book__author { color: var(--text-tertiary); font-size: 12px; line-height: 1.4; }
.book__stars { display: flex; gap: 2px; margin-top: 6px; color: var(--book-star); }
.book__stars svg { width: 12px; height: 12px; }

/* The shelf colours, used on the cards and as dots in the filter. */
:root {
    --shelf-reading: #e5730f;
    --shelf-read: #16a05a;
    --shelf-to-read: #c99400;
    --shelf-dropped: #dc2f2f;
    --book-star: #e0a400;
}
.dark {
    --shelf-reading: #ff9a45;
    --shelf-read: #3ccf6e;
    --shelf-to-read: #f2c443;
    --shelf-dropped: #f87171;
    --book-star: #f2c443;
}
[data-shelf='currently-reading'] { --shelf: var(--shelf-reading); }
[data-shelf='read'] { --shelf: var(--shelf-read); }
[data-shelf='to-read'] { --shelf: var(--shelf-to-read); }
[data-shelf='did-not-finish'] { --shelf: var(--shelf-dropped); }

.book__status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    color: var(--shelf);
    font-size: 12px;
    line-height: 1.4;
}
.book__status svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── /books ──────────────────────────────────────────────── */

.books-head { margin-top: 32px; }
.books-head h1 { font: inherit; font-size: 15px; color: var(--text-primary); }
.books-head p { margin-top: 2px; color: var(--text-tertiary); font-size: 12px; }
.books-page .books-grid { margin-top: 40px; }
.books-empty { grid-column: 1 / -1; color: var(--text-tertiary); font-size: 15px; }
/* Room for the filter to float over the last row. */
.books-page .site-footer { margin-top: 120px; }

/* The filter: one pill floating at the foot of the screen. */
.book-filter {
    position: fixed;
    left: 50%;
    bottom: max(var(--filter-bottom, 24px), env(safe-area-inset-bottom));
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 4px;
    width: min(440px, calc(100vw - 24px));
    padding: 4px;
    translate: -50% 0;
    border-radius: 999px;
    background: var(--raised);
    box-shadow: var(--popover-shadow);
    font: 13px/1.4 var(--font-sans);
    animation: book-filter-in 320ms cubic-bezier(0.33, 1, 0.68, 1) both;
}
@keyframes book-filter-in {
    from { opacity: 0; translate: -50% 12px; }
}

.book-filter button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    white-space: nowrap;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.book-filter button:hover { background: var(--surface); color: var(--text-primary); }
.book-filter button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.book-filter__rule { flex-shrink: 0; width: 1px; height: 16px; margin: 0 3px; background: var(--border-strong); }

.book-filter__menu { position: relative; min-width: 0; }
.book-filter__menu:first-child { flex: 1; }
.book-filter__menu:first-child .book-filter__options { left: 0; right: auto; }
.book-filter__toggle { width: 100%; }
.book-filter__toggle svg, .book-filter__toggle-label { flex-shrink: 0; }
.book-filter__toggle-label { color: var(--text-tertiary); }
.book-filter__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.book-filter__toggle svg { width: 12px; height: 12px; color: var(--text-tertiary); transition: rotate 160ms ease; }
.book-filter__toggle[aria-expanded='false'] svg { rotate: 180deg; }

.book-filter__options {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    display: flex;
    flex-direction: column;
    min-width: 176px;
    max-height: min(360px, 60vh);
    padding: 5px;
    overflow-y: auto;
    border-radius: var(--r-lg);
    background: var(--raised);
    box-shadow: var(--popover-shadow);
    animation: book-filter-menu 160ms ease-out both;
}
.book-filter__options[hidden] { display: none; }
.book-filter__menu-title { display: none; }
@keyframes book-filter-menu {
    from { opacity: 0; translate: 0 4px; }
}
.book-filter__options button { justify-content: space-between; width: 100%; height: 34px; border-radius: 9px; }
.book-filter__options button[aria-checked='true'] { color: var(--text-primary); }
.book-filter__options button[aria-checked='true']::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-primary);
}

/* On a phone, show values in the bar and titles inside the full-width menus. */
@media (max-width: 639px) {
    .book-filter {
        width: max-content;
        max-width: calc(100vw - 24px);
        padding: 4px 8px;
        gap: 2px;
    }
    .book-filter__rule { display: none; }
    .book-filter__menu,
    .book-filter__menu:first-child { position: static; flex: 0 1 auto; }
    .book-filter .book-filter__toggle {
        position: relative;
        height: 32px;
        padding: 0 12px;
        gap: 5px;
    }
    .book-filter__toggle-label { display: none; }
    .book-filter__value { max-width: 100%; font-size: 12px; line-height: 17px; }
    .book-filter__toggle svg { flex-shrink: 0; width: 10px; height: 10px; }
    .book-filter__menu-title { display: block; padding: 8px 14px; color: var(--text-tertiary); font-size: 12px; line-height: 18px; }
    .book-filter .book-filter__options,
    .book-filter__menu:first-child .book-filter__options { left: 0; right: 0; min-width: 0; padding: 6px; }
    .book-filter__options button { min-height: 44px; padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .book__cover, .book-filter button { transition: none; }
    .book-filter, .book-filter__options { animation: none; }
}

/* The home page's last section: more air before the Talk to me pill lands. */
#books + .page-search-slot { padding-top: 96px; min-height: 144px; }
