/* ============================================================
   THEME-BASE — Schule Herzogenbuchsee
   Geteilte Grundlage für alle Apps (Konzept, Katalog, Puzzle …):
   Farben, Typografie, Topbar, Buttons, Tags, Cards, Avatare, Intro/
   Landing, Login, Modal-Grundgerüst, Utilities.
   Jede Seite linkt diese Datei + ihre App-CSS (konzept/katalog/puzzle).
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Farben */
  --color-bg:           #F7F5F0;
  --color-surface:      #FFFFFF;
  --color-border:       #E8E4DC;
  --color-border-mid:   #D4CFC5;

  --color-text:         #1A1A18;
  --color-text-muted:   #666660;
  --color-text-faint:   #ABABAB;

  --color-primary:      #1D9E75;
  --color-primary-bg:   #E1F5EE;
  --color-primary-dark: #0F6E56;

  --color-blue:         #185FA5;
  --color-blue-bg:      #E6F1FB;

  --color-amber:        #854F0B;
  --color-amber-bg:     #FAEEDA;

  --color-red:          #993C1D;
  --color-red-bg:       #FAECE7;

  --color-purple:       #534AB7;
  --color-purple-bg:    #EEEDFE;

  /* Typografie */
  --font-serif:   'DM Serif Display', Georgia, serif;
  --font-sans:    'DM Sans', system-ui, sans-serif;

  /* Abstände */
  --radius-sm:    6px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --radius-full:  999px;

  /* Layout */
  --topbar-h:     52px;
  --sidebar-w:    240px;
}

html, body {
  height: 100%;
  background: var(--color-bg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 0.5px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Hamburger — nur auf Mobile sichtbar (siehe Konzept-Media-Query). */
.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -6px;
  border: none;
  background: none;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.topbar-menu-btn:hover { background: var(--color-bg); }
.topbar-menu-btn svg { width: 20px; height: 20px; }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}

.topbar-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.topbar-icon {
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-icon svg {
  width: 14px;
  height: 14px;
}

.topbar-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-user-name {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Topbar-Navigation (Katalog, Puzzle) */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-link {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.12s;
}
.topbar-link:hover { color: var(--color-primary-dark); }

/* Topbar-Button (gleiche Optik wie topbar-link) */
.topbar-btn {
  border: none;
  background: none;
  font-family: var(--font-sans);
  cursor: pointer;
}

/* Abmelden-Aktion im Topbar-Nutzer-Widget */
.topbar-logout {
  background: none;
  border: none;
  color: var(--color-text-faint);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  font-family: var(--font-sans);
}
.topbar-logout:hover { color: var(--color-text); }

/* Avatar als Menü-Auslöser (der „Böpfel"). */
.user-avatar-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-full);
  line-height: 0;
}
.user-avatar-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Konto-Dropdown unter dem Avatar (Name/Rolle, Cockpit, Abmelden). */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 300;
  min-width: 200px;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16);
  padding: 6px;
}
.user-menu[hidden] { display: none; }

.user-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
  border-bottom: 0.5px solid var(--color-border);
  margin-bottom: 6px;
}

.user-menu-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.user-menu-role {
  font-size: 12px;
  color: var(--color-text-muted);
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--color-bg); }

.user-menu-logout { color: var(--color-red); }

