/* Full-screen loading overlay */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

/* General Body & HTML Reset */
html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: 'Helvetica Neue', sans-serif;
    color: #e0e0e0;
}

/* Full-screen video background */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -2;
    background-color: #000;
    background-image: url('images/beforev.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

.video-background video {
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    pointer-events: none;
}

/* Main Content Wrapper */
.content {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Main Stage */
.site-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    flex-grow: 1;
}

/* --- HOME PAGE STYLES --- */
.main-title-img {
    position: absolute;
    width: 38vw;
    top: 25vh;
    left: 50%;
    transform: translateX(-50%);
    height: auto;
    z-index: 5;
    pointer-events: none;
}
.book-cover {
    width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: block;
}
.book-link {
    text-decoration: none;
    display: block;
    transform: scale(1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 4;
}
.book-link:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 6;
}
.book-group {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
}
.left-book {
    width: 14vw;
    top: 38vh;
    left: 12vw;
    transform: translate(-50%, -50%);
}
.right-book {
    width: 14vw;
    top: 52vh;
    left: 89vw;
    transform: translate(-50%, -50%);
    z-index: 5;
}
.promo-text-available {
    position: absolute;
    width: 20vw;
    top: -12vh;
    left: 55%;
    transform: translateX(-50%);
    height: auto;
    pointer-events: none;
}
.promo-text-saga {
    position: absolute;
    width: 17vw;
    top: 80vh;
    left: 89vw;
    transform: translateX(-50%);
    height: auto;
    pointer-events: none;
    z-index: 5;
}
.promo-text-coming {
    position: absolute;
    width: 20vw;
    top: 85vh;
    left: 89vw;
    transform: translateX(-50%);
    height: auto;
    pointer-events: none;
    z-index: 5;
}

/* --- FOOTER & MUSIC BUTTON --- */
footer {
    position: relative;
    width: 100%;
    text-align: center;
    padding: 1vh 0;
    color: #aaa;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.8em;
    z-index: 100;
}
footer p { margin: 0; }

#musicToggleButton {
    position: absolute;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    z-index: 101;
    transition: background-color 0.3s ease, color 0.3s ease;
}
#musicToggleButton:hover {
    background-color: rgba(255, 255, 255, 0.8);
    color: #000;
}

/* === ELEGANT FADE TRANSITION AT YOUR PERFECT SPEED === */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity 3.2s ease-in-out, transform 3.2s ease-in-out;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}
.view.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    z-index: 11;
}
.view.fading-out {
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
    z-index: 10;
}

/* --- BOOK DETAIL PAGE STYLES --- */
.book-page-container {
    display: flex;
    flex-direction: column; /* Default for mobile */
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
    gap: 3vw;
    position: relative;
    margin: auto;
    padding: 20px;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
}
.cover-container {
    flex: 0 0 auto;
    height: auto;
    text-align: center;
}
.book-cover-large {
    width: 60%;
    max-width: 300px;
    height: auto;
    object-fit: contain;
}
.book-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    color: #fff;
    font-family: 'Cinzel', serif;
}
.book-text-content {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 15px;
    box-sizing: border-box;
}
.book-details h1 {
    font-size: clamp(1.5rem, 3.5vmin, 2.5rem);
    margin-top: 0;
    text-align: center;
}
.book-details h2 {
    font-size: clamp(1rem, 2vmin, 1.5rem);
    font-style: italic;
    color: #ccc;
    margin-bottom: 1.5em;
    text-align: center;
}
.book-details p {
    font-size: clamp(0.8rem, 1.8vmin, 1.1rem);
    text-align: justify;
    line-height: 1.6;
    margin-bottom: 1.5em;
}
.book-details p.tagline {
    font-style: italic;
    text-align: center;
}

/* === BUTTON CONTAINER FOR TASTE & BUY === */
.purchase-options-container {
    margin-top: auto;
    padding-top: 2vh;
}
.button-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.taste-button-wrapper {
    /* Sits on the left */
}
.buy-buttons-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}
.purchase-button, .taste-button {
    display: block;
    padding: 10px 20px;
    background-color: #333;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
    font-size: clamp(0.7rem, 1.5vmin, 0.9rem);
    text-align: center;
    border: 2px solid #555;
}
.purchase-button:hover, .taste-button:hover {
    background-color: #555;
    border-color: #777;
}
.taste-button {
    background-color: #1a3c52;
    border-color: #3c7cac;
}
.taste-button:hover {
    background-color: #2a5c85;
    border-color: #5c9ccc;
}
.home-icon-button img {
    width: 40px;
    height: 40px;
    display: block;
    transition: transform 0.3s ease-in-out;
}
.home-icon-button:hover img {
    transform: scale(1.1);
}

/* === READING ROOM OVERLAY STYLES === */
.reading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out, backdrop-filter 0.8s ease-in-out;
    backdrop-filter: blur(0px);
}
.reading-overlay.visible {
    opacity: 1;
    pointer-events: auto;
    backdrop-filter: blur(8px);
}
#chapter-content-wrapper {
    width: 80%;
    max-width: 800px;
    height: 80vh;
    background-color: #080808;
    border: 1px solid #444;
    border-radius: 10px;
    transform: translateY(-20px);
    transition: opacity 1.0s ease-out 0.3s, transform 1.0s ease-out 0.3s;
    opacity: 0;
    display: flex;
    flex-direction: column;
}
.reading-overlay.visible #chapter-content-wrapper {
    transform: translateY(0);
    opacity: 1;
}
#chapter-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px;
    color: #e0e0e0;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    line-height: 1.7;
}
.close-button {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 3rem;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease, color 0.3s ease;
    z-index: 1001;
}
.close-button:hover {
    transform: scale(1.2);
    color: #aaa;
}

/* --- THE NEW, SMARTER MEDIA QUERY --- */
/* This spell says: ONLY use the side-by-side layout if the screen is WIDE AND TALL enough */
@media (min-width: 768px) and (min-height: 500px) {
    .book-page-container {
        flex-direction: row;
        align-items: flex-start;
    }
    .cover-container {
        flex: 0 0 33%;
        height: 100%;
        text-align: left;
    }
    .book-cover-large {
        width: 100%;
        max-width: 100%;
        height: 100%;
    }
    .book-details h1, .book-details h2, .book-details p, .book-details p.tagline {
        text-align: left;
    }
    #weaver-detail-view .book-cover-large {
        width: 80%;
        max-width: 80%;
        height: auto;
    }
}
#ebook-button { display: none; }
.coming-soon-text {
    display: block;
    width: 80%;
    max-width: 250px;
    padding: 15px 20px;
    background-color: #444;
    color: #fff;
    border-radius: 5px;
    font-size: clamp(0.8rem, 1.6vmin, 1rem);
    text-align: center;
    font-weight: bold;
    border: 2px solid #666;
    margin-bottom: 10px;
}