/* =========================
    DIE BUCHSEITEN (BASICS)
========================= */
.page {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    background: var(--parchment);
    box-sizing: border-box;
    padding: 45px 55px 75px 55px;
    color: var(--text-dark);
    transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.5s ease-in-out,
        opacity 0.3s ease-in-out;
}

.left {
    left: 0;
    width: 50%;
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    background: linear-gradient(to right, rgba(255, 255, 255, 0.3) 0%, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, 0) 85%, rgba(0, 0, 0, 0.2) 100%), var(--parchment);
    z-index: 2;
    border-radius: 4px 0 0 4px;
}

.right {
    left: 50%;
    width: 50%;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.3) 0%, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, 0) 85%, rgba(0, 0, 0, 0.2) 100%), var(--parchment);
    z-index: 2;
    border-radius: 0 4px 4px 0;
}

/* --- KONTROLLIERTE SCROLLBEREICHE --- */
#rightContent {
    max-height: 100%;
    box-sizing: border-box;
    scrollbar-width: none;
    /* Links bleibt komplett unsichtbar */
    overflow-y: visible !important; 
    -ms-overflow-style: none;
    padding: 5px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
}

#rightContent::-webkit-scrollbar {
    display: none !important;
}

#leftContent {
    max-height: 100%;
    box-sizing: border-box;
    scrollbar-width: auto !important;
    -ms-overflow-style: auto !important;
    overflow-y: auto !important;
    /* Aktiviert vertikales Scrollen rechts */
    padding: 5px 15px;
}

/* Gestaltet die rechte Scrollbar passend zum Buch-Design */
#leftContent::-webkit-scrollbar {
    display: block !important;
    width: 6px;
}

#leftContent::-webkit-scrollbar-track {
    background: rgba(90, 61, 27, 0.05);
    border-radius: 10px;
}

#leftContent::-webkit-scrollbar-thumb {
    background: rgba(82, 16, 16, 0.3);
    /* Dunkelrote, dezente Scrollbar */
    border-radius: 10px;
}

#leftContent::-webkit-scrollbar-thumb:hover {
    background: rgba(82, 16, 16, 0.6);
}

/* =========================
    CONTENT & INTELLIGENTE BILDER
========================= */
.image {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.image img {
    max-width: 100%;
    max-height: 38vh;
    max-height: 38dvh;
    height: auto;
    width: auto;
    object-fit: contain !important;
    border: 6px double #5a3d1b;
    padding: 4px;
    background: #fcf4e0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.image-whole-page {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    max-width: 100%;
}

.image-whole-page img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain !important;
    border: 6px double #5a3d1b;
    padding: 4px;
    background: #fcf4e0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.image-btn {
    background: none;
    border: none;
    position: relative;
    padding: 0;
    isolation: isolate;
    z-index: 0;
    transition: transform 0.2s ease-in-out;
}

.image-btn:hover {
    cursor: pointer;
    transform: scale(1.03);
}

.image-stack::before,
.image-stack::after {
    content: "";
    position: absolute;
    inset: 10px;
    border: 6px double #5a3d1b;
    background: #ead7aa;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
    z-index: 0;
}

.image-stack::before {
    transform: rotate(-4deg) translate(-8px, 7px);
}

.image-stack::after {
    transform: rotate(3deg) translate(9px, 4px);
    background: #f2e4bf;
}

.image-stack img {
    position: relative;
    z-index: 1;
}


.content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 0 auto;
    /* ÄNDERUNG: Flex-Grow 1 erlaubt dem Container, nach oben zu expandieren */
    min-height: 0;
    justify-content: flex-start;
    /* Sorgt dafür, dass alles nach OBEN rutscht */
    padding-bottom: 20px;
    ;
}

.content span {
    font-size: 14px;
    font-style: italic;
    letter-spacing: 1.5px;
    color: #6e4a24;
    opacity: 0.9;
    text-transform: uppercase;
}

