/* ============================================================
   BOOK LAYOUT – GRUNDSTRUKTUR
   ============================================================ */

html,
body {
    height: 100%;
    overflow: hidden;
}

:root {
    --header-height: 2.75rem;
}

#book-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}


/* ============================================================
   HEADER
   ============================================================ */

#book-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--space-lg);
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--accent);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.book-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
}

.book-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius);
    transition: background-color var(--transition), color var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.header-btn:hover {
    background-color: var(--bg-tertiary);
}

.header-btn svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.back-btn {
    color: var(--text-muted);
    font-size: 0.75rem;
    max-width: 180px;
    overflow: hidden;
}

.back-btn #back-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.back-btn:hover {
    color: var(--accent);
    background-color: var(--bg-tertiary);
}

.header-separator {
    width: 1px;
    height: 1.2rem;
    background-color: var(--border);
    flex-shrink: 0;
}

#theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 999px;
    border: 1px solid var(--accent);
    cursor: pointer;
    background: none;
    color: var(--accent);
    transition: background-color var(--transition), color var(--transition);
    min-width: 2.25rem;
    height: 1.6rem;
    flex-shrink: 0;
}

#theme-toggle:hover {
    background-color: var(--accent);
    color: var(--accent-text);
}

.theme-icon {
    width: 1rem;
    height: 1rem;
    display: block;
}


/* ============================================================
   TOC DROPDOWN
   ============================================================ */

.toc-wrapper {
    position: static;
}

.toc-dropdown {
    display: block;
    padding: 0;
    border-bottom: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 200px;
    max-height: calc(100dvh - var(--header-height));
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    box-shadow: 4px 4px 20px var(--shadow);
    z-index: 101;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.toc-dropdown::-webkit-scrollbar {
    display: none;
}

.toc-dropdown[hidden] {
    display: none;
}

.toc-home {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 2px solid var(--accent);
    background-color: var(--bg-tertiary);
}

.toc-home a {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

.toc-home a:hover {
    color: var(--accent-hover);
}

.toc-node {
    border-bottom: 1px solid var(--border);
}

.toc-node.collapsed > .toc-children,
.toc-node.collapsed > .toc-page-list {
    display: none;
}

.toc-node-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background-color: var(--bg-tertiary);
    cursor: default;
}

.toc-depth-1 > .toc-node-header {
    background-color: var(--bg-secondary);
    padding-left: calc(var(--space-md) + var(--space-sm));
}

.toc-depth-2 > .toc-node-header {
    background-color: var(--bg-secondary);
    padding-left: calc(var(--space-md) + var(--space-lg));
}

.toc-node-title {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--accent);
}

.toc-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.6rem;
    padding: 2px var(--space-xs);
    transition: color var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.toc-collapse-btn:hover {
    color: var(--accent);
}

.toc-page-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-depth-0 > .toc-page-list li a {
    padding-left: var(--space-lg);
}

.toc-depth-1 > .toc-page-list li a {
    padding-left: calc(var(--space-lg) + var(--space-sm));
}

.toc-depth-2 > .toc-page-list li a {
    padding-left: calc(var(--space-lg) + var(--space-lg));
}

.toc-page-list li a {
    display: block;
    padding-top: var(--space-xs);
    padding-bottom: var(--space-xs);
    padding-right: var(--space-md);
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--text);
    text-decoration: none;
    transition: background-color var(--transition), color var(--transition);
}

.toc-page-list li a:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent);
    text-decoration: none;
}

.toc-page-list li a.active {
    color: var(--accent);
    font-style: italic;
}

.toc-children {
    border-top: 1px solid var(--border);
}


/* ============================================================
   BOOK STAGE
   ============================================================ */

#book-stage {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.book-page {
    height: 100%;
    overflow: hidden;
    position: relative;
}

.book-page-content {
    height: 100%;
    overflow-y: auto;
    padding: var(--space-xl) clamp(var(--space-lg), 5vw, 5rem);
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--text);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.book-page-content::-webkit-scrollbar {
    display: none;
}


/* ============================================================
   PAGE ANIMATIONS
   ============================================================ */

.book-page.slide-out-left {
    animation: slideOutLeft 0.18s ease forwards;
}

.book-page.slide-in-right {
    animation: slideInRight 0.18s ease forwards;
}

.book-page.slide-out-right {
    animation: slideOutRight 0.18s ease forwards;
}

.book-page.slide-in-left {
    animation: slideInLeft 0.18s ease forwards;
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(-3%); opacity: 0; }
}

@keyframes slideInRight {
    from { transform: translateX(3%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(3%); opacity: 0; }
}

@keyframes slideInLeft {
    from { transform: translateX(-3%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}


/* ============================================================
   FOOTER
   ============================================================ */

#book-footer {
    display: flex;
    align-items: center;
    height: 2.5rem;
    padding: 0 var(--space-lg);
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.book-footer-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
}

.book-footer-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
    pointer-events: none;
}

.book-footer-center a {
    pointer-events: all;
}

.book-footer-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    flex: 1;
}

.footer-campaign {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    transition: color var(--transition);
    white-space: nowrap;
}

.footer-link:hover {
    color: var(--accent);
}

.nav-arrow {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    padding: var(--space-xs);
    border-radius: var(--radius);
    transition: background-color var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2rem;
    flex-shrink: 0;
}

.nav-arrow svg {
    width: 1.4rem;
    height: 1.4rem;
}

.nav-arrow:hover {
    background-color: var(--accent);
    color: var(--accent-text);
}

.nav-arrow:disabled {
    color: var(--border);
    cursor: default;
    background: none;
}

.page-number {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    min-width: 1.5rem;
    text-align: center;
}


/* ============================================================
   TOC PAGE (INDEX)
   ============================================================ */

.toc-page {
    padding-bottom: var(--space-xl);
}

.toc-campaign-title {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
    color: var(--accent);
    letter-spacing: 0.06em;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 2px solid var(--accent);
}

.toc-chapter {
    margin-bottom: var(--space-lg);
}

.toc-chapter-section {
    margin-bottom: var(--space-md);
}

.toc-h1 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--accent);
    letter-spacing: 0.04em;
    margin-bottom: var(--space-sm);
    margin-top: 0;
    font-weight: 600;
}

.toc-h2 {
    font-family: var(--font-heading);
    font-size: 0.92rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    margin-bottom: var(--space-xs);
    margin-top: var(--space-md);
    font-weight: 400;
}

.toc-h3 {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    margin-bottom: var(--space-xs);
    margin-top: var(--space-sm);
    font-weight: 400;
    font-style: italic;
}

.toc-pages {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-entry {
    margin: 0;
}

.toc-link {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    padding: 0.15rem 0;
    color: var(--text);
    text-decoration: none;
    transition: color var(--transition);
}

.toc-link:hover {
    color: var(--accent);
    text-decoration: none;
}

.toc-link-title {
    font-family: var(--font-body);
    font-size: 0.95rem;
    white-space: nowrap;
}

.toc-dots {
    flex: 1;
    border-bottom: 1px dotted var(--border);
    margin: 0 var(--space-xs);
    margin-bottom: 0.25rem;
    min-width: var(--space-md);
}

.toc-num {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.toc-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-lg) 0;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 480px) {
    .book-page-content {
        padding: var(--space-lg) var(--space-md);
        font-size: 0.9rem;
    }

    #book-header,
    #book-footer {
        padding: 0 var(--space-md);
    }

    .book-footer-center {
        display: none;
    }

    #back-label {
        display: none;
    }

    .toc-dropdown {
        width: 85vw;
    }
}