/* ==========================================================================
   RPG Knihy — Interactive 3D Flipbook Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=MedievalSharp&family=Spectral:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --rpg-book-max-width: 940px;
    --rpg-book-min-height: 560px;
    --rpg-book-font-body: 'Spectral', Georgia, serif;
    --rpg-book-font-heading: 'Cinzel', 'MedievalSharp', serif;
}

/* ── Container (Výchozí náhled na stránce) ───────────────────────────────── */
.rpg-book-container {
    position: relative;
    width: 100%;
    max-width: var(--rpg-book-max-width);
    margin: 2em auto;
    font-family: var(--rpg-book-font-body);
    box-sizing: border-box;
    user-select: none;
    perspective: 1800px;
}

.rpg-book-stage {
    position: relative;
    width: 100%;
    min-height: var(--rpg-book-min-height);
    height: auto;
    background: #161210;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.55), 0 5px 15px rgba(0, 0, 0, 0.4);
    padding: 16px;
    box-sizing: border-box;
}

.rpg-book-viewport {
    position: relative;
    width: 100%;
    height: auto;
    min-height: calc(var(--rpg-book-min-height) - 32px);
}

/* ── Pages Wrapper ───────────────────────────────────────────────────────── */
.rpg-book-pages-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    min-height: calc(var(--rpg-book-min-height) - 32px);
    transform-style: preserve-3d;
}

/* ── Individual Sheet ────────────────────────────────────────────────────── */
.rpg-book-page-sheet {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: calc(var(--rpg-book-min-height) - 32px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: rotateY(90deg);
    transform-origin: left center;
    transition: transform 0.55s cubic-bezier(0.645, 0.045, 0.355, 1), opacity 0.4s ease, visibility 0.4s ease;
    z-index: 1;
}

.rpg-book-page-sheet.active {
    position: relative;
    height: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: rotateY(0deg);
    z-index: 5;
}

.rpg-book-page-sheet.turned-previous {
    position: absolute;
    transform: rotateY(-90deg);
    opacity: 0;
    visibility: hidden;
}

/* ── Page Inner Styling ──────────────────────────────────────────────────── */
.rpg-book-page-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: calc(var(--rpg-book-min-height) - 32px);
    padding: 30px 45px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 6px;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0,0,0,0.3);
    background-size: cover;
}

