/**
 * Simple PDF Bookshelf Flip - Styles
 */

:root {
    --spbf-primary-color: #8B4513;
    --spbf-secondary-color: #D2691E;
    --spbf-accent-color: #FFD700;
    --spbf-text-light: #ffffff;
    --spbf-overlay-color: rgba(0, 0, 0, 0.9);
    --spbf-shelf-gradient: linear-gradient(180deg, #D2691E 0%, #8B4513 50%, #5D3A1A 100%);
    --spbf-transition: all 0.3s ease;
}

/* ==========================================================================
   Bookshelf Layout (背景画像を使用)
   ========================================================================== */
.spbf-bookshelf {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    padding: 60px 40px;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
}

/* 薄いグレーのオーバーレイ */
.spbf-bookshelf::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(128, 128, 128, 0.2);
    z-index: 1;
    pointer-events: none;
}

/* パンフレットをオーバーレイの上に表示 */
.spbf-bookshelf > * {
    position: relative;
    z-index: 2;
}

/* 背景画像が見つからない場合のフォールバック */
.spbf-bookshelf:not([style*="background-image"]) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

@media (min-width: 1600px) {
    .spbf-bookshelf {
        gap: 35px;
        padding: 70px 50px;
    }
}

@media (min-width: 1200px) and (max-width: 1599px) {
    .spbf-bookshelf {
        gap: 30px;
        padding: 60px 40px;
    }
}

@media (min-width: 800px) and (max-width: 1199px) {
    .spbf-bookshelf {
        gap: 25px;
        padding: 50px 30px;
    }
}

@media (min-width: 600px) and (max-width: 799px) {
    .spbf-bookshelf {
        gap: 20px;
        padding: 40px 20px;
    }
}

@media (max-width: 599px) {
    .spbf-bookshelf {
        gap: 15px;
        padding: 30px 15px;
    }
}

/* ==========================================================================
   Book Item (パンフレット)
   ========================================================================== */
.spbf-book-item {
    cursor: default;
    transition: none;
    text-align: center;
    padding: 0;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    perspective: 1000px;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

/* パンフレット部分のみクリック可能 */
.spbf-book-cover {
    cursor: pointer;
}

.spbf-book-item * {
    pointer-events: none;
}

/* パンフレットのカバーとタイトルはクリック可能 */
.spbf-book-cover,
.spbf-book-cover *,
.spbf-book-title {
    pointer-events: auto;
}

/* 控えめなホバー効果 */
.spbf-book-cover:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 12px 30px rgba(0, 0, 0, 0.6),
        0 0 15px rgba(255, 215, 0, 0.2);
    transition: all 0.2s ease;
}

.spbf-book-cover:hover .spbf-book-spine {
    box-shadow: 
        inset -2px 0 4px rgba(0, 0, 0, 0.4),
        2px 0 5px rgba(0, 0, 0, 0.3);
}

.spbf-book-cover:hover + .spbf-book-title,
.spbf-book-item:hover .spbf-book-title {
    color: #FFE4B5;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 1px 2px rgba(0, 0, 0, 0.6);
}

.spbf-book-cover {
    position: relative;
    display: inline-block;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    transform-style: preserve-3d;
}

.spbf-book-cover img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px 8px 8px 2px;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: #ffffff;
}

.spbf-book-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    background: linear-gradient(90deg, 
        rgba(139, 69, 19, 0.8) 0%, 
        rgba(160, 82, 45, 0.6) 30%,
        rgba(139, 69, 19, 0.4) 50%,
        rgba(160, 82, 45, 0.6) 70%,
        rgba(139, 69, 19, 0.8) 100%);
    border-radius: 2px 0 0 2px;
    box-shadow: 
        inset -2px 0 4px rgba(0, 0, 0, 0.4),
        2px 0 5px rgba(0, 0, 0, 0.3),
        inset 0 0 8px rgba(0, 0, 0, 0.2);
    z-index: 1;
    transition: all 0.2s ease;
}

/* パンフレットの影（本棚に置かれている感じ） */
.spbf-book-cover::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 5%;
    right: 5%;
    height: 6px;
    background: linear-gradient(180deg, 
        rgba(0, 0, 0, 0.3) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        transparent 100%);
    border-radius: 50%;
    filter: blur(3px);
    z-index: -1;
    transition: all 0.2s ease;
}

.spbf-book-cover:hover::after {
    bottom: -8px;
    height: 8px;
    background: linear-gradient(180deg, 
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.15) 50%,
        transparent 100%);
}

.spbf-book-title {
    margin: 12px 0 0 0;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 1px 2px rgba(0, 0, 0, 0.6);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding: 0 5px;
    transition: all 0.2s ease;
    cursor: pointer;
}

