/* ── Genre filter ─────────────────────────────────────── */
.genre-filter {
    font-weight: 600;
    opacity: 0.55;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-color);
}

.genre-filter.active {
    opacity: 1;
    background-color: var(--background-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.genre-filter:hover:not(.active) { opacity: 0.8; }

/* ── Scene layout ─────────────────────────────────────── */
.scene-label {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    opacity: 0.85;
}

.scene-pair {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    height: 280px;
    position: relative; /* anchor for .drag-book */
    overflow: visible;
}

.scene-source {
    flex: 1;
    border-radius: 14px;
    overflow: hidden;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    cursor: grab;
    position: relative;
    z-index: 4; /* highest — sits on top of drag-book */
    user-select: none;
}

.scene-source:active { cursor: grabbing; }

:root.dark .scene-source {
    filter: brightness(0.82);
}

.scene-target {
    flex: 1;
    border-radius: 14px;
    overflow: hidden;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    z-index: 1; /* lowest — drag-book sits in front */
}

:root.dark .scene-target {
    filter: brightness(0.82);
}

.scene-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    opacity: 0.3;
    flex-shrink: 0;
    pointer-events: none;
    position: relative;
    z-index: 5;
}

/* ── Scene backgrounds ────────────────────────────────── */
.bookshelf-scene { background-image: url('/bookshelf/images/bookshelf.png'); }
.bookstore-scene { background-image: url('/bookshelf/images/bookstore.jpg'); background-size: cover; background-position: center; }
.pile-scene      { background-image: url('/bookshelf/images/pile-of-books.png'); }
.desk-scene      { background-image: url('/bookshelf/images/desk.png'); }
.cart-scene      { background-image: url('/bookshelf/images/shopping-cart.png'); background-position: center bottom; }

/* ── Drag-book — appears centred on target on mousedown ── */
/* Appended to .scene-pair, positioned absolutely */
.drag-book {
    position: absolute;
    z-index: 2; /* behind source (4), in front of target (1) */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 14px 44px rgba(0,0,0,0.65);
    pointer-events: none;
    transform-origin: top center;
    animation: dangle 1s ease-in-out infinite alternate;
}

.drag-book img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.drag-book-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    text-align: center;
    padding: 8px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    z-index: 1;
}

@keyframes dangle {
    from { transform: rotate(-6deg); }
    to   { transform: rotate(6deg); }
}

/* ── Drop zone ring when hovering over target ─────────── */
.scene-target.drag-over {
    box-shadow: inset 0 0 0 3px rgba(255,255,255,0.6);
}

/* ── Placed book (permanent, centred inside target) ───── */
.placed-book-wrap {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    cursor: pointer;
}

.placed-book {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 36px rgba(0,0,0,0.6);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}

.placed-book-wrap:hover .placed-book {
    transform: scale(1.05);
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
}

.placed-book img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.placed-book-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    text-align: center;
    padding: 8px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    pointer-events: none;
    z-index: 1;
}

/* remove hint */
.placed-book-wrap::after {
    content: 'drag out to remove';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.52rem;
    white-space: nowrap;
    color: rgba(255,255,255,0.75);
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.placed-book-wrap:hover::after { opacity: 1; }

/* entrance pop */
@keyframes place-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.75); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.placed-book-wrap { animation: place-in 0.22s ease-out both; }

/* ── Ghost (used only for the drag-to-remove action) ──── */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    display: none;
    width: 62px;
    height: 90px;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 6px 10px 28px rgba(0,0,0,0.55);
    transform-origin: top center;
    animation: dangle 0.9s ease-in-out infinite alternate;
}

.drag-ghost.active { display: block; }

.drag-ghost img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.drag-ghost-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.5rem;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    padding: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    pointer-events: none;
}

/* ── Tooltip ──────────────────────────────────────────── */
.book-tooltip {
    position: fixed;
    z-index: 9998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
    max-width: 230px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #e5e7eb);
    background-color: var(--background-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    font-family: 'Noto Sans', sans-serif;
}

.book-tooltip.visible { opacity: 1; }

/* Full cover — no cropping, full image shown */
.tooltip-cover {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 8px;
    display: block;
    /* background-color set dynamically to dominant image color */
    background-color: #888;
    transition: background-color 0.3s ease;
}

.tooltip-title   { font-size: 0.85rem; font-weight: 700; margin-bottom: 2px; }
.tooltip-author  { font-size: 0.72rem; opacity: 0.65; font-weight: 400; margin-bottom: 6px; }

.tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.tooltip-tag {
    font-size: 0.6rem;
    padding: 2px 7px;
    border-radius: 99px;
    background-color: var(--badge, #f3f4f6);
    font-weight: 600;
}

.tooltip-synopsis { font-size: 0.78rem; font-weight: 400; opacity: 0.8; line-height: 1.5; margin-bottom: 6px; }
.tooltip-rating   { font-size: 0.8rem; color: gold; letter-spacing: 1px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
    .scene-pair {
        flex-direction: column;
        height: auto;
    }
    .scene-source,
    .scene-target {
        flex: none;
        width: 100%;
        height: 180px;
    }
    .scene-arrow  { transform: rotate(90deg); }
}
