/**
 * Palimpalem Responsive CSS
 *
 * Ersetzt HTML Framesets durch moderne Flexbox-Layouts.
 * Mobile-First mit Hamburger-Menü für Bildschirme < 1024px.
 * Tablets bekommen den gleichen Zoom-Modus wie Mobile.
 *
 * Created: 2026-02-24
 *
 * Layout-Klassen:
 * - .pp-layout-left        → Menü links (modelo1)
 * - .pp-layout-right       → Menü rechts (modelo2)
 * - .pp-layout-top         → Menü oben (modelo3)
 * - .pp-layout-bottom      → Menü unten (modelo4)
 * - .pp-layout-header-left → Header + Menü links (modelo5)
 * - .pp-layout-header-right→ Header + Menü rechts (modelo6)
 * - .pp-layout-none        → Kein Menü (modelo17)
 */

/* ============================================================================
   CSS RESET & BASE
   ============================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: Arial, sans-serif;
  line-height: 1.5;
  color: #464646;
  background: #ffffff;
}
/* ============================================================================
   HEADER (modelo5/6)
   ============================================================================ */

.pp-header {
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
}

/* ============================================================================
   WRAPPER (Hauptcontainer)
   ============================================================================ */

.pp-wrapper {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

/* Menü-Buttons bei top/bottom zentrieren (menubg-Tabelle shrink-to-fit + auto margins) */
.pp-layout-top .pp-menu .menubg,
.pp-layout-bottom .pp-menu .menubg {
  width: fit-content;
  margin: 0 auto;
}

.pp-below-header {
  min-height: auto;
  flex: 1;
}

/* ============================================================================
   MENÜ
   ============================================================================ */

.pp-menu {
  flex-shrink: 0;
  overflow-y: auto;
}

/* Menü-Styles aus menue.html werden dynamisch eingefügt */
/* Hier nur strukturelle Anpassungen */

.pp-menu table {
  width: 100%;
}

/* Links im Menü - target="pbodyfr" entfernt, normale Navigation */
/* Vertikale Menüs: block (untereinander) */
.pp-layout-left .pp-menu a,
.pp-layout-right .pp-menu a,
.pp-layout-header-left .pp-menu a,
.pp-layout-header-right .pp-menu a {
  display: block;
}
/* Horizontale Menüs (modelo3/4): display aus menue.html beibehalten (inline-block) */

/* ============================================================================
   CONTENT
   ============================================================================ */

.pp-content {
  flex: 1;
  overflow: auto;
  padding: 0;
  padding-left: 50px;
  padding-right: 50px;
  min-height: 100vh;
}

/* Anpassung für Header-Layouts */
.pp-below-header .pp-content {
  min-height: auto;
}

/* Wenn kein Menü (modelo17) */
.pp-full-width {
  width: 100%;
}

/* ============================================================================
   MOBILE HEADER (nur Mobile)
   ============================================================================ */

.pp-mobile-header {
  display: none; /* Nur auf Mobile sichtbar */
}

/* ============================================================================
   HAMBURGER BUTTON (SVG-basiert)
   ============================================================================ */

.pp-hamburger {
  display: none;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  /* Styles kommen hauptsächlich inline aus PHP */
}

.pp-hamburger:hover {
  opacity: 0.8;
}

.pp-hamburger:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.pp-hamburger svg {
  display: block;
}

/* ============================================================================
   OVERLAY (nur Mobile)
   ============================================================================ */

.pp-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pp-overlay.visible {
  display: block;
  opacity: 1;
}

/* ============================================================================
   MOBILE + TABLET STYLES (< 1024px)
   ============================================================================ */

@media (max-width: 1023px) {
  /* Mobile Header Bar - zeigt Hamburger + Seitentitel */
  body:not(.pp-layout-none) .pp-mobile-header {
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    z-index: 1001;
    padding: 0 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  /* Hamburger im Mobile Header anzeigen */
  .pp-mobile-header .pp-hamburger {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 12px;
    flex-shrink: 0;
    /* Größe und Styles kommen inline aus PHP */
  }

  /* Hamburger rechts für layout-right */
  .pp-mobile-header .pp-hamburger.pp-hamburger-right {
    order: 2;
    margin-right: 0;
    margin-left: 12px;
  }

  .pp-mobile-title {
    flex: 1;
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    /* Links neben dem Hamburger */
  }

  /* ===== CONTENT ZOOM-MODUS ===== */
  /* Content behält Original-Layout und wird nur skaliert */
  /* Das Desktop-Layout bleibt erhalten, wird aber verkleinert */

  html,
  body {
    overflow-x: hidden !important;
  }

  .pp-content {
    /* Keine Breiten-Begrenzung - Original-Layout bleibt erhalten */
    transform-origin: top left;
    /* Skalierung wird per JavaScript gesetzt basierend auf Content-Breite */
    /* Responsive Padding: 20% des Desktop-Wertes auf Mobile/Tablet */
    padding-left: 10px;
    padding-right: 10px;
  }

  /* ===== FORMULARE IM ZOOM-MODUS ===== */
  /* Formulare behalten Original-Layout, nur font-size für iOS */
  .pp-content form input,
  .pp-content form textarea,
  .pp-content form select {
    font-size: 16px !important; /* Verhindert Auto-Zoom auf iOS */
  }

  /* Gästebuch behält im Zoom-Modus sein Original-Layout */

  /* Wrapper wird vertikal (inkl. header-left/right Override) */
  .pp-wrapper,
  .pp-layout-header-left .pp-wrapper,
  .pp-layout-header-right .pp-wrapper {
    flex-direction: column;
  }

  /* Menü wird Overlay von links (unter Mobile Header) */
  .pp-menu {
    position: fixed;
    top: 50px; /* Unter dem Mobile Header */
    left: -280px;
    width: 280px;
    max-width: 85vw;
    height: calc(
      100dvh - 50px
    ); /* dvh = dynamic viewport, berücksichtigt iOS Safari Adressleiste */
    z-index: 1000;
    overflow-y: auto;
    transition: left 0.3s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  }

  /* Menü von rechts für layout-right und header-right */
  .pp-layout-right .pp-menu,
  .pp-layout-header-right .pp-menu {
    left: auto;
    right: -280px;
    transition: right 0.3s ease;
  }

  /* Menü offen */
  .pp-menu.open {
    left: 0;
  }

  .pp-layout-right .pp-menu.open,
  .pp-layout-header-right .pp-menu.open {
    left: auto;
    right: 0;
  }

  /* Marco-Bilder im Menü ausblenden (foto1/foto2/foto3 = Rahmen-Deko) */
  .pp-menu .foto1,
  .pp-menu .foto2,
  .pp-menu .foto3 {
    display: none !important;
  }

  /* menubg (Menü-Container) soll volle Breite nutzen */
  .pp-menu .menubg {
    width: 100% !important;
  }

  /* Menü-Tabellen einspaltig: Alle Zellen untereinander */
  .pp-menu table,
  .pp-menu tbody,
  .pp-menu tr,
  .pp-menu td {
    display: block !important;
    width: 100% !important;
  }

  /* Menü-Links für Touch optimieren — einspaltig, volle Breite */
  .pp-menu a {
    min-height: 48px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 4px 16px;
    font-size: 15px;
    width: 100% !important;
    box-sizing: border-box;
    float: none !important;
  }

  /* Content: Zoom-Modus - Breite wird per JavaScript gesetzt */
  .pp-content {
    /* width wird per JS gesetzt für Zoom */
    padding-top: 0; /* Mobile Header ist sticky, schiebt Content automatisch */
    min-height: auto;
  }

  /* Kein extra Padding bei layout-none */
  .pp-layout-none .pp-content {
    padding-top: 0;
  }

  /* ===== MODELO17 (layout-none): Selbst-designte Seiten ===== */
  /* Diese Seiten haben feste Desktop-Breiten (z.B. 1489px Tabellen).
       Browser skaliert automatisch via viewport width=1500 (page-renderer.php).
       Hier nur minimale Anpassungen für korrekte Darstellung. */
  .pp-layout-none .pp-content {
    padding: 0 !important;
  }

  /* Tabellen/Bilder: Original-Größen behalten */
  .pp-layout-none .pp-content table,
  .pp-layout-none .pp-content img {
    max-width: none !important;
  }

  /* Header-Layouts auf Mobile: Desktop-Header verstecken */
  .pp-layout-header-left .pp-header,
  .pp-layout-header-right .pp-header {
    display: none;
  }

  /* Header-Layouts: Content auch unter Mobile Header */
  .pp-layout-header-left .pp-content,
  .pp-layout-header-right .pp-content {
    padding-top: 0; /* Mobile Header ist sticky */
  }

  /* Menü oben/unten: Auch als Slide-In behandeln */
  .pp-layout-top .pp-menu,
  .pp-layout-bottom .pp-menu {
    width: 280px;
    height: calc(100dvh - 50px);
    top: 50px;
    left: -280px;
    right: auto;
  }

  .pp-layout-top .pp-menu.open,
  .pp-layout-bottom .pp-menu.open {
    left: 0;
  }
}

/* ============================================================================
   DESKTOP STYLES (>= 1024px)
   ============================================================================ */

@media (min-width: 1024px) {
  /* Mobile Header komplett verstecken */
  .pp-mobile-header {
    display: none !important;
  }

  /* Hamburger verstecken */
  .pp-hamburger {
    display: none !important;
  }

  /* Overlay verstecken */
  .pp-overlay {
    display: none !important;
  }

  /* Layout links/rechts: Horizontal */
  .pp-layout-left .pp-wrapper,
  .pp-layout-right .pp-wrapper {
    flex-direction: row;
  }

  /* Layout oben/unten: Vertikal */
  .pp-layout-top .pp-wrapper,
  .pp-layout-bottom .pp-wrapper {
    flex-direction: column;
  }

  /* Menü oben/unten: volle Breite */
  .pp-layout-top .pp-menu,
  .pp-layout-bottom .pp-menu {
    width: 100% !important;
    align-self: stretch;
    max-height: none;
    overflow: visible;
    position: static;
    /* Höhe wird per JS korrigiert (fixMenuHeight) — Flex-Column + floated
           Links in Tabellen = Browser berechnet die Höhe falsch */
  }

  /* Header-Layouts: Horizontal unter Header */
  .pp-layout-header-left .pp-wrapper,
  .pp-layout-header-right .pp-wrapper {
    flex-direction: row;
  }

  /* Menü: volle Höhe + innerer Sticky-Content */
  .pp-menu {
    align-self: stretch;
    flex-shrink: 0;
    overflow: visible;
  }

  .pp-menu-inner {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
  }

  /* Content füllt Rest */
  .pp-content {
    flex: 1;
    padding-top: 0;
  }

  /* Bei Header-Layouts: Header bleibt oben, nur Wrapper scrollt */
  html:has(.pp-layout-header-left),
  html:has(.pp-layout-header-right) {
    overflow: hidden !important;
    height: 100vh;
    margin: 0;
  }

  .pp-layout-header-left,
  .pp-layout-header-right {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden !important;
    margin: 0;
  }

  .pp-layout-header-left .pp-wrapper,
  .pp-layout-header-right .pp-wrapper {
    flex: 1;
    min-height: auto;
    overflow-y: auto;
  }

  /* Menü darf nicht größer als Wrapper sein (sonst doppelter Scrollbar) */
  .pp-layout-header-left .pp-menu,
  .pp-layout-header-right .pp-menu {
    max-height: 100%;
  }

  .pp-layout-header-left .pp-content,
  .pp-layout-header-right .pp-content {
    min-height: auto;
  }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Fokus-Styles nur für Tastatur-Navigation (nicht bei Mausklick) */
.pp-menu a:focus {
  outline: none;
}
.pp-menu a:focus-visible {
  outline: 2px solid #ff3366;
  outline-offset: -2px;
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  .pp-hamburger span,
  .pp-menu,
  .pp-overlay {
    transition: none;
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .pp-hamburger,
  .pp-overlay {
    display: none !important;
  }

  .pp-header {
    position: static;
  }

  .pp-menu {
    position: static;
    width: auto;
    max-width: none;
    page-break-after: always;
  }

  .pp-content {
    padding-top: 0;
  }
}
