/**
 * Grantha Nocturne Edition & Publisher Switcher
 */

.grantha-editions-wrapper {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.grantha-editions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.grantha-editions-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.925rem;
    font-weight: 600;
    color: #1f2937;
}

.grantha-editions-icon {
    color: #b45309;
    flex-shrink: 0;
}

.grantha-editions-work-meta {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 400;
}

.grantha-editions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.grantha-edition-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    background: #f9fafb;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    position: relative;
}

.grantha-edition-card:hover {
    border-color: #d97706;
    background: #fffbeb;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    text-decoration: none;
}

.grantha-edition-card.is-active {
    border-color: #d97706;
    background: #fffdf5;
    box-shadow: 0 0 0 1px #d97706;
}

.grantha-edition-card.is-out-of-stock {
    opacity: 0.65;
}

.grantha-edition-info {
    margin-bottom: 0.5rem;
}

.grantha-edition-publisher {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.grantha-edition-format {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.grantha-badge-format {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: #e5e7eb;
    color: #374151;
    border-radius: 4px;
}

.grantha-badge-current {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
}

.grantha-edition-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed #e5e7eb;
}

.grantha-edition-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: #047857;
}

.grantha-edition-stock .stock-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.grantha-edition-stock .stock-badge.in-stock {
    background: #ecfdf5;
    color: #065f46;
}

.grantha-edition-stock .stock-badge.out-of-stock {
    background: #fef2f2;
    color: #991b1b;
}

/* Canonical Book Directory (/books) */
.canonical-directory-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.directory-hero {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px 30px;
    background: radial-gradient(circle at 50% 20%, rgba(217, 119, 6, 0.08) 0%, transparent 70%);
    border-radius: 16px;
}

.directory-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    border: 1px solid rgba(217, 119, 6, 0.25);
}

.directory-pill-badge .badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d97706;
}

.directory-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.directory-subtitle {
    font-size: 1.05rem;
    color: #6b7280;
    max-width: 650px;
    margin: 0 auto 30px;
    line-height: 1.6;
}

.directory-search-wrapper {
    max-width: 620px;
    margin: 0 auto;
}

.directory-search-form .search-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.directory-search-form .search-icon {
    position: absolute;
    left: 16px;
    color: #9ca3af;
    pointer-events: none;
}

.directory-search-input {
    width: 100%;
    height: 52px;
    padding: 0 45px 0 48px;
    border-radius: 12px;
    border: 1.5px solid #e5e7eb;
    background: #ffffff;
    color: #111827;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.directory-search-input:focus {
    border-color: #d97706;
    outline: none;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.search-clear-btn {
    position: absolute;
    right: 16px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 16px;
}

.directory-search-hint {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    color: #6b7280;
    margin-top: 10px;
    padding: 0 6px;
}

/* Canonical Books Grid */
.canonical-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.canonical-book-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.canonical-book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: #d97706;
}

.card-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.rank-badge {
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
}

.rank-badge.trending-badge {
    background: #fef3c7;
    color: #92400e;
}

.rank-badge.classic-badge {
    background: #f3f4f6;
    color: #4b5563;
}

.stock-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
}

.stock-pill.stock-in {
    background: #ecfdf5;
    color: #065f46;
}

.stock-pill.stock-out {
    background: #fef2f2;
    color: #991b1b;
}

.canonical-book-card .title-si {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.35;
}

.canonical-book-card .title-si a {
    color: #111827;
    text-decoration: none;
}

.canonical-book-card .title-si a:hover {
    color: #d97706;
}

.canonical-book-card .title-en {
    font-size: 0.88rem;
    color: #6b7280;
    margin-bottom: 10px;
    font-style: italic;
}

.book-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.meta-tag {
    font-size: 11.5px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    padding: 2px 8px;
    border-radius: 6px;
    color: #4b5563;
}

.rating-summary-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.rating-summary-row .score {
    font-weight: 700;
    color: #111827;
}

.rating-summary-row .count {
    color: #6b7280;
    font-size: 12px;
}

.rating-summary-row .no-reviews {
    color: #9ca3af;
    font-size: 12px;
    font-style: italic;
}