/* ── Tags / Badges ────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

.tag-green  { background: var(--color-primary-bg); color: var(--color-primary-dark); }
.tag-blue   { background: var(--color-blue-bg);    color: var(--color-blue); }
.tag-amber  { background: var(--color-amber-bg);   color: var(--color-amber); }
.tag-red    { background: var(--color-red-bg);     color: var(--color-red); }
.tag-purple { background: var(--color-purple-bg);  color: var(--color-purple); }

.tag-meta {
  font-size: 11px;
  color: var(--color-text-faint);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card p {
  font-size: 15px;
  color: #333;
  line-height: 1.75;
  margin-bottom: 1rem;
}

.card p:last-child {
  margin-bottom: 0;
}

.card h2, .card h3 {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
}

.card h2:first-child,
.card h3:first-child {
  margin-top: 0;
}

.card ul, .card ol {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.card li {
  font-size: 15px;
  color: #333;
  line-height: 1.75;
  margin-bottom: 0.25rem;
}

.card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 1rem;
}

.card th {
  text-align: left;
  font-weight: 500;
  padding: 6px 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card td {
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--color-border);
  color: var(--color-text);
  vertical-align: top;
}

.card tr:last-child td {
  border-bottom: none;
}

.card blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 0.5rem 0 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--color-primary-bg);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.card blockquote p {
  color: var(--color-primary-dark);
  font-size: 14px;
  margin: 0;
}

.card a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.card a:hover {
  color: var(--color-primary-dark);
}

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  border-width: 1.5px;
  border-style: solid;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 10px;
}

.avatar-green  { background: var(--color-primary-bg); color: var(--color-primary);      border-color: var(--color-primary); }
.avatar-blue   { background: var(--color-blue-bg);    color: var(--color-blue);          border-color: var(--color-blue); }
.avatar-amber  { background: var(--color-amber-bg);   color: var(--color-amber);         border-color: var(--color-amber); }
.avatar-red    { background: var(--color-red-bg);     color: var(--color-red);           border-color: var(--color-red); }
.avatar-purple { background: var(--color-purple-bg);  color: var(--color-purple);        border-color: var(--color-purple); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--color-text);
  color: #fff;
  border-color: var(--color-text);
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-primary:disabled,
.btn-primary[disabled] {
  background: var(--color-border);
  border-color: var(--color-border);
  color: var(--color-text-faint);
  cursor: default;
  opacity: 1;
}

.btn-secondary {
  background: none;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
}

.btn-secondary:disabled,
.btn-secondary[disabled] {
  color: var(--color-text-faint);
  border-color: var(--color-border);
  cursor: default;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--color-text-muted);
  padding: 4px 10px;
  font-size: 12px;
}

.btn-ghost:hover {
  color: var(--color-text);
}

/* `.btn` setzt ein eigenes `display:` — dadurch greift das `hidden`-Attribut
   (nur UA-Regel) nicht. Explizit nachhelfen. */
.btn[hidden] { display: none; }

/* ── Intro / Landing ──────────────────────────────────────── */
.intro-shell {
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.intro-inner {
  max-width: 600px;
  width: 100%;
}

.intro-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2.5rem;
}

.intro-school {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intro-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  font-weight: 400;
}

.intro-title em {
  color: var(--color-primary);
  font-style: italic;
}

.intro-lead {
  font-size: 16px;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.intro-stats {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.intro-stat-num {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--color-primary);
  line-height: 1.2;
  font-weight: 400;
}

.intro-stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Landing: zweiter Einstieg (Konzept ↔ Katalog) */
.intro-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.intro-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.7;
  border-top: 0.5px solid var(--color-border);
  padding-top: 1.25rem;
}

.intro-hint em {
  font-style: normal;
  color: var(--color-primary-dark);
  font-weight: 500;
}

/* ── Rollenwahl / Login ───────────────────────────────────── */
.role-shell {
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.role-inner {
  max-width: 520px;
  width: 100%;
}

.role-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  font-weight: 400;
}

.role-lead {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.role-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.role-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.12s, border-color 0.12s;
  width: 100%;
}

.role-btn:hover {
  background: var(--color-bg);
}

.role-btn.active {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.role-btn-label {
  font-size: 15px;
  color: var(--color-text);
}

.name-field {
  margin-bottom: 1.5rem;
}

.name-field label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

input.name-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color 0.15s;
}

input.name-input:focus {
  border-color: var(--color-primary);
}

.login-error {
  background: var(--color-red-bg);
  color: var(--color-red);
  border: 1px solid var(--color-red);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 1rem;
}

/* ── Geteiltes Eingabefeld (Kommentare/Feedback) ──────────── */
textarea.kommentar-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  line-height: 1.6;
  resize: none;
  transition: border-color 0.15s;
}

textarea.kommentar-textarea:focus {
  border-color: var(--color-primary);
}

/* ── Modal-Grundgerüst (geteilt: Katalog-Detail, Puzzle-Overlays) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 26, 24, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  overflow-y: auto;
}

/* Klassen-Selektor würde sonst das hidden-Attribut überstimmen. */
.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 100%;
  padding: 2.5rem 3rem;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

.modal-card-sm {
  max-width: 520px;
  padding: 2rem 2.25rem;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--color-text-faint);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.modal-divider {
  border-top: 0.5px solid var(--color-border);
  margin: 1.5rem 0 1.25rem;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border-mid);
  border-radius: 2px;
}

/* ── Utilities ────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.text-muted  { color: var(--color-text-muted); }
.text-faint  { color: var(--color-text-faint); }
.text-small  { font-size: 12px; }
.text-serif  { font-family: var(--font-serif); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── Responsive (geteilt) ─────────────────────────────────── */
@media (max-width: 640px) {
  .card { padding: 1.25rem; }
  .modal-backdrop { padding: 1rem; }
  .modal-card { padding: 1.75rem 1.25rem; }
  .modal-actions { flex-wrap: wrap; }
}
