/* === GLOBALE RESETS UND TYPOGRAPHIE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === CSS-VARIABLEN – JAVASCRIPT-BLAU === */
:root {
  --primary: #3498db;       /* JavaScript-Blau */
  --primary-light: #2980b9; /* Dunkleres Blau für Hover */
  --primary-bg: #f8fafc;    /* Helles Grau-Blau */
  --text: #2c3e50;          /* Dunkler Text */
  --text-secondary: #7f8c8d;
  --success: #27ae60;
  --border-light: #eaeff5;
  --shadow: rgba(52, 152, 219, 0.15);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  line-height: 1.8;
  color: var(--text);
  background-color: var(--primary-bg);
  padding: 20px;
}

/* === KAPITEL-CONTAINER === */
.main-content {
  max-width: 900px;
  margin: 0 auto;
}

/* === ÜBERSCHRIFTEN === */
.main-content h1 {
  font-size: 2.6rem;
  margin-bottom: 28px;
  color: var(--text);
  padding-bottom: 14px;
  border-bottom: 3px solid var(--primary);
  font-weight: 800;
}

.main-content h2 {
  font-size: 1.8rem;
  margin: 32px 0 20px;
  color: var(--primary);
  font-weight: 700;
}

.main-content h3 {
  font-size: 1.4rem;
  margin: 24px 0 16px;
  color: var(--primary-light);
  font-weight: 600;
}

/* === ABSÄTZE UND LISTS === */
.main-content p,
.main-content ul,
.main-content ol {
  margin-bottom: 18px;
  font-size: 1.05rem;
}

.main-content ul,
.main-content ol {
  padding-left: 28px; /* ← WICHTIG: nicht 0 oder zu wenig! */
}

/* === ABSCHNITT ALS 'KARTE' === */
.main-content > section {
  background: linear-gradient(to bottom, #ffffff, #fafcff);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 40px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  border: 1px solid var(--border-light);
  transition: all 0.3s ease;
}

.main-content > section:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px var(--shadow);
}

/* === CODE & PRE === */
pre {
  background-color: #f8f9fa;
  border-left: 4px solid var(--primary);
  padding: 18px;
  margin: 24px 0;
  overflow-x: auto;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.95rem;
  border-radius: 0 8px 8px 0;
}

code {
  font-family: Consolas, Monaco, monospace;
  background-color: #f1f8ff;
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--primary);
  font-size: 0.95em;
}

.js-code {
  color: var(--text);
  background: none;
  padding: 0;
}

/* === AUSGABE-BEREICH === */
.ausgabe-bereich {
  margin-top: 18px;
  padding: 18px;
  background-color: #f8f9fa;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  min-height: 2.5rem;
}

/* === WARNUNGEN & HINWEISE === */
.warnung {
  background-color: #fff8e1;
  color: #5d4037;
  padding: 18px;
  border-left: 4px solid #ffc107;
  margin: 24px 0;
  border-radius: 0 8px 8px 0;
}

.regel {
  background-color: #e8f4fc;
  border-left: 4px solid var(--primary);
  padding: 18px;
  margin: 24px 0;
  border-radius: 0 8px 8px 0;
}

/* === BUTTONS === */
button {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.05rem;
  margin: 10px 10px 18px 0;
  transition: all 0.25s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  font-weight: 600;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
  background-color: var(--primary-light);
}

/* === HEADER & NAVIGATION === */
.header {
  background: linear-gradient(135deg, #2c3e50, #1a2530);
  color: white;
  padding: 1rem 0;
  margin-bottom: 24px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  position: sticky;
  top: 0;
  z-index: 1000;
  overflow: visible !important;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  min-height: 80px;
  padding: 1rem 24px;
  gap: 24px;
  position: relative;
}

/* Logo ganz links */
.header-container > .logo {
  order: 1;
  flex-shrink: 0;
  margin-right: auto;
}

/* Navigation in der Mitte mit max Platz */
.header-container > .nav-wrapper {
  order: 2;
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 800px;
}

/* Mobile Menu Toggle - Standardmäßig versteckt */
.mobile-menu-toggle {
  display: none;
}

.header-container > .mobile-menu-toggle {
  order: 3;
  margin-left: 16px;
  flex-shrink: 0;
}

/* PLU Nav nach dem Mobile Toggle */
.header-container > .plu-nav {
  order: 4;
  flex-shrink: 0;
}

/* Dark Mode ganz rechts */
.header-container > #dark-mode-toggle {
  order: 5;
  margin-left: 12px;
  flex-shrink: 0;
}

