/* ==========================
   StudioElf Bookshelf - Module.css
   Cleaned, consolidated and complete (includes color picker)
   ========================== */

/* --------------------------
   Theme variables (easy to tweak)
   -------------------------- */
:root {
    --bookshelf-gap: 1rem;
    --bookshelf-card-radius: 1rem;
    --bookshelf-card-border: #e6e6e6;
    --bookshelf-reading-bg: #ffffff;
    --bookshelf-reading-color: #212529;
    --bookshelf-muted: #575757;
    --bookshelf-shadow: 0 4px 10px rgba(0,0,0,0.08);
    --bookshelf-warning: #fff3cd;
    --bookshelf-primary: #0d6efd;
    --swatch-size: 28px;
    --swatch-gap: .5rem; 
/* dynamic offset (set by JS) */
    --bookshelf-anchor-offset: 56px; /* default / fallback */
}

.small-x {
    font-size: 0.75rem;
}


/* ==========================
   Layout & Panels
   ========================== */

/* make headings respect an offset when scrolled into view */
.bookshelf-reading-pane .bookshelf-content h2,
.bookshelf-reading-pane .bookshelf-content h3,
.bookshelf-reading-pane .bookshelf-content h4 {
    scroll-margin-top: var(--bookshelf-anchor-offset);
}

/* Prefer smooth scrolling inside the reading content when using browser-native anchors */
.bookshelf-reading-pane .bookshelf-content {
    scroll-behavior: smooth;
}

.bookshelf-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto; /* fill available height of reading pane */
    overflow: auto; /* the actual scroll surface */
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* The actual content container (separated for clarity) */
.bookshelf-content-body {
    padding: 1.25rem;
    overflow: visible; /* let inner elements overflow normally */
}

.bookshelf-sticky-header {
    position: sticky;
    z-index: 5; /* above content, but below global overlays if needed */
    background: inherit; /* keep same background as pane (prevents bleed through) */
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    /* prevent header from allowing content to show through while transparent */
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.bookshelf-sidepanel {
    border-right: 1px solid var(--bookshelf-card-border);
    background-color: #f8f9fa;
    min-height: 80vh;
    overflow-y: auto;
    padding: 1rem;
}

.bookshelf-nav {
    position: sticky;
    align-self: flex-start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: 10;
}

/* Outer container now acts as clipping boundary */
.bookshelf-container,
.bookshelf-row-wrapper { /* whichever wrapper holds the left nav + right pane */
    position: relative;
    overflow: hidden; /* <<< prevents pane contents from escaping when the page scrolls */
}

/* Reading pane setup */
.bookshelf-reading-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg);
    border-radius: var(--bookshelf-card-radius);
    box-shadow: var(--bookshelf-shadow);
    /*top: 40px;*/
    z-index: 0;
    overflow: hidden; /* <<< still needed for inner scroll clipping */
}

/* Scroll area = inner scrollable region */
.bookshelf-scrollarea {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    height: calc(100vh - 280px);
    position: relative;
}

/* Sticky title inside viewport */
.bookshelf-sticky-title {
    position: sticky;
    top: 0;
    background: var(--bs-body-bg);
    z-index: 10;
    padding: .75rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}


/* Optional: add visual shadow when content scrolled */
.bookshelf-scrollarea.scrolled .bookshelf-sticky-title {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}


.bookshelf-fade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    background: var(--bs-body-bg);
    transition: height 0.2s ease-out, opacity 0.2s ease-out;
    z-index: 10;
}

.bookshelf-reading-pane.scrolled-under .bookshelf-fade-overlay {
    opacity: 1;
}

.bookshelf-breadcriumb-search {
    position: sticky;
    z-index: 10; /* sits above overlay */
    background: var(--bs-body-bg);
}

.audit-footer {
    margin-top: auto; /* push to bottom */
    padding: .75rem 1rem;
    background-color: inherit;
}

    /* ==========================
   Grid cards (shelves & books)
   ========================== */
    .grid {
    display: grid;
    gap: var(--bookshelf-gap);
}

    .grid.third {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }

