/******************************************************
 * VARIABLES & IMPORTS
 * Definition globaler Farb-, Typografie- und Layout-Variablen sowie Schriftart-Einbindung
 ******************************************************/
:root {
  /* Farb-Schemata */
  color-scheme: light dark;
  /* Hauptfarben (Hintergrund & Text) */
  --bg-light: #fafafa;
  --text-light: #1a1a1a;
  --bg-dark: #121212;
  --text-dark: #f0f0f0;

  /* Überschriften & Textfarben */
  --h1-color-light: #000000;
  --h1-color-dark: #ffffff;
  --h2-color-light: #333333;
  --h2-color-dark: #dddddd;
  --h3-color-light: #555555;
  --h3-color-dark: #bbbbbb;
  --p-color-light: #666666;
  --p-color-dark: #aaaaaa;
  
  /* Akzentfarbe für aktive Elemente und Hover-Zustände */
  --accent-light: #8A2BE2;
  --accent-dark:  #9C6BFF;

  /* Toggle-Schalter (minimal, schwarz/weiß) */
  --toggle-off-bg: #000;        /* Hintergrund im Off-Zustand */
  --toggle-off-handle: #9C6BFF;      /* Handle-Farbe im Off-Zustand */
  --toggle-on-bg: #9C6BFF;           /* Hintergrund im On-Zustand */
  --toggle-on-handle: #000;       /* Handle-Farbe im On-Zustand */

  /* Rahmen für Toggle-Schalter (Light/Dark) */
  --toggle-border-light: #222;
  --toggle-border-dark: #ddd;
  
  /* Sidebar-Größen */
  --sidebar-width-desktop: 220px;
  --sidebar-width-mobile: 80%;
  
  /* Header-Höhen */
  --top-header-height: 60px;
  --sub-header-height: 50px;
  --top-header-height-mobile: 50px;
  --sub-header-height-mobile: 40px;
  
  /* Typografie */
  --font-main: 'IBM Plex Serif', 'Palatino Linotype', serif;
  --font-heading: 'IBM Plex Sans', system-ui, sans-serif;
}

/* Einbindung der Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Serif:wght@300;400;500;600&display=swap');

/******************************************************
 * GLOBAL STYLES
 * Basisstile für HTML-Elemente und Seitenhintergrund inkl. Smooth Scrolling
 ******************************************************/
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--top-header-height) + var(--sub-header-height) + 20px);
}

body {
  margin: 0;
  font-family: var(--font-main);
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: background-color 0.3s, color 0.3s;
  line-height: 1.6;
}

body.dark-mode {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

/******************************************************
 * SIDEBAR STYLES
 * Navigation für Desktop und mobile Geräte – vertikal zentriert
 ******************************************************/
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width-desktop);
  /* Padding wurde angepasst für vertikale Zentrierung */
  padding: 1rem;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  z-index: 998;
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: transform 0.3s ease, background-color 0.3s, color 0.3s;
  padding-top: 0;
  padding-bottom: 0;
}