@media (min-width: 1200px) and (max-width: 1599px) {
    .spbf-book-cover {
        max-width: 350px;
    }
    
    .spbf-book-title {
        font-size: 15px;
    }
}

@media (min-width: 800px) and (max-width: 1199px) {
    .spbf-book-cover {
        max-width: 300px;
    }
    
    .spbf-book-title {
        font-size: 14px;
    }
}

@media (min-width: 600px) and (max-width: 799px) {
    .spbf-book-cover {
        max-width: 250px;
    }
    
    .spbf-book-title {
        font-size: 13px;
        margin-top: 8px;
    }
}

@media (max-width: 599px) {
    .spbf-book-cover {
        max-width: 200px;
    }
    
    .spbf-book-title {
        font-size: 12px;
        margin-top: 6px;
    }
    
    .spbf-book-spine {
        width: 8px;
    }
}

/* ==========================================================================
   Modal Window (全画面表示)
   ========================================================================== */
.spbf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: none;
    overflow: hidden;
}

.spbf-modal[aria-hidden="false"] {
    display: block;
}


.spbf-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--spbf-overlay-color);
    cursor: pointer;
}

.spbf-modal-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
}

.spbf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10001;
    position: relative;
}

.spbf-modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--spbf-text-light);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.spbf-modal-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.spbf-fullscreen-btn,
.spbf-modal-close {
    background: transparent;
    border: none;
    color: var(--spbf-text-light);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--spbf-transition);
}

.spbf-fullscreen-btn:hover,
.spbf-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.spbf-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.spbf-modal-close {
    font-size: 32px;
}

.spbf-modal-close:hover {
    transform: rotate(90deg) scale(1.1);
}

.spbf-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spbf-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    gap: 20px;
    z-index: 10002;
}

.spbf-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--spbf-accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spbf-loading p {
    margin: 0;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

.spbf-flipbook {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y pinch-zoom;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding: 0;
    overflow: hidden;
    /* 中央配置を確実にする */
    margin: 0 auto;
}

.spbf-page {
    background: #ffffff;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 10px 50px rgba(0, 0, 0, 0.5),
        0 0 0 rgba(0, 0, 0, 0);
    margin: 0;
    position: absolute;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    transform-origin: center center;
    transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                opacity 0.7s ease, 
                filter 0.7s ease;
    /* 中央配置を確実にする */
    top: 50% !important;
    left: 50% !important;
}

.spbf-page canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain !important;
}

/* 左上ホッチキス留めの見た目 */
.spbf-page::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, 
        rgba(139, 69, 19, 0.8) 0%, 
        rgba(139, 69, 19, 0.6) 40%,
        rgba(139, 69, 19, 0.3) 70%,
        transparent 100%);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
    box-shadow: 
        inset -2px -2px 4px rgba(0, 0, 0, 0.5),
        2px 2px 6px rgba(0, 0, 0, 0.4);
    transform: translateZ(0);
}

.spbf-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10001;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
}


.spbf-nav-prev,
.spbf-nav-next {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--spbf-text-light);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--spbf-transition);
}

.spbf-nav-prev:hover:not(:disabled),
.spbf-nav-next:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.spbf-nav-prev:disabled,
.spbf-nav-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.spbf-page-info {
    color: var(--spbf-text-light);
    font-size: 18px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.spbf-no-items {
    text-align: center;
    padding: 60px 20px;
    color: var(--spbf-text-light);
    font-size: 18px;
}

@media (max-width: 768px) {
    .spbf-modal-header {
        padding: 15px 20px;
    }
    
    .spbf-modal-title {
        font-size: 18px;
    }
    
    .spbf-modal-close {
        width: 35px;
        height: 35px;
        font-size: 28px;
    }
    
    .spbf-modal-footer {
        padding: 15px 20px;
    }
    
    .spbf-nav-prev,
    .spbf-nav-next {
        width: 45px;
        height: 45px;
        font-size: 20px;
        padding: 8px 15px;
    }
    
    .spbf-page-info {
        font-size: 16px;
    }
    
    .spbf-page {
        max-width: 95vw;
        max-height: 85vh;
    }
}

/* 全画面表示時のスタイル */
:fullscreen .spbf-modal,
:-webkit-full-screen .spbf-modal,
:-moz-full-screen .spbf-modal,
:-ms-fullscreen .spbf-modal {
    background: #000000;
}

:fullscreen .spbf-modal-body,
:-webkit-full-screen .spbf-modal-body,
:-moz-full-screen .spbf-modal-body,
:-ms-fullscreen .spbf-modal-body {
    height: 100vh;
}

.spbf-modal.spbf-fullscreen-active {
    background: #000000;
}

.spbf-modal.spbf-fullscreen-active .spbf-modal-body {
    height: 100vh;
}