/* ── Themes: Parchment / Paper ────────────────────────────────────────────── */
.rpg-book-container[data-page-theme="parchment"] .rpg-book-page-inner {
    background-color: #f6efe0;
    background-image: radial-gradient(#ece1cb 1px, transparent 1px), linear-gradient(135deg, #faf4e8 0%, #ebe0ca 100%);
    color: #1c130d;
    border: 1px solid #d4c5a9;
}

.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-page-inner {
    background-color: #ffffff;
    background-image: linear-gradient(to bottom, #ffffff 0%, #f7f9fa 100%);
    color: #111827;
    border: 1px solid #e2e8f0;
}

.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-page-inner {
    background-color: #1a1d24;
    background-image: radial-gradient(#252a34 1px, transparent 1px), linear-gradient(135deg, #1f242d 0%, #14171d 100%);
    color: #f1f5f9;
    border: 1px solid #333b4d;
}

.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-page-inner {
    background-color: #f4eaad;
    background-image: linear-gradient(135deg, #f7eebe 0%, #e6d78e 100%);
    color: #261905;
    border: 1px solid #caa858;
}

/* ── Header & Footer ─────────────────────────────────────────────────────── */
.rpg-book-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(139, 69, 19, 0.25);
    padding-bottom: 8px;
    margin-bottom: 15px;
    font-size: 0.88em;
    font-family: var(--rpg-book-font-heading);
    letter-spacing: 1px;
    color: #6b4e3d;
}

.rpg-book-page-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(139, 69, 19, 0.2);
    padding-top: 8px;
    margin-top: 15px;
    font-size: 0.85em;
    color: #6b4e3d;
}

/* Přizpůsobení hlavičky a patičky podle zvoleného tématu papíru */
.rpg-book-container[data-page-theme="parchment"] .rpg-book-page-header,
.rpg-book-container[data-page-theme="parchment"] .rpg-book-page-header *,
.rpg-book-container[data-page-theme="parchment"] .rpg-book-page-footer,
.rpg-book-container[data-page-theme="parchment"] .rpg-book-page-footer * {
    color: #6b4e3d !important;
    text-shadow: none !important;
}

.rpg-book-container[data-page-theme="parchment"] .rpg-book-header-chapter {
    color: #8b4513 !important;
}

.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-page-header,
.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-page-header *,
.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-page-footer,
.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-page-footer * {
    color: #4b5563 !important;
    text-shadow: none !important;
}

.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-page-header,
.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-page-header *,
.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-page-footer,
.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-page-footer * {
    color: #5c4010 !important;
    text-shadow: none !important;
}

.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-page-header,
.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-page-header *,
.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-page-footer,
.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-page-footer * {
    color: #94a3b8 !important;
    text-shadow: none !important;
}

.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-header-chapter {
    color: #f59e0b !important;
}

/* ── Page Content Body ──────────────────────────────────────────────────── */
.rpg-book-page-body.rpg-book-content {
    flex-grow: 1;
    font-size: 1.05em;
    line-height: 1.75;
    overflow-y: visible;
    padding-right: 0;
    text-shadow: none !important;
}

/* Absolutní přebití pravidla [class*="rpg-"] * { color: #e8e2d6 !important; } ze šablony webu */
.rpg-book-content,
.rpg-book-content *,
#main-content .rpg-book-content,
#main-content .rpg-book-content *,
#content .rpg-book-content,
#content .rpg-book-content * {
    text-shadow: none !important;
}

.rpg-book-container[data-page-theme="parchment"] .rpg-book-content,
.rpg-book-container[data-page-theme="parchment"] .rpg-book-content *,
#main-content .rpg-book-container[data-page-theme="parchment"] .rpg-book-content,
#main-content .rpg-book-container[data-page-theme="parchment"] .rpg-book-content * {
    color: #1c130d !important;
}

.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-content,
.rpg-book-container[data-page-theme="clean-paper"] .rpg-book-content *,
#main-content .rpg-book-container[data-page-theme="clean-paper"] .rpg-book-content,
#main-content .rpg-book-container[data-page-theme="clean-paper"] .rpg-book-content * {
    color: #111827 !important;
}

.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-content,
.rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-content *,
#main-content .rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-content,
#main-content .rpg-book-container[data-page-theme="vintage-yellow"] .rpg-book-content * {
    color: #261905 !important;
}

.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-content,
.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-content *,
#main-content .rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-content,
#main-content .rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-content * {
    color: #f1f5f9 !important;
}

.rpg-book-content p,
.rpg-book-content div,
.rpg-book-content li,
.rpg-book-content td {
    margin-bottom: 0.85em;
}

/* Drop Cap na 1. písmeno kapitoly */
.rpg-book-content h3 + p::first-letter,
.rpg-book-content > p:first-child::first-letter {
    font-family: var(--rpg-book-font-heading);
    font-size: 3.2em;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 4px;
    color: #8b0000 !important;
    font-weight: bold;
}

.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-content h3 + p::first-letter,
.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-content > p:first-child::first-letter {
    color: #f39c12 !important;
}

.rpg-book-chapter-heading {
    font-family: var(--rpg-book-font-heading);
    font-size: 1.55em;
    text-align: center;
    margin-top: 0.2em;
    margin-bottom: 0.8em;
    color: #4a2c11 !important;
    border-bottom: 2px double rgba(139, 69, 19, 0.35);
    padding-bottom: 6px;
}

.rpg-book-container[data-page-theme="dark-manuscript"] .rpg-book-chapter-heading {
    color: #f1c40f !important;
    border-bottom-color: rgba(241, 196, 15, 0.35);
}

