/* Story Floating Button */
.story-float-button {
    position: fixed;
    bottom: 340px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 
        0 10px 30px rgba(139, 92, 246, 0.4),
        0 0 40px rgba(139, 92, 246, 0.2),
        0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 9997;
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.story-float-button:hover {
    animation-play-state: paused;
    transform: scale(1.05);
    box-shadow: 
        0 15px 40px rgba(139, 92, 246, 0.5),
        0 0 50px rgba(139, 92, 246, 0.3),
        0 5px 20px rgba(0, 0, 0, 0.4);
}

.story-float-button svg {
    width: 30px;
    height: 30px;
    fill: #ffffff;
}

/* Story Tooltip */
.story-tooltip {
    position: absolute;
    bottom: -40px;
    right: 80px;
    background: rgba(5, 6, 20, 0.95);
    color: #ffffff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.story-float-button:hover .story-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-5px);
}

/* Story Modal */
.story-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 0;
}

.story-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.story-modal {
    width: 95%;
    max-width: 1400px;
    background: linear-gradient(180deg, #070b1f 0%, #0a0e27 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(139, 92, 246, 0.2);
    transform: scale(0.95);
    transition: all 0.3s ease;
    height: 90vh;
    max-height: 90vh;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 5vh auto;
}

.story-modal-overlay.active .story-modal {
    transform: scale(1);
}

/* Story Modal Header */
.story-modal-header {
    padding: 15px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    position: relative;
    text-align: center;
    flex-shrink: 0;
}

.story-modal-title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.25rem 0;
}

.story-modal-subtitle {
    font-size: clamp(0.875rem, 2vw, 1.125rem);
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.story-modal-close {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.story-modal-close:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: rgba(255, 68, 68, 0.4);
    transform: rotate(90deg);
}

.story-modal-close svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    stroke-width: 2;
}

/* Story Modal Content */
.story-modal-content {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Book Container */
.book-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    perspective: 2000px;
    position: relative;
    width: 100%;
    height: 100%;
}

/* Book */
.book {
    position: relative;
    width: 900px;
    height: 600px;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
    z-index: 1;
    display: block;
}

/* Extra large screens */
@media (min-width: 1600px) and (min-height: 900px) {
    .book {
        width: 1000px;
        height: 650px;
    }
}

/* Book Pages */
.book-page {
    position: absolute;
    width: 50%;
    height: 100%;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform-origin: left center;
    transition: transform 0.6s ease, box-shadow 0.3s ease;
    backface-visibility: hidden;
    display: block;
    box-sizing: border-box;
}

/* Cover */
.cover {
    background: linear-gradient(135deg, #1a1f3a 0%, #0a0e27 100%);
    border: 2px solid rgba(53, 67, 240, 0.3);
    display: block !important;
}

.cover .page-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ffffff;
    text-align: center;
    overflow: hidden;
}

.cover h3 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.875rem;
    background: linear-gradient(135deg, #ffffff 0%, #3543F0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cover p {
    font-size: 1rem;
    color: #ffffff !important;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.start-reading {
    background: #3543F0;
    color: #ffffff;
    border: none;
    padding: 12px 30px;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-reading:hover {
    background: #2936d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(53, 67, 240, 0.4);
}

/* Left Pages */
.page-left {
    left: 0;
    transform-origin: right center;
    z-index: 5;
}

#cover-left {
    display: block !important;
}

/* Right Pages */
.page-right {
    left: 50%;
    z-index: 4;
}

/* Page Content */
.page-content {
    padding: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Page Images */
.page-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.page-image img {
    width: 90%;
    height: 90%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

/* Text Pages */
.page-right .page-content h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0a0e27;
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 2px solid #3543F0;
}

.page-right .page-content p {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #333;
    margin-bottom: 0.375rem;
}

.page-right .page-content p.highlight {
    background: rgba(53, 67, 240, 0.1);
    padding: 0.5rem;
    border-left: 3px solid #3543F0;
    font-weight: 600;
    margin: 0.5rem 0;
    font-size: 0.75rem;
    box-sizing: border-box;
}

/* Back Cover */
.back-cover {
    left: 0;
    transform-origin: right center;
    background: 
        linear-gradient(135deg, rgba(10, 14, 39, 0.8) 0%, rgba(26, 31, 58, 0.8) 100%),
        url('book-back-cover.png') center/cover;
    color: #ffffff;
    z-index: 1;
}

.back-cover .page-content {
    text-align: center;
}

.back-cover blockquote {
    font-size: 1.25rem;
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 2rem;
    padding: 0;
    border: none;
    color: rgba(255, 255, 255, 0.9);
}

/* Founder Info */
.founder-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.founder-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #3543F0;
}

.founder-details h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 0.25rem 0;
}

.founder-details p {
    font-size: 1rem;
    color: #3543F0;
    margin: 0;
}

/* Page States */
.book-page.flip {
    transform: rotateY(-180deg);
}

.page-left.flip {
    z-index: 15;
}

/* Book Navigation - Hide bottom navigation */
.book-navigation {
    display: none;
}

/* Page Navigation Arrows */
.page-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

/* Height-based adjustments */
@media (max-height: 900px) {
    .book {
        width: 700px;
        height: 450px;
    }
    .story-modal {
        min-height: 600px;
    }
}

@media (max-height: 800px) {
    .book {
        width: 600px;
        height: 380px;
    }
    .page-content {
        padding: 1.5rem;
    }
}

