/* Themenseite — ergänzt die Grundtokens aus index; hier nur benötigte Layout-/Komponenten */

:root {
  --bg: #090b18;
  --card: #15182b;
  --accent: #8b5cf6;
  --accent2: #6d5dfc;
  --success: #62e58f;
  --warn: #f6c344;
  --fail: #e94560;
  --text: #f4f4fb;
  --text2: #a7acc2;
  --border: rgba(255, 255, 255, .09);
  --glass: rgba(255, 255, 255, .055);
  --radius: 14px;
  --quiz-card-min: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background:
    radial-gradient(circle at 35% 0%, rgba(139, 92, 246, .16), transparent 36%),
    radial-gradient(circle at 90% 15%, rgba(98, 229, 143, .08), transparent 28%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
}

/* Höhe des fixierten Footer-Bereichs (Desktop). Wird für Sidebar-max-height
   und das ::before-Spacer-Element der Sidebar referenziert, damit der
   Footer den Sidebar-Inhalt nicht überdeckt. */
:root {
  --side-footer-height: 200px;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  grid-column: 1;
  border-right: 1px solid var(--border);
  background: rgba(10, 12, 27, .78);
  padding: 24px 20px;
  padding-bottom: calc(var(--side-footer-height) + 12px);
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Desktop: Footer-Nav fix unten links in der Sidebar-Spalte —
   bleibt beim Scrollen sichtbar, unabhängig von der Hauptinhalts-Höhe. */
.app-footer-nav.side-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 260px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
  background: rgba(10, 12, 27, .92);
  padding: 12px 20px max(16px, calc(16px + env(safe-area-inset-bottom, 0px)));
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  flex-wrap: nowrap;
  min-height: 48px;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #fb5f8f, var(--accent2));
  font-size: 1.55rem;
  box-shadow: 0 12px 30px rgba(139, 92, 246, .22);
}
.brand strong { display: block; font-size: 1.1rem; }
.brand span { color: var(--text2); font-size: .83rem; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 10px;
  color: var(--text2);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

a.nav-item:link,
a.nav-item:visited {
  color: var(--text2);
}

a.nav-item:hover:not(.active) { color: var(--text); background: rgba(255, 255, 255, .04); }

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(139, 92, 246, .95), rgba(109, 93, 252, .55));
}

a.nav-item.active:link,
a.nav-item.active:visited {
  color: #fff;
}

.nav-item.disabled { opacity: .48; cursor: not-allowed; }

.nav-icon { width: 24px; text-align: center; font-size: 1rem; }

.nav-badge {
  margin-left: auto;
  font-size: .72rem;
  color: #d6c8ff;
  background: rgba(139, 92, 246, .28);
  border: 1px solid rgba(139, 92, 246, .35);
  border-radius: 999px;
  padding: 2px 8px;
}

.sidebar-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(139, 92, 246, .12), rgba(255, 255, 255, .035));
  border-radius: var(--radius);
  padding: 16px;
}

.sidebar-card h3 { font-size: .98rem; margin-bottom: 8px; }
.sidebar-card p { color: var(--text2); font-size: .84rem; }

.content {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 0;
  padding: 22px 28px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: -22px -28px 22px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 27, .48);
}

#authNav { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.search-box {
  flex: 1;
  max-width: 440px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .045);
  color: var(--text);
  padding: 0 16px;
  font: inherit;
  outline: none;
}

.search-box:focus { border-color: rgba(139, 92, 246, .65); }

/* Intro */
.themes-page-hero {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 28px;
  background: linear-gradient(135deg, rgba(139, 92, 246, .14), rgba(21, 24, 43, .92));
}

.themes-page-hero .eyebrow {
  color: #c9b3ff;
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  margin-bottom: 12px;
}

.themes-page-hero h1 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 800;
  margin-bottom: 14px;
  line-height: 1.2;
}

.themes-page-hero .lead {
  color: var(--text2);
  font-size: .98rem;
  max-width: 720px;
  margin-bottom: 14px;
}

.themes-page-hero ul {
  margin: 12px 0 0 1.1rem;
  color: var(--text2);
  font-size: .92rem;
}

.themes-page-hero li { margin-bottom: 6px; }

/* Themen-Kacheln */
.topic-overview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.topic-overview-head h2 { font-size: 1.15rem; font-weight: 700; }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 12px;
  margin-bottom: 36px;
}