.book-synopsis {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
    margin: 0 0 16px;
}

.editions-preview-block {
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px dashed #e5e7eb;
}

.editions-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
}

.editions-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.edition-mini-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    font-size: 12px;
    border-radius: 6px;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #1f2937;
    transition: all 0.15s ease;
}

.edition-mini-pill:hover {
    border-color: #d97706;
    background: #fffbeb;
    text-decoration: none;
}

.edition-mini-pill.out-of-stock {
    opacity: 0.6;
}

.edition-price {
    font-weight: 600;
    color: #047857;
}

.edition-more {
    font-size: 11.5px;
    color: #6b7280;
}

.card-footer .btn-view-editions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: #111827;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s ease;
}

.card-footer .btn-view-editions:hover {
    background: #d97706;
    text-decoration: none;
}

.directory-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #f9fafb;
    border-radius: 16px;
    border: 1px dashed #d1d5db;
}

.directory-empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}



/* ---------------------------------------------------------------------------
   Directory: search, genre tiles, facets and autocomplete.
   The catalog is far too large to browse, so /books leads with search and genre
   and only shows a grid once the reader has narrowed it.
   --------------------------------------------------------------------------- */

.directory-hero {
    margin-bottom: 32px;
}

.directory-subtitle {
    max-width: 62ch;
    color: #6b7280;
    margin: 8px 0 20px;
}

.directory-search-field {
    position: relative;
    display: flex;
    gap: 8px;
    max-width: 720px;
}

#directory-search-input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
}

#directory-search-input:focus {
    outline: none;
    border-color: #d97706;
}

.directory-search-btn {
    padding: 14px 22px;
    border: none;
    border-radius: 12px;
    background: #d97706;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.directory-search-btn:hover {
    background: #b45309;
}

.search-clear-btn {
    position: absolute;
    right: 108px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    text-decoration: none;
    font-size: 18px;
}

.directory-search-hint {
    margin: 10px 0 0;
    color: #6b7280;
    font-size: 14px;
}

/* Autocomplete panel */
.directory-suggest {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    overflow: hidden;
    max-height: 420px;
    overflow-y: auto;
}

.suggest-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    color: #111827;
    text-decoration: none;
    border-bottom: 1px solid #f3f4f6;
}

.suggest-row:last-child {
    border-bottom: none;
}

.suggest-row:hover,
.suggest-row.is-active {
    background: #fef3c7;
    text-decoration: none;
}

.suggest-row--author .suggest-title::before {
    content: '✍ ';
    color: #d97706;
}

.suggest-title {
    font-weight: 600;
}

.suggest-meta {
    color: #6b7280;
    font-size: 13px;
}

/* Genre tiles */
.section-heading {
    font-size: 20px;
    margin: 0 0 16px;
}

.genre-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 40px;
}

.genre-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #fff;
    color: #111827;
    text-decoration: none;
    transition: border-color .15s, transform .15s;
}

.genre-tile:hover {
    border-color: #d97706;
    transform: translateY(-2px);
    text-decoration: none;
}

.genre-name {
    font-weight: 700;
}

.genre-count {
    color: #6b7280;
    font-size: 13px;
}

/* Results bar, facets, load more */
.directory-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.active-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    text-decoration: none;
    font-size: 14px;
}

.filter-chip:hover {
    background: #fde68a;
    text-decoration: none;
}

.chip-x {
    opacity: .6;
}

.result-count {
    color: #6b7280;
    font-size: 14px;
}

.directory-sort select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.directory-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: start;
}

.directory-facets {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 16px;
    background: #fff;
    position: sticky;
    top: 16px;
}

.facet-heading {
    font-size: 15px;
    margin: 0 0 10px;
}

.facet-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 460px;
    overflow-y: auto;
}

.facet-list a {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
}

.facet-list a:hover,
.facet-list a.is-active {
    color: #d97706;
    text-decoration: none;
}

.facet-count {
    color: #9ca3af;
}

.directory-load-more {
    display: flex;
    justify-content: center;
    margin: 28px 0 8px;
}

