/* ========================================
   BOOK PAGE
   Extracted from legacy site.css as an additive page stylesheet.
   Load after site.css, lists.css, and members.css.
======================================== */

/* ---- legacy site.css lines 2389-2399 ---- */
/* ========================================
   BOOK PAGE EXTENSIONS
======================================== */

.page-book #about,
.page-book #series-reading-order,
.page-book #genres-themes,
.page-book #editions {
    scroll-margin-top: 100px;
}


/* ---- legacy site.css lines 5671-5936 ---- */
/* ========================================
   BOOK HERO
======================================== */

.book-hero-inner {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: var(--s-6);
    align-items: start;
}

.book-hero-cover {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.book-hero-cover img,
.book-cover-trigger img {
    width: 88px;
}

.book-hero-main {
    display: grid;
    gap: var(--s-5);
    min-width: 0;
}

.book-hero-content {
    min-width: 0;
    --stack-space: var(--s-4);
}

.book-hero-content h1 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    line-height: 1.12;
    letter-spacing: -0.02em;
    font-weight: 800;
    margin: 0;
}

.book-byline {
    color: var(--text-muted-inverse);
    font-size: 0.95rem;
    line-height: 1.4;
}

.book-byline a {
    color: var(--white);
    text-decoration: none;
}

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

.book-hero-details {
    display: grid;
    grid-template-columns: auto minmax(180px, auto) auto auto;
    justify-content: start;
    align-items: start;
    gap: var(--s-8);
    max-width: var(--measure-content);
}

.book-hero-detail {
    position: relative;
    display: grid;
    gap: 2px;
    min-width: 0;
    padding-right: var(--s-6);
}

.book-hero-detail:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 18%;
    bottom: 18%;
    width: 1px;
    background: var(--white-16);
}

.book-hero-detail-label,
.book-hero-series-label {
    font-size: 0.72rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--white-62);
}

.book-hero-detail-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--s-2);
    font-size: 0.95rem;
    line-height: 1.4;
    font-weight: 600;
    color: var(--white-90);
}

.book-hero-detail-value--truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-hero-detail-rating .stars {
    background: var(--white-22);
    transform: translateY(4px);
}

.book-hero-detail-rating .stars::before {
    background: var(--white-90);
}

.book-hero-detail-subvalue {
    margin-top: 2px;
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--white-72);
}

.book-hero-buy,
.book-hero-series,
.book-hero-organize {
    width: 100%;
    max-width: var(--measure-compact);
}

.buy-btn-primary.buy-btn-primary--hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: var(--s-5) var(--s-6);
    border-radius: 12px;
    background: var(--white);
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.buy-btn-primary.buy-btn-primary--hero span {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-left: var(--s-4);
    white-space: nowrap;
}

.book-hero-series {
    display: grid;
    gap: var(--s-4);
}

.book-hero-series-item {
    display: grid;
    gap: 2px;
}

.book-hero-series-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--s-2);
    font-size: 0.95rem;
    line-height: 1.4;
    font-weight: 600;
    color: var(--white-90);
}

.book-hero-series-value a {
    color: var(--white);
    text-decoration: none;
    overflow-wrap: break-word;
}

.book-hero-series-value a:hover {
    text-decoration: underline;
}

.book-hero-series-num {
    font-size: 0.84rem;
    line-height: 1.2;
    color: var(--white-72);
    white-space: nowrap;
}

.book-hero-cover-note {
    display: block;
    margin-top: var(--s-1);
    font-size: 0.72rem;
    line-height: 1.2;
    color: var(--white-62);
    text-align: center;
}

@media (hover: hover) and (pointer: fine) {
    .book-hero-cover-note {
        display: none;
    }
}

@media (max-width: 767px) {
    .book-hero-main {
        display: contents;
    }

    .book-hero-content {
        grid-column: 2;
        min-width: 0;
    }

    .book-hero-details {
        grid-template-columns: 1fr 1.4fr;
        gap: var(--s-4) var(--s-6);
    }

    .book-hero-detail::after {
        display: none;
    }

    .book-hero-organize,
    .book-hero-buy,
    .book-hero-series {
        grid-column: 1 / -1;
        max-width: none;
    }
}