@media (max-height: 700px) {
    .book {
        width: 500px;
        height: 320px;
    }
    .story-modal-header {
        padding: 10px;
    }
    .story-modal-title {
        font-size: 1.25rem;
    }
    .story-modal-subtitle {
        font-size: 0.875rem;
    }
    .story-modal-content {
        padding: 10px;
    }
}

@media (max-height: 600px) {
    .story-modal {
        height: 98vh;
        min-height: 500px;
    }
    .book {
        width: 450px;
        height: 280px;
    }
    .page-content {
        padding: 1rem;
    }
}

.page-nav-arrow:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.page-nav-arrow.prev {
    left: -20px;
}

.page-nav-arrow.next {
    right: -20px;
}

.page-nav-arrow svg {
    width: 20px;
    height: 20px;
    stroke: #374151;
    stroke-width: 2;
}

.page-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-nav-arrow:disabled:hover {
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    stroke-width: 2;
}

.page-indicator {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

/* Mobile Navigation Arrows */
.mobile-nav-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-nav-arrow:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.mobile-nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.mobile-nav-arrow svg {
    width: 20px;
    height: 20px;
    stroke: #374151;
}

.mobile-nav-arrow.prev {
    left: 10px;
}

.mobile-nav-arrow.next {
    right: 10px;
}

.mobile-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile Page Counter */
.mobile-page-counter {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.875rem;
    z-index: 20;
}

/* Medium screens - 90% view */
@media (max-width: 1400px) {
    .book {
        width: 750px;
        height: 500px;
    }
}

/* Tablet - Mid size screens (90% to 60% viewport) */
@media (max-width: 1200px) {
    .story-modal {
        height: 85vh;
        min-height: 500px;
        margin: 7.5vh auto;
    }
    
    .book {
        width: 600px;
        height: 380px;
    }
}

@media (max-width: 1024px) {
    .story-modal {
        height: 85vh;
        max-height: 85vh;
        margin: 7.5vh auto;
    }
    
    .story-modal-header {
        padding: 12px;
    }
    
    .story-modal-title {
        font-size: 1.25rem;
    }
    
    .story-modal-subtitle {
        font-size: 0.875rem;
    }
    
    .book {
        width: 500px;
        height: 320px;
    }
    
    .story-modal-content {
        padding: 10px;
    }
    
    .page-content {
        padding: 1rem;
    }
}

@media (max-width: 900px) {
    .story-modal {
        height: 80vh;
        margin: 10vh auto;
    }
    
    .book {
        width: 450px;
        height: 290px;
    }
}

@media (max-width: 768px) {
    .story-float-button {
        bottom: 280px;
        right: 20px;
        width: 55px;
        height: 55px;
    }
    
    .story-modal {
        width: 95%;
        max-height: 85vh;
        min-height: auto;
    }
    
    /* Hide page navigation arrows on mobile - use mobile arrows instead */
    .page-nav-arrow {
        display: none !important;
    }
    
    .story-modal-header {
        padding: 20px;
    }
    
    .story-modal-title {
        font-size: 1.5rem;
    }
    
    .story-modal-subtitle {
        font-size: 1rem;
    }
    
    .story-modal-content {
        padding: 20px;
        position: relative;
    }
    
    /* Hide desktop navigation */
    .book-navigation {
        display: none;
    }
    
    /* Show mobile navigation */
    .mobile-nav-arrow {
        display: flex;
    }
    
    .mobile-page-counter {
        display: block;
    }
    
    /* Mobile book layout - single page view */
    .book-container {
        min-height: 350px;
        perspective: none;
        position: relative;
        padding: 10px 0;
    }
    
    .book {
        width: 90%;
        height: 400px;
        max-width: 400px;
        transform-style: flat;
        position: relative;
        margin: 0 auto;
    }
    
    /* Show only one page at a time on mobile */
    .book-page {
        position: absolute !important;
        width: 100%;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
        display: none !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        border-radius: 12px;
        margin-bottom: 0;
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .book-page.mobile-active {
        display: block !important;
        visibility: visible;
        opacity: 1;
        position: relative !important;
    }
    
    /* Remove flip animation on mobile */
    .book-page.flip {
        transform: none !important;
    }
    
    /* Adjust page content for mobile */
    .page-content {
        padding: 20px;
        min-height: 350px;
    }
    
    .page-image img {
        width: 100%;
        height: auto;
        max-height: 300px;
        object-fit: contain;
    }
    
    /* Text sizing for mobile */
    .page-right .page-content h3 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }
    
    .page-right .page-content p {
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
    }
    
    .page-right .page-content p.highlight {
        font-size: 0.8125rem;
        padding: 0.5rem;
        margin: 0.75rem 0;
    }
    
    .cover h3 {
        font-size: 1.75rem;
    }
    
    .cover p {
        font-size: 1rem;
    }
    
    .start-reading {
        padding: 10px 24px;
        font-size: 1rem;
    }
    
    .back-cover blockquote {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .founder-details h4 {
        font-size: 1.125rem;
    }
    
    .founder-details p {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .story-modal-title {
        font-size: 1.25rem;
    }
    
    .story-modal-subtitle {
        font-size: 0.875rem;
    }
    
    .page-content {
        padding: 15px;
        min-height: 300px;
    }
    
    .page-right .page-content h3 {
        font-size: 1.125rem;
    }
    
    .page-right .page-content p {
        font-size: 0.8125rem;
    }
    
    .page-right .page-content p.highlight {
        font-size: 0.75rem;
    }
    
    .cover h3 {
        font-size: 1.5rem;
    }
    
    .start-reading {
        padding: 8px 20px;
        font-size: 0.875rem;
    }
}