.topic-card {
  /* Kacheln sind <button>: UA-Styles erben oft dunkle Schrift → explizit hell halten */
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .02)), var(--card);
  cursor: pointer;
  transition: border-color .2s, transform .2s;
  text-align: left;
}

.topic-card:hover {
  border-color: rgba(139, 92, 246, .45);
  transform: translateY(-2px);
}

.topic-card.selected {
  border-color: var(--accent);
  box-shadow: 0 8px 28px rgba(108, 99, 255, .18);
}

.topic-card .topic-icon { font-size: 1.75rem; margin-bottom: 10px; display: block; line-height: 1; }
.topic-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.topic-card p {
  font-size: .84rem;
  color: var(--text2);
  margin-bottom: 12px;
  line-height: 1.5;
}

.topic-meta {
  font-size: .72rem;
  font-weight: 700;
  color: #d6c8ff;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.quiz-section-head {
  margin-bottom: 14px;
}

.quiz-section-head h2 { font-size: 1.1rem; margin-bottom: 6px; }
.quiz-section-head p { font-size: .88rem; color: var(--text2); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--quiz-card-min)), 1fr));
  gap: 12px;
  justify-content: start;
}

.grid > .card { min-width: 0; width: 100%; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .025)), var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 30px rgba(108, 99, 255, .15);
}

.card .icon { font-size: 2rem; margin-bottom: 12px; }
.card .icon-img {
  width: 44px; height: 44px; object-fit: contain;
  margin-bottom: 14px; display: block;
}

.card h3 { font-size: .98rem; font-weight: 700; margin-bottom: 8px; }

.card p { font-size: 0.82rem; color: var(--text2); margin-bottom: 16px; }

.card .meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text2);
  font-weight: 600;
  flex-wrap: wrap;
}

.card .meta span {
  background: var(--glass);
  padding: 4px 10px;
  border-radius: 20px;
}

.difficulty {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  margin-bottom: 10px;
  font-size: .75rem;
  font-weight: 700;
}

.difficulty.very-easy { color: #d8fff0; background: rgba(98, 229, 143, .16); }
.difficulty.easy { color: #c9f7ff; background: rgba(72, 205, 255, .14); }
.difficulty.medium { color: #ffe8a3; background: rgba(246, 195, 68, .15); }
.difficulty.hard { color: #ffd4a3; background: rgba(255, 152, 72, .14); }
.difficulty.very-hard { color: #ffc2d0; background: rgba(233, 69, 96, .16); }

.btn {
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #a076ff, #7446ef);
  color: #fff;
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(108, 99, 255, .3); }

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

.filter-row { margin-bottom: 14px; }

.filter-label {
  color: var(--text2);
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.hidden { display: none !important; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 450px;
  transform: translateY(20px);
  transition: transform .3s;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal h2 { margin-bottom: 16px; font-size: 1.4rem; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  color: var(--text2);
}

.text-input {
  width: 100%;
  background: var(--glass);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.loading-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text2);
}

@media (max-width: 980px) {
  .app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }
  .sidebar {
    position: static;
    grid-column: auto;
    grid-row: auto;
    max-height: none;
    overflow: visible;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px 8px;
    order: 1;
    flex: 0 0 auto;
  }
  .sidebar .brand {
    justify-content: center;
    min-height: 48px;
    padding-bottom: 4px;
  }
  .side-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 10px;
    margin: 0 -6px;
    padding-left: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .side-nav .nav-item {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    min-height: 42px;
    padding: 9px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .nav-item.disabled { display: none; }
  .sidebar-card { display: none; }
  .content {
    grid-column: auto;
    grid-row: auto;
    order: 2;
  }
  .sidebar {
    padding-bottom: 8px;
  }
  .app-footer-nav.side-footer {
    position: static;
    grid-column: auto;
    grid-row: auto;
    left: auto;
    bottom: auto;
    order: 3;
    width: 100%;
    box-sizing: border-box;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 12px max(12px, calc(10px + env(safe-area-inset-bottom, 0px)));
    border-top: 1px solid var(--border);
    border-right: 0;
    background: rgba(7, 9, 20, 0.96);
  }
  .app-footer-nav .nav-item {
    flex: 1 1 0;
    justify-content: center;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 0.78rem;
  }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: stretch; margin: -18px -18px 18px; padding: 16px 18px; }
  .content { padding: 18px; }
  .grid { grid-template-columns: 1fr; }
}