@media (min-width: 768px) {
    .book-hero-inner {
        grid-template-columns: 126px minmax(0, 1fr);
        gap: var(--s-10);
    }

    .book-hero-cover img,
    .book-cover-trigger img {
        width: 126px;
    }

    .book-hero .book-hero-detail-value--truncate {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }
}

@media (min-width: 992px) {
    .book-hero-inner {
        grid-template-columns: 180px minmax(0, var(--measure-content));
        gap: var(--s-12);
    }

    .book-hero-cover img,
    .book-cover-trigger img {
        width: 180px;
    }
}


/* ---- legacy site.css lines 2813-2912 ---- */
/* ========================================
   BOOK HERO ORGANIZE
======================================== */

.book-hero-organize {
    width: 100%;
    max-width: var(--measure-compact);

    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--white-22);
    border-radius: 12px;
    background: var(--white);
    color: var(--text);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.book-hero-organize .book-organize-label {
    display: block;
    margin-bottom: var(--s-2);

    color: var(--accent);
    font-size: 0.68rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.book-hero-organize .organize-rail {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;

    width: 100%;
    min-width: 0;
}

.book-hero-organize .organize-segment {
    display: flex;
    align-items: center;
    gap: 3px;

    padding: 0;
    border: 0;
    background: transparent;
    min-height: 0;
}

.book-hero-organize .organize-segment + .organize-segment::before {
    display: none;
}

.book-hero-organize .organize-btn {
    width: 26px;
    height: 26px;
    min-height: 26px;
    padding: 0;

    border-radius: 999px;
    font-size: 0.78rem;
    line-height: 1;
}

.book-hero-organize .member-rating {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;

    margin-left: 2px;
    min-width: 0;
}

.book-hero-organize .star {
    width: 17px;
    height: 17px;
    padding: 0;

    font-size: 15px;
    line-height: 1;
}

@media (max-width: 767px) {

    .book-hero-organize {
        max-width: none;
        padding: var(--s-3);
    }

    .book-hero-organize .organize-rail {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .book-hero-organize .organize-rail::-webkit-scrollbar {
        display: none;
    }
}


/* ---- legacy site.css lines 2913-3205 ---- */
/* ========================================
   BOOK TRACK CTA (LOGGED OUT)
======================================== */

.book-cta-track {
    margin-top: var(--s-5);
    margin-bottom: var(--section-gap-lg)
}

.book-cta-track-inner {
    display: grid;
    gap: var(--s-4);
    padding: var(--s-5) var(--s-6);

    border: 1px dashed var(--border);
    border-radius: 12px;

    background: var(--surface-subtle);
}

.book-cta-track-label {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent);
}

.book-cta-track-copy p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--muted);
}

.book-cta-track-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 40px;
    padding: 0 var(--s-5);

    border-radius: 10px;
    border: 1px solid var(--accent);

    background: var(--accent);
    color: var(--white);

    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;

    transition:
        background-color 0.18s ease,
        border-color 0.18s ease;
}

.book-cta-track-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    text-decoration: none;
}

/* Desktop alignment with hero rhythm */
@media (min-width: 768px) {
    .book-cta-track-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }
}
/* Detail strip */

.book-detail-strip {
    padding-top: var(--s-6);
    padding-bottom: var(--s-6);
}

.book-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-6) var(--s-8);
}

.book-detail-item {
    min-width: 0;
}

/* Series fit */

.series-fit-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: var(--s-6);
    background: var(--card);
    margin-top: var(--s-5);
}

.series-fit-card:first-of-type {
    margin-top: 0;
}

.series-fit-head {
    display: flex;
    justify-content: space-between;
    gap: var(--s-5);
    align-items: start;
    margin-bottom: var(--s-4);
}

.series-fit-title {
    font-size: 1rem;
    line-height: 1.3;
    font-weight: 700;
}

.series-fit-title a {
    color: var(--text);
    text-decoration: none;
}

.series-fit-title a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.series-fit-num {
    flex: 0 0 auto;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.84rem;
    white-space: nowrap;
}

.series-fit-copy {
    color: var(--text);
}

.series-fit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-5);
    margin-top: var(--s-4);
}

.series-fit-actions a {
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 600;
}

