/* Minimal Bookshelf Stylesheet with vertical book spines & tooltips */

:root {
    --star-color: #ffb300;
    --box-bg: #f2f4f6;
    --box-border: #979b9d;
    --border-radius: 0.2rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --star-color: #ffc107;
        --box-bg: #252521;
        --box-border: #979b9d;
    }
}

.books-container {
    max-width: 65em;
    margin: 0 auto;
    padding: 1rem 0;
}

/* Controls Layout */
.books-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
    border-bottom: 1px dotted var(--alt);
    padding-bottom: 1rem;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.books-search-bar {
    margin-left: auto;
}

.books-search-bar input[type="search"] {
    width: 250px;
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
}

@media (max-width: 45em) {
    .books-search-bar {
        margin-left: 0;
        width: 100%;
    }
    .books-search-bar input[type="search"] {
        width: 100%;
    }
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.25;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: var(--link) !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: color 0.15s;
}

.filter-btn:hover {
    color: var(--link) !important;
    text-decoration: underline !important;
    text-decoration-style: dotted !important;
    background: none !important;
    box-shadow: none !important;
}

.filter-btn:active {
    box-shadow: none !important;
}

/* Stats Summary */
.books-stats-summary {
    font-size: 0.9rem;
    margin-bottom: 2rem;
    opacity: 0.8;
}

/* The Bookshelf Row */
.book-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end; /* Spines stand on the shelf */
    gap: 6px;
    padding: 0;
    margin: 0 0 3.5rem 0;
    list-style: none;
    background: transparent;
}

.book-grid > li {
    display: block;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Vertical Book Spine */
.book-item {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-bottom: none;
    border-radius: 3px 3px 0 0;
    padding: 12px 6px;
    min-width: 32px;
    text-decoration: none !important;
    transition: transform 0.2s ease, filter 0.2s ease;
    position: relative;
    cursor: pointer;
    
    /* Rotate text vertically */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    text-align: left;
    
    /* Shadow representing depth on the shelf */
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
}

.book-item:hover {
    transform: translateY(-8px);
    filter: brightness(1.15);
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.25);
}

.book-title {
    font-size: 0.85rem;
    font-weight: bold;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 140px;
}

.book-author {
    font-size: 0.7rem;
    font-style: italic;
    opacity: 0.85;
    margin-top: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-rating-badge {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--star-color);
    margin-top: auto;
    padding-top: 5px;
}

/* Commentary Dot Indicator on the spine */
.comment-dot {
    position: absolute;
    bottom: 8px;
    right: 50%;
    transform: translateX(50%);
    width: 6px;
    height: 6px;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Pure CSS Hover Details Popup (Tooltip) */
.book-details-popup {
    display: none;
    position: absolute;
    bottom: 100%; /* Position above the book spine */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--box-bg);
    color: var(--primary) !important;
    border: 1px solid var(--box-border);
    border-radius: var(--border-radius);
    padding: 0.8rem;
    box-shadow: 0 2px 4px -2px var(--primary);
    z-index: 100;
    width: 200px;
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: left;
    margin-bottom: 10px; /* Space between spine top and popup */
    
    /* Reset vertical text styles to horizontal layout */
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    white-space: normal;
    
    /* Prevent interaction interference on hover */
    pointer-events: none;
}

/* Tooltip Arrow pointing down - outer border */
.book-details-popup::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--box-border) transparent transparent transparent;
    z-index: 99;
}

/* Tooltip Arrow pointing down - inner background fill */
.book-details-popup::after {
    content: "";
    position: absolute;
    top: calc(100% - 1px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--box-bg) transparent transparent transparent;
    z-index: 101;
}

/* Show popup on hover */
.book-item:hover .book-details-popup {
    display: block;
}

/* Details Popup Semantic Styling */
.book-details-popup h4.popup-title {
    margin: 0 0 0.2rem 0;
    font-size: 0.9rem;
    font-weight: bold;
    font-family: 'georgia', serif;
    line-height: 1.2;
}

.book-details-popup p.popup-author {
    margin: 0 0 0.4rem 0;
    font-size: 0.8rem;
    font-style: italic;
    opacity: 0.8;
    line-height: 1.2;
}

.book-details-popup dl.popup-meta {
    margin: 0;
    padding-top: 0.4rem;
    border-top: 1px dotted var(--box-border);
    font-size: 0.75rem;
    font-family: var(--main-font);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.6rem;
    line-height: 1.3;
}

.book-details-popup dl.popup-meta dt {
    font-weight: bold;
    margin: 0;
}

.book-details-popup dl.popup-meta dd {
    margin: 0;
    text-transform: capitalize;
}

.book-details-popup dl.popup-meta dd.rating-val {
    color: var(--star-color);
    font-weight: bold;
}

.book-details-popup p.popup-commentary {
    margin: 0.4rem 0 0 0;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--link);
}

/* Detail Page Styles */
.back-link-wrapper {
    margin-bottom: 1.5rem;
}

.back-link {
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--link);
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.book-detail-container {
    margin-top: 1rem;
}

.book-detail-title {
    margin-top: 0;
    margin-bottom: 0.3rem;
}

.book-detail-author {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-style: italic;
    opacity: 0.95;
}

.book-rating-detail {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 1rem;
    color: var(--star-color);
    font-weight: bold;
    font-size: 1.1rem;
}



.book-info-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    opacity: 0.9;
    padding: 0;
    margin-bottom: 0;
}

.info-item {
    display: flex;
    gap: 0.4rem;
    margin: 0;
}

.info-item dt {
    font-weight: bold;
    margin: 0;
}

.info-item dd {
    margin: 0;
}

.info-item dd.status-val {
    text-transform: capitalize;
    font-weight: bold;
}

.book-detail-commentary {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-top: 2rem;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* Shelf filtering and tab active states */
.shelf-section {
    display: none;
}

/* Fallback: default state when JS hasn't run yet */
.books-container:not([data-active-shelf]) #section-all {
    display: block;
}

.books-container:not([data-active-shelf]) .filter-buttons a[href="#all"] {
    color: var(--primary) !important;
    font-weight: bold;
    text-decoration: none !important;
}

/* Active shelf display states */
.books-container[data-active-shelf="all"] #section-all {
    display: block;
}

.books-container[data-active-shelf="currently-reading"] #section-currently-reading {
    display: block;
}

.books-container[data-active-shelf="read"] #section-read {
    display: block;
}

.books-container[data-active-shelf="to-read"] #section-to-read {
    display: block;
}

/* Active tab state */
.filter-btn.active {
    color: var(--primary) !important;
    font-weight: bold;
    text-decoration: none !important;
}

@media (max-width: 45em) {
    .search-filter-group {
        width: 100%;
        margin-left: 0;
    }
    #rating-filter {
        flex: 1;
        min-width: 120px;
    }
    .books-search-bar {
        flex: 2;
        min-width: 180px;
    }
}


