@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&display=swap');

/* Container */
.sidma-bookshelf-wrapper {
    font-family: 'Montserrat', sans-serif;
    perspective: 1000px;
    width: 100%;
}

/* Shelf Group (Accordion) */
.sidma-shelf-group {
    margin-bottom: 30px;
    background: transparent;
}

/* Header */
.sidma-shelf-header {
    cursor: pointer;
    padding: 15px 20px;
    background: #FFFFFF;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: background 0.3s;
}

.sidma-shelf-header:hover {
    background: #F9FAFB;
}

.shelf-cat-title {
    color: #0C1657;
    /* Brand Navy */
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
}

.shelf-toggle-icon {
    color: #0C1657;
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.3s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.sidma-shelf-group.is-open .shelf-toggle-icon {
    transform: rotate(180deg);
}

/* Books Container */
.sidma-shelf-books-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, opacity 0.5s ease;
    opacity: 0;
}

.sidma-shelf-group.is-open .sidma-shelf-books-container {
    max-height: 5000px;
    opacity: 1;
    overflow: visible;
}

/* The Plank */
.sidma-shelf-plank {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-start;
    /* Align books left */
    gap: 15px;
    padding: 40px 30px 20px;
    background: url('https://www.transparenttextures.com/patterns/wood-pattern.png'), linear-gradient(to bottom, #2b1d0e, #1a1208);
    background-blend-mode: multiply;
    border-radius: 0 0 8px 8px;
    box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 15px solid #140e06;

    /* Auto Height (No Max Height) */
    height: auto;
}

/* Book Spine */
.sidma-book-spine {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.3s;
    transform-origin: bottom center;
    box-shadow: -4px 0 8px rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    background: var(--spine-color);
    background-image: linear-gradient(90deg,
            rgba(255, 255, 255, 0.15) 0%,
            rgba(255, 255, 255, 0) 15%,
            rgba(0, 0, 0, 0.1) 85%,
            rgba(0, 0, 0, 0.3) 100%);
    width: 60px;
    margin-right: 2px;
    padding: 10px 0 0 0;
}

/* Bookmark Icon */
.sidma-bookmark-icon {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 5px;
    flex-shrink: 0;
    color: #FFD700;
    filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.5));
}

.sidma-bookmark-icon svg {
    color: #FFD700;
    fill: currentColor;
}

/* Spine Content Wrapper */
.spine-content {
    flex-grow: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 0 15px 0;
    overflow: hidden;
}

/* The Book Title Text */
.book-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);

    font-family: 'Cinzel', serif !important;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;

    color: #FFD700;
    background: linear-gradient(to bottom, #FDB931 0%, #FFD700 50%, #FDB931 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);

    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    max-width: 23ch;
    /* 23 Char Limit */
    max-height: 100%;
}

/* Tooltip */
.sidma-book-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #FFFFFF;
    color: #333333;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    line-height: 1.4;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    max-width: 220px;
    white-space: normal;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 100;
    margin-bottom: 8px;
}

.sidma-book-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #FFFFFF transparent transparent transparent;
}

/* Hover */
.sidma-book-spine:hover {
    transform: translateY(-20px) scale(1.05);
    z-index: 20;
    filter: brightness(1.2);
}

.sidma-book-spine:hover .sidma-book-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Mobile */
@media (max-width: 768px) {
    .sidma-shelf-plank {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 20px;
    }

    .sidma-book-spine {
        width: 100%;
        height: 50px !important;
        margin-right: 0;
        transform-origin: center;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        padding: 0 15px;
    }

    .sidma-bookmark-icon {
        width: auto;
        margin-bottom: 0;
        margin-right: 15px;
    }

    .spine-content {
        writing-mode: horizontal-tb;
        transform: none;
        display: block;
        flex-grow: 1;
        width: auto;
        padding: 0;
        text-align: left;
    }

    .book-title {
        writing-mode: horizontal-tb;
        transform: none;
        display: block;
        width: auto;
        max-width: 100%;
        max-height: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #FFD700;
        background: linear-gradient(to bottom, #FDB931 0%, #FFD700 50%, #FDB931 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .sidma-book-tooltip {
        display: none;
    }
}