/* ============================================================
   inTouch API Docs – gemeinsames Stylesheet
   Layout nach dem Vorbild der Cloudflare Developer Docs
   (Top-Bar + feste Sidebar + Content), Akzentfarbe = inTouch-Blau.
   ============================================================ */

:root {
  --bg:            #0a0a0a;
  --bg-elevated:   #121212;
  --surface:       #161616;
  --surface-hover: #1e1e1e;
  --border:        #2a2a2a;
  --border-soft:   #1f1f1f;

  --fg:            #e8e6e3;
  --fg-strong:     #f0ebe3;   /* warmes Off-White für Headlines */
  --muted:         #9a9a9a;
  --muted-dim:     #6e6e6e;

  --accent:        #0084ff;   /* inTouch-Blau */
  --accent-hover:  #339dff;
  --accent-soft:   rgba(0, 132, 255, 0.12);
  --accent-border: rgba(0, 132, 255, 0.35);

  --green:         #34d399;
  --amber:         #fbbf24;
  --red:           #f87171;

  --topbar-h:      60px;
  --sidebar-w:     272px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 24px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================================
   Top-Bar
   ============================================================ */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6bb6ff);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.brand-name { color: var(--fg-strong); font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }

.brand-badge {
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  text-transform: uppercase;
}

.topbar-divider { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; }

.topnav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.topnav a {
  color: var(--muted);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 7px;
  white-space: nowrap;
}
.topnav a:hover { color: var(--fg); background: var(--surface); text-decoration: none; }
.topnav a.active { color: var(--fg-strong); }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

/* Suche */
.search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 230px;
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  cursor: text;
}
.search:focus-within { border-color: var(--accent-border); }
.search svg { flex-shrink: 0; opacity: 0.7; }
.search input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--fg); font-size: 13.5px; font-family: var(--sans);
}
.search input::placeholder { color: var(--muted-dim); }
.kbd {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-elevated);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 6px;
  max-height: 60vh; overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  display: none;
}
.search-results.open { display: block; }
.search-results a {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--fg);
}
.search-results a:hover, .search-results a.sel { background: var(--surface-hover); text-decoration: none; }
.search-results .r-title { font-size: 13.5px; }
.search-results .r-ctx { font-size: 11.5px; color: var(--muted-dim); }
.search-results .r-empty { padding: 14px 10px; color: var(--muted-dim); font-size: 13px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 16px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); width: 34px; height: 34px; cursor: pointer;
  align-items: center; justify-content: center;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  position: fixed;
  top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  padding: 18px 12px 60px;
  overflow-y: auto;
  background: var(--bg);
  z-index: 90;
}

.filter {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 22px;
}
.filter:focus-within { border-color: var(--accent-border); }
.filter input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--fg); font-size: 13.5px; font-family: var(--sans);
}
.filter input::placeholder { color: var(--muted-dim); }

.nav-group { margin-bottom: 26px; }
.nav-group-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: 1.3px;
  color: var(--muted-dim);
  text-transform: uppercase;
  padding: 0 10px;
  margin-bottom: 8px;
}
.nav-group a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
}
.nav-group a:hover { background: var(--surface); color: var(--fg); text-decoration: none; }
.nav-group a.active { background: var(--surface-hover); color: var(--fg-strong); font-weight: 500; }
.nav-group a .nav-icon { width: 15px; text-align: center; opacity: 0.75; flex-shrink: 0; }
.nav-group a.soon { color: var(--muted-dim); cursor: default; pointer-events: none; }
.nav-group a.soon:hover { background: none; }

.nav-empty { padding: 8px 10px; color: var(--muted-dim); font-size: 13px; display: none; }

/* ============================================================
   Content
   ============================================================ */

.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.content { max-width: 900px; padding: 44px 44px 120px; }
.content.wide { max-width: 1180px; }

h1, h2, h3, h4 { color: var(--fg-strong); font-weight: 600; }
h1 { font-size: 2.15rem; line-height: 1.2; margin: 0 0 14px; letter-spacing: -0.5px; }
h2 { font-size: 1.4rem; margin: 52px 0 14px; padding-top: 6px; }
h3 { font-size: 1.08rem; margin: 32px 0 10px; }
h4 {
  font-size: 0.8rem; margin: 22px 0 8px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600;
}
p { margin: 0 0 14px; }
.lead { font-size: 1.06rem; color: var(--muted); max-width: 680px; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }

