/* ============================================================
   MaHe ODF Embedder v2 – Stylesheet
   Nativer PDF.js Canvas-Renderer, Zeitungs-Blättereffekt
   ============================================================ */

:root {
  --odf-accent:      #c0392b;
  --odf-accent-d:    #96281b;
  --odf-bg:          #f0ece3;
  --odf-paper:       #fdfaf5;
  --odf-border:      #d5c9b5;
  --odf-text:        #2c2416;
  --odf-muted:       #7a6e60;
  --odf-toolbar-bg:  #ede9df;
  --odf-header-bg:   #231c10;
  --odf-radius:      5px;
  --odf-shadow:      0 2px 8px rgba(30,20,5,.15), 0 8px 30px rgba(30,20,5,.07);
}

/* ── Wrapper ─────────────────────────────────────────────── */
.mahe-odf-wrapper {
  position: relative;
  background: var(--odf-bg);
  border: 1px solid var(--odf-border);
  border-radius: var(--odf-radius);
  overflow: hidden;
  margin: 1.5em 0 2em;
  box-shadow: var(--odf-shadow);
  font-family: Georgia, 'Times New Roman', serif;
}

/* ── Header (optional – nur wenn title gesetzt) ──────────── */
.mahe-odf-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--odf-header-bg);
  border-bottom: 2px solid var(--odf-accent);
}

.mahe-odf-icon {
  flex-shrink: 0;
  line-height: 0;
}

.mahe-odf-icon svg {
  width: 22px;
  height: 27px;
}

.mahe-odf-title {
  margin: 0;
  padding: 0;
  font-size: .88rem;
  font-weight: 700;
  font-style: italic;
  color: #f2eddf;
  letter-spacing: .02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Toolbar – alles auf EINER Zeile ─────────────────────── */
.mahe-odf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 8px;
  height: 38px;          /* kompakt */
  background: var(--odf-toolbar-bg);
  border-bottom: 1px solid var(--odf-border);
  flex-wrap: nowrap;     /* NIEMALS umbrechen */
  overflow: hidden;
}

.mahe-odf-nav,
.mahe-odf-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.mahe-odf-pageinfo {
  font-size: .72rem;
  color: var(--odf-muted);
  min-width: 80px;
  text-align: center;
  font-family: Georgia, serif;
  white-space: nowrap;
}

.mahe-zoom-label {
  font-size: .7rem;
  color: var(--odf-muted);
  min-width: 30px;
  text-align: center;
  font-family: Georgia, serif;
}

/* ── Buttons – kleiner ───────────────────────────────────── */
.mahe-odf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--odf-border);
  border-radius: 3px;
  background: var(--odf-paper);
  color: var(--odf-text);
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, border-color .2s, color .2s, transform .1s;
  flex-shrink: 0;
}

.mahe-odf-btn svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.mahe-odf-btn:hover {
  background: var(--odf-accent);
  border-color: var(--odf-accent-d);
  color: #fff;
  transform: translateY(-1px);
}

.mahe-odf-btn:active  { transform: none; }
.mahe-odf-btn:disabled,
.mahe-odf-btn[disabled] {
  opacity: .32;
  cursor: default;
  pointer-events: none;
}

/* ── Viewport ────────────────────────────────────────────── */
.mahe-odf-viewport {
  position: relative;
  overflow: hidden;
  background: #dedad2;
  /* Subtle grain texture */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

/* ── Canvas-Container ────────────────────────────────────── */
.mahe-canvas-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--odf-border) transparent;
}

.mahe-canvas-wrap::-webkit-scrollbar       { width: 6px; }
.mahe-canvas-wrap::-webkit-scrollbar-track { background: transparent; }
.mahe-canvas-wrap::-webkit-scrollbar-thumb { background: var(--odf-border); border-radius: 3px; }

/* ── PDF Canvas ──────────────────────────────────────────── */
.mahe-pdf-canvas {
  display: block;
  width: 100%;
  height: auto !important;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.25),
    0 1px 4px rgba(0,0,0,0.15);
  background: #fff;
  opacity: 0;
  transition: opacity .32s ease;
  transform-origin: center top;
  border: 1px solid rgba(180,160,130,.4);
}

.mahe-pdf-canvas.mahe-page-visible {
  opacity: 1;
}

/* ── Blätter-Animationen ─────────────────────────────────── */

/* Neue Seite von rechts einschwingen */
@keyframes slideInRight {
  from { transform: translateX(60px) rotateY(-8deg); opacity: 0; }
  to   { transform: translateX(0)    rotateY(0deg);  opacity: 1; }
}

