/* ==================== THEME SWITCHER PILL ==================== */

.theme-pill-container {
  position: relative;
  width: 30px;
  height: 30px;
}

/* Desktop: Button ohne Abstand */
.site-nav > .theme-pill-container {
  margin-left: 0;
  margin-right: 0;
}

/* Desktop: Menü mit Abstand zum Button und nach rechts ausgerichtet */
@media only screen and (min-width: 769px) {
  .nav-menu {
    margin-left: auto;
    margin-right: 0.75rem;
  }
}

.theme-pill {
  background: var(--accent-1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 17px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: all 0.3s ease;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
}

:root[data-theme="light"] .theme-pill,
html[data-theme="light"] .theme-pill {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] .theme-pill,
html[data-theme="dark"] .theme-pill {
  background: #000;
  border-color: rgba(255, 255, 255, 0.15);
}

:root[data-theme="crt"] .theme-pill,
html[data-theme="crt"] .theme-pill {
  background: #000;
  border-color: rgba(51, 255, 51, 0.3);
  box-shadow: 0 0 15px rgba(51, 255, 51, 0.2);
}

/* Collapsed state */
.theme-pill.collapsed {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 0;
}

.theme-pill.collapsed .theme-option:not(.active) {
  display: none;
}

/* Theme Option Buttons */
.theme-option {
  background: transparent;
  border: 1px solid transparent;
  width: 26px;
  height: 26px;
  border-radius: 13px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  order: 0;
}

/* Active button kommt immer nach oben */
.theme-option.active {
  order: -1;
}

:root[data-theme="light"] .theme-option,
html[data-theme="light"] .theme-option {
  color: #000;
}

:root[data-theme="dark"] .theme-option,
html[data-theme="dark"] .theme-option {
  color: #fff;
}

:root[data-theme="crt"] .theme-option,
html[data-theme="crt"] .theme-option {
  color: #33ff33;
}

.theme-option:hover:not(.active) {
  background: rgba(128, 128, 128, 0.1);
}

/* Active button - mit Schatten-Effekt */
.theme-option.active {
  order: -1;
  background: var(--background);
  border: 1px solid var(--accent-2);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .theme-option.active,
html[data-theme="light"] .theme-option.active {
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

:root[data-theme="dark"] .theme-option.active,
html[data-theme="dark"] .theme-option.active {
  background: #000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

:root[data-theme="crt"] .theme-option.active,
html[data-theme="crt"] .theme-option.active {
  background: #000;
  border-color: rgba(51, 255, 51, 0.4);
  box-shadow: 0 2px 4px rgba(51, 255, 51, 0.2);
}

/* Collapsed state borders - gleich dünn wie Pill */
.theme-pill.collapsed .theme-option.active {
  border: 1px solid rgba(128, 128, 128, 0.3);
}

:root[data-theme="light"] .theme-pill.collapsed .theme-option.active,
html[data-theme="light"] .theme-pill.collapsed .theme-option.active {
  border-color: rgba(0, 0, 0, 0.1);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] .theme-pill.collapsed .theme-option.active,
html[data-theme="dark"] .theme-pill.collapsed .theme-option.active {
  border-color: rgba(255, 255, 255, 0.15);
  background: #000;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

:root[data-theme="crt"] .theme-pill.collapsed .theme-option.active,
html[data-theme="crt"] .theme-pill.collapsed .theme-option.active {
  border-color: rgba(51, 255, 51, 0.3);
  background: #000;
  box-shadow: 0 1px 2px rgba(51, 255, 51, 0.15);
}

/* CRT Icon Cursor Blink Animation */
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.theme-pill:not(.collapsed) .crt-icon .cursor {
  animation: blink 1s step-end infinite;
}

/* Mobile: Button nach dem Hamburger-Menü */
@media only screen and (max-width: 768px) {
  /* Button im Desktop-Menü (nach nav-menu) ausblenden */
  .site-nav > .theme-pill-container {
    display: none;
  }
  
  /* Button im Mobile-Menü anzeigen - am Anfang */
  .nav-menu {
    position: relative;
    padding-top: 60px; /* Platz für den Button oben */
  }
  
  .nav-menu .theme-pill-container {
    display: block;
    position: absolute;
    top: 1rem;
    right: 1rem;
    margin: 0;
  }
}


/* ==================== CRT MODE STYLES ==================== */

:root[data-theme="crt"],
html[data-theme="crt"] {
  --background: #000;
  --text: #33ff33;
  --link: #33ff33;
  --link-hover: #66ff66;
  --accent-1: #001100;
  --accent-2: #003300;
  --accent-3: #33ff33;
  --highlight: #003300;
}

:root[data-theme="crt"] body,
html[data-theme="crt"] body {
  font-family: var(--mono-space-font);
  background: #000;
  color: #33ff33;
  text-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
}

/* CRT Mode: Alle Texte in Monospace */
:root[data-theme="crt"] *,
html[data-theme="crt"] * {
  font-family: var(--mono-space-font);
}

/* Scanlines */
:root[data-theme="crt"] body::before,
html[data-theme="crt"] body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 9999;
}

/* CRT Glow */
:root[data-theme="crt"] h1,
:root[data-theme="crt"] h2,
:root[data-theme="crt"] h3,
html[data-theme="crt"] h1,
html[data-theme="crt"] h2,
html[data-theme="crt"] h3 {
  text-shadow: 0 0 10px rgba(51, 255, 51, 0.8);
}

:root[data-theme="crt"] a,
html[data-theme="crt"] a {
  text-decoration: underline;
  text-shadow: 0 0 5px rgba(51, 255, 51, 0.7);
}

:root[data-theme="crt"] pre,
:root[data-theme="crt"] code,
html[data-theme="crt"] pre,
html[data-theme="crt"] code {
  background: #001100;
  color: #33ff33;
  border: 1px solid #003300;
}

:root[data-theme="crt"] img,
html[data-theme="crt"] img {
  opacity: 0.8;
  filter: contrast(1.2) brightness(0.9);
}

/* CRT flicker */
@keyframes flicker {
  0% { opacity: 0.98; }
  50% { opacity: 1; }
  100% { opacity: 0.98; }
}

:root[data-theme="crt"] body,
html[data-theme="crt"] body {
  animation: flicker 0.15s infinite;
}

:root[data-theme="crt"] .pill,
:root[data-theme="crt"] a.category,
:root[data-theme="crt"] button,
html[data-theme="crt"] .pill,
html[data-theme="crt"] a.category,
html[data-theme="crt"] button {
  background: #001100;
  border-color: #003300;
  color: #33ff33;
  text-shadow: 0 0 3px rgba(51, 255, 51, 0.5);
}

:root[data-theme="crt"] .pill:hover,
:root[data-theme="crt"] a.category:hover,
html[data-theme="crt"] .pill:hover,
html[data-theme="crt"] a.category:hover {
  background: #003300;
  box-shadow: 0 0 10px rgba(51, 255, 51, 0.3);
}