/* ========================= */
/*   Layout fürs PSE         */
/* ========================= */

.periods {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  overflow-x: auto;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.pse-row,
.lanth-row,
.act-row {
  width: max-content;
}

html, body {
  overflow-x: auto;
}

.pse-row {
  display: grid;
  grid-template-columns: repeat(18, 60px);
  gap: 5px;
  justify-content: center;
  align-items: center;
}

.lanth-row {
  display: grid;
  grid-template-columns: repeat(15, 60px);
  column-gap: 5px;
  margin-left: calc((60px + 5px) * 3);
  margin-top: 20px;
}

.act-row {
  display: grid;
  grid-template-columns: repeat(15, 60px);
  column-gap: 5px;
  margin-left: calc((60px + 5px) * 3);
}


/* ========================= */
/*   Element-Kästchen        */
/* ========================= */

.element {
  position: relative; /* nötig, damit .number sich relativ zum Kästchen ausrichtet */
  height: 60px;
  width: 60px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #cfcfcf;
  background: #f8f9fa;
  box-sizing: border-box;

  /* Ordnungszahl oben links im Kästchen */
.number {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.70rem;
  font-weight: bold;
}

  /* Textfarbe über Variable */
  color: var(--pse-on-swatch-text);
}

.element.leer {
  background: transparent;
  border: none;
  cursor: default;
}

.symbol { font-size: 1.1rem; }
.number { font-size: 0.65rem; }

.element:active { transform: translateY(1px); }


/* ========================= */
/*   Farbklassen             */
/* ========================= */

.actinide { background: #ffe0b3; }
.alkali-metal { background: #ffb3b3; }
.alkaline-earth-metal { background: #ffd9b3; }
.diatomic-nonmetal { background: #bfefff; }
.lanthanide { background: #fff0b3; }
.metalloid { background: #cfe7b4; }
.noble-gas { background: #e6b3ff; }
.polyatomic-nonmetal { background: #bfefff; }
.post-transition-metal { background: #cccccc; }
.transition-metal { background: #d5d5ff; }
.unknown-alkali-metal { background: #ffb3b3; }
.unknown-noble-gas { background: #e6b3ff; }
.unknown-metalloid { background: #cfe7b4; }
.unknown-post-transition-metal { background: #cccccc; }
.unknown-transition-metal { background: #d5d5ff; }
.platzhalter { background: #ffffff; }
.gap { background: rgba(0,0,0,0.04); border-style: dashed; }


/* ========================= */
/*   Infotafeln / Karten     */
/* ========================= */

.element-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-family: 'Inter', sans-serif;

  background-color: var(--pse-card-body-bg);
  color: var(--pse-card-body-text);
}

/* Header der Karte */
.element-header {
  padding: 20px;
  text-align: center;
  position: relative;
  border-radius: 12px 12px 0 0;

  /* behält Hintergrund (Kategorie), Textfarbe kommt aus Variable */
  color: var(--pse-on-swatch-text);
}

/* Kategorie-Farben */
.element-header.actinide { background: #ffe0b3; }
.element-header.alkali-metal { background: #ffb3b3; }
.element-header.alkaline-earth-metal { background: #ffd9b3; }
.element-header.diatomic-nonmetal { background: #bfefff; }
.element-header.lanthanide { background: #fff0b3; }
.element-header.metalloid { background: #cfe7b4; }
.element-header.noble-gas { background: #e6b3ff; }
.element-header.polyatomic-nonmetal { background: #bfefff; }
.element-header.post-transition-metal { background: #cccccc; }
.element-header.transition-metal { background: #d5d5ff; }
.element-header.unknown-alkali-metal { background: #ffb3b3; }
.element-header.unknown-noble-gas { background: #e6b3ff; }
.element-header.unknown-metalloid { background: #cfe7b4; }
.element-header.unknown-post-transition-metal { background: #cccccc; }
.element-header.unknown-transition-metal { background: #d5d5ff; }


/* ========================= */
/*   Card-Inhalt             */
/* ========================= */

.element-header .element-number {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 2rem;
  font-weight: bold;
}

.element-header .element-mass {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.3rem;
  font-weight: bold;
}

.element-header .element-symbol {
  font-size: 4rem;
  font-weight: bold;
  margin: 0;
}

.element-header .element-name {
  font-size: 1.5rem;
  margin-top: 6px;
}

.element-properties {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  font-size: 1rem;
}

.element-properties .property {
  margin: 2px 0;
}


/* ========================= */
/*   Darkmode-Seite PSE      */
/* ========================= */

.dark-mode.page-pse {
  --pse-on-swatch-text: #000000;   /* schwarz auf Kästchen & Header */
  --pse-card-body-bg: #252528;     /* Kartenkörper dunkel */
  --pse-card-body-text: #ffffff;   /* Kartenkörper-Text weiß */
}

/* ========================= */
/* Infotafel im Dark Mode   */
/* ========================= */
.dark-mode .modal-content {
  background-color: #252528; /* Dunkler Hintergrund für den Modal-Inhalt */
  color: #fff;            /* Heller Text */
  border: 1px solid #252528; /* Leichter Rand, um es vom Hintergrund abzuheben */
}

.dark-mode .modal-header {
  border-bottom: 1px solid #252528; /* Rand der Kopfzeile anpassen */
}

.dark-mode .btn-close {
  filter: invert(1) grayscale(100%) brightness(2); /* Macht das Schließ-Icon weiß */
}

/* ========================= */
/* Filter       */
/* ========================= */

.pse-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-family: 'Inter', sans-serif;
}

.filter-group {
  position: relative;
}

.filter-buttons button,
.filter-group .dropdown button,
.filter-group .toggle {
  background: #e9e9e9;
  border: 1px solid #d5d5d5;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  margin: 0.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
}

.filter-buttons button:hover,
.filter-group .dropdown button:hover,
.filter-group .toggle:hover {
  background: #dcdcdc;
}

.filter-buttons button.active,
.filter-group .dropdown button.active {
  background: #4a4a4a;
  color: #fff;
  border-color: #4a4a4a;
}

/* Dropdown */
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  min-width: 150px;
}

.dropdown.show {
  display: block;
}

/* Neue CSS-Regel für die Filterung */
.element.filtered-out {
  opacity: 0.3;
  background: transparent !important;
}

/* Media-Query für kleinere Bildschirme */
@media (max-width: 768px) {
  .pse-filters {
    flex-direction: column; /* Stapelt die Filter-Gruppen vertikal */
  }

  .filter-group {
    width: 100%; /* Macht jede Filter-Gruppe über die volle Breite */
  }

  .pse-row,
  .lanth-row,
  .act-row {
    grid-template-columns: repeat(18, 50px); /* Verkleinert die Element-Kästchen */
    gap: 3px;
  }
}