#dark-mode-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

#dark-mode-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.logo img {
  height: 40px;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* PLU Navigation & Support Button */
.plu-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.plu-link {
  color: #F7DF1E;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.plu-link:hover {
  background-color: rgba(247, 223, 30, 0.15);
  color: #F9E79F;
}

.support-btn {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.support-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(231, 76, 60, 0.4);
  filter: brightness(1.1);
}

@media (max-width: 900px) {
  .plu-nav {
    gap: 8px;
  }
  .plu-link {
    font-size: 0.75rem;
    padding: 4px 8px;
  }
  .support-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
}

@media (max-width: 768px) {
  .plu-nav {
    margin-right: 8px;
  }
  .support-btn {
    display: none;
  }
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 1.2rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.nav-link {
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
  position: relative;
  padding: 6px 0;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.3s ease;
}

.nav-link:hover {
  color: var(--primary);
}

.nav-link:hover::after {
  width: 100%;
}

/* === FOOTER === */
.footer {
  text-align: center;
  padding: 2.2rem 0;
  color: var(--text-secondary);
  border-top: 1px solid #eee;
  margin-top: 50px;
  font-size: 0.95rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  body {
    padding: 14px;
  }
  .header-container {
    flex-direction: column;
    gap: 16px;
  }
  .nav-list {
    flex-direction: column;
    gap: 12px;
  }
  button {
    width: 100%;
    max-width: 300px;
    margin: 8px auto 16px;
  }
}

/* === DROPDOWN MENÜ === */
.nav-item.dropdown {
  position: relative !important;
}

.dropdown-menu {
  position: absolute;
  top: 100% !important;
  left: 0 !important;
  background: white;
  list-style: none;
  min-width: 250px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  border-radius: 10px;
  padding: 10px 0;
  display: none;
  z-index: 10000 !important;
  border: 1px solid #eee;
  margin-top: 8px !important;
}

.dropdown-menu a {
  color: var(--text);
  padding: 12px 20px;
  display: block;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}

.dropdown-menu a:hover {
  background-color: #f1f9ff;
  color: var(--primary);
  padding-left: 24px;
}

@media (max-width: 768px) {
  .dropdown-menu {
    position: static !important;
    background: #34495e;
    margin-top: 12px !important;
    border-radius: 10px;
  }
  .dropdown-menu a {
    color: white;
  }
  .dropdown-menu a:hover {
    background-color: #2c3e50;
    color: var(--primary);
  }
}

/* === HERO-BEREICH MIT DYNAMISCHER ANIMATION === */
.hero-section {
  text-align: center;
  padding: 80px 24px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  margin-bottom: 40px;
  border: 1px solid var(--border-light);
}

/* Hintergrund mit dynamischer SVG-Farbe */
.hero-section {
  background: 
    linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(245,247,250,0.95) 100%),
    /* Standard: Helles Blau */
    url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='10' y='60' font-family='monospace' font-size='40' fill='%233498db22'%3E%7B %7D%3C/text%3E%3C/svg%3E");
  background-size: 120px;
}

/* Dark Mode: Helleres Blau für bessere Sichtbarkeit */
html.dark-mode .hero-section {
  background: 
    linear-gradient(135deg, rgba(30,30,30,0.9) 0%, rgba(26,26,26,0.95) 100%),
    /* Dark Mode: Helleres, sichtbares Blau */
    url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='10' y='60' font-family='monospace' font-size='40' fill='%2364b5f622'%3E%7B %7D%3C/text%3E%3C/svg%3E");
  background-size: 120px;
}

/* Animation – identisch für beide Modi */
.hero-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, var(--shadow) 0%, transparent 70%);
  animation: rotate 20s linear infinite;
  z-index: 0;
}

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

.hero-section h1 {
  position: relative;
  z-index: 1;
  font-size: 2.8rem;
  color: var(--text);
  animation: fadeInUp 1s ease-out;
  font-weight: 800;
}

