:root {
    --bg-color: #1a1512;
    --paper-color: #f7f1e3;
    --paper-dark: #e8dcc4;
    --text-color: #2c2520;
    --text-light: #706357;
    --accent-color: #8c3b19;
    --accent-hover: #a64c24;
    --border-color: rgba(44, 37, 32, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(30, 20, 15, 0.65) 0%, rgba(10, 5, 5, 0.75) 100%),
        url("images/build/bkg.jpg");
    background-repeat: repeat;
    color: var(--paper-color);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: scroll; /* Force vertical scrollbar to prevent horizontal layout shifts */
}

.container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

.site-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    color: #e3d2b3;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.site-subtitle {
    font-family: 'Lora', serif;
    font-style: italic;
    color: #a8947b;
    font-size: 1.2rem;
}

.book-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
    flex-grow: 1;
}

.page-content {
    background-color: var(--paper-color);
    border-radius: 4px;
    box-shadow: 
        inset 0 0 40px rgba(139, 90, 43, 0.1),
        0 20px 50px rgba(0,0,0,0.5),
        0 0 0 1px rgba(255,255,255,0.1);
    display: flex;
    flex: 1; /* Make it strictly fill the remaining space */
    min-width: 0; /* Prevent flex items from overflowing container */
    width: 100%;
    min-height: 700px;
    position: relative;
    overflow: hidden;
    color: var(--text-color);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.page-content.active {
    opacity: 1;
    transform: translateY(0);
}

/* Spine effect in the middle */
.page-content::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, 
        rgba(0,0,0,0) 0%, 
        rgba(0,0,0,0.05) 45%,
        rgba(0,0,0,0.15) 50%,
        rgba(0,0,0,0.05) 55%,
        rgba(0,0,0,0) 100%);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
}

.image-section {
    flex: 0 0 50%;
    width: 50%;
    padding: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border-color);
    position: relative;
}

.page-content.no-image .image-section {
    visibility: hidden; /* Keep blank space on desktop layout */
}

.modal-trigger {
    cursor: pointer;
}

.image-wrapper {
    position: relative;
    border: 8px solid white;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    transform: rotate(-1deg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: white;
}

.image-wrapper:hover {
    transform: rotate(0deg) scale(1.02);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}

.image-wrapper img {
    max-width: 100%;
    max-height: 600px;
    display: block;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.zoom-hint {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0,0,0,0.6);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-wrapper:hover .zoom-hint {
    opacity: 1;
}

.text-section {
    flex: 0 0 50%;
    width: 50%;
    padding: 4rem 3rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 750px;
}

.page-title {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 2rem;
    position: relative;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: var(--accent-color);
}

.page-text {
    font-family: 'Lora', serif;
    font-size: 1.1rem;
    line-height: 1.8;
}

.page-text p {
    margin-bottom: 1.5rem;
}

.page-text hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
}

.page-text sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
    top: -0.5em;
}

.page-text a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px dotted var(--accent-color);
    transition: color 0.2s, border-bottom 0.2s;
}

.page-text a:hover {
    color: var(--accent-hover);
    border-bottom: 1px solid var(--accent-hover);
}

.footnote {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Navigation Buttons */
.nav-button {
    background: rgba(20, 15, 12, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e3d2b3;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
}

.nav-button:hover {
    background: rgba(140, 59, 25, 0.8);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.nav-button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Progress Area */
.progress-container {
    margin-top: 3rem;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--progress, 0%);
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.page-counter {
    text-align: center;
    margin-top: 1rem;
    font-family: 'Cinzel', serif;
    color: #a8947b;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.4);
    font-size: 0.9rem;
}

/* Form Styles */
.form-container {
    margin-top: 2rem;
    background: rgba(0,0,0,0.03);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-container h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.submit-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-family: 'Inter', sans-serif;
}

.submit-btn:hover {
    background: var(--accent-hover);
}

.form-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    display: none;
}

.form-message.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Hide reCAPTCHA badge on pages without the form */
body:not(.show-recaptcha) .grecaptcha-badge {
    visibility: hidden !important;
}

/* Responsive */
@media (max-width: 900px) {
    .page-content {
        flex-direction: column;
        min-height: auto;
    }
    
    .page-content::after {
        display: none; /* Hide spine on mobile */
    }
    
    .page-content.no-image .image-section {
        display: none; /* Completely collapse the space on mobile */
    }
    
    .image-section {
        flex: none;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 2rem;
    }
    
    .text-section {
        flex: none;
        width: 100%;
        padding: 2rem;
        max-height: none; /* Let content expand naturally on mobile */
        overflow-y: visible;
    }
    
    .nav-button {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        z-index: 100;
        box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    }
    
    .nav-button:hover {
        transform: translateY(-50%) scale(1.1);
    }
    
    .prev-btn { left: 10px; }
    .next-btn { right: 10px; }
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; 
    z-index: 1000; 
    padding-top: 50px;
    padding-bottom: 50px;
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border: 10px solid white;
    background: white;
    animation-name: zoom;
    animation-duration: 0.3s;
}

@keyframes zoom {
    from {transform:scale(0.9); opacity: 0;}
    to {transform:scale(1); opacity: 1;}
}

.modal-close {
    position: absolute;
    top: 25px;
    right: 40px;
    color: #f1f1f1;
    font-size: 50px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 1001;
}

.modal-close:hover,
.modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