hr { border: none; border-top: 1px solid var(--border-soft); margin: 44px 0; }

.eyebrow {
  display: inline-block;
  font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

/* Code */
code {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 1.5px 5px; border-radius: 5px;
  font-family: var(--mono); font-size: 0.87em;
  color: var(--fg-strong);
}
pre {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 14px 0;
  font-size: 13px; line-height: 1.6;
}
pre code { background: none; border: none; padding: 0; font-size: 13px; color: var(--fg); }

.copy-btn {
  position: absolute; top: 9px; right: 9px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px; padding: 4px 9px;
  font-size: 11.5px; font-family: var(--sans);
  cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { color: var(--fg); border-color: var(--accent-border); }
.copy-btn.done { color: var(--green); border-color: var(--green); }

/* Endpunkt-Zeile */
.endpoint {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  margin: 12px 0 6px;
  flex-wrap: wrap;
}
.method {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.7px;
  color: #fff; padding: 3px 9px; border-radius: 5px;
}
.method.get  { background: #2563eb; }
.method.post { background: #059669; }
.path { font-family: var(--mono); font-size: 13.5px; color: var(--fg-strong); }
.endpoint .who { margin-left: auto; font-size: 11.5px; color: var(--muted-dim); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }
.req { color: var(--accent); font-weight: 600; }

/* Panels / Callouts */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 16px 0;
}
.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  padding: 13px 16px;
  margin: 16px 0;
  font-size: 13.8px;
}
.note strong { color: var(--fg-strong); }
.note.warn { border-left-color: var(--amber); background: rgba(251,191,36,0.09); }

/* Chips */
.chip {
  display: inline-block;
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 20px;
  margin: 3px 5px 3px 0;
  font-size: 12.5px; color: var(--fg);
  font-family: var(--mono);
}
.badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.4px;
  border-radius: 20px; padding: 2px 9px;
  text-transform: uppercase;
}
.badge.stable { background: rgba(52,211,153,0.14); color: var(--green); }
.badge.soon   { background: var(--surface); color: var(--muted-dim); }

/* ============================================================
   Landing-Page
   ============================================================ */

.hero { padding: 80px 0 64px; }
.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -2px;
  margin-bottom: 22px;
  max-width: 14ch;
}
.hero .lead { font-size: 1.12rem; max-width: 34ch; margin-bottom: 34px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

.btn-hero {
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 26px;
  border-radius: 24px;
  font-size: 15px; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
  cursor: pointer;
}
.btn-hero:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 22px;
  border-radius: 24px;
  font-size: 15px; font-weight: 500;
  background: transparent; color: var(--fg);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--sans);
}
.btn-ghost:hover { border-color: var(--accent-border); color: var(--fg-strong); text-decoration: none; }
.btn-ghost .marks { display: flex; gap: 4px; opacity: 0.85; }
.btn-ghost .marks span {
  width: 18px; height: 18px; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 9px; color: var(--muted);
  font-family: var(--mono);
}

.section-title { font-size: 1.9rem; letter-spacing: -0.8px; margin: 0 0 28px; }

/* Tab-Panel mit Eckmarken (wie im Referenz-Layout) */
.tabpanel { position: relative; border: 1px solid var(--border); border-radius: 2px; }
.tabpanel::before, .tabpanel::after,
.tabpanel > .corner-b::before, .tabpanel > .corner-b::after {
  content: ""; position: absolute;
  width: 5px; height: 5px;
  background: var(--muted-dim);
}
.tabpanel::before { top: -3px; left: -3px; }
.tabpanel::after  { top: -3px; right: -3px; }
.tabpanel > .corner-b::before { bottom: -3px; left: -3px; }
.tabpanel > .corner-b::after  { bottom: -3px; right: -3px; }