body.dark-mode .sidebar {
  background-color: var(--bg-dark);
  color: var(--text-dark);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

/* Versteckt die Sidebar mit einer Transformations-Animation */
.sidebar.hidden {
  transform: translateX(calc(-1 * var(--sidebar-width-desktop) - 1rem));
}

/* Touch-Bereich für mobile Navigation */
.sidebar-touch-area {
  display: none; /* Standard: ausgeblendet, nur bei mobilen Geräten sichtbar */
  position: fixed;
  left: 0;
  top: var(--top-header-height-mobile);
  bottom: 0;
  width: 20px;
  z-index: 997;
  background-color: transparent;
}

/* Liste in der Sidebar */
.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.sidebar li {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  width: 100%;
}

body.dark-mode .sidebar li {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Link-Styling in der Sidebar */
.sidebar a {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 0.5rem 0;
  font-family: var(--font-heading);
  font-weight: 400;
  transition: transform 0.2s, color 0.2s;
  width: 100%;
}
.sidebar a:hover {
  text-decoration: none;
  transform: translateX(5px);
  color: var(--accent-light);
}
body.dark-mode .sidebar a:hover {
  color: var(--accent-dark);
}
.sidebar a.active {
  font-weight: 500;
  color: var(--accent-light);
}
body.dark-mode .sidebar a.active {
  color: var(--accent-dark);
}

/******************************************************
 * TOP HEADER STYLES
 * Erster Header mit Branding und Navigationselementen
 ******************************************************/
#top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: var(--top-header-height);
  border-bottom: none;
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: background-color 0.3s, color 0.3s, height 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

body.dark-mode #top-header {
  background-color: var(--bg-dark);
  color: var(--text-dark);
  border-bottom-color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Aufteilung in drei Bereiche innerhalb des Top-Headers */
.top-header-left,
.top-header-center,
.top-header-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.top-header-left {
  flex: 0 0 auto;
}
.top-header-center {
  flex: 1 1 auto;
  justify-content: center;
}
.top-header-right {
  flex: 0 0 auto;
}

/* Branding und Logo */
.brand-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  transition: color 0.3s;
  display: inline-flex;
  align-items: center;
}
.brand-title::before {
  content: '';
  display: none;
  width: 8px;
  height: 8px;
  background-color: var(--accent-light);
  margin-right: 8px;
  border-radius: 1px;
}
body.dark-mode .brand-title::before {
  background-color: var(--accent-dark);
}

.brand-title .highlight {
  color: var(--accent-dark);
}
/* Beschriftung in den Header-Bereichen */
.top-header-left span,
.top-header-right span {
  font-size: 0.9rem;
  opacity: 0.8;
  font-family: var(--font-heading);
}

/******************************************************
 * TOGGLE SWITCH STYLES
 * Schaltflächen für Theme- und Navigationswechsel (Light/Dark)
 ******************************************************/
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  min-width: 44px; /* Verhindert Schrumpfen auf mobilen Geräten */
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 34px;
  transition: 0.4s;
  /* Standard: schwarzer Hintergrund mit Rahmen in Light Mode */
  background-color: var(--toggle-off-bg);
  border: 2px solid var(--toggle-border-light);
}
body.dark-mode .toggle-slider {
  border: 2px solid var(--toggle-border-dark);
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--toggle-off-handle);
  transition: 0.4s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
/* Geprüfter Zustand: Weißer Track, schwarzer Handle */
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--toggle-on-bg);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px) translateY(-50%);
  background-color: var(--toggle-on-handle);
}

/******************************************************
 * SUB HEADER STYLES
 * Zweiter Header zur Anzeige dynamischer Inhalte (z.B. aktueller Artikel)
 ******************************************************/
#sub-header {
  position: fixed;
  top: var(--top-header-height);
  left: 0;
  right: 0;
  z-index: 998;
  height: var(--sub-header-height);
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: background-color 0.3s, color 0.3s, top 0.3s, height 0.3s;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding: 0 1.5rem;
}
body.dark-mode #sub-header {
  background-color: var(--bg-dark);
  color: var(--text-dark);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#current-article {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  margin: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/******************************************************
 * MAIN CONTENT STYLES
 * Zentraler Inhaltsbereich der Seite
 ******************************************************/
main {
  padding: 2rem;
  /* Abstand oben angepasst, um Header (Top & Sub) zu berücksichtigen */
  padding-top: calc(var(--top-header-height) + var(--sub-header-height) + 80px);
  display: flex;
  justify-content: center;
  transition: padding 0.3s;
}

.content {
  max-width: 750px;
  width: 100%;
}

/******************************************************
 * LOADING MESSAGE
 * Anzeige, wenn Inhalte geladen werden
 ******************************************************/
.loading-message {
  padding: 3rem;
  text-align: center;
  color: var(--p-color-light);
  font-family: var(--font-heading);
}
body.dark-mode .loading-message {
  color: var(--p-color-dark);
}

/******************************************************
 * TYPOGRAPHY & ARTICLE-STYLES
 * Überschriften, Paragraphen, Artikel-Metadaten und Tags
 ******************************************************/
/* Offset für Anker-Links (um Header nicht zu verdecken) */
h1, h2, h3 {
  scroll-margin-top: calc(var(--top-header-height) + var(--sub-header-height) + 60px);
  font-family: var(--font-heading);
  line-height: 1.3;
}

h1 {
  font-size: 2.2rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--h1-color-light);
  transition: color 0.3s;
}
body.dark-mode h1 {
  color: var(--h1-color-dark);
}