/* card */
.grid-card {
    display: flex;
    flex-direction: column;
    /*background: #fff;*/
    border-radius: var(--bookshelf-card-radius);
    border: 1px solid var(--bookshelf-card-border);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    cursor: pointer;
    min-height: 220px;
}

    .grid-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 20px rgba(0,0,0,0.08);
        border-color: var(--bs-warning);
    }

/* featured image area */
.featured-image-container-wrap {
    height: 150px;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* placeholders */
/* Applies only to form controls within this module */
.form-control::placeholder {
    font-style: italic;
    color: var(--bs-secondary-color, #6c757d); /* optional subtle tone */
    opacity: 0.9; /* ensure it's still readable */
}

/* External Tools*/
.heading-popup {
    width: 16rem;
    padding: 10px;
    display: none;
}

    .heading-popup.show {
        display: block;
    }

    .heading-popup.hidden {
        display: none;
    }


/* Code */
.bm-code {
    font-family: var(--bs-font-monospace, monospace);
    background-color: var(--bs-gray-100);
    color: var(--bs-body-color);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    white-space: nowrap;
}


.dark-mode .bm-code {
    background-color: var(--bs-gray-800);
    color: var(--bs-gray-100);
}
/* cover image */

.featured-image-container-shelf {
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    transition: opacity .24s ease-in-out;
    background-size: contain;
    background-position: right;
}
.featured-image-container-book {
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    transition: opacity .24s ease-in-out;
    background-size: contain;
    background-position: center;
}
/* optional overlay icon (SVG) in featured area */
.featured-image-container-wrap .svg-icon {
    position: absolute;
    bottom: 10px;
    left: 8px;
    font-size: 1.6rem;
    color: rgba(255,255,255,0.9);
    pointer-events: none;
}

/* card content & footer */
.grid-card-content {
    padding: 1rem;
    flex: 1 0 auto;
}

.grid-card-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(0,0,0,0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .9rem;
    color: var(--bookshelf-muted);
}

/* Add hover effects and transitions */
.grid-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .grid-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    }

/* title truncation helper */
.text-limit-lines-2 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

/* ==========================
   Elegant Bookshelf Scrollbar
   - Adapts to light/dark mode
   - Minimal track, rounded "button" thumb
   ========================== */

.bookshelf-scrollarea {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--bs-primary) var(--bs-tertiary-bg, var(--bs-gray-200));
}

    /* WebKit browsers (Chrome, Edge, Safari) */
    .bookshelf-scrollarea::-webkit-scrollbar {
        width: 8px; /* thin scrollbar */
    }

    .bookshelf-scrollarea::-webkit-scrollbar-track {
        background: transparent; /* subtle / invisible track */
        border-radius: 10px;
    }

    .bookshelf-scrollarea::-webkit-scrollbar-thumb {
        background-color: var(--bs-primary); /* matches Bootstrap theme */
        border-radius: 50%; /* perfectly round button */
        min-height: 40px; /* prevents tiny dot on long pages */
        border: 2px solid var(--bs-body-bg); /* “pill” look against background */
        transition: background-color 0.3s ease, transform 0.2s ease;
    }

        .bookshelf-scrollarea::-webkit-scrollbar-thumb:hover {
            background-color: var(--bs-primary-hover, #0b5ed7);
            transform: scale(1.1); /* subtle pop when hovering */
        }

/* Dark mode adjustment */
.dark-mode .bookshelf-scrollarea::-webkit-scrollbar-thumb {
    background-color: var(--bs-primary);
    border: 2px solid var(--bs-dark);
}

.dark-mode .bookshelf-scrollarea::-webkit-scrollbar-track {
    background: transparent;
}


/* ==========================
   Lists (chapters & pages)
   ========================== */
.list-group-item {
    transition: background-color .15s ease;
    cursor: pointer;
}

    /* hover */
    .list-group-item:hover {
/*        background-color: var(--bs-body-color);
        color: var(--bs-body-bg);*/
    }

    /* bootstrap active compatibility */
    /*.list-group-item.active {
        background-color: var(--bookshelf-primary) !important;
        color: #fff !important;
        font-weight: 600;
    }*/

    /* page selection uses warning style (your choice text-bg-warning) */
    /*.list-group-item.text-bg-warning,
    .list-group-item.selected-page {
        background-color: var(--bookshelf-warning) !important;
    }*/

/* muted helper */
.text-muted {
    color: var(--bookshelf-muted) !important;
}

/* svg icon general */
.svg-icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -0.125em;
    margin-inline-end: .5rem;
    fill: currentColor;
}

