/* obdexer — design tokens, layout, components */

:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #0b1117;
  --panel2: #0f1720;
  --line: #1c2a36;
  --muted: #a8bccc;        /* aufgehellt für Kontrast (war #8da2b2) */
  --text: #eef7ff;
  --text2: #d2e1ed;        /* aufgehellt (war #bdd0de) */
  --accent: #0ea5e9;
  --accent2: #22d3ee;
  --warn: #f59e0b;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 18px 48px rgba(0, 0, 0, .34);
  --radius: 14px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(34, 211, 238, .55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: linear-gradient(180deg, #07111a 0%, #05070a 44%, #040506 100%);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

/* Globaler Focus-Ring — sichtbar nur bei Tastatur-Navigation.
 * Outline wird nur dann unterdrückt, wenn das Element NICHT per Tastatur fokussiert
 * wurde (Maus-Klick → :focus, aber nicht :focus-visible). So bleibt der Tastatur-
 * Fokusring auch in Browsern erhalten, die :focus-visible nicht voll unterstützen. */
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

/* Skip-Link für Tastatur-User */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #00111a;
  padding: 12px 18px;
  font-weight: 800;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 1000;
}
.skip-link:focus {
  left: 0;
  outline: 3px solid var(--accent2);
  outline-offset: -3px;
}

/* Visually hidden — nur für Screenreader sichtbar (aria-live Mitteilungen) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

/* Hero / Topbar */
.hero { padding: 20px 0 26px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(34, 211, 238, .42);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(14, 165, 233, .22), rgba(15, 23, 32, .9));
  font-weight: 900;
  letter-spacing: -.07em;
  text-transform: uppercase;
  font-size: 1.05rem;
}
.brand strong { display: block; font-size: 1.08rem; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); font-size: .78rem; }

/* Sprach-Switch in der Topbar */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 7, 10, .55);
}
.lang-switch .lang-icon {
  font-size: .95rem;
  margin-right: 2px;
  opacity: .8;
}
.lang-switch .lang-option {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.lang-switch .lang-option:hover {
  color: var(--text);
  background: rgba(34, 211, 238, .1);
}
.lang-switch .lang-option.active {
  background: rgba(34, 211, 238, .22);
  color: var(--text);
  cursor: default;
}
.lang-switch .lang-option:focus-visible {
  outline: 2px solid var(--focus, #22d3ee);
  outline-offset: 2px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

/* Reset-Button im Search-Row */
.reset-btn {
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, .55);
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: border-color .15s, color .15s;
}
.reset-btn:hover { border-color: var(--accent); color: white; }
.reset-btn[hidden] { display: none; }

.hero-copy, .hero-panel, .sidebar, .detail, .guide, .footer, .legal-card {
  border: 1px solid var(--line);
  background: rgba(11, 17, 23, .84);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 54px);
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent2);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: .78rem;
}
/* Hero-Headline ist je nach Kontext h1 (Startseite) oder p (Detail-Seite, weil
   dort der Code-H1 zentral ist) — visuell aber IMMER gleich. Selector deckt
   beide Tags ab. */
.hero h1, .hero .hero-headline {
  margin: 0;
  max-width: 980px;
  font-size: clamp(2.25rem, 5.8vw, 6rem);
  font-weight: 900;
  line-height: .93;
  letter-spacing: -.07em;
  color: var(--text);
  /* Browser-Auto-Hyphens deaktiviert, nur explicit &shy; bricht — schöner Mobile-Wrap */
  hyphens: manual;
  word-break: normal;
  overflow-wrap: break-word;
}
.hero .hero-count {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}
.lead {
  max-width: 760px;
  color: var(--text2);
  font-size: 1.07rem;
  margin: 24px 0 0;
}

/* Search-Card */
.search-card {
  margin-top: 30px;
  padding: 16px;
  border: 1px solid rgba(34, 211, 238, .22);
  border-radius: var(--radius);
  background: rgba(5, 7, 10, .5);
}
.search-card label {
  display: block;
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: 9px;
}
.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}
.search-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: #020405;
  color: white;
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 1.22rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: 0;
}
.search-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .16);
}
.search-row button {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #00111a;
  border-radius: var(--radius-sm);
  padding: 0 24px;
  font-weight: 900;
  cursor: pointer;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}
.quick-links button, .chip, .pill {
  border: 1px solid var(--line);
  background: rgba(15, 23, 32, .9);
  color: var(--text2);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: .84rem;
}
/* Pills sind nur dekorativ (Spans), Buttons müssen Touch-Target erfüllen.
 * WCAG 2.5.5 verlangt min. 44×44 px für interaktive Elemente. */
.quick-links button, .chip {
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.quick-links button:hover, .chip:hover, .chip.active, .chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: white;
  background: rgba(14, 165, 233, .16);
}

