/* ============================================================
   Reading List — save buttons (everywhere) + the list page
   ============================================================ */

:root {
    --rl-accent: #2563eb;
    --rl-accent-2: #6366f1;
}

/* ===== Save button (overlaid on book covers) ===== */
.rl-save-btn {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    z-index: 4;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transform: translateY(-4px) scale(0.9);
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.rl-save-btn svg { width: 18px; height: 18px; }
.rl-save-btn svg .rl-fill { fill: transparent; transition: fill 0.2s; }

/* Reveal on card hover, or keep visible if saved */
.lib-card-cover:hover .rl-save-btn,
.la-suggest-cover:hover .rl-save-btn,
.rl-save-btn:focus-visible { opacity: 1; transform: translateY(0) scale(1); }
.rl-save-btn.is-saved { opacity: 1; transform: translateY(0) scale(1); background: var(--rl-accent); }
.rl-save-btn.is-saved svg .rl-fill { fill: #fff; }
.rl-save-btn:hover { background: var(--rl-accent); transform: translateY(0) scale(1.08); }
.rl-save-btn.is-pulsing { animation: rl-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes rl-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Always show on touch devices (no hover) */
@media (hover: none) {
    .rl-save-btn { opacity: 1; transform: none; }
}

/* ===== Owned (already in "My Books") indicators ===== */
/* On an owned card the reading-list "+" is swapped for an owned badge. */
.lib-card.is-owned .rl-save-btn { display: none !important; }

/* Owned badge (sits where the "+" would be); decorative — clicks fall through
   to the card link so the cover opens the book. */
.rl-owned-badge {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    z-index: 4;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #10b981;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.rl-owned-badge svg { width: 18px; height: 18px; }

/* ===== Styled hover tooltips (kept inside the cover's overflow box) ===== */
/* The cover is overflow:hidden, so the tip drops BELOW the button and wraps
   within the cover width instead of spilling out the top/sides. */
.rl-save-btn[data-tip]::after,
.rl-owned-badge[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    width: max-content;
    max-width: 130px;
    white-space: normal;
    text-align: center;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.96);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 6;
}
.rl-save-btn[data-tip]:hover::after,
.rl-save-btn[data-tip]:focus-visible::after,
.rl-owned-badge[data-tip]:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Toast ===== */
.rl-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111827;
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    z-index: 10050;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90vw;
}
.rl-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.rl-toast a { color: #93b4ff; font-weight: 600; text-decoration: none; }
.rl-toast a:hover { text-decoration: underline; }

/* ============================================================
   Reading List page
   ============================================================ */
.rl-page { min-height: 70vh; }

.rl-hero {
    padding: 48px 0 24px;
    text-align: center;
}
.rl-hero-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    margin: 0 0 8px;
    background: linear-gradient(135deg, var(--rl-accent), var(--rl-accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.rl-hero-sub { color: var(--text-secondary, #6b7280); font-size: 1.05rem; margin: 0; }

/* Tabs */
.rl-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 24px 0 32px;
}
.rl-tab {
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-color, #fff);
    color: var(--text-primary, #1f2937);
    border-radius: 999px;
    padding: 9px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.rl-tab:hover { border-color: var(--rl-accent); color: var(--rl-accent); }
.rl-tab.active { background: linear-gradient(135deg, var(--rl-accent), var(--rl-accent-2)); color: #fff; border-color: transparent; }
.rl-tab-count {
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    padding: 1px 8px;
    min-width: 20px;
}
.rl-tab.active .rl-tab-count { background: rgba(255, 255, 255, 0.25); }
[data-theme="dark"] .rl-tab { background: #1e2230; border-color: rgba(255,255,255,0.08); color: #e5e7eb; }

/* Grid */
.rl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 22px;
    padding-bottom: 60px;
}

/* Reading list card */
.rl-item {
    position: relative;
    border-radius: 14px;
    background: var(--bg-color, #fff);
    border: 1px solid var(--border-color, #eceef2);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.25s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    animation: rl-card-in 0.35s ease-out backwards;
}
.rl-item:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12); }
.rl-item.is-dragging { opacity: 0.45; }
.rl-item.drag-over { outline: 2px dashed var(--rl-accent); outline-offset: 2px; }
.rl-item.removing { opacity: 0; transform: scale(0.85); }
[data-theme="dark"] .rl-item { background: #1a1d28; border-color: rgba(255,255,255,0.06); }

@keyframes rl-card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.rl-item-cover { position: relative; aspect-ratio: 2 / 3; background: var(--bg-secondary, #eef0f4); display: block; }
.rl-item-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rl-item-cover .rl-card-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; font-size: 0.8rem; color: var(--text-secondary); }

/* progress bar for books in progress */
.rl-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,0.15); }
.rl-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--rl-accent), var(--rl-accent-2)); }

.rl-item-body { padding: 12px 12px 14px; }
.rl-item-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 2px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rl-item-author { font-size: 0.8rem; color: var(--text-secondary, #6b7280); margin: 0 0 10px; }

.rl-item-actions { display: flex; align-items: center; gap: 8px; }

.rl-status-select {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f7f8fa);
    color: var(--text-primary, #1f2937);
    cursor: pointer;
    font-family: inherit;
}
[data-theme="dark"] .rl-status-select { background: #232633; color: #e5e7eb; border-color: rgba(255,255,255,0.1); }

.rl-remove-btn {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: transparent;
    color: #ef4444;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.rl-remove-btn:hover { background: rgba(239, 68, 68, 0.1); }
.rl-remove-btn svg { width: 16px; height: 16px; }

.rl-drag-handle {
    position: absolute;
    top: 8px; inset-inline-start: 8px;
    z-index: 3;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s;
    backdrop-filter: blur(6px);
}
.rl-item:hover .rl-drag-handle { opacity: 1; }
.rl-drag-handle:active { cursor: grabbing; }
.rl-drag-handle svg { width: 16px; height: 16px; }

/* Empty state */
.rl-empty {
    text-align: center;
    padding: 60px 20px;
    max-width: 460px;
    margin: 0 auto;
}
.rl-empty-icon {
    width: 72px; height: 72px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(37,99,235,0.1), rgba(99,102,241,0.1));
    color: var(--rl-accent);
}
.rl-empty-icon svg { width: 34px; height: 34px; }
.rl-empty h2 { font-size: 1.3rem; margin: 0 0 8px; }
.rl-empty p { color: var(--text-secondary, #6b7280); margin: 0 0 22px; line-height: 1.6; }
.rl-empty-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 600px) {
    .rl-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
}