/* Editions */

.edition-group + .edition-group {
    margin-top: var(--s-8);
    padding-top: var(--s-8);
    border-top: 1px solid var(--border);
}

.edition-group h3 {
    margin: 0 0 var(--s-5);
    font-size: 1rem;
    line-height: 1.3;
}

.edition-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: var(--s-6);
    padding: var(--s-4) 0;
    border-top: 1px solid var(--black-05);
}

.edition-row:first-of-type {
    border-top: none;
    padding-top: 0;
}

.edition-main {
    min-width: 0;
}

.edition-main strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.3;
}

.edition-submeta {
    margin-top: 2px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--muted);
}

.edition-meta {
    flex: 0 0 auto;
    text-align: right;
}

.edition-isbn {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--muted);
}

/* Compact sidebar list */

.compact-book-list .book-link {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 0.92rem;
}

.compact-book-list .book-row {
    align-items: start;
}

/* Responsive */

@media (max-width: 767px) {
    .book-detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .series-fit-head,
    .edition-row {
        flex-direction: column;
    }

    .edition-meta {
        text-align: left;
    }
}

@media (min-width: 992px) {
    .book-detail-grid {
        display: grid;
        grid-template-columns: repeat(4, auto);
        justify-content: start;
        gap: var(--s-8); /* tighter control */
    }

    .book-detail-item {
        padding-right: 0;
        border-right: 1px solid var(--border);
        text-align: left;
        position: relative;
        padding-right: var(--s-6);
    }

    .book-detail-item:last-child {
        border-right: 0;
        padding-right: 0;
    }

    .book-detail-item:not(:last-child)::after {
        content: "";
        position: absolute;
        right: 0;
        top: 20%;
        bottom: 20%;
        width: 1px;
        background: var(--border);
        opacity: 0.6;
    }

    .book-detail-item .meta-label,
    .book-detail-item .meta-value {
        text-align: left;
    }
}

@media (max-width: 640px) {
    .book-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .book-action-btn {
        width: 100%;
    }

    .book-hero-badges {
        gap: var(--s-2);
    }

    .book-hero-badges span {
        font-size: 0.78rem;
    }
}

/* ---- legacy site.css lines 3206-3429 ---- */
/* ========================================
   TAP-TO-EXPAND COVER
======================================== */

.book-cover-trigger {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    display: block;
    width: 100%;
    cursor: zoom-in;
    border-radius: var(--cover-radius);
}

.book-cover-trigger img {
    display: block;
    width: 100%;
    border-radius: var(--cover-radius);
    box-shadow: var(--cover-shadow);
}

.book-cover-trigger:focus-visible,
.cover-modal-close:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* Modal shell */

.cover-modal[hidden] {
    display: none;
}

.cover-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
}

.cover-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(2px);
}

.cover-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(92vw, 420px);
    max-height: 88vh;
    margin: 6vh auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}

.cover-modal-body {
    position: relative;
    width: 100%;
    padding: 24px;
    box-sizing: border-box;
}

.cover-modal-body img {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(88vh - 48px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.cover-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cover-modal-close:hover {
    background: var(--white);
}

/* Keep this primarily mobile-driven.
   On desktop the button still works, but the UX benefit is mostly mobile. */
@media (min-width: 992px) {
    .cover-modal-dialog {
        width: min(78vw, 520px);
    }
}

@media (max-width: 420px) {
    .cover-modal-dialog {
        padding: 16px;
    }

    .cover-modal-close {
        top: 14px;
        right: 14px;
    }
}

/* ========================================
   SMART BUY MODULE
======================================== */

.book-buy {
    padding-top: var(--s-6);
}

/* PRIMARY CTA */

.buy-primary {
    margin-bottom: var(--s-5);
}

.buy-btn-primary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--s-5) var(--s-6);
    border-radius: 12px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
}

.buy-btn-primary span {
    font-size: 0.82rem;
    opacity: 0.9;
}

/* SECONDARY LINKS */

.buy-secondary {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
}

.buy-link {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: var(--s-4) var(--s-5);
    border-radius: 10px;

    background: var(--card);
    border: 1px solid var(--border);

    text-decoration: none;
    color: var(--text);
}