/* Hero panel (Status + Stats) */
.hero-panel {
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 390px;
}
.status-light {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text2);
}
.status-light span {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--warn);
  box-shadow: 0 0 20px var(--warn);
}
.status-light.ready span {
  background: var(--ok);
  box-shadow: 0 0 20px var(--ok);
}
.status-light.error span {
  background: var(--danger);
  box-shadow: 0 0 20px var(--danger);
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.refresh-btn {
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, .5);
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.refresh-btn:hover {
  border-color: var(--accent);
  color: white;
}

.stats {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}
.stats div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(5, 7, 10, .42);
}
.stats dt {
  font-size: .76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.stats dd {
  margin: 4px 0 0;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Kilometerzähler-Animation für die Stats-Werte (übernommen aus singular.brosemedien.de).
   Jede Ziffer sitzt in einem .digit-slot mit overflow:hidden; bei Wert-Änderung
   slidet die alte Ziffer raus und die neue rein. */
.digit-slot {
  display: inline-block;
  overflow: hidden;
  height: 1em;
  position: relative;
  vertical-align: top;
  /* kein min-width — sonst werden Tausender-Punkte zu breit ("9. 533") */
}
.digit-slot .d-old,
.digit-slot .d-new,
.digit-slot .d-static {
  display: block;
  line-height: 1;
}
.digit-slot .d-old {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transition: transform .45s cubic-bezier(.22, .61, .36, 1);
}
.digit-slot .d-new {
  transition: transform .45s cubic-bezier(.22, .61, .36, 1);
}
@media (prefers-reduced-motion: reduce) {
  .digit-slot .d-old, .digit-slot .d-new { transition: none; }
}
.hero-panel p {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
}

/* App-Layout — Detail steht im DOM VOR der Sidebar (Mobile zeigt Detail direkt unter
 * dem Suchfeld). Auf Desktop sortiert grid-template-areas die Sidebar wieder nach links. */
.app-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-areas: "sidebar detail";
  gap: 18px;
  align-items: start;
}
.app-layout > .sidebar { grid-area: sidebar; }
.app-layout > .detail { grid-area: detail; }

.sidebar, .detail {
  border-radius: var(--radius);
  padding: 16px;
}
.sidebar {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.filters {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}
.filter-title, .section-head {
  font-weight: 800;
  color: white;
}
.chip-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}
.chip-row .chip {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 7px 2px;
  font-size: .82rem;
  min-width: 0;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  background: #020405;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px;
  outline: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; font-size: 1rem; }
.section-head span { color: var(--muted); }

.results { display: grid; gap: 9px; }
.result-card {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(15, 23, 32, .78);
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}
.result-card:hover, .result-card.active, .result-card[aria-current="true"] {
  border-color: var(--accent);
  background: rgba(14, 165, 233, .14);
}
.result-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.18rem;
  font-weight: 900;
  color: white;
}
.result-title { color: var(--text2); font-size: .92rem; }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.result-meta span {
  border: 1px solid rgba(141, 162, 178, .35);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--muted);
  font-size: .72rem;
}

/* Detail */
.detail { min-height: 620px; }
.empty-state {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 240px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state strong { color: white; font-size: 1.2rem; }

.code-detail { display: grid; gap: 20px; }
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.code-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}
.code-title {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: .86;
  letter-spacing: -.09em;
}
/* Programmatic focus (tabindex=-1) soll keinen sichtbaren Ring zeigen — der Titel
 * ist nur Sprung-Ziel für Screenreader/Tastatur, nicht interaktiv. */
.code-title:focus { outline: none; }
.code-title:focus-visible { outline: none; box-shadow: none; }
.code-subtitle {
  margin: 14px 0 0;
  max-width: 850px;
  color: var(--text2);
  font-size: clamp(1.1rem, 2vw, 1.55rem);
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}
.copy-link, .pdf-btn {
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, .5);
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
  font: inherit;
  transition: border-color .15s, color .15s, background .15s;
}
.copy-link:hover, .pdf-btn:hover { border-color: var(--accent); color: white; }
.pdf-btn:disabled { opacity: .55; cursor: progress; }
.pdf-btn::before {
  content: "↓";
  display: inline-block;
  margin-right: 5px;
  font-weight: 700;
}

/* Likelihood-Badges für Mögliche Ursachen */
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 9px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
  vertical-align: 2px;
  white-space: nowrap;
}
/* Likelihood-Logik: hoch = wahrscheinlichste Ursache = klarer Hinweis = grün
                       low  = unwahrscheinlich, eher Randverdacht = rot */
.badge-high {
  background: rgba(34, 197, 94, .14);
  color: #86efac;
  border-color: rgba(34, 197, 94, .38);
}
.badge-medium {
  background: rgba(245, 158, 11, .16);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, .42);
}
.badge-low {
  background: rgba(244, 63, 94, .18);
  color: #fda4af;
  border-color: rgba(244, 63, 94, .42);
}

.description { color: var(--text2); margin: 0; line-height: 1.65; }

.meaning-grid, .content-grid, .guide-grid { display: grid; gap: 12px; }
.meaning-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.meaning-card, .info-card, .guide-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(5, 7, 10, .42);
  padding: 15px;
}
.meaning-card span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .09em;
}
.meaning-card b { display: block; margin-top: 5px; font-size: 1.02rem; }

