/* ============================================
   STEFAN ZWEIG - LAYOUT SYSTEM
   Einfache Lösung basierend auf Master-Template
   ============================================ */

/* ===== 0. BOX-SIZING RESET ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ===== 1. CSS VARIABLES - DESIGN SYSTEM ===== */
:root {
  /* Layout-Dimensionen */
  --layout-margin: 60px;
  --layout-sidebar-width: 200px;
  --layout-content-width: 1200px;
  
  /* Ad-Dimensionen */
  --ad-height: 400px;
  --ad-width: 200px;
  
  /* Spacing */
  --ad-sticky-top: 20px;
  --layout-gap: 1.5rem;
  
  /* Colors */
  --ad-border-color: #ccc;
  --ad-bg-color: #f5f5f5;
  --ad-left-color: #ff6b00;
  --ad-right-color: #f472b6;
}

/* ===== 2. WERBEFLÄCHEN - STICKY POSITIONING ===== */
/* Einfache Lösung wie im Master-Template */
.ad-left,
.ad-right {
  position: sticky;
  top: var(--ad-sticky-top);
  height: fit-content;
  z-index: 10;
}

/* Mobile: Werbeflächen verstecken */
@media (max-width: 1023px) {
  .ad-left,
  .ad-right {
    display: none !important;
  }
}

/* ===== 3. AD-SLOT STYLING ===== */
.ad-slot {
  width: var(--ad-width);
  height: var(--ad-height);
  min-width: var(--ad-width);
  max-width: var(--ad-width);
  border: 1px solid var(--ad-border-color);
  background: var(--ad-bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
}

/* Linke Werbung - Orange */
.ad-left {
  background: rgba(255, 107, 0, 0.15);
  padding: 0.5rem 0;
}

.ad-left .ad-slot {
  background: var(--ad-left-color) !important;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.875rem;
  border: 3px solid #ff4500 !important;
  box-shadow: 0 4px 12px rgba(255, 107, 0, 0.4) !important;
  border-radius: 4px;
}

/* Rechte Werbung - Pink */
.ad-right .ad-slot {
  background: var(--ad-right-color) !important;
  color: #111827 !important;
  font-weight: 600;
  font-size: 0.875rem;
  border: 2px solid #f472b6 !important;
  box-shadow: 0 4px 12px rgba(244, 114, 182, 0.3) !important;
  border-radius: 4px;
}

/* Ad-Slot Text Styling */
.ad-slot > div {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: #111827;
}

/* ===== 4. VIEWPORT & OVERFLOW ===== */
/* Globale CSS-Einstellungen für stefanzweig.de */
html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  position: relative;
}

/* Verhindert horizontales Scrollen - nur für Block-Elemente */
div, section, article, aside, header, footer, nav, main {
  max-width: 100%;
  box-sizing: border-box;
}

/* Grid-Container Responsive Fix */
.grid {
  max-width: 100vw;
  width: 100%;
  box-sizing: border-box;
}

/* Responsive Grid-Layout für Desktop */
@media (min-width: 1024px) {
  .grid.grid-cols-\\[60px_200px_1200px_200px_60px\\] {
    max-width: min(1720px, 100vw);
    width: 100%;
    box-sizing: border-box;
  }
}

/* Desktop: Page Layout aktivieren */
@media (min-width: 1024px) {
  .page-layout.hidden.lg\:flex {
    display: flex !important;
  }
  
  .page-layout .ad-left,
  .page-layout .ad-right {
    display: block !important;
    visibility: visible !important;
  }
}

/* Mobile: Grid auf eine Spalte reduzieren */
@media (max-width: 1023px) {
  .grid {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }
  
  /* Page Layout auf Mobile: Nur Content, keine Werbeflächen */
  .page-layout {
    flex-direction: column !important;
    gap: 0 !important;
    padding: 0 !important;
  }
  
  .page-layout .ad-left,
  .page-layout .ad-right {
    display: none !important;
  }
  
  .page-layout .main-content {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* Container für zentrierte, monitorangepasste Darstellung */
.container,
#wrapper,
main {
  width: 100%;
  max-width: 1200px; /* oder 970px, je nach Layout */
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

/* Page Layout mit Flexbox - Hauptstruktur */
/* WICHTIG: Nur auf Desktop aktivieren, nicht auf Mobile */
@media (min-width: 1024px) {
  .page-layout {
    display: flex !important;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    max-width: min(1720px, 100vw); /* Responsive: max 1720px oder Viewport-Breite */
    margin: 0 auto;
    padding: 0;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    min-height: 100vh;
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Überschreibe Tailwind hidden lg:flex - KRITISCH für Desktop-Sichtbarkeit */
  .page-layout.hidden,
  .page-layout.hidden.lg\:flex,
  div.page-layout.hidden,
  div.page-layout.hidden.lg\:flex {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    position: relative !important;
  }
}

/* Mobile: Page Layout komplett verstecken */
@media (max-width: 1023px) {
  .page-layout {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }
}

/* Main Content - Flexible Breite in der Mitte */
.page-layout .main-content {
  flex: 1 1 1200px;
  min-width: 0; /* Wichtig für Flexbox */
  max-width: 1200px;
  box-sizing: border-box;
}

/* Werbeflächen im Page Layout */
.page-layout .ad-left,
.page-layout .ad-right {
  flex: 0 0 200px !important; /* Feste Breite für Werbeflächen */
  min-width: 200px;
  max-width: 200px;
  width: 200px;
  position: sticky !important;
  top: var(--ad-sticky-top);
  height: fit-content;
  align-self: flex-start;
  box-sizing: border-box;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Main Wrapper mit Flexbox-Layout */
.main-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* Anpassung für Werbeflächen im main-wrapper */
.main-wrapper .ad-left,
.main-wrapper .ad-right {
  flex: 0 0 200px; /* Feste Breite für Werbeflächen */
  position: sticky;
  top: var(--ad-sticky-top);
  height: fit-content;
  align-self: flex-start;
}

.main-wrapper .content {
  flex: 1 1 auto; /* Flexible Breite für Content */
  min-width: 0; /* Wichtig für Flexbox */
}

/* ===== 5. RESPONSIVE MEDIA ===== */
img,
video {
  max-width: 100%;
  height: auto;
}

/* ===== 6. FONT RENDERING ===== */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