.content h2 {
    margin: 0;
    font-size: 32px;
    color: #521010;
    font-family: 'Georgia', serif !important; 
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6);
    border-bottom: 1px dashed rgba(90, 61, 27, 0.35);
    padding-bottom: 6px;
}

.content p {
    line-height: 1.65;
    font-size: 17px;
    text-align: center;
    text-justify: inter-word;
    margin: 0;
}

.image-caption {
    padding: 2em 0 0 0;
}

.image-caption p {
    font-family: 'Georgia', serif; 
    color: #521010;
}

.report-text {
    display: block;
    white-space: pre-line;
    font-size: 17px; 
}

.report-text::first-letter {
    float: left;
    font-family: carribean, "Times New Roman", serif;
    font-size: 4.8rem;
    line-height: 0.78;
    margin: 0.12rem 0.55rem 0 0;
    color: #521010;
    font-weight: bold;
    text-shadow:
        1px 1px 0 #f7e8bd,
        2px 2px 0 rgba(184, 134, 11, 0.45),
        0 4px 8px rgba(54, 31, 17, 0.28);
}

/* =========================
    DESKTOP COVER-MODUS INTERN
========================= */
#leftpage.hidden~.right #rightContent {
    overflow: hidden !important;
    max-height: 100% !important;
    height: 100% !important;
    padding: 45px !important;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    transition: padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#leftpage.hidden~.right .content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    height: 100% !important;
    width: 100% !important;
    gap: 14px !important;
}

.cover-logo {
    display: block;
    margin: 20px auto 0 auto;
    width: auto;
    max-width: 100%;
    max-height: calc(100% - 180px) !important;
    min-height: 6em;
    object-fit: contain !important;
    flex-shrink: 1;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

#leftpage.hidden~.right {
    left: 0 !important;
    width: 100% !important;
    z-index: 2;
    color: #fbf2db;
    background:
        radial-gradient(circle at 50% 18%, rgba(218, 165, 32, 0.22), rgba(218, 165, 32, 0) 34%),
        linear-gradient(135deg, #5a351e 0%, var(--leather) 48%, var(--leather-dark) 100%);
    box-shadow:
        inset 0 0 0 2px rgba(218, 165, 32, 0.32),
        inset 0 0 55px rgba(0, 0, 0, 0.55);
}

#leftpage.hidden~.right .content h2 {
    color: #f7d98d;
    border-bottom-color: rgba(247, 217, 141, 0.38);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

#leftpage.hidden~.right .content p,
#leftpage.hidden~.right .content span {
    color: #fbf2db !important;
    text-align: center;
}

#leftpage.hidden~.right .cover-logo {
    filter:
        drop-shadow(0 10px 18px rgba(0, 0, 0, 0.65))
        drop-shadow(0 0 10px rgba(218, 165, 32, 0.22));
}

/* =========================
    INHALTSVERZEICHNIS (TOC)
========================= */
.toc h2 {
    color: #521010;
}

.toc ul {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.toc li {
    padding: 12px 5px;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-dark);
    border-bottom: 1px dotted rgba(90, 61, 27, 0.25);
    transition: all 0.2s ease;
}

.toc li:hover {
    color: #521010;
    padding-left: 12px;
    background: rgba(90, 61, 27, 0.06);
}

