/* Hülle der PWA: Grundlayout, Kopfleiste, Navigation, Knöpfe, leere Zustände.
   Inhaltsansichten (Timeline, Suche, Submit) bringen ihr eigenes CSS mit. */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  /* Schutz gegen waagerechtes Scrollen der Seite auch bei 360px */
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Sprungmarke für Tastatur und Screenreader */
.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 20;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
}
.skip-link:focus { top: var(--s-2); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- Kopfleiste */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-4) var(--s-7);
  background: #0D0D12;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 0 0 auto;
  min-height: var(--tap);
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  background: var(--brand);
  border-radius: 9px;
}
.brand__mark svg { display: block; }

.brand__name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Navigation als Pillen */
.app-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.app-nav__list {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
  /* Die Navigation darf waagerecht scrollen, die Seite nicht. */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.app-nav__list::-webkit-scrollbar { display: none; }

.nav-pill {
  display: inline-flex;
  align-items: center;
  /* Innenabstand wie vorgegeben; min-height hebt das Ziel auf 44px (SPEC: Touch >= 44px) */
  padding: 7px 13px;
  min-height: var(--tap);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-pill:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav-pill[aria-current="page"] {
  background: var(--surface-3);
  color: var(--text);
}

/* Suchfeld und Avatar */
.header-tools {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}

.header-search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 320px;
}

.header-search input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--s-3);
  background: #141420;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
}
.header-search input::placeholder { color: var(--text-muted); }

/* Anmeldezustand rechts in der Kopfleiste */
.header-auth { display: flex; align-items: center; flex: 0 0 auto; }

.header-signin {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--s-3);
  min-height: var(--tap);
  border-radius: var(--r-sm);
  color: var(--link);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.header-signin:hover { background: var(--surface-2); text-decoration: none; }

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: var(--brand-weak);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 13px;
}

/* ------------------------------------------------------------------- Inhalt */

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--s-7);
}

.view__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-4);
  margin-bottom: var(--s-6);
}

.view__head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* Die Überschrift bekommt beim Routenwechsel den Fokus, ohne sichtbaren Ring. */
.view__title:focus { outline: none; }

/* Leerer Zustand — Platzhalter bis die Inhaltsansichten kommen */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  text-align: center;
}

.empty-state__title {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 17px;
}

.empty-state__text {
  margin: 0;
  max-width: 46ch;
  color: var(--text-muted);
  font-size: 14px;
}

/* -------------------------------------------------------------------- Knöpfe */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 11px 18px;
  min-height: var(--tap);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--brand);
  color: #FFFFFF;
}
.btn--primary:hover { background: #6D2EDB; }

.btn--secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--secondary:hover { background: var(--surface-3); }

/* ---------------------------------------------------------- Zustandsmarker */
/* Farbvertrag mit Punkt UND Text — Zustand nie allein über Farbe. */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text);
}
.badge__dot {
  width: 9px; height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
}
.badge--ok     .badge__dot { background: var(--ok); }
.badge--manual .badge__dot { background: var(--manual); }
.badge--ai     .badge__dot { background: var(--ai); }
.badge--gap    .badge__dot { background: var(--gap-hatch); border-radius: 2px; }

/* -------------------------------------------------------------------- Mobil */

@media (max-width: 760px) {
  .app-header {
    /* Umbruch: Marke + Avatar in Zeile 1, Navigation in Zeile 2, Suche in Zeile 3 */
    flex-wrap: wrap;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
  }
  .brand { order: 1; }
  .header-auth { order: 2; margin-left: auto; }
  .app-nav { order: 3; flex: 1 1 100%; }
  .header-tools {
    order: 4;
    flex: 1 1 100%;
    margin-left: 0;
  }
  .header-search { max-width: none; }
  .app-main { padding: var(--s-5) var(--s-4); }
  h1 { font-size: 22px; }
  .empty-state { padding: var(--s-6) var(--s-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
