/* Flipbook im Buch-Design (viadavita). Groessen skalieren mit --pw (Seitenbreite in px, von JS gesetzt). */
:root {
    --brand: #7a3e2b;
    --brand-dark: #4f2619;
    --ink: #2f2420;
    --muted: #6f5f58;
    --paper: #fffcf6;
    --paper-edge: #f3eadf;
    --gold: #d4ad6a;
    --pw: 520px;
    --ph: 722px;
}

html, body { height: 100%; }
.fb-body {
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(255, 236, 214, 0.10), transparent 60%),
        linear-gradient(160deg, #3a2a23 0%, #241914 100%);
    color: var(--ink);
    font-family: "Inter Variable", Inter, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Buehne ---------- */
.fb-stage {
    position: fixed;
    inset: 0 0 76px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.fb-wrap { position: relative; }
.fb-book { filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.45)); }
.fb-loading {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 245, 235, 0.8);
    font-size: 14px;
}
.fb-loading[hidden] { display: none; }
.fb-spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid rgba(255, 245, 235, 0.3); border-top-color: #fff;
    animation: fbspin 0.8s linear infinite;
}
@keyframes fbspin { to { transform: rotate(360deg); } }

/* Unsichtbarer Messbereich fuer die Seitenaufteilung */
.fb-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }

/* ---------- Seite ---------- */
.pg {
    width: var(--pw);
    height: var(--ph);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    background: var(--paper);
    font-size: calc(var(--pw) / 34);
    line-height: 1.6;
    color: var(--ink);
}
.pg.left  { background: linear-gradient(to left, rgba(80, 50, 30, 0.13), rgba(80, 50, 30, 0) 7%), var(--paper); }
.pg.right { background: linear-gradient(to right, rgba(80, 50, 30, 0.13), rgba(80, 50, 30, 0) 7%), var(--paper); }
.pg.single { background: var(--paper); }

.pg-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 2.6em 2.6em 1.8em 2.6em;
}
.pg.left .pg-inner  { padding-right: 3.1em; }
.pg.right .pg-inner { padding-left: 3.1em; }

