/**
 * Tantos Flipbook v7.0 - Smooth Realistic Styles
 */

/* Container */
.tantos-flipbook-container {
    position: relative;
    margin: 0 auto;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    font-family: 'Segoe UI', -apple-system, sans-serif;
    user-select: none;
    min-height: 400px;
}

/* Loading */
.tantos-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    text-align: center;
    z-index: 100;
}

.tantos-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    border: 3px solid rgba(78,205,196,0.2);
    border-top-color: #4ecdc4;
    border-radius: 50%;
    animation: tfspin 0.8s linear infinite;
}

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

.tantos-loading p { margin-top: 8px; }

.tf-err { text-align: center; padding: 30px; }
.tf-err p { color: #ff6b6b; font-size: 15px; }

/* Viewer */
.tantos-viewer {
    width: 100%;
    height: calc(100% - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 15px;
    position: relative;
}

/* Book */
.tf-book {
    position: relative;
    transform-origin: center center;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* Shadow under book */
.tf-shadow {
    position: absolute;
    bottom: -15px;
    left: 10%;
    width: 80%;
    height: 25px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.35) 0%, transparent 70%);
    filter: blur(10px);
    z-index: -1;
    transition: all 0.4s ease;
}

/* ============================================
   COVER (Single Page - Closed Book)
   ============================================ */
.tf-cover {
    position: relative;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: right center;
    box-shadow:
        2px 2px 8px rgba(0,0,0,0.2),
        5px 5px 15px rgba(0,0,0,0.15),
        8px 8px 30px rgba(0,0,0,0.1);
    border-radius: 2px 5px 5px 2px;
}

.tf-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 2px 5px 5px 2px;
}

/* Cover book edge (thickness) */
.tf-cover::after {
    content: '';
    position: absolute;
    top: 3px;
    right: -5px;
    width: 7px;
    height: calc(100% - 6px);
    background: linear-gradient(90deg, #d8d4cc 0%, #c0bbb0 50%, #d0ccc2 100%);
    border-radius: 0 3px 3px 0;
    box-shadow: 2px 0 4px rgba(0,0,0,0.15);
}

/* Cover flip out animation */
.tf-cover.tf-flip-out {
    transform: perspective(1500px) rotateY(-180deg);
}

/* Cover flip in animation */
.tf-cover.tf-flip-in {
    animation: tfCoverIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tfCoverIn {
    0% { transform: perspective(1500px) rotateY(-180deg); }
    100% { transform: perspective(1500px) rotateY(0deg); }
}

/* ============================================
   SPREAD (Two Pages - Open Book)
   ============================================ */
.tf-spread {
    display: none;
    position: relative;
}

/* Page container */
.tf-page {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Paper styling */
.tf-page-paper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #fffefb 0%, #faf8f3 50%, #f5f2eb 100%);
}

/* Paper grain texture */
.tf-page-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0,0,0,0.003) 3px,
        rgba(0,0,0,0.003) 4px
    );
    pointer-events: none;
    z-index: 2;
}

/* LEFT PAGE: binding shadow on right edge */
.tf-left .tf-page-paper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 25px;
    height: 100%;
    background: linear-gradient(270deg,
        rgba(0,0,0,0.1) 0%,
        rgba(0,0,0,0.06) 30%,
        rgba(0,0,0,0.02) 60%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 3;
}

/* RIGHT PAGE: binding shadow on left edge */
.tf-right .tf-page-paper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 25px;
    height: 100%;
    background: linear-gradient(90deg,
        rgba(0,0,0,0.1) 0%,
        rgba(0,0,0,0.06) 30%,
        rgba(0,0,0,0.02) 60%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 3;
}

/* Page image */
.tf-page-paper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 1;
}

/* Hover curl shadow */
.tf-left:hover .tf-page-paper {
    box-shadow: inset -8px 0 15px -5px rgba(0,0,0,0.08);
}

.tf-right:hover .tf-page-paper {
    box-shadow: inset 8px 0 15px -5px rgba(0,0,0,0.08);
}

/* Left page outer shadow */
.tf-left .tf-page-paper {
    border-radius: 5px 0 0 5px;
    box-shadow: -3px 2px 8px rgba(0,0,0,0.1);
}

/* Right page outer shadow */
.tf-right .tf-page-paper {
    border-radius: 0 5px 5px 0;
    box-shadow: 3px 2px 8px rgba(0,0,0,0.1);
}

/* ============================================
   PAGE FLIP ANIMATION
   ============================================ */

/* Forward flip - right page */
.tf-right.tf-flip-page {
    animation: tfFlipRight 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform-origin: left center;
    z-index: 100;
}

@keyframes tfFlipRight {
    0% {
        transform: perspective(2000px) rotateY(0deg);
        box-shadow: 3px 2px 8px rgba(0,0,0,0.1);
    }
    20% {
        box-shadow: 8px 2px 20px rgba(0,0,0,0.2);
    }
    50% {
        transform: perspective(2000px) rotateY(-90deg);
        box-shadow: 15px 2px 30px rgba(0,0,0,0.25);
    }
    80% {
        box-shadow: 8px 2px 20px rgba(0,0,0,0.2);
    }
    100% {
        transform: perspective(2000px) rotateY(-180deg);
        box-shadow: -3px 2px 8px rgba(0,0,0,0.1);
    }
}

/* Backward flip - left page */
.tf-left.tf-flip-page-back {
    animation: tfFlipLeft 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform-origin: right center;
    z-index: 100;
}

@keyframes tfFlipLeft {
    0% {
        transform: perspective(2000px) rotateY(0deg);
        box-shadow: -3px 2px 8px rgba(0,0,0,0.1);
    }
    20% {
        box-shadow: -8px 2px 20px rgba(0,0,0,0.2);
    }
    50% {
        transform: perspective(2000px) rotateY(90deg);
        box-shadow: -15px 2px 30px rgba(0,0,0,0.25);
    }
    80% {
        box-shadow: -8px 2px 20px rgba(0,0,0,0.2);
    }
    100% {
        transform: perspective(2000px) rotateY(180deg);
        box-shadow: 3px 2px 8px rgba(0,0,0,0.1);
    }
}

/* ============================================
   CONTROLS
   ============================================ */
.tf-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, rgba(10,10,26,0.95), rgba(10,10,26,0.7));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 50;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.tf-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.tf-btn:hover {
    background: rgba(78,205,196,0.25);
    color: #4ecdc4;
}

.tf-btn:active { transform: scale(0.9); }

.tf-btn.tf-off {
    opacity: 0.2;
    pointer-events: none;
}

.tf-info {
    color: #fff;
    font-size: 14px;
    background: rgba(255,255,255,0.08);
    padding: 8px 16px;
    border-radius: 20px;
    min-width: 80px;
    text-align: center;
}

.tf-cur { color: #4ecdc4; font-weight: 700; }

.tf-sep {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    margin: 0 4px;
}

.tf-zoom {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    min-width: 40px;
    text-align: center;
}

/* Mobile */
@media (max-width: 768px) {
    .tantos-flipbook-container {
        border-radius: 0;
        margin: 0 -15px;
    }

    .tf-controls {
        height: 50px;
        gap: 5px;
    }

    .tf-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .tf-info {
        font-size: 12px;
        padding: 6px 10px;
        min-width: 60px;
    }

    .tf-zoom, .tf-sep { display: none; }
}
