/* ==========================================================================
   books.css — layout only, deliberately light on decoration.
   Reads quark2's design tokens (--q2-*, --pico-*) where they exist so the
   book pages stay in sync with whatever accent color / light-dark mode /
   fonts the site already has configured, and falls back to sane defaults
   for use outside quark2.
   ========================================================================== */

/* ---------- List page ---------- */

.section-label {
    font-family: var(--pico-font-family-display, inherit);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .85rem;
    color: var(--q2-muted, #6b7280);
    margin: 2.5rem 0 1rem;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.book-grid--featured {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.book-card {
    display: flex;
    flex-direction: column;
    border-radius: var(--q2-radius, 8px);
    overflow: hidden;
    box-shadow: var(--q2-shadow-sm, 0 1px 3px rgba(0, 0, 0, .1));
    background: var(--q2-card-bg, var(--pico-card-background-color, #fff));
}

.book-grid--featured .book-card {
    flex-direction: row;
    box-shadow: var(--q2-shadow-md, 0 4px 12px rgba(0, 0, 0, .12));
}

.book-card__cover {
    display: block;
    flex-shrink: 0;
    background: var(--q2-muted-bg, #f3f4f6);
}

.book-card__cover img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.book-grid--featured .book-card__cover {
    width: 40%;
    max-width: 220px;
}

.book-card__cover--placeholder {
    display: block;
    aspect-ratio: 3 / 4.4;
}

.book-card__body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.book-card__title {
    margin: 0;
    font-size: 1.1rem;
}

.book-card__author {
    margin: 0;
    color: var(--q2-muted, #6b7280);
    font-size: .9rem;
}

.book-card__summary {
    margin: .25rem 0 0;
    font-size: .95rem;
    line-height: 1.5;
}

.book-card__link {
    margin-top: auto;
    font-size: .9rem;
    color: var(--q2-link, var(--pico-primary, #242424));
}

/* ---------- Book section pages (TOC / preface / sample / reviews) ---------- */

.book-context {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--q2-border, var(--pico-muted-border-color, #e5e7eb));
}

.book-context__cover {
    flex-shrink: 0;
    display: block;
}

.book-context__cover img {
    display: block;
    width: 60px;
    height: auto;
    border-radius: calc(var(--q2-radius, 8px) / 2);
    box-shadow: var(--q2-shadow-sm, 0 1px 3px rgba(0, 0, 0, .1));
}

.book-context__eyebrow {
    margin: 0;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--q2-muted, #6b7280);
}

.book-context__title {
    margin: .15rem 0;
    font-size: 1.1rem;
}

.book-context__title a {
    color: inherit;
    text-decoration: none;
}

.book-context__author {
    margin: 0 0 .5rem;
    font-size: .9rem;
    color: var(--q2-muted, #6b7280);
}

.book-context__back {
    font-size: .9rem;
    color: var(--q2-link, var(--pico-primary, #242424));
}

/* Sidebar entry for the page you're already on: same position as the
   other links, visually distinct, and deliberately not a link. */
.book-sidebar-nav__current {
    display: inline-block;
    font-weight: 600;
    color: var(--pico-color, inherit);
    border-left: 2px solid var(--q2-accent, var(--pico-primary, #242424));
    padding-left: .6rem;
    margin-left: -.65rem;
}

/* ---------- Individual book page ---------- */

.book-header {
    display: grid;
    grid-template-columns: minmax(180px, 280px) 1fr;
    gap: 2rem;
    align-items: start;
    margin-bottom: 2.5rem;
}

.book-header__cover img {
    width: 100%;
    height: auto;
    border-radius: var(--q2-radius, 8px);
    box-shadow: var(--q2-shadow-md, 0 4px 12px rgba(0, 0, 0, .12));
}

.book-header__title {
    margin: 0 0 .25rem;
}

.book-header__subtitle {
    margin: 0 0 1.25rem;
    font-style: italic;
    color: var(--q2-muted, #6b7280);
}

/* Regularly organized metadata: a two-column definition list, label | value */
.book-meta-table {
    margin: 0;
}

.book-meta-row {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 1rem;
    padding: .4rem 0;
    border-bottom: 1px solid var(--q2-border, var(--pico-muted-border-color, #e5e7eb));
}

.book-meta-row dt {
    font-weight: 600;
    color: var(--q2-muted, #6b7280);
}

.book-meta-row dd {
    margin: 0;
}

/* Body: content + sidebar */

.book-body {
    display: grid;
    grid-template-columns: 1fr minmax(220px, 280px);
    gap: 3rem;
    align-items: start;
}

.book-body__sidebar {
    position: sticky;
    top: 1.5rem;
    border-left: 1px solid var(--q2-border, var(--pico-muted-border-color, #e5e7eb));
    padding-left: 1.5rem;
}

.sidebar-heading {
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--q2-muted, #6b7280);
    margin: 0 0 .75rem;
}

.book-sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.book-sidebar-nav a {
    color: var(--q2-link, var(--pico-primary, #242424));
    text-decoration: none;
}

.book-sidebar-nav a:hover {
    text-decoration: underline;
}

/* Prev / next pager, same idea as quark2's item-template pager */

.book-pager {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--q2-border, var(--pico-muted-border-color, #e5e7eb));
}

.book-pager__prev,
.book-pager__next {
    display: flex;
    align-items: center;
    gap: .5rem;
    max-width: 45%;
    text-decoration: none;
    color: var(--pico-color, inherit);
}

.book-pager__next {
    margin-left: auto;
    text-align: right;
}

.book-pager__label {
    font-size: .95rem;
}

.book-pager .is-disabled {
    color: var(--q2-muted, #9ca3af);
    pointer-events: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
    .book-header,
    .book-body {
        grid-template-columns: 1fr;
    }

    .book-body__sidebar {
        position: static;
        border-left: none;
        border-top: 1px solid var(--q2-border, var(--pico-muted-border-color, #e5e7eb));
        padding-left: 0;
        padding-top: 1.5rem;
    }

    .book-grid--featured .book-card {
        flex-direction: column;
    }

    .book-grid--featured .book-card__cover {
        width: 100%;
        max-width: none;
    }
}

.book-blurb {
    margin: 0 0 1.75rem;
    padding: .9rem 1.1rem;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--pico-color, inherit);
    background: var(--q2-muted-bg, #f3f4f6);
    border-left: 3px solid var(--q2-accent, var(--pico-primary, #242424));
    border-radius: 0 var(--q2-radius, 8px) var(--q2-radius, 8px) 0;
}
