/* --- Global Reset & Scroll Snap --- */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #000;
    overflow-x: hidden; /* Prevent unwanted horizontal scrolling on mobile */
}

/* Container for full-page scrolling */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

section {
    scroll-snap-align: start;
    position: relative;
    background-size: cover;
    background-position: center;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

/* Vignette Overlay: Darker on mobile for text readability */
section::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.3) 100%);
    z-index: 1;
}

.container {
    position: relative;
    z-index: 2;
}

/* --- Typography (Fluid Sizing) --- */
.hero-title {
    font-family: 'Cormorant Garamond', serif;
    /* Scales from 2.5rem on small screens to 5.5rem on large screens */
    font-size: clamp(2.5rem, 10vw, 5.5rem);
    line-height: 0.95;
    text-transform: uppercase;
    font-weight: 400;
}

.journal-excerpt {
    font-family: 'Cormorant Garamond', sans-serif;
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 300;
    line-height: 1.6;
    max-width: 550px;
}

.series-tag {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1rem, 3vw, 1.6rem);
    line-height: 1.2;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.brand-text {
    font-family: 'Cormorant Garamond', sans-serif;
    letter-spacing: 0.3em;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-top: 1px solid rgba(0,0,0,0.2);
    display: inline-block;
    padding-top: 15px;
    margin-top: 20px;
}

/* --- Backgrounds --- */
.bg-section-1 { background-image: url('/images/main.jpg'); }
.bg-section-2 { background-image: url('/images/page2.jpg'); background-color: rgb(10, 19, 30); }
.bg-section-3 { background-image: url('/images/page3.jpg'); }
.bg-section-4 { background-image: url('/images/page4.jpg'); }
.bg-section-5 { background-color: rgb(19, 20, 76); }

/* --- Buttons --- */
.btn-journal {
    display: inline-block;
    width: 100%; /* Full width on mobile */
    max-width: 280px;
    padding: 12px 20px;
    text-decoration: none;
    font-family: 'Cormorant Garamond', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-align: center;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

/* Desktop Button width */
@media (min-width: 768px) {
    .btn-journal { width: 220px; }
}

.btn-journal.outline {
    border: 1px solid rgba(255, 255, 255, 0.8);
    color: #ffffff;
    background: transparent;
}

.btn-journal.outline:hover {
    background: rgba(255, 255, 255, 1);
    color: #000;
}

.btn-journal.solid {
    background-color: #e9ecef;
    color: #1a1a1a;
    border: 1px solid #e9ecef;
}

/* --- Book Modal (3D Flip Animation) --- */
.book-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: radial-gradient(circle, #1a1a1a 0%, #000 100%);
    z-index: 10000;
    align-items: center; justify-content: center;
    perspective: 2500px;
    transition: opacity 0.4s ease;
}

.book-viewport {
    width: 90vw;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-offset-container {
    width: 100%;
    max-width: 450px; /* Mobile width */
    height: 100%;
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    position: relative;
}

/* Desktop Spread Logic */
@media (min-width: 992px) {
    .book-offset-container { width: 40vw; max-width: none; }
    /* Shifts the spine to the center so two pages are visible */
    .book-offset-container.open-spread { transform: translateX(50%); }
}

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

.paper {
    position: absolute;
    width: 100%;
    height: 100%;
    /* Default for mobile: flip from the center or right to stay in place */
    transform-origin: center;
    transition: transform 1.2s cubic-bezier(0.15, 0, 0.15, 1);
    transform-style: preserve-3d;
}

@media (min-width: 992px) {
    /* Desktop: flip from the left edge to create the book-opening effect */
    .paper { transform-origin: left; }
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: #fdfaf0;
    padding: clamp(20px, 5vw, 60px); /* Slightly tighter padding for mobile */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow-y: auto;
    color: #333;
}

.back { transform: rotateY(180deg); }

/* The actual flip animation */
.paper.flipped {
    transform: rotateY(-180deg);
}

/* Exit Button Styling */
.exit-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 10px 20px;
    cursor: pointer;
    z-index: 10002;
    transition: all 0.3s ease;
    font-family: 'Cormorant Garamond', sans-serif;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
}

.exit-btn:hover {
    background: #fff;
    color: #000;
}

/* Helper for author image spacing */
@media (max-width: 991px) {
    .bg-section-5 { padding: 80px 0; }
}