/* ==========================================================================
   QWIK CODEX — DIGITAL BOOKLET ENGINE (booklet.css)
   Authentic Publication Styling, Dual-Page Spread, & Print Protection
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Theme Variables & Color Palettes
   -------------------------------------------------------------------------- */
:root {
    /* Brand Primary Accent */
    --primary: #FF007A;
    --primary-hover: #E0006C;
    --primary-subtle: rgba(255, 0, 122, 0.08);

    /* Reading Tone: Clean White Paper */
    --desk-bg: #0F172A;
    --paper-bg: #FFFFFF;
    --paper-line: #E2E8F0;
    --paper-text: #1E293B;
    --paper-muted: #64748B;
    --paper-brand: #0F172A;
    --paper-highlight: #F8FAFC;
    
    /* Publication Accents */
    --badge-green: #064E3B;
    --badge-green-light: #D1FAE5;
    --badge-navy: #1E293B;
    --badge-navy-light: #EFF6FF;

    /* Realistic Page & Shadow Elements */
    --book-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.55);
    --page-curl-left: inset -14px 0 24px -10px rgba(0, 0, 0, 0.08);
    --page-curl-right: inset 14px 0 24px -10px rgba(0, 0, 0, 0.08);

    /* Typography Scale */
    --font-heading: 'Cinzel', Georgia, serif;
    --font-subheading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="sepia"] {
    --desk-bg: #2B231D;
    --paper-bg: #FBF0D9;
    --paper-line: #E6D7B9;
    --paper-text: #2D241E;
    --paper-muted: #7E7062;
    --paper-brand: #3A2F27;
    --paper-highlight: #F3E5C8;
    --badge-green: #274E13;
    --badge-green-light: #E2ECD8;
    --page-curl-left: inset -14px 0 24px -10px rgba(45, 36, 30, 0.12);
    --page-curl-right: inset 14px 0 24px -10px rgba(45, 36, 30, 0.12);
}

[data-theme="dark"] {
    --desk-bg: #070B14;
    --paper-bg: #141C2E;
    --paper-line: #243047;
    --paper-text: #F8FAFC;
    --paper-muted: #94A3B8;
    --paper-brand: #FFFFFF;
    --paper-highlight: #1B253D;
    --badge-green: #10B981;
    --badge-green-light: rgba(16, 185, 129, 0.15);
    --page-curl-left: inset -14px 0 24px -10px rgba(0, 0, 0, 0.35);
    --page-curl-right: inset 14px 0 24px -10px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------------------------------
   2. Reset & Strict Content Protection
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    min-width: 0;
}

html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--desk-bg);
    color: var(--paper-text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

/* --------------------------------------------------------------------------
   3. Top Master Toolbar
   -------------------------------------------------------------------------- */
.book-top-bar {
    height: 56px;
    background: rgba(10, 15, 28, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #243047;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    color: #FFFFFF;
}

.bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-return {
    color: #FFFFFF;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.2s ease;
}

.btn-return:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.divider-v {
    width: 1px;
    height: 20px;
    background: #334155;
}

.bar-book-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94A3B8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}

.bar-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-arrow {
    background: #1E293B;
    border: 1px solid #334155;
    color: #FFFFFF;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nav-arrow:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
}

.nav-arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-scrub-wrap {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    min-width: 110px;
    text-align: center;
    color: #F8FAFC;
}

.bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-tool-icon {
    background: #1E293B;
    border: 1px solid #334155;
    color: #FFFFFF;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.btn-tool-icon:hover {
    background: #334155;
    color: var(--primary);
}

/* --------------------------------------------------------------------------
   4. Dual-Page Viewport & Realistic Book Geometry
   -------------------------------------------------------------------------- */
.book-viewport {
    height: calc(100vh - 106px);
    height: calc(100dvh - 106px);
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 24px;
    overflow: auto;
}

.book-stage {
    display: flex;
    width: 100%;
    max-width: 1180px;
    height: 100%;
    max-height: 860px;
    background: transparent;
    box-shadow: var(--book-shadow);
    border-radius: 6px;
    position: relative;
    transform-origin: center center;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-spine {
    width: 16px;
    height: 100%;
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.22) 0%, 
        rgba(0, 0, 0, 0.04) 50%, 
        rgba(0, 0, 0, 0.22) 100%
    );
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.35);
    z-index: 10;
    flex-shrink: 0;
}

/* Printable Sheet Specifications */
.sheet-page {
    flex: 1;
    height: 100%;
    background: var(--paper-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.sheet-left {
    border-radius: 6px 0 0 6px;
    border: 1px solid var(--paper-line);
    border-right: none;
    box-shadow: var(--page-curl-left);
}

.sheet-right {
    border-radius: 0 6px 6px 0;
    border: 1px solid var(--paper-line);
    border-left: none;
    box-shadow: var(--page-curl-right);
}

.sheet-inner {
    padding: 40px 46px;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    scrollbar-width: thin;
    scrollbar-color: var(--paper-line) transparent;
}

.sheet-inner::-webkit-scrollbar {
    width: 5px;
}

.sheet-inner::-webkit-scrollbar-thumb {
    background: var(--paper-line);
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   5. Running Headers, Footers & Folios
   -------------------------------------------------------------------------- */
.doc-running-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid var(--paper-brand);
    padding-bottom: 8px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.hdr-brand {
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    color: var(--paper-brand);
    text-transform: uppercase;
}

.hdr-series {
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--paper-muted);
    letter-spacing: 0.04em;
}

.doc-running-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--paper-line);
    padding-top: 8px;
    margin-top: 22px;
    font-size: 0.72rem;
    color: var(--paper-muted);
    font-weight: 600;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   6. Booklet Cover Layout
   -------------------------------------------------------------------------- */
.cover-wrapper {
    height: 100%;
    border: 3px double var(--paper-line);
    padding: 46px 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    background: var(--paper-bg);
}

.cover-badge-top {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: var(--paper-muted);
    text-transform: uppercase;
}

.cover-icon-emblem {
    font-size: 3.8rem;
    color: var(--primary);
    margin: 18px 0;
}

.cover-titles h1 {
    font-family: var(--font-heading);
    font-size: 2.3rem;
    line-height: 1.15;
    color: var(--paper-brand);
    margin-bottom: 14px;
    letter-spacing: -0.01em;
}

.cover-titles p {
    font-size: 0.92rem;
    color: var(--paper-muted);
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.6;
}

.cover-edition-tag {
    display: inline-block;
    background: var(--badge-green);
    color: #FFFFFF;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 6px 16px;
    border-radius: 4px;
    margin-top: 22px;
}

.cover-footer-meta {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--paper-muted);
}

