/* =========================================
   Virtual Binder Library
   ========================================= */
.library-subtitle {
    text-align: right;
    color: #666;
    margin-bottom: 40px;
    font-size: 1.2rem;
}

.binder-grid {
    display: flex;
    flex-wrap: wrap; 
    gap: 15px; 
    padding: 20px 20px 0 20px;
    align-items: flex-end;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 280px, /* height of book + padding */
        #8B5A2B 280px,
        #6B4226 295px
    );
    min-height: 300px;
}

/* The Book Wrapper - static footprint */
.book-wrapper {
    width: 50px; 
    height: 260px;
    position: relative;
    flex-shrink: 0;
    margin-bottom: 20px; 
}

/* The actual physical book that expands */
.book-inner {
    width: 50px;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0; /* Anchor to right edge so it expands left */
    display: flex;
    flex-direction: row; /* RTL default: Spine on right */
    border-radius: 4px 8px 8px 4px;
    box-shadow: -3px 0 6px rgba(0,0,0,0.4) inset, -2px 2px 5px rgba(0,0,0,0.2);
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.4s;
    cursor: pointer;
    overflow: hidden;
    z-index: 1;
}

.book-wrapper:hover .book-inner {
    width: 220px;
    transform: translateY(-20px);
    box-shadow: -5px 15px 25px rgba(0,0,0,0.4);
    z-index: 10;
}

.book-spine {
    width: 50px;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.15); /* Darken spine for depth */
    border-right: 2px solid rgba(255,255,255,0.2);
    position: relative;
    box-shadow: inset 4px 0 8px rgba(0,0,0,0.2);
}

.spine-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: white;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    width: 240px; 
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-cover {
    width: 170px;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    position: relative;
}


.binder-label {
    box-sizing: border-box;
    background: #fbf8ef; /* Warm parchment / antique bookplate paper */
    color: #2b231d;      /* Classic archival ink */
    padding: 10px 8px;
    width: 82%;
    border: 1px solid #b8a68d;
    outline: 1px solid #b8a68d;
    outline-offset: -4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15), inset 0 0 12px rgba(184, 166, 141, 0.25);
    font-family: var(--font-serif);
    font-weight: 700;
    -webkit-text-stroke: 0.5px currentColor;
    font-size: 1.25rem;
    line-height: 1.25;
    position: relative;
    z-index: 3;
    border-radius: 2px;
    text-align: center;
    margin: 0 auto;
}

.binder-count {
    box-sizing: border-box;
    color: #2b231d;
    font-size: 0.85rem;
    margin-top: 12px;
    font-family: var(--font-serif);
    font-weight: 600;
    -webkit-text-stroke: 0.3px currentColor;
    z-index: 3;
    background: rgba(251, 248, 239, 0.85);
    padding: 3px 12px;
    border-radius: 12px;
    border: 1px solid rgba(184, 166, 141, 0.6);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* =========================================
   Open Binder View
   ========================================= */
.open-book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.back-btn {
    background: transparent;
    color: var(--color-dark);
    border: 1px solid var(--color-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    padding: 8px 16px;
    cursor: pointer;
}
.back-btn:hover { background: var(--color-dark); color: white; }

#open-book-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    margin: 0;
}

.book-search-container {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #ccc;
    padding: 5px 15px;
    border-radius: 2px;
}
.book-search-container input {
    border: none;
    outline: none;
    padding: 8px;
    margin: 0;
}

/* The Page and Rings Container */
.binder-page-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: flex-start;
}

/* The Left-Side Metal Rings (Since RTL, they are on the right side of the paper!) */
.metal-rings-container {
    width: 40px;
    background: linear-gradient(to right, #ccc, #eee, #aaa);
    border-radius: 0 4px 4px 0;
    box-shadow: inset 2px 0 5px rgba(0,0,0,0.2);
    position: relative;
    z-index: 5;
}
.metal-rings-container::after {
    content: '';
    position: absolute;
    top: 5%;
    bottom: 5%;
    left: -15px; /* Loops over into the paper */
    right: 5px;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 30px,
        #b0b0b0 30px,
        #f5f5f5 33px,
        #707070 38px,
        transparent 38px,
        transparent 60px
    );
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.4));
}

.binder-page {
    flex-grow: 1;
    background: #fffdf9; /* Slightly warm paper color */
    min-height: 70vh;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-radius: 4px 0 0 4px;
    padding: 40px 60px 40px 40px;
    position: relative;
    /* Simulating paper lines */
    background-image: repeating-linear-gradient(transparent, transparent 31px, #e8e8e8 31px, #e8e8e8 32px);
    background-attachment: local;
    line-height: 32px;
    z-index: 1;
    overflow: hidden;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.binder-page.turning {
    transform: translateX(20px) rotateY(-10deg);
    opacity: 0;
}

/* Table of Contents Item */
.toc-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    cursor: pointer;
    padding: 5px 0;
    border-bottom: 1px dotted #ccc;
    font-size: 1.2rem;
    font-family: var(--font-serif);
    font-weight: bold;
    -webkit-text-stroke: 0.4px currentColor;
    color: var(--color-dark);
}
.toc-item:hover { color: var(--color-accent); }
.toc-item .page-num { font-family: var(--font-sans); color: #888; font-size: 0.9rem; font-weight: normal; -webkit-text-stroke: 0; }

/* The Folded Corner */
.dog-ear {
    position: absolute;
    bottom: 0;
    left: 0; /* Bottom left */
    width: 0;
    height: 0;
    border-style: solid;
    /* White corner to "erase" the page, grey flap for the fold */
    border-width: 0 40px 40px 0;
    border-color: transparent #e0e0e0 #ffffff transparent;
    box-shadow: 2px -2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}
.dog-ear:hover {
    border-width: 0 50px 50px 0;
}