.tabbar { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabbar button {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 15px 22px;
  font-size: 14px; font-family: var(--sans);
  cursor: pointer; white-space: nowrap;
  margin-bottom: -1px;
}
.tabbar button:hover { color: var(--fg); }
.tabbar button.active { color: var(--fg-strong); border-bottom-color: var(--accent); }

.tabbody { padding: 34px 34px 30px; display: none; }
.tabbody.active { display: block; }

.tab-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  display: grid; place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}
.tab-head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.tab-head h3 { margin: 0; font-size: 1.22rem; }
.tabbody p { max-width: 720px; color: var(--muted); }

.tab-links { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-top: 22px; }
.tab-links .more { color: var(--muted); font-size: 13.5px; }
.tab-links .more:hover { color: var(--accent); }

.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0 8px;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 20px;
  color: var(--fg);
}
.card:hover { border-color: var(--accent-border); text-decoration: none; background: var(--surface-hover); }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.card .card-icon { font-size: 20px; margin-bottom: 12px; display: block; }

/* Seitenfuß-Navigation */
.pagenav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 64px; padding-top: 26px;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.pagenav a {
  display: block;
  border: 1px solid var(--border); border-radius: 11px;
  padding: 13px 18px; min-width: 190px;
  color: var(--fg);
}
.pagenav a:hover { border-color: var(--accent-border); text-decoration: none; }
.pagenav .dir { display: block; font-size: 11.5px; color: var(--muted-dim); margin-bottom: 2px; }
.pagenav .next { margin-left: auto; text-align: right; }

footer.site {
  border-top: 1px solid var(--border-soft);
  margin-top: 40px; padding-top: 22px;
  color: var(--muted-dim); font-size: 12.5px;
}

/* ============================================================
   Human / Machine — Ansichtsumschalter
   ------------------------------------------------------------
   Die Maschinenfassung jeder Seite liegt als <pre class="machine-doc">
   im HTML und ist per Default aus. Geschaltet wird über
   html.machine-view (NICHT body) — nur so kann das Inline-Snippet
   im <head> die Klasse setzen, bevor der Body existiert; sonst
   blitzt bei gemerkter Auswahl kurz die Human-Ansicht auf.
   Denselben Text gibt es unter <pfad>.txt für Agenten ohne JS.
   ============================================================ */

.machine-doc { display: none; }

html.machine-view .topbar,
html.machine-view .sidebar,
html.machine-view .main > .content { display: none; }

html.machine-view .main { margin-left: 0; padding-top: 0; }

html.machine-view .machine-doc {
  display: block;
  margin: 0 auto;
  max-width: 900px;
  padding: 46px 28px 130px;      /* unten Platz für die Pille */
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);          /* kein Panel-Look: reiner Text auf Seitengrund */
  border: none;
  border-radius: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-x: visible;
  tab-size: 2;
}

/* Der Copy-Button aus initCopyButtons() sitzt auch hier — praktisch,
   damit der ganze Briefing-Text in einem Rutsch in die Zwischenablage geht. */
html.machine-view .machine-doc .copy-btn { top: 46px; right: 28px; }

.viewtoggle {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.viewtoggle button {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: none;
  border-radius: 999px;
  padding: 6px 15px;
  font-family: var(--mono); font-size: 12px;
  color: var(--muted-dim);
  cursor: pointer;
  white-space: nowrap;
}
.viewtoggle button::before {
  content: "●";
  font-size: 8px;
  color: var(--muted-dim);
  line-height: 1;
}
.viewtoggle button:hover { color: var(--muted); }
.viewtoggle button.active {
  background: var(--bg-elevated);
  color: var(--fg-strong);
}
.viewtoggle button.active::before { color: var(--accent); }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1080px) {
  .search { width: 170px; }
  .topnav { display: none; }
}

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.6); }
  .main { margin-left: 0; }
  .content { padding: 30px 20px 90px; }
  .search { display: none; }
  .brand-badge { display: none; }
  .hero { padding: 50px 0 40px; }
  .tabbody { padding: 24px 20px; }

  .viewtoggle { bottom: 14px; }
  .viewtoggle button { padding: 6px 13px; font-size: 11.5px; }
  html.machine-view .machine-doc { padding: 26px 18px 110px; font-size: 12.5px; }
  html.machine-view .machine-doc .copy-btn { top: 26px; right: 18px; }
}
