/* ==========================================================================
   Activity pages: list, category, tag and search
   Loaded after users/css/books/books.css, which provides the hero, grid,
   tiles, empty state and pagination. Also loaded by page_detail.html for
   toasts and the quick preview.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb-nav {
    margin: 0 0 1rem;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
    list-style: none;
    background: none;
}

.breadcrumb li a {
    color: var(--brand-primary);
    text-decoration: none;
}

.breadcrumb li a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-muted);
}

.breadcrumb-current {
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */
.filter-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    align-items: end;
    gap: 0.75rem;
    margin: 0 0 1.5rem;
    padding: 0 0 1.25rem;
    border-bottom: 1px solid var(--border-medium);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    cursor: pointer;
    background-color: var(--input-bg);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
}

.filter-group select:hover {
    border-color: var(--brand-primary);
}

.filter-group select:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 1px;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
}

.btn-clear-filters {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--brand-primary);
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-clear-filters:hover {
    color: var(--brand-primary);
    text-decoration-thickness: 2px;
}

@media (max-width: 1200px) {
    .filter-bar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 576px) {
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-actions:empty {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Subcategory links and "in" context line
   -------------------------------------------------------------------------- */
.tag-filter-bar {
    margin: 0 0 clamp(2rem, 4vw, 3.5rem);
}

.tag-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
}

.tag-filter-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.tag-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-btn {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    transition: border-color 0.15s ease;
}

.tag-btn:hover {
    color: var(--text-primary);
    border-color: var(--brand-primary);
}

.tag-btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.active-filters-label {
    color: var(--text-secondary);
}

.filter-badge {
    color: var(--brand-primary);
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Page tiles: show the whole sheet on white paper
   -------------------------------------------------------------------------- */
.book-tile[data-page-slug] {
    cursor: pointer;
}

.page-sheet-tile .book-cover {
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
}

.page-sheet-tile .book-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
}

.page-sheet-tile .book-cover img,
.page-sheet-tile .no-cover {
    border: 1px solid var(--border-medium);
    border-radius: 2px;
    transition: border-color 0.15s ease;
}

.page-sheet-tile .no-cover {
    background: var(--bg-secondary);
}

.page-sheet-tile:hover .book-cover img,
.page-sheet-tile:hover .no-cover {
    border-color: var(--brand-primary);
}

.book-type {
    margin-right: auto;
}

.quick-preview-image {
    cursor: grabbing;
    background: var(--browse-sheet, #ffffff);
}

/* --------------------------------------------------------------------------
   Toasts (created by pages.js)
   -------------------------------------------------------------------------- */
.jolly-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: min(420px, calc(100vw - 40px));
    padding: 0.875rem 1.125rem;
    font-weight: 500;
    color: var(--bg-primary);
    background: var(--text-primary);
    border-radius: 6px;
    animation: toastIn 0.2s ease, toastOut 0.3s ease 2.7s forwards;
}

.toast-success i { color: var(--success-text); }
.toast-error i { color: var(--error-text); }
.toast-warning i { color: var(--warning-text); }
.toast-info i { color: var(--info-text); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .jolly-toast {
        animation: toastOut 0.01s linear 2.7s forwards;
    }
}