h2 {
  font-size: 1.4rem;
  font-weight: 400;
  margin-top: 0;
  margin-bottom: 2rem;
  color: var(--h2-color-light);
  transition: color 0.3s;
}
body.dark-mode h2 {
  color: var(--h2-color-dark);
}

h3 {
  font-size: 1.3rem;
  font-weight: 500;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--h3-color-light);
  transition: color 0.3s;
}
body.dark-mode h3 {
  color: var(--h3-color-dark);
}

p {
  font-size: 1.05rem;
  line-height: 1.7;
  margin: 0 0 1.5rem 0;
  color: var(--p-color-light);
  transition: color 0.3s;
}
body.dark-mode p {
  color: var(--p-color-dark);
}

article {
  margin-bottom: 5rem;
  position: relative;
}

.article-meta {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-size: 0.9rem;
  color: #888;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-family: var(--font-heading);
}
body.dark-mode .article-meta {
  border-top-color: rgba(255,255,255,0.1);
  color: #777;
}

/* Tags im Artikel */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 3px;
  margin-right: 5px;
  background-color: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.7);
  font-family: var(--font-heading);
}
body.dark-mode .tag {
  background-color: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}

/******************************************************
 * RESPONSIVE STYLES (max-width: 800px)
 * Anpassungen für Tablets und Smartphones
 ******************************************************/