/* =========================
    NAVIGATION CONTROLS
========================= */
.nav {
    width: 100%;
    max-width: 1800px;
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    z-index: 20;
    height: 50px;
    transition: max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.container:has(#leftpage.hidden) .nav {
    max-width: 900px;
}

body:has(.galleria-container.fullscreen) .nav {
    display: none !important;
}

.nav button {
    background: linear-gradient(135deg, #8b5a2b, #5a3d1b);
    color: #fcf4e0;
    border: 2px solid var(--gold);
    padding: 12px 36px;
    border-radius: 4px;
    font-family: 'Georgia', serif;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.nav button:hover {
    background: linear-gradient(135deg, #a16935, #6e4a24);
    border-color: var(--gold-hover);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

/* =========================
    POPUP OVERLAY & GALLERIA FIXES
========================= */
.popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: rgba(20, 12, 5, 0.95) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 99999 !important;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in-out;
}

/* Kritisches CSS, wenn die Galerie geschlossen wird */
.popup-overlay.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body:has(:fullscreen) .popup-overlay,
body.galleria-fullscreen .popup-overlay {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

.popup-content {
    background: radial-gradient(circle at 50% 50%, #fbf2db 0%, #f3e3be 60%, #e3ce9c 100%) !important;
    border: 12px solid #361f11 !important;
    border-radius: 14px;
    padding: 30px;
    max-width: 90vw;
    max-height: 85vh;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.9);
    position: relative;
    /* Fixiert den Close-Button relativ zu dieser Box */
    box-sizing: border-box;
    overflow: visible !important;
}

.popup-close {
    position: absolute !important;
    top: -25px !important;
    right: -25px !important;
    width: 44px !important;
    height: 44px !important;
    background: #521010 !important;
    color: #fbf2db !important;
    border: 3px solid #361f11 !important;
    border-radius: 50% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    font-size: 26px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6) !important;
    z-index: 100000 !important;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.popup-close:hover {
    background: #7a1c1c !important;
    transform: scale(1.1) !important;
}

.galleria-container {
    /* Use explicit viewport units instead of 100% so the JS doesn't crash */
    width: 80vw;
    height: 75vh; 
    
    /* Keep it safely contained within the popup's borders */
    max-width: 100%;
    max-height: calc(85vh - 60px); 
    
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 auto;
}

.galleria-container.fullscreen {
    position: initial !important;
}

.galleria {
    width: 100% !important;
    /* Force the height here as well to be absolutely sure */
    height: 100% !important; 
    background: #000;
}

/* =========================
    STATE CLASSES & SEITENNUMMERN
========================= */
.nav-center {
    justify-content: center !important;
}

.nav-space {
    justify-content: space-between !important;
}

.btn-disabled {
    background: #3a3a3a !important;
    border-color: #555 !important;
    color: #777 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.page-num-inner {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Georgia', serif;
    font-size: 13px;
    font-style: italic;
    color: #5a3d1b;
    font-weight: bold;
    opacity: 0.8;
    z-index: 10;
    background: var(--parchment-dark);
    padding: 2px 14px;
    border-radius: 10px;
    border: 1px solid rgba(90, 61, 27, 0.2);
}

/* Macht das Element JEDERZEIT und gegen JEDEN Widerstand unsichtbar */
.hidden {
    display: none !important;
}

/* ========================================================
   MAGISCHE ZAUBERSTAB-LADEANIMATION
   ======================================================== */
.magic-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #5a3d1b;
    font-family: 'Georgia', serif;
}

.magic-wand-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
}

/* Der rotierende Zauberstab */
.magic-wand {
    font-size: 40px;
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 80px;
    transform-origin: center;
    animation: spinWand 2s linear infinite;
    display: inline-block;
}

/* Die funkelnden Sterne drumherum */
.magic-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 20px;
    animation: pulseStars 1.5s ease-in-out infinite alternate;
    pointer-events: none;
}

.star-1 {
    position: absolute;
    top: 10px;
    left: 10px;
}

.star-2 {
    position: absolute;
    top: 15px;
    right: 10px;
    animation-delay: 0.3s;
}

.star-3 {
    position: absolute;
    bottom: 15px;
    left: 20px;
    animation-delay: 0.6s;
}

.magic-loader p {
    font-size: 16px;
    font-style: italic;
    color: #5a3d1b;
    margin: 5px 0 0 0;
    text-align: center;
    animation: fadeText 1.5s ease-in-out infinite alternate;
}

/* --- ANIMATIONS-LOGIK (Keyframes) --- */
@keyframes spinWand {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulseStars {
    0% {
        transform: scale(0.6);
        opacity: 0.3;
        filter: drop-shadow(0 0 2px gold);
    }

    100% {
        transform: scale(1.2);
        opacity: 1;
        filter: drop-shadow(0 0 8px orange);
    }
}

@keyframes fadeText {
    0% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Der schwebende Hinweis-Bubble (näher an den Button herangerückt) */
.toc-hint-bubble {
    position: absolute;
    top: 38px;
    /* Weniger Abstand nach oben – rückt näher an den Button heran */
    left: 20px;
    /* Weiter nach links geschoben, damit er genau unter dem Button startet */
    background: #7a5328;
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    pointer-events: none;
    /* Klicks gehen durch den Hint durch */
    animation: popIn 0.4s ease-out forwards, pulseHint 1.5s infinite ease-in-out 0.4s;
}

/* Kleiner Pfeil nach oben zum Button */
.toc-hint-bubble::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 25px;
    /* Position des Pfeils, damit er genau auf die Mitte deines Buttons zeigt */
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #7a5328 transparent;
}

/* Sanftes Ausblenden nach Ablauf des Timeouts */
.toc-hint-bubble.fade-out {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Animationen */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.7);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulseHint {
    0% {
        box-shadow: 0 4px 15px rgba(122, 83, 40, 0.4);
    }

    50% {
        box-shadow: 0 4px 25px rgba(235, 180, 110, 0.8);
    }

    100% {
        box-shadow: 0 4px 15px rgba(122, 83, 40, 0.4);
    }
}

/* Globale Hilfsklasse zum unsichtbar Machen von Elementen */
.hidden {
    display: none !important;
}

/* ========================================================
   NEUER FOOTER-STYLE (Seitenzahl + Titel)
   ======================================================== */
.page-footer {
    position: absolute;
    bottom: 20px;
    /* Abstand zum unteren Seitenrand */
    left: 50px;
    /* Symmetrischer linker Rand */
    right: 50px;
    /* Symmetrischer rechter Rand */
    height: 30px;
    display: flex;
    justify-content: space-between;
    /* Titel links, Zahl rechts */
    align-items: center;
    border-top: 1px solid rgba(90, 61, 27, 0.2);
    /* Dezente Trennlinie */
    padding-top: 8px;
    font-family: 'Georgia', serif;
    font-size: 12px;
    font-style: italic;
    color: #5a3d1b;
    opacity: 0.8;
    z-index: 5;
    pointer-events: none;
    /* Klicks gehen durch den Footer hindurch */
}

/* Optional: Fein-Styling der einzelnen Bestandteile */
.page-num {
    font-weight: bold;
    font-size: 13px;
}

.footer-text {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    /* Verhindert Überlappung bei langen Titeln */
}

.toc-general {
    margin-bottom: 10px;
    padding-bottom: 10px;
}

.toc-general .toc-item {
    font-weight: bold;
    color: #521010;
}

.toc-archive {
    font-size: 0.9em;
    opacity: 0.8;
}

.toc-subheader {
    font-size: 0.75rem;          /* Klein */
    text-transform: uppercase;   /* Gibt eine elegante Struktur */
    letter-spacing: 0.1em;       /* Macht es "luftiger" */
    color: #888;                 /* Dezent, nicht zu schwarz */
    margin: 0.5em 0; 
    font-weight: 600;
    border-bottom: 1px solid #eee; /* Ganz dezente Linie zur Trennung */
    padding-bottom: 2px;
}

/* Optional: Die Listen selbst etwas feiner machen */
.toc {
    list-style: none;
    padding: 0;
}

.toc-item {
    padding: 4px 0;
    cursor: pointer;
    font-size: 0.95rem;
}

.toc-item:hover {
    color: #5a3d1b; /* Sanfter Farbwechsel beim Drüberfahren */
}

/* Standard für Desktop: Element ausblenden */
.mobile-hint-container {
    display: none;
}
