/* Experience Book Styles - "The Archive (Bunko)" */
:root {
    --book-width: 380px;
    --book-height: 540px;
    --paper-color: #fcfaf5;
    /* Washi White */
    --indigo-dark: #1a237e;
    --indigo-light: #534bae;
    --hanko-red: #b71c1c;
    --ink-black: #0d0d0d;
}

/* Global Reset for this component to prevent sizing issues */
.library-container *,
.library-container *::before,
.library-container *::after {
    box-sizing: border-box;
}

/* Container */
.library-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Vertically center */
    padding: 2rem 0;
    /* Balanced padding */
    min-height: 80vh;
    /* Ensure enough height to center */
    perspective: 2500px;
    width: 100%;
}

/* ... existing styles ... */

/* Back Faces: Seigaiha Pattern */
.page-back {
    transform: rotateY(180deg);
    background: #f7f5f0;
    /* Soft grey/white */
    background-image:
        radial-gradient(circle at 100% 50%, transparent 20%, rgba(26, 35, 126, 0.03) 21%, rgba(26, 35, 126, 0.03) 34%, transparent 35%, transparent),
        radial-gradient(circle at 0% 50%, transparent 20%, rgba(26, 35, 126, 0.03) 21%, rgba(26, 35, 126, 0.03) 34%, transparent 35%, transparent) 0px 50px;
    background-size: 100px 100px;
    border-left: none;
    /* Removed border to ensure exact width match with front */
    box-shadow: -1px 0 5px rgba(0, 0, 0, 0.05);
    /* Change border to shadow for separation */
}

.book-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.book-wrapper {
    width: var(--book-width);
    height: var(--book-height);
    position: relative;
    z-index: 10;
    transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1);
    /* Smooth centering */
}

/* When book is open, shift it right by half its width (190px) to center the spine */
.book-wrapper.book-open {
    transform: translateX(190px);
}

@media (max-width: 800px) {

    /* On widely mobile, centering is different */
    .book-wrapper.book-open {
        transform: translateX(0);
        /* Keep centered default or adjust as needed */
    }
}

.book {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

/* Page Base */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
}

.page.flipped {
    transform: rotateY(-180deg);
}

.page-front,
.page-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 4px 0 10px rgba(0, 0, 0, 0.05), 1px 1px 5px rgba(0, 0, 0, 0.1);
}

/* Front Faces: Washi Paper */
.page-front {
    background: var(--paper-color);
    background-image: url("https://www.transparenttextures.com/patterns/cream-paper.png");
    /* Subtle texture */
    padding: 40px;
    color: var(--ink-black);
}

/* Spine Shadow */
.page-front::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
    pointer-events: none;
}

/* Back Faces: Seigaiha Pattern */
.page-back {
    transform: rotateY(180deg);
    background: #f7f5f0;
    /* Soft grey/white */
    background-image:
        radial-gradient(circle at 100% 50%, transparent 20%, rgba(26, 35, 126, 0.03) 21%, rgba(26, 35, 126, 0.03) 34%, transparent 35%, transparent),
        radial-gradient(circle at 0% 50%, transparent 20%, rgba(26, 35, 126, 0.03) 21%, rgba(26, 35, 126, 0.03) 34%, transparent 35%, transparent) 0px 50px;
    background-size: 100px 100px;
    border-left: 2px solid rgba(0, 0, 0, 0.05);
}

.page-back-content {
    background-color: var(--paper-color);
    background-image: url("https://www.transparenttextures.com/patterns/cream-paper.png");
    width: 100%;
    height: 100%;
    padding: 40px;
    color: var(--ink-black);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
    /* Ensure left alignment like a real page */
}

/* ==================
   COVER DESIGN
   ================== */
.cover-front {
    background: var(--indigo-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 4px solid var(--indigo-dark);
    /* Thick border for hardcover feel */
}

/* Texture for Cover */
.cover-front::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("https://www.transparenttextures.com/patterns/black-linen.png");
    opacity: 0.3;
    pointer-events: none;
}

.cover-title-group {
    position: relative;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 40px 20px;
}

.cover-front h1 {
    font-family: 'Noto Serif JP', serif;
    font-weight: 900;
    font-size: 3.5rem;
    line-height: 1;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
    color: #fff;
}

.cover-subtitle {
    font-family: 'Shippori Mincho', serif;
    font-size: 1.5rem;
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 0.2em;
    display: inline-block;
    color: rgba(255, 255, 255, 0.8);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    padding-left: 15px;
    margin-left: 15px;
    height: 120px;
}

.hanko-seal {
    width: 60px;
    height: 60px;
    border: 2px solid var(--hanko-red);
    color: var(--hanko-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Shippori Mincho', serif;
    font-weight: 900;
    font-size: 0.9rem;
    margin-top: 30px;
    transform: rotate(-10deg);
    background: rgba(183, 28, 28, 0.1);
}

/* ==================
   INTERNAL PAGES
   ================== */
.page-deco-line {
    width: 40px;
    height: 2px;
    background: var(--hanko-red);
    margin: 10px 0 25px;
}

.page-header {
    font-family: 'Noto Serif JP', serif;
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--indigo-dark);
    margin-bottom: 5px;
}

.page-sub {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #888;
}

.illustration-box {
    width: 100%;
    height: 140px;
    background: rgba(26, 35, 126, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    border: 1px dashed rgba(26, 35, 126, 0.2);
    border-radius: 2px;
    color: var(--indigo-dark);
    font-size: 3rem;
    position: relative;
    overflow: hidden;
}

.illustration-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
    opacity: 1;
    padding: 10px;
}

.tech-list {
    list-style: none;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    line-height: 1.8;
}

.tech-list li {
    position: relative;
    padding-left: 15px;
    color: #444;
}

.tech-list li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--hanko-red);
    font-weight: bold;
    font-size: 0.7rem;
    top: 1px;
}

.page-number {
    position: absolute;
    bottom: 25px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    color: #aaa;
}

/* Controls */
.controls {
    margin-top: 2rem;
    /* Reduced top margin for tighter layout */
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
    /* Center the controls */
    position: relative;
    z-index: 50;
    width: 100%;
}

.ctrl-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #ddd;
    color: var(--indigo-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    font-size: 1.2rem;
}

.ctrl-btn:hover {
    background: var(--indigo-dark);
    color: #fff;
    border-color: var(--indigo-dark);
    transform: translateY(-2px);
}

/* Mobile */
@media (max-width: 600px) {
    :root {
        --book-width: 85vw;
        --book-height: 500px;
        /* Smaller height on mobile */
    }

    .library-container {
        padding-bottom: 5rem;
        /* More space for scroll on mobile */
    }

    /* Hide Back Pages on Mobile to simulate single-sided stack */
    .page-back {
        display: none !important;
    }

    .show-desktop {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    /* Reduce padding on mobile for more space */
    .page-front,
    .page-back-content {
        padding: 25px;
    }
}

/* Default Desktop Styles */
/* .show-desktop is visible by default, allowing internal display properties (block, flex, etc.) to work */

.show-mobile {
    display: none;
}