/* =================================================
   REVERIE HOUSE - UNIFIED BOOKS SYSTEM STYLESHEET
   Consolidated: library.css + print.css + books.css + reader.css
   Manages: Library View, Book Cards, TOC, Reader, Print Shop
   ================================================= */

/* =================================================
   CSS VARIABLES & THEME SYSTEM
   ================================================= */

:root {
    /* Library colors */
    --library-primary: #000080;
    --library-primary-hover: #333399;
    --library-text: #333333;
    --library-text-light: #666666;
    --library-bg: #ffffff;
    --library-border: #cccccc;
    
    /* Book-specific colors */
    --seeker-color: #5c3d5e;
    --prince-color: #A52A2A;
    
    /* Reader theme - customizable */
    --reader-theme-bg: #ffffff;
    --reader-theme-text: #333333;
    --reader-font-size: 19px;
    --reader-line-height: 1.75;
    --reader-font-family: "Crimson Text", Georgia, serif;
    
    /* Chapter-specific theming (set dynamically per chapter) */
    --chapter-hue: 230;
    --chapter-saturation: 60%;
    --chapter-lightness: 45%;
    --chapter-primary: #4a5f8f;
    
    /* Dynamic color system (for reading view) */
    --ecosystem-hue: 230;
    --ecosystem-saturation: 80%;
    --ecosystem-lightness: 35%;
    --color-drift: 0;
    --primary-dynamic: hsl(calc(var(--ecosystem-hue) + var(--color-drift)), var(--ecosystem-saturation), var(--ecosystem-lightness));
    --glow-dynamic: hsla(var(--ecosystem-hue), calc(var(--ecosystem-saturation) * 1.5), calc(var(--ecosystem-lightness) + 20%), 0.3);
}

/* Theme variations */
.theme-dark {
    --reader-theme-bg: #1a1a1a;
    --reader-theme-text: #e0e0e0;
}

.theme-sepia {
    --reader-theme-bg: #f7f3e9;
    --reader-theme-text: #5c4b37;
}

/* =================================================
   BASE HTML & BODY STYLES
   ================================================= */