.pg-head {
    flex: 0 0 auto;
    height: 1.6em;
    font-size: 0.68em;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pg.left .pg-head { text-align: left; }
.pg.right .pg-head { text-align: right; }
.pg-body { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.pg-body > :last-child { margin-bottom: 0; }
.pg-foot {
    flex: 0 0 auto;
    padding-top: 0.6em;
    font-family: "Fraunces Variable", Georgia, serif;
    font-size: 0.8em;
    color: var(--muted);
    text-align: center;
}

/* ---------- Inhalt ---------- */
.b-chapter { padding: 2.4em 0 1.4em; text-align: center; }
.b-chapter .kicker {
    font-size: 0.7em; letter-spacing: 0.22em; text-transform: uppercase; color: var(--brand); font-weight: 600;
}
.b-chapter h2 {
    margin: 0.35em 0 0;
    font-family: "Fraunces Variable", Georgia, serif;
    font-weight: 600;
    font-size: 2.05em;
    line-height: 1.15;
    color: var(--ink);
}
.b-orn { display: block; margin: 0.9em auto 0; width: 4.5em; height: 1px; background: var(--brand); opacity: 0.45; position: relative; }
.b-orn::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 0.45em; height: 0.45em;
    background: var(--paper); border: 1px solid var(--brand); transform: translate(-50%, -50%) rotate(45deg);
}

.b-q { margin: 0 0 1.25em; }
.b-q h3 {
    margin: 0 0 0.35em;
    font-family: "Fraunces Variable", Georgia, serif;
    font-weight: 600;
    font-size: 1.02em;
    line-height: 1.35;
    color: var(--brand);
}
/* Sprachaufnahme: kleiner ▶-Knopf unter der Frage */
.b-voice {
    display: inline-flex; align-items: center; gap: 0.4em; margin: 0 0 0.5em; padding: 0.28em 0.75em 0.28em 0.5em;
    border: 1px solid rgba(122, 62, 43, 0.35); border-radius: 999px; background: rgba(255, 255, 255, 0.7);
    color: var(--brand); font: 600 0.72em/1 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; cursor: pointer;
}
.b-voice:hover { background: #fff; border-color: var(--brand); }
.b-voice svg { width: 1.15em; height: 1.15em; fill: currentColor; }
.b-voice .i-pause { display: none; }
.b-voice.is-playing { background: var(--brand); color: #fff; border-color: var(--brand); }
.b-voice.is-playing .i-play { display: none; }
.b-voice.is-playing .i-pause { display: inline; }
.b-q p {
    margin: 0;
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    font-size: 1em;
    line-height: 1.62;
    white-space: pre-line;
    hyphens: auto;
    -webkit-hyphens: auto;
    text-align: left;
    overflow-wrap: break-word;
}

.b-fig { margin: 0.2em 0 1.4em; text-align: center; }
.b-fig .frame {
    border: 0; font: inherit;
    display: inline-block;
    background: #fff;
    padding: 0.55em 0.55em 0.55em;
    box-shadow: 0 0.35em 1.1em rgba(60, 35, 20, 0.18), 0 0 0 1px rgba(60, 35, 20, 0.06);
    transform: rotate(-0.6deg);
    cursor: zoom-in;
    max-width: 100%;
}
.b-fig:nth-of-type(even) .frame { transform: rotate(0.7deg); }
.b-fig img {
    display: block;
    height: var(--fig-h, 14em);
    width: calc(var(--fig-h, 14em) * 0.82); /* feste Box: Layout haengt nicht vom Laden des Bildes ab */
    max-width: 100%;
    object-fit: contain;
    background: var(--paper-edge);
}
.b-fig figcaption { margin-top: 0.6em; font-size: 0.78em; font-style: italic; color: var(--muted); }

/* ---------- Umschlag ---------- */
.pg.cover, .pg.backcover {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.10), transparent 55%),
        linear-gradient(135deg, #8a4733 0%, var(--brand) 45%, var(--brand-dark) 100%);
    color: #fff4e8;
}
.pg.cover::before, .pg.backcover::before {
    content: ""; position: absolute; inset: 1.4em;
    border: 1px solid rgba(212, 173, 106, 0.75);
    box-shadow: inset 0 0 0 0.3em rgba(212, 173, 106, 0.18);
    pointer-events: none;
}
.pg.cover::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 1.6em;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.28), rgba(255, 255, 255, 0.06) 60%, rgba(0, 0, 0, 0));
}
.cover-inner {
    position: absolute; inset: 3.2em 3em; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center;
}
.cover-label { font-size: 0.72em; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold); }
.cover-title {
    font-family: "Fraunces Variable", Georgia, serif; font-weight: 600; font-size: 2.6em; line-height: 1.12; color: #fff6ea;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.cover-name { margin-top: 0.8em; font-family: "Fraunces Variable", Georgia, serif; font-style: italic; font-size: 1.1em; color: rgba(255, 244, 232, 0.85); }
.cover-years { margin-top: 0.3em; font-size: 0.85em; letter-spacing: 0.18em; color: var(--gold); }
.cover-brand { font-family: "Fraunces Variable", Georgia, serif; font-size: 0.95em; letter-spacing: 0.08em; color: var(--gold); }
.cover-brand small { display: block; font-family: "Inter Variable", Inter, sans-serif; font-size: 0.65em; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.8; margin-top: 0.3em; }
.cover-orn { width: 5em; height: 1px; background: var(--gold); margin: 1.2em auto; opacity: 0.8; }
.back-quote { font-family: "Fraunces Variable", Georgia, serif; font-style: italic; font-size: 1.25em; line-height: 1.5; color: #fff4e8; max-width: 16em; }

/* Vorsatz und Titelseite */
.pg.endpaper {
    background:
        radial-gradient(circle at 1px 1px, rgba(122, 62, 43, 0.12) 1px, transparent 1.2px) 0 0 / 1.4em 1.4em,
        #f4e9dc;
}
.title-page { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 3em; }
.title-page .kicker { font-size: 0.72em; letter-spacing: 0.28em; text-transform: uppercase; color: var(--brand); font-weight: 600; }
.title-page h1 { margin: 0.5em 0 0; font-family: "Fraunces Variable", Georgia, serif; font-weight: 600; font-size: 2.4em; line-height: 1.15; }
.title-page .name { margin-top: 0.6em; font-family: "Fraunces Variable", Georgia, serif; font-style: italic; color: var(--muted); font-size: 1.1em; }
.title-page .quote { margin-top: 2.2em; font-family: "Iowan Old Style", Georgia, serif; font-style: italic; color: var(--muted); max-width: 18em; }

/* Inhaltsverzeichnis */
.toc-title { margin: 1.2em 0 1.2em; text-align: center; font-family: "Fraunces Variable", Georgia, serif; font-weight: 600; font-size: 1.8em; }
.toc-row {
    width: 100%; border: 0; background: transparent; text-align: left; font: inherit;
    display: flex; align-items: baseline; gap: 0.5em; padding: 0.42em 0; cursor: pointer;
    font-family: "Fraunces Variable", Georgia, serif; font-size: 1.02em; color: var(--ink);
}
.toc-row .n { color: var(--brand); font-size: 0.8em; min-width: 1.6em; }
.toc-row .dots { flex: 1; border-bottom: 1px dotted rgba(122, 62, 43, 0.35); transform: translateY(-0.3em); }
.toc-row:hover { color: var(--brand); }

/* Stammbaum, Impressum, leere Seite */
.tree-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tree-wrap h2 { margin: 0.6em 0 0.8em; text-align: center; font-family: "Fraunces Variable", Georgia, serif; font-weight: 600; font-size: 1.5em; }
.tree-wrap .tree-img { border: 0; background: transparent; padding: 0; width: 100%; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.tree-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.imprint { position: absolute; inset: auto 3em 3em 3em; font-size: 0.78em; line-height: 1.6; color: var(--muted); }
.imprint p { margin: 0 0 0.6em; }
/* «Fortsetzung folgt» (nur Besitzer eines Gratis-Buchs, docs/upgrade-momente) */
.more-wrap { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 0 0.5em; }
.more-eyebrow { margin: 0; font-size: 0.7em; letter-spacing: 0.24em; text-transform: uppercase; color: var(--eyebrow, var(--brand)); }
.more-wrap h2 { margin: 0.4em 0 0.6em; font-family: var(--head-font, "Fraunces Variable", Georgia, serif); font-weight: 600; font-style: var(--title-style, normal); font-size: 1.5em; line-height: 1.2; }
.more-text { margin: 0 0 1em; font-size: 0.88em; line-height: 1.6; color: var(--muted); }
.more-list { list-style: none; margin: 0 auto 1.4em; padding: 0; font-family: "Fraunces Variable", Georgia, serif; font-style: italic; font-size: 0.92em; line-height: 1.7; color: var(--ink); }
.more-list li::before { content: "🔒 "; font-style: normal; font-size: 0.75em; opacity: 0.6; }
.more-cta { align-self: center; display: inline-block; padding: 0.7em 1.4em; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 600; font-size: 0.88em; text-decoration: none; }
.more-cta:hover { background: var(--brand-dark, var(--brand)); }
.empty-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 3em; font-family: "Fraunces Variable", Georgia, serif; font-style: italic; color: var(--muted); }

/* ---------- Bedienleiste ---------- */
.fb-toolbar {
    position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    display: flex; align-items: center; gap: 4px;
    padding: 6px; border-radius: 999px;
    background: rgba(255, 250, 244, 0.95); backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 30;
}
.fb-tb-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 999px; border: 0; background: transparent; color: var(--ink); cursor: pointer;
}
.fb-tb-btn svg, .fb-tb-text svg { width: 20px; height: 20px; }
.fb-tb-btn:hover, .fb-tb-text:hover { background: #f3e8de; }
.fb-tb-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.fb-tb-mid { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.fb-tb-text {
    display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border-radius: 999px; border: 0;
    background: transparent; color: var(--ink); font: 600 14px/1 "Inter Variable", Inter, sans-serif; cursor: pointer;
}
.fb-tb-info { font: 500 13px/1 "Inter Variable", Inter, sans-serif; color: var(--muted); white-space: nowrap; min-width: 6.5em; text-align: center; }
.fb-tb-sep { width: 1px; height: 24px; background: rgba(47, 36, 32, 0.15); margin: 0 4px; }
.fb-toc {
    position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%);
    width: min(360px, 90vw); max-height: 60vh; overflow: auto;
    background: #fffaf4; border-radius: 18px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35); padding: 8px;
}
.fb-toc button {
    display: flex; width: 100%; gap: 10px; align-items: baseline; text-align: left; border: 0; background: transparent;
    padding: 10px 12px; border-radius: 12px; cursor: pointer; font: 500 14px/1.35 "Inter Variable", Inter, sans-serif; color: var(--ink);
}
.fb-toc button:hover { background: #f3e8de; }
.fb-toc .n { color: var(--brand); font-weight: 600; min-width: 1.5em; }
.fb-toc .p { margin-left: auto; color: var(--muted); font-size: 12px; }

@media (max-width: 640px) {
    .fb-tb-hide-sm { display: none; }
    .fb-tb-text span { display: none; }
    .fb-tb-text { padding: 0 12px; }
}

/* ---------- Grossansicht ---------- */
.fb-lightbox {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
    background: rgba(20, 14, 11, 0.92); padding: 24px; cursor: zoom-out;
}
.fb-lightbox[hidden] { display: none; }
.fb-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.fb-lightbox-close {
    position: absolute; top: 14px; right: 18px; width: 44px; height: 44px; border-radius: 999px; border: 0;
    background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) { .fb-spinner { animation: none; } }

/* ======================================================================
   Buch-Vorlagen (inc/book_themes.php): Farben/Schriften als CSS-Variablen
   aus flipbook.php (:root), Umschlag-Varianten ueber body.cv-<art>
   ====================================================================== */
.fb-body {
    background:
        radial-gradient(ellipse at 50% 35%, rgba(255, 236, 214, 0.10), transparent 60%),
        linear-gradient(160deg, var(--stage1, #3a2a23) 0%, var(--stage2, #241914) 100%);
}
.pg.cover, .pg.backcover {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.10), transparent 55%),
        linear-gradient(135deg, var(--cover1, #8a4733) 0%, var(--cover2, #7a3e2b) 45%, var(--cover3, #4f2619) 100%);
    color: var(--cover-ink, #fff4e8);
}
.pg.cover::before, .pg.backcover::before { border-color: var(--frame, rgba(212, 173, 106, 0.75)); box-shadow: none; }
.cover-label, .cover-years, .cover-brand { color: var(--cover-accent, #d4ad6a); }
.cover-title { color: var(--cover-title, #fff6ea); font-family: var(--head-font); font-style: var(--title-style, normal); }
.cover-name { color: var(--cover-sub, rgba(255, 244, 232, 0.85)); }
.back-quote { color: var(--cover-ink, #fff4e8); }
.cover-orn { background: var(--cover-accent, #d4ad6a); }
.pg.endpaper {
    background: radial-gradient(circle at 1px 1px, var(--line, rgba(122, 62, 43, 0.12)) 1px, transparent 1.2px) 0 0 / 1.4em 1.4em, var(--endpaper, #f4e9dc);
}
.b-chapter .kicker, .title-page .kicker { color: var(--eyebrow, var(--brand)); }
.b-chapter h2, .b-q h3, .title-page h1, .toc-title { font-family: var(--head-font); }

/* Helle Umschlaege: kein dunkler Textschatten */
.cv-label .cover-title, .cv-photo .cover-title, .cv-dots .cover-title, .cv-wash .cover-title { text-shadow: none; }

/* Leinen & Salbei: Leinenstruktur und Titelschild */
.cv-label .pg.cover {
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.03) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.03) 0 1px, transparent 1px 3px),
        linear-gradient(135deg, var(--cover1), var(--cover3));
}
.cv-label .pg.cover::before { display: none; }
.cv-label .cover-mid { background: var(--label-bg); border: 1px solid var(--frame); padding: 2em 1.5em; box-shadow: 0 0.3em 1em rgba(0, 0, 0, 0.08); }

/* Modern: grosses Titelfoto, Text darunter linksbuendig */
.cv-photo .pg.cover::before { display: none; }
.cover-photo { position: absolute; left: 0; right: 0; top: 0; height: 52%; background: linear-gradient(135deg, var(--x1), var(--x2)); background-size: cover; background-position: center; }
.cv-photo .cover-inner { inset: 56% 2.6em 2.2em 2.8em; justify-content: flex-start; align-items: flex-start; text-align: left; }
.cv-photo .cover-label { order: 1; }
.cv-photo .cover-mid { order: 2; margin-top: 0.6em; }
.cv-photo .cover-brand { order: 3; margin-top: auto; }
.cv-photo .cover-title { font-weight: 700; letter-spacing: -0.02em; font-size: 2.3em; }
.cv-photo .cover-orn { margin: 0.8em 0; }
.cv-photo .b-fig .frame { transform: none; }

/* Elegant: doppelter Goldrahmen */
.cv-double .pg.cover::before { inset: 1.2em; }
.cv-double .cover-inner::before { content: ""; position: absolute; inset: -1.4em -1.2em; border: 1px solid var(--frame); opacity: 0.5; pointer-events: none; }

/* Kinderbuch: runde Farbflaechen */
.cv-dots .pg.cover::before { display: none; }
.cover-dot { position: absolute; border-radius: 50%; }
.cover-dot.d1 { width: 48%; height: 35%; background: var(--x1); top: -8%; left: -14%; }
.cover-dot.d2 { width: 38%; height: 27%; background: var(--x2); bottom: 3%; right: -10%; }
.cover-dot.d3 { width: 12%; height: 8.6%; background: var(--x3); top: 21%; right: 15%; }
.cv-dots .cover-title { font-size: 2.9em; }
.cv-dots .b-fig .frame { border-radius: 12px; }

/* Aquarell: weiche Farbflaechen */
.cv-wash .pg.cover::before { display: none; }
.cover-wash {
    position: absolute; inset: -15%;
    background:
        radial-gradient(circle at 25% 30%, var(--x1), transparent 40%),
        radial-gradient(circle at 75% 72%, var(--x2), transparent 45%),
        radial-gradient(circle at 72% 22%, var(--x3), transparent 35%);
    opacity: 0.55; filter: blur(8px);
}