/* ==========================
   Buttons & btn groups
   ========================== */
.btn-bookshelf-group.gap-1 {
    gap: .25rem;
}

.btn-bookshelf.rounded-pill,
.btn-bookshelf-group .btn {
    border-radius: 50rem !important;
}

/* small visual vertical rule */
.vr {
    width: 1px;
    background-color: rgba(0,0,0,0.06);
    margin: 0 .5rem;
    align-self: stretch;
}

/* card header style used by editor/cards */
.card-header {
    font-size: 1.05rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    padding: .75rem 1rem;
}

/* tidy hover for any .card */
.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

/* ==========================
   Color picker (complete, accessible)
   - .color-dropdown (container)
   - .color-grid (inner grid)
   - .color-cell (swatch)
   ========================== */

.color-dropdown {
    width: 100%;
    max-width: 320px;
    max-height: 320px;
    overflow-y: auto;
    border-radius: .5rem;
    background: #fff;
    padding: .5rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    z-index: 1050;
}

    /* grid of swatches */
    .color-dropdown .color-grid {
        display: grid;
        grid-template-columns: repeat(8, var(--swatch-size));
        gap: var(--swatch-gap);
        justify-content: start;
        align-items: center;
        padding: .5rem;
    }

/* each swatch */
.color-cell {
    width: var(--swatch-size);
    height: var(--swatch-size);
    border-radius: 6px;
    border: 2px solid #dee2e6;
    box-sizing: border-box;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease;
    outline: none;
}

    /* hover/focus */
    .color-cell:hover,
    .color-cell:focus {
        transform: scale(1.08);
        box-shadow: 0 6px 14px rgba(0,0,0,0.12);
        border-color: rgba(0,0,0,0.14);
    }

    /* selected swatch (applies when you set .selected on the element) */
    .color-cell.selected {
        box-shadow: 0 0 0 4px rgba(13,110,253,0.12), inset 0 0 0 1px rgba(0,0,0,0.08);
        border-color: rgba(13,110,253,0.6);
    }

    /* provide keyboard operability states (if you attach key handlers) */
    .color-cell:focus-visible {
        box-shadow: 0 0 0 4px rgba(13,110,253,0.12);
        border-color: rgba(13,110,253,0.6);
    }

/* label under swatches (optional) */
.color-dropdown .color-label {
    font-size: .8rem;
    color: var(--bookshelf-muted);
    margin-top: .5rem;
    text-align: left;
}

.breadcrumb {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: var(--bs-body-bg);
}

.breadcrumb-item a,
.breadcrumb-item {
    max-width: 200px; /* limit for all but last */
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

    .breadcrumb-item:last-child a,
    .breadcrumb-item:last-child {
        max-width: none; /* last crumb shows full text */
        overflow: visible;
        text-overflow: clip;
    }


/* ==========================
   Small helpers & responsive
   ========================== */

@media (max-width: 768px) {
    .grid.third {
        grid-template-columns: 1fr;
    }

    .featured-image-container-wrap {
        height: 140px;
    }

    .bookshelf-sidepanel {
        padding: .75rem;
    }

    .bookshelf-reading-pane .bookshelf-sticky-header {
        padding: .5rem;
    }
}

.hidden-visually {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: -1px;
}

/* DraggableList */

.draggable {
    cursor: grab; /* W3C standards syntax, all modern browser */
}

    .draggable:active {
        cursor: grabbing;
    }
.draggable-list {
    display: flex;
    flex-direction: column;
    min-height: 6.25rem; /* ~100px */
}

/* Default item */
.draggable-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem;
    border-radius: var(--bs-border-radius, 0.375rem);
    border: 2px solid transparent;
    user-select: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

    /* Hover: border only, no background */
    .draggable-item:hover {
        border-color: var(--bs-primary, #0d6efd);
    }

    /* Dragging item */
    .draggable-item.dragging {
        opacity: 0.85;
        border-color: var(--bs-primary, #0d6efd);
    }

    /* Drop target */
    .draggable-item.drop-target {
        border-color: var(--bs-secondary, #6c757d);
    }