.buy-link:hover {
    background: var(--accent-04);
}

.buy-link:first-child {
    border-color: var(--accent-18);
    background: var(--accent-04);
}

.buy-store {
    font-weight: 600;
}

.buy-format {
    font-size: 0.8rem;
    color: var(--muted);
}

.meta-rating {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
    line-height: 1.2;
}

.meta-rating .stars {
    flex: 0 0 auto;
}

.meta-rating .star {
    width: 13px;
    height: 13px;
}

.rating-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.rating-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.meta-value--truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ---- legacy site.css lines 4737-4741 ---- */
.page-book .sidebar .meta-row {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: var(--s-4);
}


/* ---- legacy site.css lines 4971-5201 ---- */

.reading-order-note {
    max-width: 62ch;
    margin-top: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--surface-radius-sm);
    background: var(--white-10);
    border: 1px solid var(--white-16);
    color: var(--white-88);
    font-size: 0.9rem;
    line-height: 1.45;
}

.reading-order-note strong {
    color: var(--white);
    font-weight: 700;
    margin-right: 4px;
}

.reading-order-note span {
    color: var(--white-82);
}

.genre-short {
    display: none;
}

@media (max-width: 767px) {
    .genre-full {
        display: none;
    }

    .genre-short {
        display: inline;
    }
}

.book-description {
    font-size: 0.97rem;
    line-height: 1.72;
    color: var(--text);
}

.book-description br + br {
    display: block;
    content: "";
    margin-top: var(--content-gap);
}

.editions-section .section-intro {
    margin-bottom: var(--s-6);
}

.edition-cover-rail {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(132px, 150px);
    gap: var(--s-5);

    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;

    padding-bottom: var(--s-4);
}

.edition-card {
    scroll-snap-align: start;

    display: grid;
    gap: var(--s-4);

    min-width: 0;
    padding: var(--s-4);

    border: 1px solid var(--border);
    border-radius: var(--surface-radius-sm);
    background: var(--card);
}

.edition-cover {
    width: 100%;
    aspect-ratio: 2 / 3;

    display: flex;
    align-items: end;
    justify-content: center;

    overflow: hidden;
    border-radius: var(--cover-radius);
    background: var(--surface-subtle);
}

.edition-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.edition-card-body {
    display: grid;
    gap: var(--s-2);
}

.edition-card-title {
    font-size: 0.88rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--text);
}

.edition-card-meta {
    display: grid;
    gap: 2px;

    font-size: 0.76rem;
    line-height: 1.35;
    color: var(--muted);
}

.edition-badge {
    color: var(--accent);
    font-weight: 700;
}

.edition-buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 34px;
    margin-top: var(--s-2);
    padding: 0 var(--s-4);

    border-radius: var(--surface-radius-sm);
    border: 1px solid var(--accent-18);
    background: var(--accent-04);

    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
}

.edition-buy:hover {
    background: var(--accent-08);
    border-color: var(--accent-22);
    text-decoration: none;
}

/* Cover container */
.edition-cover {
    width: 100%;
    aspect-ratio: 2 / 3;

    display: flex;
    align-items: end;
    justify-content: center;

    overflow: hidden;
    border-radius: var(--cover-radius);

    /* 👇 placeholder background */
    background: var(--surface-subtle);
}

/* Image */
.edition-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;

    /* 👇 smooth fade-in */
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* When loaded */
.edition-cover-img[src] {
    opacity: 1;
}

/* Horizontal edition rail polish */
.edition-cover-rail {
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-22) transparent;
}

.edition-cover-rail::-webkit-scrollbar {
    height: 8px;
}

.edition-cover-rail::-webkit-scrollbar-track {
    background: transparent;
}

.edition-cover-rail::-webkit-scrollbar-thumb {
    background: var(--accent-18);
    border-radius: 999px;
}

.edition-cover-rail::-webkit-scrollbar-thumb:hover {
    background: var(--accent-22);
}

/* Subtle scroll hint */
.edition-group {
    position: relative;
}

@media (min-width: 992px) {
    .edition-group::after {
        width: 44px;
    }
}

.meta-title {
    display: block;
    line-height: 1.35;
}

.meta-subvalue {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--muted);
    font-weight: 500;
}

