/* Poppins wird lokal geladen (css/fonts.css, per <link> in index.html) –
   bewusst KEIN Google-Fonts-@import mehr (Datenschutz). */

/* ---------- Design‑Tokens ---------- */
:root {
  --primary: #137337;   /* dezentes Grün */
  --bg: rgba(255, 255, 255, 0.75);
  --card: #ffffff;
  --shadow: rgba(0, 0, 0, 0.08);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Background Image ---------- */
body {
  font-family: "Poppins", sans-serif;
  color: #1f2937;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../img/bk4.png") center/cover no-repeat;
  z-index: -3;
}

body::after {
  /* leichter Weiß‑Overlay für Lesbarkeit */
  content: "";
  position: fixed;
  inset: 0;
  backdrop-filter: blur(2px);
  background: rgba(255, 255, 255, 0.4);
  z-index: -2;
}

/* ---------- Reader Shell ---------- */
.reader {
  background: var(--bg);
  width: 100%;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  box-shadow: 0 12px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: saturate(180%) blur(8px);
  position: relative;
}

/* ---------- Topbar (Willkommen) ---------- */
.reader__topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #16803d 0%, var(--primary) 45%, #0e5a2b 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(17, 70, 40, 0.35);
  position: relative;
  z-index: 10;
}

.reader__logo {
  height: 40px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
}

.reader__titles {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  flex: 1 1 auto;
}