.btn-load-more {
    padding: 12px 28px;
    border: 1px solid #d97706;
    border-radius: 12px;
    background: #fff;
    color: #d97706;
    font-weight: 700;
    text-decoration: none;
}

.btn-load-more:hover {
    background: #fffbeb;
    text-decoration: none;
}

.btn-load-more.is-loading {
    opacity: .6;
    pointer-events: none;
}

@media (max-width: 860px) {
    .directory-layout {
        grid-template-columns: 1fr;
    }

    .directory-facets {
        position: static;
    }

    .search-clear-btn {
        display: none;
    }
}

/* ---------------------------------------------------------------------------
   Other translations of the same original work.

   Deliberately quieter than the editions band above it: editions are a buying
   choice, translations are a browsing one. Same shape, no accent border, no
   selected state.
   --------------------------------------------------------------------------- */

.grantha-translations-wrapper {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    background: #fdfcfa;
    border: 1px solid #ece7df;
    border-radius: 12px;
}

.grantha-translations-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f3f0ea;
}

.grantha-translations-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.925rem;
    font-weight: 600;
    color: #1f2937;
}

.grantha-translations-icon {
    color: #7c6a52;
    flex-shrink: 0;
}

.grantha-translations-work-meta {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 400;
}

.grantha-translations-note {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #6b7280;
}

.grantha-translations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.7rem;
}

.grantha-translation-card {
    display: block;
    padding: 0.7rem 0.85rem;
    border: 1px solid #ece7df;
    border-radius: 8px;
    background: #ffffff;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

a.grantha-translation-card:hover {
    border-color: #d1c4ad;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    text-decoration: none;
}

.grantha-translation-card.is-unavailable {
    opacity: 0.65;
    cursor: default;
}

.grantha-translation-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    color: #1f2937;
    margin-bottom: 0.3rem;
}

.grantha-translation-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.grantha-translation-rating {
    color: #b45309;
    font-weight: 600;
}

.grantha-translation-rating.is-unrated {
    color: #9ca3af;
    font-weight: 400;
}

.grantha-translation-reviews {
    font-weight: 400;
    color: #9ca3af;
}

.grantha-translation-oos {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: #9ca3af;
}


/**
 * Directory card cover.
 *
 * The card computed a `primary_image` from the day it was written and no template ever
 * printed it, so /books has always been a wall of text. The resolver now answers with the
 * publisher's photograph for works nobody has photographed, which is nearly all of them,
 * so there is finally something worth printing.
 */
.canonical-book-card .card-cover {
    display: block;
    float: left;
    width: 72px;
    margin: 0 0.85rem 0.5rem 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.canonical-book-card .card-cover img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
}

.canonical-book-card .book-meta-row,
.canonical-book-card .rating-summary-row {
    clear: both;
}

.grantha-editions-work-link {
    margin-left: 0.5rem;
    color: #b45309;
    text-decoration: none;
    white-space: nowrap;
}

.grantha-editions-work-link:hover {
    text-decoration: underline;
}

/* ---- Unified review feed ---- */

/**
 * The chip is per row, not a section header. The feed is chronological and its three
 * sources interleave, so grouping them would bury the work's newest review under forty
 * old edition reviews.
 */
.review-chip {
    display: inline-block;
    margin: 0 0 0.4rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    line-height: 1.5;
    text-decoration: none;
}

.review-chip--edition {
    background: #fff7ed;
    color: #b45309;
    border: 1px solid #fed7aa;
}

.review-chip--edition:hover {
    background: #ffedd5;
    color: #92400e;
}

.review-chip--work {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.review-owns {
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: #065f46;
    font-size: 0.68rem;
}

.unified-reviews__empty {
    color: #6b7280;
    font-size: 0.9rem;
}

.unified-reviews__pager {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.unified-reviews__pager a,
.unified-reviews__pager .is-current {
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    color: #4b5563;
    background: #f3f4f6;
}

.unified-reviews__pager .is-current {
    background: #b45309;
    color: #fff;
}

/* The feed renders on a product page as well as a work page, so its styles live in
   the stylesheet both load rather than in book-page.css, which only the work page pulls. */