/* ── Book Cover ──────────────────────────────────────────────────────────── */
.rpg-book-sheet-cover .rpg-book-cover-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: calc(var(--rpg-book-min-height) - 32px);
    border-radius: 8px;
    padding: 30px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.55), inset 0 0 20px rgba(0,0,0,0.4);
    background-color: #3d2314;
    color: #f5e6ca;
    cursor: pointer;
}

/* Cover Themes */
.rpg-book-container[data-cover-theme="leather-dark"] .rpg-book-cover-inner { background: linear-gradient(135deg, #3d2314 0%, #24140b 100%); }
.rpg-book-container[data-cover-theme="leather-red"] .rpg-book-cover-inner { background: linear-gradient(135deg, #581818 0%, #300c0c 100%); }
.rpg-book-container[data-cover-theme="leather-blue"] .rpg-book-cover-inner { background: linear-gradient(135deg, #1b2a4a 0%, #0d1627 100%); }
.rpg-book-container[data-cover-theme="leather-green"] .rpg-book-cover-inner { background: linear-gradient(135deg, #163b28 0%, #0a1f14 100%); }
.rpg-book-container[data-cover-theme="ancient-black"] .rpg-book-cover-inner { background: linear-gradient(135deg, #22252a 0%, #111215 100%); }

.rpg-book-cover-frame {
    width: 90%;
    height: 90%;
    border: 3px double #d4af37;
    border-radius: 6px;
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.2);
}

.rpg-book-cover-emboss {
    text-align: center;
}

.rpg-book-cover-icon {
    font-size: 3.5em;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.rpg-book-cover-title {
    font-family: var(--rpg-book-font-heading);
    font-size: 2.2em;
    color: #f7d070;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8), 0 0 10px rgba(247, 208, 112, 0.3);
    letter-spacing: 1.5px;
}

.rpg-book-cover-subtitle {
    font-family: var(--rpg-book-font-heading);
    font-size: 1.2em;
    color: #d1b880;
    margin: 0 0 15px 0;
    font-weight: 400;
    letter-spacing: 1px;
}

.rpg-book-cover-author {
    font-size: 1.05em;
    color: #e2cca0;
    margin-bottom: 20px;
    font-style: italic;
}

.rpg-book-cover-desc {
    font-size: 0.95em;
    line-height: 1.5;
    opacity: 0.9;
    max-width: 480px;
    margin: 0 auto 20px auto;
}

.rpg-book-cover-prompt {
    display: inline-block;
    padding: 8px 18px;
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    border-radius: 20px;
    font-size: 0.9em;
    font-family: var(--rpg-book-font-heading);
    color: #f7d070;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.rpg-book-sheet-cover:hover .rpg-book-cover-prompt {
    background: rgba(212, 175, 55, 0.4);
    transform: scale(1.05);
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.rpg-book-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding: 10px 16px;
    background: #201815;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
    flex-wrap: wrap;
    gap: 10px;
}

.rpg-book-btn {
    background: linear-gradient(180deg, #4a362c 0%, #2d201a 100%);
    color: #f3e5ab;
    border: 1px solid #6b4e3d;
    padding: 8px 16px;
    border-radius: 5px;
    font-family: var(--rpg-book-font-heading);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rpg-book-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #5e463a 0%, #3a2a22 100%);
    border-color: #d4af37;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

.rpg-book-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rpg-book-page-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d8c39d;
    font-family: var(--rpg-book-font-heading);
    font-size: 0.9em;
}

.rpg-book-select-page {
    background: #120e0c;
    color: #f3e5ab;
    border: 1px solid #4a362c;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: var(--rpg-book-font-heading);
    outline: none;
    cursor: pointer;
}

.rpg-book-select-page:focus {
    border-color: #d4af37;
}

.rpg-book-toolbar-extra {
    display: flex;
    gap: 8px;
}

.rpg-book-icon-btn {
    background: rgba(255,255,255,0.06);
    color: #d8c39d;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rpg-book-icon-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
    color: #ffffff;
}

/* ── Fullscreen Mode Style (Maximální využití plného obrazu monitoru) ──────── */
.rpg-book-container.is-fullscreen,
.rpg-book-container:fullscreen,
.rpg-book-container:-webkit-full-screen,
.rpg-book-container:-moz-full-screen,
.rpg-book-container:-ms-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 15px !important;
    background: #080605 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
    z-index: 9999999 !important;
}

.rpg-book-container.is-fullscreen .rpg-book-stage,
.rpg-book-container:fullscreen .rpg-book-stage,
.rpg-book-container:-webkit-full-screen .rpg-book-stage {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: calc(100vh - 75px) !important;
    min-height: 0 !important;
    max-height: calc(100vh - 75px) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 16px !important;
    margin: 0 auto !important;
    max-width: 1400px !important;
}

.rpg-book-container.is-fullscreen .rpg-book-viewport,
.rpg-book-container:fullscreen .rpg-book-viewport,
.rpg-book-container:-webkit-full-screen .rpg-book-viewport {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
}

.rpg-book-container.is-fullscreen .rpg-book-pages-wrapper,
.rpg-book-container:fullscreen .rpg-book-pages-wrapper,
.rpg-book-container:-webkit-full-screen .rpg-book-pages-wrapper {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
}

.rpg-book-container.is-fullscreen .rpg-book-page-sheet,
.rpg-book-container:fullscreen .rpg-book-page-sheet,
.rpg-book-container:-webkit-full-screen .rpg-book-page-sheet {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

.rpg-book-container.is-fullscreen .rpg-book-page-inner,
.rpg-book-container:fullscreen .rpg-book-page-inner,
.rpg-book-container:-webkit-full-screen .rpg-book-page-inner,
.rpg-book-container.is-fullscreen .rpg-book-cover-inner,
.rpg-book-container:fullscreen .rpg-book-cover-inner,
.rpg-book-container:-webkit-full-screen .rpg-book-cover-inner {
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 30px 50px !important;
}

.rpg-book-container.is-fullscreen .rpg-book-page-body,
.rpg-book-container:fullscreen .rpg-book-page-body,
.rpg-book-container:-webkit-full-screen .rpg-book-page-body {
    flex: 1 1 auto !important;
    height: 100% !important;
    font-size: 1.25em !important;
    line-height: 1.8 !important;
    overflow-y: auto !important;
}

.rpg-book-container.is-fullscreen .rpg-book-toolbar,
.rpg-book-container:fullscreen .rpg-book-toolbar,
.rpg-book-container:-webkit-full-screen .rpg-book-toolbar {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 10px auto 0 auto !important;
}

/* ── Modal Table of Contents ─────────────────────────────────────────────── */
.rpg-book-toc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.rpg-book-toc-modal.open {
    opacity: 1;
    visibility: visible;
}

.rpg-book-toc-content {
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    background: #241c18;
    border: 2px solid #d4af37;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    color: #f5e6ca;
}

.rpg-book-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4a362c;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.rpg-book-toc-header h3 {
    margin: 0;
    font-family: var(--rpg-book-font-heading);
    color: #f7d070;
}

.rpg-book-toc-close {
    background: none;
    border: none;
    color: #d8c39d;
    font-size: 1.8em;
    cursor: pointer;
    line-height: 1;
}

.rpg-book-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.rpg-book-toc-list li {
    margin-bottom: 6px;
}

.rpg-book-toc-list a {
    display: block;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    color: #f3e5ab;
    text-decoration: none;
    transition: background 0.2s ease;
}

.rpg-book-toc-list a:hover {
    background: rgba(212, 175, 55, 0.2);
    color: #ffffff;
}

/* ── Error Box ───────────────────────────────────────────────────────────── */
.rpg-book-error {
    padding: 12px 18px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    border-radius: 6px;
    margin: 1em 0;
    font-family: sans-serif;
}