html, body {
    width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body.toc-open {
    overflow: hidden;
}

/* =================================================
   MAIN CONTENT & LIBRARY SECTION
   ================================================= */

.main-content {
    max-width: 900px;
    margin: 30px auto 40px auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

.library-section {
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 100%;
    box-sizing: border-box;
}

/* Hide invite section when in reading mode */
body.reading-mode .invite-section {
    display: none !important;
}

/* Hide library header when in reading mode */
body.reading-mode .library-header {
    display: none;
}

/* Full-width borderless reading mode */
body.reading-mode .library-section {
    border: none;
    box-shadow: none;
    background-color: transparent;
    max-width: none;
}

body.reading-mode .main-content {
    max-width: none;
    margin: 0;
    padding: 0;
}

.library-header {
    text-align: center;
    padding: 30px 30px 24px 30px;
    border-bottom: 1px solid #e0e0e0;
}

.library-logo {
    height: 60px;
    width: auto;
    margin-bottom: 16px;
}

.library-logo--large {
    height: 110px;
}

.library-description {
    font-size: 1rem;
    color: #555555;
    margin: 0;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.library-subnote {
    text-align: center;
    padding: 20px 30px 30px 30px;
    color: #777777;
}

.library-subnote small {
    font-size: 0.85rem;
    line-height: 1.6;
}

.library-subnote a {
    color: #000080;
    text-decoration: none;
}

.library-subnote a:hover {
    text-decoration: underline;
}

/* =================================================
   LIBRARY VIEW - BOOKS CONTAINER & BOOK CARDS
   ================================================= */

.library-view {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 60px 20px;
    display: flex;
    justify-content: center;
}

.book-shelf {
    display: flex;
    justify-content: center;
    gap: 50px;
    flex-wrap: wrap;
    width: 100%;
}

.books-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    padding: 40px 30px;
    justify-items: center;
}

.book-card {
    background-color: transparent;
    border: none;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease;
    max-width: 380px;
}

.book-card:hover {
    transform: translateY(-3px);
}

.book-cover-container {
    margin-bottom: 20px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.book-cover-container:hover {
    opacity: 0.85;
}

.book-cover {
    width: 100%;
    max-width: 250px;
    height: auto;
    border: 2px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-card[data-featured="true"] .book-cover {
    border-color: var(--seeker-color);
}

.book-card[data-featured="false"] .book-cover {
    border-color: var(--prince-color);
}

.book-card h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 15px 0 8px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.book-author {
    font-size: 0.95rem;
    color: #666666;
    font-style: italic;
    margin: 0 0 15px 0;
}

/* Status Badge */
.book-status {
    margin: 15px 0;
}

.status-available {
    display: inline-block;
    padding: 6px 16px;
    background-color: #4CAF50;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-coming-soon {
    display: inline-block;
    padding: 6px 16px;
    background-color: #999999;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Format Buttons */
.book-format-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.book-format-btn {
    padding: 10px 20px;
    background-color: #000080;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.book-format-btn:hover:not(:disabled) {
    background-color: #333399;
}

.book-format-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* =================================================
   PRINT SHOP - ORDER PAGE
   ================================================= */

.print-content {
    background: #faf7fc;
}

/* Checkout Messages */
.checkout-message {
    max-width: 1000px;
    margin: 20px auto 30px auto;
    padding: 20px 30px;
    border-radius: 6px;
    text-align: center;
}

.checkout-message.success {
    background-color: #d4edda;
    border: 2px solid #28a745;
    color: #155724;
}

.checkout-message.cancel {
    background-color: #fff3cd;
    border: 2px solid #ffc107;
    color: #856404;
}

.checkout-message h3 {
    margin: 0 0 10px 0;
    font-size: 1.4rem;
}

.checkout-message p {
    margin: 0 0 15px 0;
    font-size: 1rem;
}

.checkout-message button {
    padding: 10px 24px;
    background-color: #000080;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.checkout-message button:hover {
    background-color: #333399;
}

/* Main Order Section */
.order-section {
    padding: 40px 30px 60px 30px;
    border-bottom: 1px solid #e0e0e0;
}

.order-content {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: start;
}

/* Left side - Book showcase */
.order-left {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.book-showcase {
    text-align: center;
    width: 100%;
}

.showcase-cover {
    width: 100%;
    max-width: 320px;
    height: auto;
    border: 3px solid var(--seeker-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
    transition: transform 0.3s ease;
    cursor: pointer;
    position: relative;
}

.showcase-cover:hover {
    transform: scale(1.015);
}

.princes-cover {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.princes-cover:hover {
    transform: scale(1.02);
}

.first-print-label {
    margin-top: 10px;
    text-align: center;
    font-size: 1.18em;
    font-weight: bold;
    color: #000;
    letter-spacing: 0.03em;
    width: 100%;
}

.book-title {
    font-size: 2.1rem;
    font-weight: bold;
    color: #8c6bb1;
    margin: 8px 0 16px 0;
    line-height: 1.18;
    text-align: center;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Book synopsis */
.book-synopsis {
    margin-top: 24px;
    padding: 20px;
    background-color: #f9f9f9;
    border-left: 4px solid var(--seeker-color);
    text-align: left;
    max-width: 360px;
}

.book-synopsis p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #333;
    margin: 0 0 12px 0;
}

.book-synopsis p:last-child {
    margin-bottom: 0;
}

/* Synopsis box - modern bounded style */
.synopsisbox {
    font-size: 0.92rem;
    color: #2a2a2a;
    line-height: 1.65;
    background: #fff;
    border: 1px solid #d5d5d5;
    border-radius: 0;
    padding: 16px 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Right side - Order form */
.order-right {
    background-color: #f9f9f9;
    border: 2px solid #d0d0d0;
    padding: 40px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.order-form h3 {
    font-size: 1.8rem;
    margin: 0 0 15px 0;
    color: #2a2a2a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.order-description {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.7;
    margin: 0 0 25px 0;
}

.order-description strong {
    color: #2a2a2a;
    font-size: 1.05rem;
    display: block;
    margin-bottom: 6px;
}

/* Quantity slider */
.quantity-slider-container {
    margin: 25px 0;
}

.quantity-slider-container label {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0;
    color: #2a2a2a;
    text-align: center;
}

.quantity-slider-container label span {
    display: inline-block;
    transition: transform 0.3s ease;
}

#quantity-display {
    color: var(--seeker-color);
    font-size: 1.3rem;
    animation: casualRock1 4.2s ease-in-out infinite;
}

#copies-label {
    color: var(--seeker-color);
    font-size: 1.1rem;
    animation: casualRock2 3.8s ease-in-out infinite;
}

@keyframes casualRock1 {
    0%, 100% { transform: rotate(-1deg) translateY(0px); }
    25% { transform: rotate(2deg) translateY(-1px); }
    50% { transform: rotate(-1.5deg) translateY(1px); }
    75% { transform: rotate(1deg) translateY(-0.5px); }
}

@keyframes casualRock2 {
    0%, 100% { transform: rotate(1deg) translateY(0px); }
    25% { transform: rotate(-2deg) translateY(1px); }
    50% { transform: rotate(1.5deg) translateY(-1px); }
    75% { transform: rotate(-1deg) translateY(0.5px); }
}

.quantity-slider-container label span.quantity-bump {
    animation: quantityBump 0.4s ease !important;
}

@keyframes quantityBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(5deg); }
    100% { transform: scale(1); }
}

.slider-wrapper {
    position: relative;
    padding: 20px 0;
    margin-bottom: 15px;
}

.quantity-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #9374c2 50%, #8c6bb1 100%);
    outline: none;
    border-radius: 4px;
    position: relative;
    z-index: 2;
    --slider-tilt: 0deg;
}

.quantity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-image: url('/assets/slider_knob.png');
    background-size: cover;
    background-position: center;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: rotate(var(--slider-tilt, 0deg));
    transition: transform 0.15s ease-out;
    animation: knobPulse 6s ease-in-out infinite, knobGlint 8s ease-in-out infinite;
}

@keyframes knobPulse {
    0%, 100% { transform: rotate(var(--slider-tilt, 0deg)) scale(1); }
    50% { transform: rotate(var(--slider-tilt, 0deg)) scale(1.03); }
}

@keyframes knobGlint {
    0%, 90%, 100% { filter: brightness(1); }
    93%, 97% { filter: brightness(1.4); }
    95% { filter: brightness(1.6); }
}

.quantity-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.quantity-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.quantity-slider::-moz-range-thumb {
    width: 40px;
    height: 40px;
    background-image: url('/assets/slider_knob.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: grab;
    border-radius: 50%;
    border: none;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    transform: rotate(var(--slider-tilt));
}

.quantity-slider::-moz-range-thumb:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.quantity-slider::-moz-range-thumb:active {
    cursor: grabbing;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.slider-notches {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 8px;
    margin-top: -4px;
    pointer-events: none;
    z-index: 1;
}

.slider-notch {
    position: absolute;
    width: 3px;
    height: 16px;
    background: white;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1px;
}

.quantity-select {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid #d0d0d0;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.quantity-select:hover {
    border-color: #000080;
}

.quantity-select:focus {
    outline: none;
    border-color: #000080;
}

/* Price display */
.price-display {
    background-color: white;
    border: 2px solid #e0e0e0;
    padding: 20px;
    margin: 25px 0;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 1rem;
}

.price-row + .price-row {
    border-top: 1px solid #f0f0f0;
}

.price-label {
    font-weight: 500;
    color: #555;
}

.price-value {
    font-weight: 600;
    color: #2a2a2a;
}

.total-row {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid #d0d0d0 !important;
}

.total-row .price-label {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2a2a2a;
}

.total-row .price-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #7a3fc7;
    transition: color 0.6s cubic-bezier(0.4,0.7,0.5,1);
}

.total-row .price-value.price-animating {
    color: #b39ddb;
}

/* Order button */

.order-now-btn {
    width: 100%;
    padding: 18px 24px;
    background: linear-gradient(120deg, #8c6bb1 0%, #a084ca 50%, #6c4f8c 100%);
    background-size: 200% 100%;
    background-position: 50% 0%;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.15rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 20px rgba(140, 107, 177, 0.35), 
                0 0px 0px 0px #fff, 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}



@keyframes orderShimmer {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 100% 0%;
    }
}

.order-now-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.free-shipping-banner {
    text-align: center;
    margin-bottom: 14px;
    font-weight: bold;
    color: #000;
    letter-spacing: 0.03em;
    font-size: 1.02em;
}


.order-now-btn:hover {
    background-position: 80% 0%;
    box-shadow: 0 10px 32px 0 rgba(108, 79, 140, 0.55), 0 0 0 4px rgba(187,166,224,0.10) inset;
    transform: translateY(-2px) scale(1.015);
    letter-spacing: 3px;
}

.order-now-btn:hover::before {
    opacity: 1;
}

.order-now-btn:active {
    transform: translateY(-1px) scale(0.99);
    box-shadow: 0 4px 14px rgba(135, 64, 141, 0.4);
    transition: all 0.1s ease;
}

/* Action buttons - Kindle, Read Online, ePub, Request Copy */
.kindle-btn {
    display: block;
    margin: 12px 0 0 0;
    text-align: center;
    text-decoration: none;
}

.kindle-button,
.read-online-btn,
.download-epub-btn,
.request-copy-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: #2a2a2a;
    border: 3px solid #2a2a2a;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Override for Read Online - make it blue */
.read-online-btn {
    background: #000080;
    border-color: #000080;
}

.kindle-button:hover {
    border-color: #FFB84D;
    transform: scale(1.03);
}

.read-online-btn:hover {
    border-color: #4da6ff;
    transform: scale(1.03);
}

.download-epub-btn:hover {
    border-color: #3dbd43;
    transform: scale(1.03);
}

.request-copy-btn {
    padding: 10px 18px;
    font-size: 0.88rem;
    background: var(--prince-color);
    border: 3px solid var(--prince-color);
    white-space: nowrap;
}

.request-copy-btn:hover {
    border-color: #000;
    transform: scale(1.03);
}

.kindle-button:active,
.read-online-btn:active,
.download-epub-btn:active,
.request-copy-btn:active {
    transform: scale(1.01);
}

.cc0-notice {
    margin-top: 12px;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    font-size: 0.66rem;
    color: #666;
    line-height: 1.5;
    text-align: center;
}

.cc0-notice a {
    color: var(--seeker-color);
    text-decoration: none;
}

.cc0-notice a:hover {
    text-decoration: underline;
}

.order-note {
    margin: 20px 0 0 0;
    text-align: center;
    font-size: 0.9rem;
    color: #777;
    line-height: 1.6;
}

.order-note a {
    color: #000080;
    text-decoration: none;
}

.order-note a:hover {
    text-decoration: underline;
}

/* Print book cover specific styles */
.print-book-cover {
    width: 220px;
    height: auto;
    border: 1px solid #000080;
    border-radius: 4px;
}

.print-synopsis-box {
    padding: 10px;
    max-width: 460px; 
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #000080;
    background-color: #ffffff;
    text-align: center;
}

.print-seeker-title {
    font-size: 42px;
    margin-bottom: 2px;
    color: var(--seeker-color);
}

.print-seeker-info {
    color: #7f2c86;
    margin-bottom: 15px;
}

.print-seeker-synopsis {
    border-color: #8c2596;
    color: #333333;
}

/* =================================================
   READER - CHAPTER DISPLAY
   ================================================= */

.reader-content {
    max-width: 100%;
    margin: 0 auto;
    background: var(--reader-theme-bg);
    color: var(--reader-theme-text);
}

body.reading-mode .chapter-reader {
    max-width: 750px;
    margin: 0 auto 60px auto;
    padding: 80px 40px 0 40px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.chapter-reader {
    background: white;
}

body.reading-mode .chapter-content {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 20px 0 60px 0;
    max-width: 680px;
    margin: 0 auto;
    font-size: 19px;
    line-height: 1.75;
}

.chapter-content {
    padding: 40px;
    max-width: 750px;
    margin: 0 auto;
    font-family: var(--reader-font-family);
    font-size: var(--reader-font-size);
    line-height: var(--reader-line-height);
    color: var(--reader-theme-text);
}

/* Compact chapter header */
.chapter-header-compact {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

body.reading-mode .chapter-header-compact {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.chapter-number {
    font-size: 12px;
    color: #999;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

body.reading-mode .chapter-number {
    font-size: 11px;
    color: #999;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.chapter-title-compact {
    font-size: 28px;
    font-weight: 400;
    color: #2a2a2a;
    margin: 0;
    line-height: 1.3;
    font-style: italic;
}

body.reading-mode .chapter-title-compact {
    font-size: 32px;
    font-weight: 400;
    color: #2a2a2a;
    margin: 0;
    line-height: 1.3;
    font-style: italic;
}

/* Chapter body wrapper */
.chapter-body {
    margin-top: 20px;
}

/* Old inline header (deprecated but kept for compatibility) */
.chapter-header-inline {
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.chapter-title-inline {
    font-size: 28px;
    font-weight: 400;
    color: #2a2a2a;
    margin: 0;
    line-height: 1.3;
    font-style: italic;
}

.chapter-content h1 {
    font-size: 2rem;
    margin: 2em 0 1em 0;
    color: var(--chapter-primary);
}

.chapter-content h2 {
    font-size: 1.5rem;
    margin: 1.5em 0 0.75em 0;
    color: var(--chapter-primary);
}

.chapter-content h3 {
    font-size: 1.25rem;
    margin: 1.25em 0 0.5em 0;
    color: var(--chapter-primary);
}

.chapter-content p {
    margin: 0 0 1.5em 0;
    text-align: justify;
}

.chapter-content p:first-of-type,
.chapter-content h1 + p,
.chapter-content h2 + p,
.chapter-content h3 + p {
    text-indent: 0;
}

.chapter-content p:first-of-type::first-letter {
    font-size: 3.5em;
    line-height: 0.9;
    float: left;
    margin: 0.1em 0.1em 0 0;
    font-weight: bold;
    color: var(--chapter-primary);
}

.chapter-content blockquote {
    margin: 2em 2em;
    padding: 1em 1.5em;
    border-left: 4px solid var(--chapter-primary);
    background: rgba(0, 0, 0, 0.02);
    font-style: italic;
}

.chapter-content blockquote::before {
    content: '"';
    font-size: 3em;
    color: var(--chapter-primary);
    opacity: 0.3;
    float: left;
    margin: -0.3em 0.1em 0 -0.5em;
}

.chapter-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.chapter-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1.5em 0;
}

.chapter-content ul, .chapter-content ol {
    margin: 1em 0 1.5em 2em;
}

.chapter-content li {
    margin: 0.5em 0;
    line-height: 1.6;
}

/* =================================================
   CHAPTER FOOTER - CONTINUE READING & BOOK INFO
   ================================================= */

.chapter-footer-module {
    margin-top: 30px;
    margin-bottom: 10px;
}

/* Unified footer box */
.footer-unified-box {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    padding: 30px;
}

/* Footer layout - two columns */
.footer-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
    align-items: stretch;
}

.footer-left-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    min-height: 100%;
}

.footer-right-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-book-cover {
    width: 100%;
    max-width: 220px;
    height: auto;
    display: block;
    border: 2px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.footer-book-cover:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.footer-book-cover:active {
    animation: jostle 0.3s ease;
    transform: translateY(-2px);
}

@keyframes jostle {
    0%, 100% { transform: translateY(-2px) rotate(0deg); }
    25% { transform: translateY(-2px) rotate(-2deg); }
    50% { transform: translateY(-2px) rotate(2deg); }
    75% { transform: translateY(-2px) rotate(-1deg); }
}

.footer-left-column h3 {
    margin: 0 0 12px 0;
    font-size: 1.4rem;
}

.footer-book-author {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    margin: 0 0 16px 0;
}

.footer-format-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    margin-top: 8px;
}

.footer-format-btn {
    padding: 10px 16px;
    background-color: #222;
    color: #fafafa;
    border: 2px solid var(--chapter-primary, #222);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: background-color 0.2s, border-color 0.2s;
}

.footer-format-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--chapter-primary, #222) 150%, white);
    background-color: #333;
}

.footer-format-btn:disabled {
    background-color: #cccccc;
    border-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.footer-toc-btn {
    padding: 12px 18px;
    background-color: var(--chapter-primary, #000080);
    color: var(--chapter-text-color, white);
    border: 2px solid;
    border-color: color-mix(in srgb, var(--chapter-primary, #000080) 80%, black);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
    margin-bottom: 8px;
    width: 100%;
}

.footer-toc-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--chapter-primary, #000080) 30%, transparent);
}

/* Continue Reading section - redesigned with horizontal layout */
.footer-continue-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.footer-next-label {
    font-size: 0.75rem;
    color: color-mix(in srgb, var(--chapter-primary, #000080) 80%, black);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    text-align: left;
    margin-bottom: 4px;
}

.footer-continue-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-toc-hamburger {
    padding: 12px 18px;
    background-color: #222;
    color: #fafafa;
    border: 2px solid var(--chapter-primary, #222);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
}

.footer-toc-hamburger:hover {
    border-color: color-mix(in srgb, var(--chapter-primary, #222) 150%, white);
    background-color: #333;
}

.footer-next-btn-compact {
    flex: 1;
    padding: 12px 18px;
    background-color: #222;
    color: #fafafa;
    border: 2px solid var(--chapter-primary, #222);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
}

.footer-next-btn-compact:hover {
    border-color: color-mix(in srgb, var(--chapter-primary, #222) 150%, white);
    background-color: #333;
}

.footer-next-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    flex: 1;
    min-height: 2.6rem;
    display: flex;
    align-items: center;
}

.footer-next-arrow {
    font-size: 1.2rem;
    opacity: 0.8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.footer-next-btn-compact:hover .footer-next-arrow {
    transform: translateX(4px);
}

.footer-continue-divider {
    margin: 0;
    border: none;
    border-top: 1px solid #d0d0d0;
}

/* Order Print Copies button */
.footer-order-btn {
    padding: 14px 20px;
    background-color: var(--chapter-primary, #000080);
    color: var(--chapter-text-color, white);
    border: 2px solid;
    border-color: color-mix(in srgb, var(--chapter-primary, #000080) 80%, black);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
    margin-bottom: 8px;
    width: 100%;
}

.footer-order-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--chapter-primary, #000080) 30%, transparent);
}

/* =================================================
   TABLE OF CONTENTS (TOC) OVERLAY
   ================================================= */

.toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.toc-container {
    background: white;
    max-width: 80%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
}

.toc-container * {
    box-sizing: border-box;
}

/* Minimalist Header - Canon Style */
.toc-header {
    padding: 12px 20px;
    border-bottom: 1px solid #d0d0d0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.toc-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2a2a2a;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toc-header h3::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    background-image: url('/assets/icon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.reader-btn {
    padding: 8px 18px;
    background-color: #666666;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}

.reader-btn:hover {
    background-color: #444444;
}

.reader-btn.secondary {
    background-color: transparent;
    color: #000080;
}

.reader-btn.secondary:hover {
    background-color: #f0f0f0;
}

.toc-content {
    padding: 20px;
    max-height: calc(90vh - 60px);
    overflow-y: auto;
}

/* TOC Layout - Side by Side */
.toc-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3px;
    align-items: stretch; /* Both sections stretch to match height */
    min-width: 700px;
    max-width: 490px;
    margin: 0 auto;
}

/* Book Info Section - Left Side */
.toc-cover-section {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    /* height: 100%; removed - let grid handle height */
    align-self: stretch; /* Ensure it stretches to match grid row */
}

.toc-book-card {
    text-align: center;
    width: 100%;
}

.toc-book-cover-container {
    margin-bottom: 12px;
}

.toc-book-cover {
    width: 100%;
    max-width: 200px;
    border: 2px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.toc-book-cover:hover {
    transform: translateY(-4px); /* Rise up effect instead of scale */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    filter: brightness(1.05);
}

/* Book-specific border colors matching main book cards */
.toc-book-card[data-featured="true"] .toc-book-cover {
    border-color: var(--seeker-color);
}

.toc-book-card[data-featured="false"] .toc-book-cover {
    border-color: var(--prince-color);
}

.toc-book-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.toc-book-card h3 {
    font-size: 1.3rem;
    margin: 0 0 6px 0;
}

.toc-book-card .book-author {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    margin: 0 0 12px 0;
}

.toc-book-card .book-status {
    margin: 10px 0;
}

.toc-book-card .book-format-buttons,
.toc-format-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.toc-book-card .book-format-btn,
.toc-format-btn {
    padding: 10px 16px;
    background-color: #222;
    color: #fafafa;
    border: 2px solid #222;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: background-color 0.2s, border-color 0.2s;
}

/* Seeker's buttons - dark grey, purple border */
.seeker-chapter-part .toc-format-btn {
    background-color: #222;
    border-color: var(--seeker-color);
}
.seeker-chapter-part .toc-format-btn:hover:not(:disabled) {
    border-color: #a084b6;
}

/* Seeker's Order Books button - filled with purple */
.seeker-chapter-part .toc-order-btn:not(:disabled) {
    background-color: var(--seeker-color);
    color: #ffffff;
    border-color: var(--seeker-color);
}
.seeker-chapter-part .toc-order-btn:hover:not(:disabled) {
    background-color: #a084b6;
    border-color: #a084b6;
}

/* Prince's buttons - dark grey, lighter grey border */
.prince-chapter-part .toc-format-btn {
    background-color: #222;
    border: 2px solid #bbb;
}
.prince-chapter-part .toc-format-btn:hover:not(:disabled) {
    border-color: var(--prince-color);
}

/* Prince's Order Books button - filled with brown/red */
.prince-chapter-part .toc-order-btn:not(:disabled) {
    background-color: var(--prince-color);
    color: #ffffff;
    border-color: var(--prince-color);
}
.prince-chapter-part .toc-order-btn:hover:not(:disabled) {
    background-color: #8b0000;
    border-color: #8b0000;
}

.toc-book-card .book-format-btn:hover:not(:disabled),
.toc-format-btn:hover:not(:disabled) {
    background-color: #777777;
}

/* Disabled state for unavailable books */
.toc-book-card .book-format-btn:disabled,
.toc-format-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Chapters Section - Canon-style Rows */
.toc-chapters-section {
    min-width: 0;
    border: 1px solid #e0e0e0;
    background: #fafafa;
    align-self: stretch; /* Ensure it stretches to match grid row */
    display: flex;
    flex-direction: column;
}

/* Table of Contents header text - standardized */
/* Table of Contents header text - standardized */
.toc-chapters-header {
    font-size: 13px;
    font-weight: 700;
    font-family: monospace;
    color: #181818;
    margin: 0;
    padding: 10px 15px;
    text-align: left;
    background: #fafafa;
    border-bottom: 2px solid #e0e0e0;
}

.chapter-section {
    margin-top: 0;
}

/* Part headers in Prince's Reverie - standardized to match TOC header */
.chapter-section h2,
.toc-part-header {
    font-size: 13px;
    font-weight: 700;
    font-family: monospace;
    color: #666666;
    margin: 0;
    padding: 10px 15px;
    background: #fafafa;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-left: none;
}

.chapter-section h2:hover,
.toc-part-header:hover {
    background: #f0f0f0;
}

.chapter-section h2 .arrow,
.toc-part-header .arrow {
    font-size: 11px;
    transition: transform 0.2s;
}

/* Non-foldable header (Seeker's Reverie) */
.toc-section-header-no-fold {
    cursor: default !important;
}

.toc-section-header-no-fold:hover {
    background: #f5f5f5 !important;
}

/* Chapter Rows - Like Canon Log Entries */
.chapter-section-content {
    display: flex;
    flex-direction: column;
}

.chapter-section-content p,
.toc-row {
    margin: 0;
    padding: 10px 15px;
    font-size: 13px;
    font-family: monospace;
    line-height: 1.4;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chapter-section-content p:nth-child(odd) {
    background-color: #fafafa;
}

.chapter-section-content p:nth-child(even) {
    background-color: #ffffff;
}

.chapter-section-content p:hover:not(.coming-soon):not(.blank-row) {
    background-color: #f0f4ff;
}

.chapter-section-content p b {
    color: #181818;
    font-weight: 700;
    font-size: 12px;
}

.chapter-section-content p a {
    color: #333333;
    text-decoration: none;
    font-weight: 400;
}

.chapter-section-content p a:hover {
    color: #000080;
    text-decoration: underline;
}

.chapter-section-content p.coming-soon {
    opacity: 0.5;
    cursor: not-allowed;
}

.chapter-section-content p.coming-soon:hover {
    background-color: inherit;
    cursor: not-allowed;
}

.chapter-section-content p.coming-soon em {
    font-size: 10px;
    color: #666666;
    font-style: italic;
}

.chapter-section-content p a:hover {
    text-decoration: underline;
}

.arrow {
    margin-right: 8px;
    color: #666666;
    font-weight: bold;
    display: inline-block;
    transition: transform 0.2s;
}

/* Book-specific color theming */
.seeker-chapter-part .toc-chapters-header {
    color: var(--seeker-color);
}

.seeker-chapter-part .chapter-section h2,
.seeker-chapter-part .toc-part-header,
.seeker-chapter-part .arrow,
.seeker-chapter-part a {
    color: var(--seeker-color);
}

.seeker-chapter-part p b {
    color: #666666;
}

.seeker-chapter-part p span {
    color: #181818;
}

.seeker-chapter-part .chapter-section h2:hover,
.seeker-chapter-part .toc-part-header:hover,
.seeker-chapter-part a:hover {
    background-color: rgba(92, 61, 94, 0.1);
}

/* Prince's TOC matches Seeker's, but uses red */
.prince-chapter-part .toc-chapters-header {
    color: #181818;
    border-bottom: 2px solid #e0e0e0;
}

.prince-chapter-part .chapter-section h2,
.prince-chapter-part .toc-part-header,
.prince-chapter-part .arrow,
.prince-chapter-part a {
    color: var(--prince-color);
}

.prince-chapter-part p b {
    color: #181818;
    font-weight: 700;
    font-size: 12px;
}

.prince-chapter-part p span {
    color: #181818;
}

/* Part headers with borders */
.prince-chapter-part .chapter-section h2,
.prince-chapter-part .toc-part-header {
    border-top: 1px solid var(--prince-color);
    border-bottom: 1px solid var(--prince-color);
}

.prince-chapter-part .chapter-section h2:hover,
.prince-chapter-part .toc-part-header:hover {
    background-color: rgba(139, 0, 0, 0.25);
}

/* Chapter rows hover - lighter red */
.prince-chapter-part .chapter-part-content p:hover:not(.coming-soon):not(.blank-row) {
    background-color: rgba(139, 0, 0, 0.12);
}

.prince-chapter-part a:hover {
    background-color: rgba(139, 0, 0, 0.12);
}

/* Chapter parts for multi-part books */
.chapter-part {
    margin-bottom: 16px;
}

/* Part header styling now consolidated above with .chapter-section h2 */

.chapter-part-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.chapter-part-content p {
    margin: 0;
    padding: 10px 15px;
    font-size: 13px;
    font-family: monospace;
    line-height: 1.4;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chapter-part-content p:nth-child(odd) {
    background-color: #fafafa;
}

.chapter-part-content p:nth-child(even) {
    background-color: #ffffff;
}

.chapter-part-content p:hover:not(.coming-soon):not(.blank-row) {
    background-color: #f0f4ff;
}

.chapter-part-content p b {
    color: #666666;
    font-weight: 600;
    font-size: 11px;
}

.chapter-part-content p a {
    color: #333333;
    text-decoration: none;
    font-weight: 400;
}

.chapter-part-content p a:hover {
    color: #000080;
    text-decoration: underline;
}

.chapter-part-content p.coming-soon {
    opacity: 0.5;
    cursor: not-allowed;
}

.chapter-part-content p.coming-soon:hover {
    background-color: inherit;
}

.chapter-part-content p.coming-soon em {
    font-size: 10px;
    color: #666666;
}

/* Blank rows for consistent part sizing */
.chapter-part-content p.blank-row {
    opacity: 0;
    pointer-events: none;
    cursor: default;
}

.chapter-part-content p.blank-row:hover {
    background: inherit;
}

/* =================================================
   READER HEADER (Top navigation bar)
   ================================================= */

.reader-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* =================================================
   READING SUB-HEADER (Sticky navigation during reading)
   ================================================= */

.reading-sub-header {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--chapter-primary, white);
    border-bottom: 2px solid hsla(var(--chapter-hue, 230), var(--chapter-saturation, 60%), calc(var(--chapter-lightness, 45%) - 10%), 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: var(--chapter-text-color, white);
}

.reading-sub-header + .reading-sub-header {
    display: none;
}

.sub-header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.sub-header-btn {
    padding: 8px 16px;
    background-color: transparent;
    color: var(--chapter-text-color, white);
    border: 1px solid;
    border-color: color-mix(in srgb, var(--chapter-text-color, white) 30%, transparent);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.sub-header-btn:hover {
    background-color: color-mix(in srgb, var(--chapter-text-color, white) 10%, transparent);
    border-color: color-mix(in srgb, var(--chapter-text-color, white) 50%, transparent);
}

.sub-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--chapter-text-color, white);
    overflow: hidden;
}

.sub-header-book-title {
    font-weight: 600;
    color: var(--chapter-text-color, white);
}

.sub-header-separator {
    color: color-mix(in srgb, var(--chapter-text-color, white) 50%, transparent);
}

.sub-header-chapter-number {
    font-weight: 600;
    color: var(--chapter-text-color, white);
}

.sub-header-chapter-title {
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--chapter-text-color, white);
}

.sub-header-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.sub-header-nav-btn,
.sub-header-toc-btn {
    padding: 8px 14px;
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--chapter-text-color, white);
    border: 1px solid color-mix(in srgb, var(--chapter-text-color, white) 30%, transparent);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.sub-header-nav-btn:hover:not(:disabled),
.sub-header-toc-btn:hover {
    background-color: rgba(0, 0, 0, 0.3);
    border-color: color-mix(in srgb, var(--chapter-text-color, white) 50%, transparent);
}

.sub-header-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sub-header-toc-btn {
    margin: 0 4px;
}

/* =================================================
   LOADING & ERROR STATES
   ================================================= */

.loading-state, .error-state {
    padding: 60px 40px;
    text-align: center;
    font-size: 1.1rem;
    color: #666;
}

.loading-state::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #ddd;
    border-top-color: #000080;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

.error-state button {
    margin-top: 20px;
    padding: 10px 24px;
    background-color: #000080;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}

.error-state button:hover {
    background-color: #333399;
}

/* =================================================
   UTILITY CLASSES
   ================================================= */

.coming-soon {
    opacity: 0.5;
}

.coming-soon em {
    font-style: italic;
    color: #999;
}

.toc-notice {
    margin: 20px 0;
    padding: 16px 20px;
    background: #f0f8ff;
    border-left: 4px solid #000080;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}

.toc-notice-small {
    margin: 12px 0;
    padding: 10px 14px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

/* =================================================
   ORDER PAGE - BOOK SHOWCASE STYLING
   ================================================= */

/* Book stats grid */
.book-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 10px;
    font-size: 0.88rem;
    color: #444;
    line-height: 1.3;
    width: 100%;
    margin-top: 8px;
    text-align: left;
}

/* Action buttons container */
.action-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
    flex: 1;
}

/* =================================================
   ORDER PAGE - PRESS SECTION STYLING
   ================================================= */

/* Desktop default styles for order press section */
.order-press-section {
    background: white;
    padding: 24px 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 40px;
    margin-bottom: 0;
    padding-left: 80px;
}

.order-press-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
}

.order-press-logo img {
    height: 120px;
    width: auto;
    margin-bottom: 4px;
}

.order-press-logo > div {
    font-size: 1em;
    font-weight: 600;
    color: #87408d;
    letter-spacing: 0.08em;
}

.order-press-text {
    font-size: 0.8em;
    color: #444;
    line-height: 1.8;
    max-width: 480px;
}

/* =================================================
   RESPONSIVE - TABLET & MOBILE
   ================================================= */

@media (min-width: 1024px) {
    .chapter-content {
        font-size: 20px;
        line-height: 1.8;
    }
}

@media (max-width: 768px) {
    .main-content {
        margin: 20px auto;
        padding: 0 16px;
    }
    
    body.reading-mode .main-content {
        margin: 0;
        padding: 0;
    }
    
    body.reading-mode .chapter-reader {
        margin: 60px auto 40px auto;
        padding: 0 24px;
    }
    
    body.reading-mode .chapter-content {
        padding: 40px 0;
        font-size: 18px;
    }
    
    body.reading-mode .chapter-title-compact {
        font-size: 26px;
    }
    
    .library-header {
        padding: 20px 15px;
    }
    
    .logo-container {
        padding: 12px;
    }
    
    .logo-container img {
        height: 80px !important;
    }
    
    .library-logo {
        height: 50px;
    }
    
    .library-logo--large {
        height: 86px;
    }
    
    .library-description {
        font-size: 0.85rem;
        max-width: 100%;
        padding: 0 10px;
    }
    
    .books-container {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 30px 20px;
    }
    
    .book-card {
        padding: 20px;
        max-width: 100%;
    }
    
    .book-card h3 {
        font-size: 1.4rem;
    }
    
    .order-content {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
        flex-direction: column !important;
        display: flex !important;
    }
    
    .order-right {
        padding: 24px !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    
    .order-left {
        width: 100% !important;
    }
    
    /* Override inline styles for order section */
    .order-section {
        padding: 24px 12px !important;
    }
    
    /* Redesign Press section for mobile appeal */
    .order-press-section {
        flex-direction: row !important;
        gap: 20px !important;
        padding: 24px 16px !important;
        padding-left: 16px !important;
        align-items: center !important;
        background: linear-gradient(135deg, #fdfbff 0%, #f9f5fc 100%) !important;
        display: grid !important;
        grid-template-columns: auto 1fr !important;
    }
    
    .order-press-logo {
        padding: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
        justify-self: start !important;
    }
    
    .order-press-logo img {
        height: 72px !important;
        width: auto !important;
        margin-bottom: 0 !important;
    }
    
    .order-press-logo > div {
        font-size: 0.9em !important;
        font-weight: 700 !important;
        color: #87408d !important;
        letter-spacing: 0.08em !important;
    }
    
    .order-press-text {
        max-width: 100% !important;
        text-align: left !important;
        font-size: 0.64rem !important;
        color: #555 !important;
        line-height: 1.6 !important;
        padding-left: 0 !important;
        justify-self: stretch !important;
    }
    
    /* Show mobile first print edition label on mobile */
    .mobile-first-print-label {
        display: block !important;
    }
    
    /* Hide desktop first print edition label on mobile to avoid duplication */
    .first-print-label {
        display: none !important;
    }
    
    /* Adjust invite section fallback for older styles */
    .invite-section {
        flex-direction: column !important;
        gap: 16px !important;
        padding: 32px 20px !important;
        padding-left: 20px !important;
        align-items: center !important;
        background: linear-gradient(135deg, #fdfbff 0%, #f9f5fc 100%) !important;
    }
    
    .invite-section > div:first-child {
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 8px !important;
    }
    
    .invite-section > div:first-child img {
        height: 80px !important;
        width: auto !important;
        margin-bottom: 0 !important;
    }
    
    .invite-section > div:first-child > div {
        font-size: 1.1em !important;
        font-weight: 700 !important;
        color: #87408d !important;
        letter-spacing: 0.12em !important;
    }
    
    .invite-section > div:last-child {
        max-width: 100% !important;
        text-align: center !important;
        font-size: 0.92rem !important;
        color: #555 !important;
        line-height: 1.7 !important;
    }
    
    /* Book stack mobile */
    .book-stack {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Move book cover and rearrange order on mobile */
    .book-stack {
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Cover art first */
    .showcase-cover {
        max-width: 280px !important;
        margin: 0 auto !important;
        order: -3 !important;
    }
    
    /* First Print Edition label below cover, above stats */
    .first-print-label {
        order: -2 !important;
        margin-top: 16px !important;
        margin-bottom: 8px !important;
        text-align: center !important;
        width: 100% !important;
    }
    
    /* Book stats grid - center it but left-align items */
    .book-stats-grid {
        order: -1 !important;
        grid-template-columns: 1fr 1fr !important;
        margin: 0 auto 10px auto !important;
        max-width: 280px !important;
        width: 100% !important;
        gap: 3px 8px !important;
        font-size: 0.82rem !important;
    }
    
    .book-stats-grid > div {
        text-align: left !important;
    }
    
    /* Fix order form sizing on mobile */
    .order-form {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .order-form > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .quantity-slider-container,
    .slider-wrapper,
    .quantity-slider {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .price-display {
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .order-now-btn {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .book-title,
    .synopsisbox,
    .first-print-label,
    .free-shipping-banner,
    .order-note {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Reduce CC0 notice font on mobile */
    .cc0-notice {
        font-size: 0.58rem !important;
        padding: 10px !important;
        line-height: 1.4 !important;
    }
    
    /* Compact action buttons section on mobile */
    .action-buttons-container {
        gap: 8px !important;
        margin-top: 16px !important;
    }
    
    /* Make action buttons more compact */
    .read-online-btn,
    .download-epub-btn,
    .kindle-button {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
    }
    
    /* More compact CC0 notice */
    .cc0-notice {
        font-size: 0.52rem !important;
        padding: 8px !important;
        line-height: 1.3 !important;
        margin-top: 12px !important;
    }
    
    /* Prince's Reverie section - complete mobile redesign */
    .princes-section {
        padding: 24px 16px !important;
        background: linear-gradient(135deg, #fffbfb 0%, #fff5f8 100%) !important;
    }
    
    /* Outer container - single column stack */
    .princes-section > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 20px !important;
    }
    
    /* Inner flex container - vertical stack */
    .princes-section > div > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0 !important;
        width: 100% !important;
        max-width: 340px !important;
    }
    
    /* Cover art - centered and sized for mobile */
    .princes-cover {
        width: 160px !important;
        height: auto !important;
        max-width: 160px !important;
        margin: 0 auto 16px auto !important;
        flex-shrink: 0 !important;
        order: 1 !important;
    }
    
    /* Title section */
    .princes-section h3 {
        order: 2 !important;
        font-size: 1.35rem !important;
        margin: 0 0 12px 0 !important;
        text-align: center !important;
        width: 100% !important;
    }
    
    /* Synopsis section */
    .princes-section > div > div > div:nth-child(2) {
        order: 3 !important;
        max-width: 100% !important;
        width: 100% !important;
        margin-bottom: 16px !important;
    }
    
    .princes-section .synopsisbox {
        padding: 14px 16px !important;
        font-size: 0.86rem !important;
        margin: 0 !important;
        line-height: 1.6 !important;
        background: rgba(255, 255, 255, 0.7) !important;
    }
    
    /* Form section - clean vertical layout */
    .princes-section > div > div > div:nth-child(3) {
        order: 4 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
    }
    
    /* Form label */
    .princes-section > div > div > div:nth-child(3) > p {
        margin: 0 !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        color: #8b0000 !important;
        text-align: center !important;
        width: 100% !important;
    }
    
    /* Form inputs container */
    .princes-section > div > div > div:nth-child(3) > div {
        width: 100% !important;
        max-width: 260px !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    /* Input fields */
    .princes-section input[type="text"],
    .princes-section input[type="email"] {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
    }
    
    /* Submit button */
    .princes-section button {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 10px !important;
        font-size: 0.9rem !important;
    }
    
    /* Success/error message */
    .princes-section #request-message {
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        font-size: 0.85rem !important;
    }
    
    /* TOC Mobile Optimizations */
    .toc-overlay {
        padding: 10px;
    }
    
    .toc-container {
        max-width: 95%;
        max-height: 85vh;
    }
    
    .toc-layout {
        grid-template-columns: 1fr;
        gap: 30px;
        min-width: 0; /* Remove min-width constraint */
    }
    
    .toc-cover-section {
        position: relative;
    }
    
    .toc-content {
        padding: 15px;
    }
    
    .footer-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .chapter-content {
        padding: 30px 20px;
        font-size: 18px;
    }
    
    .sub-header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .sub-header-info {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .sub-header-nav {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body.reading-mode .chapter-reader {
        margin: 50px auto 30px auto;
        padding: 0 20px;
    }
    
    body.reading-mode .chapter-content {
        padding: 30px 0;
        font-size: 17px;
    }
    
    body.reading-mode .chapter-title-compact {
        font-size: 24px;
    }
    
    .library-logo {
        height: 40px;
    }
    
    .library-logo--large {
        height: 72px;
    }
    
    .library-description {
        font-size: 0.85rem;
    }
    
    .books-container {
        padding: 24px 16px;
    }
    
    .book-card {
        padding: 16px;
    }
    
    .book-card h3 {
        font-size: 1.3rem;
    }
    
    .book-cover {
        max-width: 100%;
    }
    
    .order-right {
        padding: 20px !important;
    }
    
    .order-section {
        padding: 20px 8px !important;
    }
    
    .order-content {
        gap: 20px !important;
    }
    
    .order-press-section {
        padding: 16px 12px !important;
        grid-template-columns: auto 1fr !important;
        gap: 16px !important;
    }
    
    .order-press-logo img {
        height: 60px !important;
    }
    
    .order-press-text {
        font-size: 0.60rem !important;
        line-height: 1.5 !important;
    }
    
    .invite-section {
        padding: 16px 12px !important;
        padding-left: 12px !important;
    }
    
    .invite-section img {
        height: 80px !important;
    }
    
    .invite-section > div:last-child {
        font-size: 0.8rem !important;
        line-height: 1.6 !important;
    }
    
    .showcase-cover {
        max-width: 240px !important;
    }
    
    .book-stats-grid {
        font-size: 0.78rem !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 2px 6px !important;
        margin: 0 auto 8px auto !important;
    }
    
    .synopsisbox {
        font-size: 0.85rem !important;
        padding: 14px !important;
    }
    
    .princes-section {
        padding: 16px 8px !important;
    }
    
    .princes-cover {
        max-width: 120px !important;
        width: 120px !important;
    }
    
    .princes-section h3 {
        font-size: 1.05rem !important;
    }
    
    .princes-section .synopsisbox {
        font-size: 0.78rem !important;
        padding: 10px 12px !important;
    }
    
    .princes-section > div > div > div:nth-child(3) > div {
        max-width: 100% !important;
    }
    
    /* More compact action buttons on very small screens */
    .read-online-btn,
    .download-epub-btn,
    .kindle-button {
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
    }
    
    .cc0-notice {
        font-size: 0.48rem !important;
        padding: 6px !important;
        line-height: 1.2 !important;
        margin-top: 10px !important;
    }
    
    .action-buttons-container {
        gap: 6px !important;
        margin-top: 12px !important;
    }
    
    .order-form h3,
    .book-title {
        font-size: 1.5rem;
    }
    
    .toc-header {
        padding: 20px;
        flex-direction: column;
        gap: 12px;
    }
    
    .toc-content {
        padding: 20px;
    }
    
    .chapter-content {
        padding: 20px 16px;
        font-size: 17px;
    }
}

/* =================================================
   ACCESSIBILITY
   ================================================= */

/* Focus states for accessibility */
.reader-btn:focus,
.book-format-btn:focus,
.chapter-section h2:focus,
.chapter-section-content a:focus,
.book-cover-container:focus,
.sub-header-btn:focus,
.sub-header-nav-btn:focus,
.sub-header-toc-btn:focus {
    outline: 2px solid #000080;
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .book-card,
    .chapter-content,
    .toc-container {
        border: 2px solid currentColor;
    }
}

/* =================================================
   PRINT STYLES
   ================================================= */

@media print {
    .toc-overlay,
    .library-header,
    .library-subnote,
    .book-format-buttons,
    .footer-format-buttons,
    .footer-toc-btn,
    .footer-continue-section,
    .reading-sub-header,
    .sub-header-content,
    .order-now-btn,
    .checkout-message {
        display: none !important;
    }
    
    .chapter-content {
        max-width: 100%;
        padding: 0;
    }
    
    .chapter-content p {
        orphans: 3;
        widows: 3;
    }
}

/* =================================================
   DARK MODE SUPPORT (Optional)
   ================================================= */

@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode support
    :root {
        --library-bg: #1a1a1a;
        --library-text: #e0e0e0;
        --library-border: #444;
        --reader-theme-bg: #1a1a1a;
        --reader-theme-text: #e0e0e0;
    }
    
    .library-section,
    .book-card,
    .chapter-content,
    .toc-container {
        background-color: var(--library-bg);
        color: var(--library-text);
    }
    */
}