/* --------------------------------------------------------------------------
   7. Section Headers, Tables & Callout Blocks
   -------------------------------------------------------------------------- */
.guide-header-title {
    font-family: var(--font-subheading);
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--paper-brand);
    margin-bottom: 6px;
}

.guide-header-sub {
    font-size: 0.85rem;
    color: var(--paper-muted);
    margin-bottom: 18px;
}

.guide-box {
    background: var(--paper-highlight);
    border: 1px solid var(--paper-line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
}

.guide-box h4 {
    font-size: 0.86rem;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--paper-brand);
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-box p {
    font-size: 0.82rem;
    color: var(--paper-muted);
    line-height: 1.6;
}

.ch-header-block {
    margin-bottom: 16px;
}

.ch-pretag {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ch-main-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--paper-brand);
    line-height: 1.25;
}

.state-strip {
    background: rgba(0, 0, 0, 0.03);
    border-left: 4px solid var(--primary);
    padding: 7px 12px;
    margin: 16px 0 10px;
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--paper-brand);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 4px 4px 0;
}

.state-strip span:last-child {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--paper-muted);
    font-weight: 600;
}

/* Formal Publication Tables */
.pub-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin: 12px 0;
}

.pub-table th, .pub-table td {
    padding: 9px 12px;
    border: 1px solid var(--paper-line);
    text-align: left;
    vertical-align: top;
}

.pub-table th {
    background: rgba(0, 0, 0, 0.03);
    color: var(--paper-brand);
    font-weight: 800;
    letter-spacing: 0.02em;
}

.pub-table td strong {
    color: var(--paper-brand);
}

/* State Park Item Rows */
.park-item-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--paper-line);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.park-item-row:last-child {
    border-bottom: none;
}

.park-name-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--paper-brand);
}

.park-year-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--paper-muted);
    font-weight: 600;
}

.park-fact-desc {
    font-size: 0.78rem;
    color: var(--paper-muted);
    line-height: 1.45;
}

/* --------------------------------------------------------------------------
   8. Table of Contents Side Drawer
   -------------------------------------------------------------------------- */
.toc-drawer {
    position: fixed;
    top: 56px;
    right: -360px;
    width: 340px;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    background: #0F172A;
    color: #FFFFFF;
    border-left: 1px solid #222F46;
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.toc-drawer.open {
    right: 0;
    box-shadow: -15px 0 35px rgba(0, 0, 0, 0.6);
}

.toc-header {
    padding: 18px 20px;
    border-bottom: 1px solid #222F46;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-header h3 {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #F8FAFC;
}

.btn-close-toc {
    background: none;
    border: none;
    color: #94A3B8;
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-close-toc:hover {
    color: #FFFFFF;
}

.toc-body {
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-item-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 6px;
    color: #CBD5E1;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
}

.toc-item-link:hover {
    background: #1E293B;
    color: var(--primary);
}

.toc-pg-num {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: #64748B;
}

.toc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
}

.toc-overlay.show {
    display: block;
}

/* --------------------------------------------------------------------------
   9. Bottom Scrubber & DRM Protection Bar
   -------------------------------------------------------------------------- */
.book-bottom-bar {
    height: 50px;
    background: rgba(10, 15, 28, 0.98);
    border-top: 1px solid #243047;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.slider-container {
    flex: 0 0 240px;
    display: flex;
    align-items: center;
}

.slider-container input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
    height: 4px;
    background: #1E293B;
    border-radius: 2px;
}

.bottom-helper-hints {
    font-size: 0.75rem;
    color: #64748B;
    display: flex;
    align-items: center;
    gap: 20px;
}

.bottom-helper-hints kbd {
    background: #1E293B;
    border: 1px solid #334155;
    color: #E2E8F0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.protection-tag {
    color: #10B981;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --------------------------------------------------------------------------
   10. Responsive Adaptation (Tablet & Mobile Single-Page)
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .book-spine {
        display: none;
    }

    .sheet-left {
        display: none;
    }

    .sheet-right {
        border-radius: 6px;
        border: 1px solid var(--paper-line);
        box-shadow: none;
    }

    .sheet-inner {
        padding: 26px 20px;
    }

    .bar-book-title {
        display: none;
    }

    .bottom-helper-hints {
        display: none;
    }

    .slider-container {
        flex: 1;
        max-width: 100%;
    }
}

/* --------------------------------------------------------------------------
   11. Strict Anti-Print Directives (Anti-Rip / DRM)
   -------------------------------------------------------------------------- */
@media print {
    html, body {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
    }
}