.content-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.info-card h3 { margin: 0 0 12px; font-size: 1rem; }
.info-card ul { margin: 0; padding-left: 18px; color: var(--text2); }
.info-card li + li { margin-top: 8px; }

/* Layout-Schutz: ohne min-width:0 würde ein langer <pre>-Inhalt
   (lange Quellen-URLs in den Rohdaten) den Grid-Track aufweiten und alle
   anderen Felder nach rechts schieben. */
.code-detail, .info-card, .raw-card { min-width: 0; max-width: 100%; }
.raw-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(5, 7, 10, .5);
  padding: 14px;
  overflow: hidden;
}
.raw-card summary { cursor: pointer; color: var(--muted); }
.raw-card pre, pre {
  max-height: 420px;
  max-width: 100%;
  overflow: auto;
  color: #b6d8ea;
  margin: 0;
}

/* Guide */
.guide {
  margin: 18px 0;
  border-radius: var(--radius);
  padding: 22px;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
}
.guide h2 { margin: 0 0 10px; }
.guide p { margin: 0; color: var(--text2); }
.guide-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.guide-grid b { display: block; font-size: 2rem; line-height: 1; color: white; }
.guide-grid span { display: block; color: var(--text2); margin-top: 8px; }

/* Footer */
.footer {
  margin: 18px 0 28px;
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: .92rem;
}
.footer nav { display: flex; flex-wrap: wrap; gap: 14px; }
.footer a:hover { color: white; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  border: 1px solid var(--line);
  background: #08111a;
  color: white;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

/* Legal pages */
.legal-page { padding-top: 20px; }
.legal-card {
  border-radius: var(--radius);
  padding: clamp(22px, 5vw, 52px);
  max-width: 920px;
  margin: 0 auto;
}
.legal-card h1 { margin: 0 0 18px; font-size: clamp(2rem, 5vw, 4rem); letter-spacing: -.06em; }
.legal-card h2 { margin-top: 28px; }
.legal-card p { color: var(--text2); }
.legal-card ul { color: var(--text2); }
.legal-card a { color: var(--accent2); text-decoration: underline; }
.legal-placeholder {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: rgba(5, 7, 10, .42);
  margin: 18px 0;
}

/* Responsive */
@media (max-width: 1060px) {
  .hero-grid, .app-layout, .guide { grid-template-columns: 1fr; }
  /* Auf Mobile DOM-Reihenfolge: Detail zuerst (direkt unter Suchfeld), dann Sidebar */
  .app-layout { grid-template-areas: "detail" "sidebar"; }
  .sidebar { position: static; max-height: none; }

  /* Hero-Panel auf Mobile kompakt: Stats + Status + Reload kommen in einer schmalen
   * Leiste daher, damit der Detail-Block direkt unter dem Suchfeld sichtbar ist und
   * nicht erst eine halbe Bildschirmhöhe weiter unten. */
  .hero-panel {
    min-height: 0;
    padding: 14px 16px;
    gap: 10px;
  }
  .status-row { margin: 0; }
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
  }
  .stats div {
    padding: 8px 10px;
    background: transparent;
    border: 0;
  }
  .stats dt { font-size: .68rem; }
  .stats dd { font-size: 1.1rem; margin: 2px 0 0; letter-spacing: -.02em; }
  .hero-panel p#buildInfo {
    font-size: .72rem;
    margin: 0;
    opacity: .7;
  }
  /* Auf Mobile: Detail-Block nicht künstlich aufblasen — die feste min-height ist
   * für Desktop gedacht, damit die rechte Spalte beim Empty-State nicht zusammenfällt. */
  .detail { min-height: 0; }

  .meaning-grid, .content-grid, .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 660px) {
  .shell { width: min(100% - 20px, 1480px); }
  .hero { padding-top: 12px; }
  .hero-copy, .hero-panel, .sidebar, .detail, .guide, .legal-card { padding: 16px; }
  .search-row { grid-template-columns: 1fr; }
  .search-row button { height: 48px; }
  /* Mobile: dichter packen, weniger Whitespace zwischen Suchfeld und Detail */
  .hero-grid { gap: 12px; }
  .app-layout { gap: 12px; }
  .lead { font-size: 1rem; margin: 14px 0 0; }
  .search-card { margin-top: 18px; }
  .meaning-grid, .content-grid, .guide-grid { grid-template-columns: 1fr; }
  .detail-head { display: grid; }
  .footer { align-items: flex-start; flex-direction: column; }
  .code-title { font-size: 3.7rem; }
  /* Mobile: Sprach-Switch kompakter */
  .topbar { gap: 12px; flex-wrap: wrap; }
  .lang-switch { padding: 3px 6px; }
  .lang-switch .lang-option { padding: 4px 9px; font-size: .78rem; }
  .lang-switch .lang-icon { display: none; }
  /* Familien-Chips bleiben auch mobil alle 8 in einer Reihe — gewünschtes UX */
  .chip-row .chip { padding: 7px 1px; font-size: .76rem; }
}

/* Bevorzugung „reduzierte Bewegung" respektieren */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
