/* Handbuch (flip-book) – extends public.css */

.hb-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Header ── */
.hb-header {
  position: sticky;
  top: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px clamp(12px, 4vw, 48px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--wwm-border-soft);
}
.hb-back {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  transition: color .2s;
}
.hb-back:hover { color: var(--text); }
.hb-back-short { display: none; }
.hb-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--wwm-gold);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-toggle {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.lang-btn {
  min-width: 44px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  background: rgba(7, 20, 33, 0.8);
  border: 1px solid var(--wwm-border);
  transition: all .2s;
  letter-spacing: .5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lang-btn.active {
  background: linear-gradient(135deg, var(--wwm-gold), var(--wwm-gold-deep));
  color: #071421;
  border-color: transparent;
}
.lang-btn:hover:not(.active) {
  color: var(--text);
  border-color: var(--wwm-border-glow);
}

/* ── Book scene ── */
.book-scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 12px 8px;
  width: 100%;
  max-width: 100vw;
}
.book-stage {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.book-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  touch-action: pan-y pinch-zoom;
}
#book {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

/* ── Pages ── */
.page {
  background: #f5f0e8;
  overflow: hidden;
}
.pg {
  position: absolute;
  inset: 0;
  padding: clamp(16px, 4vw, 36px) clamp(18px, 4.5vw, 40px) clamp(40px, 6vw, 52px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #c4a870 transparent;
  background: #f5f0e8;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.page:nth-child(odd) .pg  { box-shadow: inset -6px 0 12px -4px rgba(0, 0, 0, .1); }
.page:nth-child(even) .pg { box-shadow: inset  6px 0 12px -4px rgba(0, 0, 0, .1); }

.pg h1, .pg h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 700;
  color: #7a5c0a;
  border-bottom: 1px solid #d4a843;
  padding-bottom: 6px;
  margin: 0 0 14px;
  line-height: 1.3;
}
.pg h3 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 700;
  color: #4a2e06;
  margin: 18px 0 10px;
}
.pg h4 {
  font-size: 13px;
  font-weight: 700;
  color: #5a3a0a;
  margin: 12px 0 8px;
}
.pg p {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(12px, 1.5vw, 14px);
  color: #1c1408;
  line-height: 1.75;
  margin-bottom: 11px;
}
.pg ul, .pg ol { padding-left: 20px; margin-bottom: 12px; }
.pg li {
  font-family: Georgia, serif;
  font-size: clamp(12px, 1.5vw, 13px);
  color: #1c1408;
  line-height: 1.65;
  margin-bottom: 4px;
}
.pg code {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #6b3a00;
  background: #e8dcc8;
  padding: 1px 4px;
  border-radius: 3px;
  word-break: break-all;
}
.pg pre {
  background: #e4d8c0;
  border: 1px solid #c8b080;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 13px;
  overflow-x: auto;
  max-width: 100%;
}
.pg pre code { background: none; padding: 0; font-size: 11px; color: #2e1200; }
.pg-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
}
.pg table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  font-size: 11px;
  font-family: system-ui, sans-serif;
}
.pg th {
  background: #e0d0b0;
  padding: 5px 7px;
  text-align: left;
  font-weight: 700;
  border-bottom: 1px solid #c4a870;
  color: #3a2006;
}
.pg td {
  padding: 4px 7px;
  border-bottom: 1px solid #ddd0b8;
  color: #1c1408;
  vertical-align: top;
}
.pg tr:nth-child(even) td { background: rgba(0, 0, 0, .025); }
.pg blockquote {
  border-left: 3px solid #d4a843;
  padding: 6px 12px;
  margin: 0 0 12px;
  color: #6a4a1a;
  font-style: italic;
  font-size: 12px;
  background: rgba(212, 168, 67, .07);
  border-radius: 0 4px 4px 0;
}
.pg a { color: #8b6914; word-break: break-word; }
.pg hr { border: none; border-top: 1px solid #c4a870; margin: 14px 0; }
.pg img { max-width: 100%; height: auto; }

/* ── Cover ── */
.page-cover, .page-back {
  background: linear-gradient(160deg, #1a0c00 0%, #2d1805 55%, #1a0c00 100%) !important;
}
.page-cover .pg, .page-back .pg {
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.cover-inner, .back-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px;
}
.cover-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #c4a843;
}
.cover-title {
  font-family: Georgia, serif;
  font-size: clamp(20px, 6vw, 34px);
  font-weight: 900;
  color: #f5c842;
  line-height: 1.15;
}
.cover-line {
  width: 48px;
  height: 2px;
  background: linear-gradient(90deg, #f5c842, #c4a843);
}
.cover-sub {
  font-size: 11px;
  color: #8b7040;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.back-title {
  font-family: Georgia, serif;
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 700;
  color: #f5c842;
}
.back-line { width: 36px; height: 1px; background: #c4a843; }
.back-link {
  font-size: 11px;
  color: #8b7040;
  text-decoration: none;
  border-bottom: 1px solid #6b5030;
  padding-bottom: 1px;
}
.back-link:hover { color: #c4a843; }

/* ── Controls ── */
.book-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  width: 100%;
  max-width: 960px;
  padding: 14px 4px 10px;
  gap: 10px;
}
.ctrl-btn {
  background: linear-gradient(135deg, var(--wwm-gold), var(--wwm-gold-deep));
  color: #071421;
  border: none;
  cursor: pointer;
  padding: 12px 18px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 800;
  transition: opacity .2s, transform .2s;
  min-height: 44px;
  flex: 0 1 auto;
}
.ctrl-btn:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.ctrl-btn:disabled { opacity: .35; cursor: default; transform: none; }
.pg-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  flex: 1 1 120px;
  min-width: 0;
}
.pg-numbers {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 600;
}
.pg-chapter {
  font-size: var(--fs-xs);
  color: var(--muted);
  max-width: min(300px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 8px;
}

/* ── TOC ── */
.toc-fab {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  z-index: 300;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wwm-gold), var(--wwm-gold-deep));
  border: none;
  cursor: pointer;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(246, 211, 101, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #071421;
  transition: transform .2s, box-shadow .2s;
}
.toc-fab:hover { transform: scale(1.06); }
.toc-panel {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  left: max(16px, env(safe-area-inset-left));
  z-index: 299;
  width: auto;
  max-width: 360px;
  margin-left: auto;
  max-height: min(60vh, 60dvh);
  background: var(--wwm-bg-card);
  border: 1px solid var(--wwm-border);
  border-radius: var(--r-lg);
  overflow-y: auto;
  box-shadow: var(--shadow-acc);
  opacity: 0;
  transform: translateY(12px) scale(.97);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.toc-panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.toc-panel h3 {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.toc-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 10px 8px;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  min-height: 44px;
  transition: background .15s;
  line-height: 1.35;
}
.toc-item:hover { background: var(--wwm-accent-dim); }

.hb-footer {
  text-align: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: var(--fs-xs);
}
.hb-footer a { color: var(--muted); text-decoration: none; }
.hb-footer a:hover { color: var(--wwm-gold); }

/* ── Mobile / tablet ── */
@media (max-width: 768px) {
  .hb-header {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "back lang"
      "title title";
  }
  .hb-back { grid-area: back; }
  .hb-title {
    grid-area: title;
    white-space: normal;
    line-height: 1.25;
    padding: 4px 0 2px;
  }
  .lang-toggle { grid-area: lang; justify-self: end; }
  .hb-back-short { display: none; }
  .book-scene { padding: 12px 8px 4px; }
  .book-controls {
    gap: 8px;
  }
  .ctrl-btn {
    flex: 1 1 calc(50% - 8px);
    padding: 12px 10px;
    justify-content: center;
    text-align: center;
  }
  .pg-indicator {
    order: -1;
    flex: 1 1 100%;
    width: 100%;
  }
  .pg-chapter { white-space: normal; max-width: 100%; }
}

@media (max-width: 480px) {
  .hb-back-long { display: none; }
  .hb-back-short { display: inline; }
  .cover-title { font-size: clamp(18px, 8vw, 28px); }
}

@media (min-width: 481px) {
  .hb-back-short { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