@media (max-width: 800px) {
  #top-header {
    height: var(--top-header-height-mobile);
    padding: 0 1rem;
    z-index: 1000;
  }
  
  @media (max-width: 800px) {
    h1, h2, h3 {
      scroll-margin-top: calc(var(--top-header-height-mobile) + var(--sub-header-height-mobile) + 60px);
    
  }
  
  .brand-title {
    font-size: 1.25rem;
  }
  
  #sub-header {
    top: var(--top-header-height-mobile);
    height: var(--sub-header-height-mobile);
    z-index: 999;
  }
  
  #current-article {
    font-size: 1rem;
  }

  .sidebar {
    width: var(--sidebar-width-mobile);
    max-width: 300px;
    transform: translateX(-105%); /* Sidebar komplett außerhalb des Bildschirms */
    padding: 1.25rem;
    z-index: 998;
    position: fixed;
    background-color: var(--bg-light);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.25);
    justify-content: center;
  }
  
  body.dark-mode .sidebar {
    background-color: var(--bg-dark);
  }
  
  .sidebar:not(.hidden) {
    transform: translateX(0);
    box-shadow: 2px 0 15px rgba(0,0,0,0.15);
  }
  
  .sidebar.hidden {
    transform: translateX(-105%);
    visibility: hidden;
  }
  
  .sidebar-touch-area {
    display: block;
    width: 30px; /* Vergrößerte Swipe-Fläche */
  }
  
  .sidebar-touch-area {
    position: fixed;
    left: 0;
    top: var(--top-header-height-mobile);
    bottom: 0;
    width: 30px;
    z-index: 997;
    background-color: transparent;
  }
  
  /* Swipe-Indikator für mobile Navigation */
  .swipe-indicator {
    position: absolute;
    top: 50%;
    left: 10px;
    width: 3px;
    height: 40px;
    border-radius: 3px;
    opacity: 0.3;
    background-color: var(--accent-light);
  }
  
  body.dark-mode .swipe-indicator {
    background-color: var(--accent-dark);
  }
  
  main {
    padding: 1.25rem;
    padding-top: calc(var(--top-header-height-mobile) + var(--sub-header-height-mobile) + 60px);
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    transition: margin-left 0.3s ease;
  }
  
  /* Leicht gedimmter Hauptinhalt bei offener Sidebar */
  .sidebar:not(.hidden) ~ main {
    opacity: 0.9;
    margin-left: 0;
  }
  
  h1, h2, h3 {
    scroll-margin-top: calc(var(--top-header-height-mobile) + var(--sub-header-height-mobile) + 40px);
  }

  h1 {
    font-size: 1.8rem;
  }
  
  h2 {
    font-size: 1.2rem;
  }
  
  h3 {
    font-size: 1.1rem;
  }
  
  p {
    font-size: 1rem;
  }
  
  article {
    margin-bottom: 3.5rem;
  }
  
  /* Angepasste Toggle-Schalter für mobile Ansicht */
  .toggle-switch {
    width: 36px;
    height: 18px;
    min-width: 36px;
    opacity: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 5px;
  }
  
  /* Versteckte Schalter im DOM */
  #nav-toggle, #theme-toggle {
    opacity: 0;
    position: absolute;
  }
  
  #nav-toggle-label {
    cursor: pointer;
  }
  
  .top-header-left .toggle-switch,
  .top-header-right .toggle-switch {
    z-index: 1000;
  }
  
  .toggle-slider:before {
    height: 14px;
    width: 14px;
    top: 50%;
    left: 2px;
  }
  
  .toggle-slider {
    border-width: 2px !important;
    background-color: var(--toggle-off-bg) !important;
    box-shadow: 0 0 3px rgba(255,255,255,0.3);
  }
  
  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px) translateY(-50%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  }
  
  .top-header-left, .top-header-right {
    background-color: rgba(255,255,255,0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
  }
  
  body.dark-mode .top-header-left,
  body.dark-mode .top-header-right {
    background-color: rgba(30, 30, 30, 0.6); 
    border: 1px solid rgba(80, 80, 80, 0.3);
  }
  
  body.dark-mode .toggle-slider {
    background-color: #333 !important;
    border-color: rgba(180, 180, 180, 0.5) !important;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.2) !important;
  }
  
  .top-header-left span,
  .top-header-right span {
    font-size: 0.8rem;
    font-weight: 600;
    color: inherit;
    display: inline-block;
  }
  
  body.dark-mode .top-header-left span,
  body.dark-mode .top-header-right span {
    color: rgba(220, 220, 220, 0.9);
  }
  
  .article-meta {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/******************************************************
 * MOBILE FOOTER & EXTRASTYLES (max-width: 500px)
 * Weitere Anpassungen für sehr kleine Bildschirme
 ******************************************************/
@media (max-width: 500px) {
  .brand-title {
    font-size: 1.1rem;
  }
  
  .top-header-left span,
  .top-header-right span {
    display: inline-block !important;
    font-size: 0.7rem;
    color: inherit;
    opacity: 0.9;
  }
  
  main {
    padding: 1rem;
    padding-top: calc(var(--top-header-height-mobile) + var(--sub-header-height-mobile) + 40px);
  }
  
  #top-header {
    justify-content: space-between;
    padding: 0.25rem 0.5rem;
  }
  
  .toggle-switch {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    width: 32px;
    height: 16px;
    min-width: 32px;
  }
  
  .toggle-slider:before {
    height: 12px;
    width: 12px;
    left: 2px;
  }
  
  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px) translateY(-50%);
  }
  
  .toggle-slider {
    background-color: var(--toggle-off-bg) !important;
  }
  
  h1 {
    font-size: 1.5rem;
  }
}

/******************************************************
 * OVERLAY FOR MOBILE NAVIGATION
 * Halbtransparente Überlagerung bei geöffneter Sidebar auf mobilen Geräten
 ******************************************************/
#sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 997;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: auto;
}

/******************************************************
 * ALL ARTICLES (LISTING) STYLES
 * Darstellung mehrerer Artikel untereinander
 ******************************************************/
.all-articles {
  width: 100%;
}
.article-item {
  position: relative;
  padding-bottom: 3rem;
  margin-bottom: 3rem;
}
/* Trennlinie zwischen Artikeln */
.article-divider {
  height: 1px;
  background-color: rgba(0,0,0,0.1);
  margin: 4rem 0;
  width: 100%;
}
body.dark-mode .article-divider {
  background-color: rgba(255,255,255,0.1);
}

/******************************************************
 * CODE BLOCK STYLES
 * Formatierung und Darstellung von Code-Blöcken
 ******************************************************/
code {
  font-family: 'IBM Plex Mono', monospace;
  background-color: rgba(0,0,0,0.05);
  padding: 1rem;
  border-radius: 3px;
  font-size: 0.9em;
  display: block;
  white-space: pre-wrap;
  margin: 1.5rem 0;
  line-height: 1.5;
  overflow-x: auto;
}

body.dark-mode code {
  background-color: rgba(255,255,255,0.1);
}