.hero-subtitle {
  position: relative;
  z-index: 1;
  font-size: 1.5rem;
  color: var(--primary);
  margin-top: 16px;
  animation: fadeInUp 1s ease-out 0.2s both;
  font-weight: 600;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-subtitle {
  position: relative;
  z-index: 1;
  font-size: 1.5rem;
  color: var(--primary);
  margin-top: 16px;
  animation: fadeInUp 1s ease-out 0.2s both;
  font-weight: 600;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === KAPITEL-NAVIGATION AM ENDE === */
.kapitel-navigation {
  margin-top: 40px;
  padding-top: 28px;
  text-align: center;
  border-top: 2px dashed var(--primary);
}

.kapitel-navigation p {
  margin-bottom: 20px;
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
}

.nav-button {
  display: inline-block;
  background: linear-gradient(to right, var(--primary), var(--primary-light));
  color: white;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
  font-size: 1rem;
}

.nav-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
  background: linear-gradient(to right, var(--primary-light), #1a6db3);
}

/* === BACK-TO-TOP BUTTON === */
#back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 50px;
  height: 50px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover {
  background-color: var(--primary-light);
  transform: translateY(-2px);
}

/* === TABELLEN MIT RAHMEN === */
.main-content table {
  width: 100%;
  border-collapse: collapse; /* WICHTIG: Damit Rahmen zusammengezogen werden */
  margin: 20px 0;
}

.main-content th,
.main-content td {
  padding: 14px;
  text-align: left;
  border: 1px solid #dfe6ec; /* Heller Rahmen für alle Zellen */
}

.main-content th {
  background-color: #e8f4fc;
  font-weight: 700;
  color: #2c3e50;
}

/* ================================================================== */
/*                        DARK MODE – JAVASCRIPT-BLAU                 */
/* ================================================================== */

html.dark-mode {
  --primary: #3498db;
  --primary-light: #2980b9;
  --primary-bg: #1a1a1a;
  --text: #f0f0f0;
  --text-secondary: #c0c0c0;
  --border-light: #444;
  --shadow: rgba(52, 152, 219, 0.25);
}

html.dark-mode body {
  background-color: #121212;
  color: var(--text);
}

html.dark-mode .header {
  background: linear-gradient(135deg, #1a1a1a, #0d0d0d);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

html.dark-mode .main-content > section {
  background: linear-gradient(to bottom, #252525, #202020);
  border: 1px solid #3a3a3a;
}

/* Textboxen */
html.dark-mode .regel {
  background-color: #2a3a4a !important;
  border-left-color: var(--primary) !important;
}
html.dark-mode .warnung {
  background-color: #3a2a2a !important;
  border-left-color: #e74c3c !important;
}

/* Links */
html.dark-mode a {
  color: #64b5f6 !important;
}

html.dark-mode a:hover {
  color: var(--primary) !important;
}

/* Code */
html.dark-mode pre,
html.dark-mode code {
  background-color: #2d2d2d !important;
  color: #81d4fa !important;
}

/* Dropdown */
html.dark-mode .dropdown-menu {
  background: #2d2d2d !important;
  border: 1px solid #444 !important;
}
html.dark-mode .dropdown-menu a {
  color: #f0f0f0 !important;
}
html.dark-mode .dropdown-menu a:hover {
  background-color: #3a3a3a !important;
  color: var(--primary) !important;
}

/* Interaktive Demos */
html.dark-mode .box-visual,
html.dark-mode .color-demo-container {
  background: #2a2a2a !important;
  border-color: #444 !important;
}

html.dark-mode .slider-value {
  background: #3a3a3a !important;
  color: #64b5f6 !important;
}

/* Dark Mode: Warnung – bessere Lesbarkeit */
html.dark-mode .warnung {
  color: #ffe0b2 !important; /* Helles Orange – gut lesbar auf Dunkelrot */
}

/* Dark Mode: Ausgabe-Bereich und Code */
html.dark-mode .ausgabe-bereich {
  background-color: #252525 !important;
  color: #f0f0f0 !important;
  border-color: #444 !important;
}

html.dark-mode pre,
html.dark-mode code {
  background-color: #2d2d2d !important;
  color: #81d4fa !important; /* Helles Blau für JS-Code */
  border-color: #444 !important;
}

/* Dark Mode: Tabellen-Header – bessere Sichtbarkeit */
html.dark-mode .main-content table th {
  background-color: #3a3a3a !important; /* Dunkler als Body */
  color: #f0f0f0 !important;
  border-color: #555 !important;
}

/* Dark Mode: Tabellen-Zellen */
html.dark-mode .main-content table td {
  background-color: #2a2a2a !important;
  color: #f0f0f0 !important;
  border-color: #555 !important;
}