/* Neue Seite von links einschwingen */
@keyframes slideInLeft {
  from { transform: translateX(-60px) rotateY(8deg); opacity: 0; }
  to   { transform: translateX(0)     rotateY(0deg); opacity: 1; }
}

/* Alte Seite nach links verschwinden */
@keyframes slideOutLeft {
  from { transform: translateX(0)     rotateY(0deg);  opacity: 1; }
  to   { transform: translateX(-80px) rotateY(12deg); opacity: 0; }
}

/* Alte Seite nach rechts verschwinden */
@keyframes slideOutRight {
  from { transform: translateX(0)    rotateY(0deg);   opacity: 1; }
  to   { transform: translateX(80px) rotateY(-12deg); opacity: 0; }
}

.mahe-pdf-canvas.mahe-page-enter-right { animation: slideInRight .38s cubic-bezier(.25,.46,.45,.94) forwards; }
.mahe-pdf-canvas.mahe-page-enter-left  { animation: slideInLeft  .38s cubic-bezier(.25,.46,.45,.94) forwards; }
.mahe-pdf-canvas.mahe-page-exit-right  { animation: slideOutRight .32s ease forwards; position: absolute; }
.mahe-pdf-canvas.mahe-page-exit-left   { animation: slideOutLeft  .32s ease forwards; position: absolute; }

/* ── Flip-Overlay (Klickzonen + visueller Hinweis) ───────── */
.mahe-flip-l,
.mahe-flip-r {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 52px;
  z-index: 5;
  cursor: pointer;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none; /* JS regelt click via .mahe-flip-l/.mahe-flip-r */
}

.mahe-flip-l { left: 0;  background: linear-gradient(to right, rgba(192,57,43,.18), transparent); }
.mahe-flip-r { right: 0; background: linear-gradient(to left,  rgba(192,57,43,.18), transparent); }

.mahe-odf-viewport:hover .mahe-flip-l,
.mahe-odf-viewport:hover .mahe-flip-r { opacity: 1; pointer-events: auto; }

@keyframes flipPulse {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}
.mahe-flip-l.mahe-flip-active,
.mahe-flip-r.mahe-flip-active { animation: flipPulse .42s ease; }

/* ── iFrame (ODF-Fallback) ───────────────────────────────── */
.mahe-odf-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--odf-paper);
  z-index: 1;
}

/* ── Ladeindikator ───────────────────────────────────────── */
.mahe-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--odf-bg);
  z-index: 10;
  gap: 14px;
  color: var(--odf-muted);
  font-size: .84rem;
  font-style: italic;
  transition: opacity .4s ease;
}

.mahe-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--odf-border);
  border-top-color: var(--odf-accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Fehlerbox ───────────────────────────────────────────── */
.mahe-error-box {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--odf-bg);
  color: var(--odf-muted);
  font-style: italic;
  z-index: 11;
  text-align: center;
  padding: 24px;
}

.mahe-err-link {
  color: var(--odf-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--odf-accent);
}
.mahe-err-link:hover { color: var(--odf-accent-d); }

/* Shortcode-Fehler */
.mahe-odf-error {
  color: var(--odf-accent);
  font-size: .84rem;
  padding: 8px 14px;
  background: #fdf2f2;
  border-left: 3px solid var(--odf-accent);
  margin: 1em 0;
}

/* ── Footer ──────────────────────────────────────────────── */
.mahe-odf-footer {
  display: flex;
  justify-content: center;
  padding: 4px 10px;
  background: var(--odf-toolbar-bg);
  border-top: 1px solid var(--odf-border);
}

.mahe-odf-copy {
  font-size: .62rem;
  color: #b0a898;
  font-family: Georgia, serif;
  font-style: italic;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mahe-odf-copy a {
  color: #b0a898;
  text-decoration: none;
}
.mahe-odf-copy a:hover { color: var(--odf-accent); }

/* ── Vollbild ────────────────────────────────────────────── */
.mahe-odf-wrapper.mahe-fullscreen-mode {
  position: fixed;
  inset: 0;
  z-index: 99999;
  margin: 0;
  border-radius: 0;
  border: none;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .mahe-odf-btn {
    width: 32px;
    height: 32px;
  }

  .mahe-odf-btn svg {
    width: 15px;
    height: 15px;
  }

  .mahe-flip-l,
  .mahe-flip-r {
    opacity: .5;
    pointer-events: auto;
  }

  .mahe-odf-pageinfo {
    font-size: .68rem;
    min-width: 70px;
  }
}

@media (max-width: 360px) {
  .mahe-zoom-label { display: none; }
}