.reader__welcome {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader__sub {
  font-size: 0.8rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader__legal {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.reader__legal a {
  color: #fff;
  opacity: 0.9;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.reader__legal a:hover {
  opacity: 1;
  border-bottom-color: rgba(255, 255, 255, 0.8);
}

/* ---------- Schwebende Steuerung (Blättern, Zoom, Vollbild) ---------- */
.reader__controls {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 25;
  transition: opacity 0.3s ease;
}

.ctl {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #374151;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.08s;
}
.ctl svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.ctl:hover { background: rgba(19, 115, 55, 0.12); color: var(--primary); }
.ctl:active { transform: scale(0.9); }
.ctl:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Vollbild-Button hervorgehoben, Icon wechselt je nach Zustand */
.ctl--fs {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(19, 115, 55, 0.42);
}
.ctl--fs:hover { background: #0e5a2b; color: #fff; }
.ctl--fs .ctl__ic-close { display: none; }
.ctl--fs.is-active .ctl__ic-open { display: none; }
.ctl--fs.is-active .ctl__ic-close { display: block; }

/* ---------- Viewer ---------- */
.reader__viewer {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 0.5rem;
  min-height: 0; /* erlaubt dem Flexkind, in der Höhe zu schrumpfen */
  /* dezenter "Spotlight" hinter dem Buch für mehr Tiefe/Wow */
  background:
    radial-gradient(ellipse 62% 78% at 50% 46%,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(255, 255, 255, 0.18) 45%,
      rgba(255, 255, 255, 0) 72%),
    radial-gradient(ellipse 120% 120% at 50% 50%,
      rgba(0, 0, 0, 0) 60%,
      rgba(17, 70, 40, 0.10) 100%); /* sanfte Vignette in dezentem Grün */
}

/* Ensure flipbook fills the container */
#flipbook {
  width: 100%;
  height: 100%;
}

/* responsive */
@media (max-width: 640px) {
  .reader { border-radius: 0; }
  .reader__topbar { gap: 10px; padding: 8px 12px; }
  .reader__logo { height: 32px; }
  .reader__welcome { font-size: 0.98rem; white-space: normal; }
  .reader__sub { display: none; }
  .reader__legal { font-size: 0.72rem; gap: 10px; }
  .reader__viewer { padding: 0.25rem; }
  .reader__controls { bottom: 12px; gap: 3px; padding: 6px 8px; }
  .ctl { width: 38px; height: 38px; }
  .ctl svg { width: 20px; height: 20px; }
}

/* ---------- DearFlip Toolbar komplett verstecken ---------- */
.df-ui,
.dflip-ui,
.df-ui-btn,
.dflip-toolbar,
.df-toolbar,
.dflip-controls,
.df-controls,
.dflip-container .controls,
#flipbook .df-ui,
#flipbook .dflip-ui,
#flipbook .dflip-toolbar {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Flipbook Container anpassen */
.dflip-container,
.df-container {
  height: 100% !important;
}

.dflip-stage,
.df-stage {
  height: 100% !important;
  top: 0 !important;
}

/* Improve flipbook focus */
#flipbook:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Mobile improvements */
@media (max-width: 768px) {
  .reader__welcome {
    font-size: 1.02rem;
  }
}

/* PDF Schutz */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Verhindere Bild-Speichern */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* Print Styles - Leere Seite beim Drucken */
@media print {
  body * {
    display: none !important;
  }
  
  body:after {
    content: "Drucken ist nicht erlaubt.";
    display: block !important;
    font-size: 24px;
    text-align: center;
    margin-top: 50%;
  }
}

/* Verstecke Canvas Context Menu */
canvas {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ==========================================================================
   Login-Overlay  (öffentliche Seite; PDF liegt hinter Basic Auth)
   ========================================================================== */

/* Sichtbarkeit: solange gesperrt, nur das Login zeigen; nach Erfolg den Reader. */
body.locked .reader { display: none; }
body.unlocked .login { display: none; }
body.unlocked .reader { animation: reader-in 0.6s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes reader-in {
  from { opacity: 0; transform: scale(0.995); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  body.unlocked .reader { animation: none; }
}

.login {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login__card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 32px 32px;
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  animation: login-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login__logo {
  width: 120px;
  height: auto;
  margin-bottom: 4px;
}

.login__title {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.4px;
}

.login__subtitle {
  margin-top: -8px;
  font-size: 0.9rem;
  color: #6b7280;
}

.login__field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  text-align: left;
}

.login__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
}

.login__input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: #1f2937;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(19, 115, 55, 0.15);
}

.login__btn {
  width: 100%;
  padding: 13px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.2s, transform 0.05s;
}

.login__btn:hover { filter: brightness(1.08); }
.login__btn:active { transform: translateY(1px); }
.login__btn:disabled { opacity: 0.65; cursor: progress; }

.login__error {
  min-height: 1.2em;
  font-size: 0.85rem;
  font-weight: 500;
  color: #b91c1c;
}

.login__progress {
  width: 100%;
  margin-top: 2px;
}

.login__track {
  position: relative;
  height: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
}

.login__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.login__bar.indeterminate {
  width: 40%;
  animation: login-slide 1.1s infinite ease-in-out;
}

.login__pct {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: #6b7280;
}

/* Fehlerhafte Eingabe: kurzes Wackeln */
.login__card.shake { animation: login-shake 0.4s; }

@keyframes login-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@keyframes login-slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .login__card,
  .login__card.shake,
  .login__bar.indeterminate { animation: none; }
}

/* Login-Fußzeile mit Rechtslinks (öffentlich erreichbar – Pflicht fürs Impressum) */
.login__legal {
  margin-top: 4px;
  font-size: 0.78rem;
  color: #6b7280;
}
.login__legal a {
  color: #6b7280;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.login__legal a:hover {
  color: var(--primary);
  border-bottom-color: currentColor;
}

/* ==========================================================================
   Rechtsseiten (Impressum / Datenschutz)
   ========================================================================== */
body.legal {
  display: block;
  align-items: initial;
  justify-content: initial;
  padding: 40px 20px;
  overflow-y: auto;
}

.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px clamp(20px, 5vw, 48px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14);
  color: #1f2937;
  line-height: 1.6;
}

.legal-page h1 {
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}
.legal-page h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #111827;
  margin: 28px 0 8px;
}
.legal-page p { margin: 8px 0; }
.legal-page ul { margin: 8px 0 8px 22px; }
.legal-page li { margin: 4px 0; }
.legal-page a { color: var(--primary); }
.legal-page address {
  font-style: normal;
  margin: 8px 0;
}
.legal-page .legal-meta {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #6b7280;
}
.legal-page .legal-back {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--primary);
  text-decoration: none;
}
.legal-page .legal-back:hover { text-decoration: underline; }
.legal-page hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 28px 0;
}