/* ──────────────────────────────────────────────────────────────
   Hilfe / Dokumentation (/hilfe/)

   Loaded only on docs pages, via `extraCss` in layouts/docs.njk.
   Design tokens (--bg, --accent, …) come from global.css — never
   redeclare them here.
   ────────────────────────────────────────────────────────────── */

.docs-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 48px;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 24px 80px;
  align-items: start;
}

/* ── Sidebar ── */
.docs-sidebar {
  position: sticky;
  top: 88px;
  font-size: 14px;
  /* The nav is taller than most viewports. Sticky alone pins it and the page
     scrolls past, so the last categories become unreachable — it needs its own
     scroll box. `contain` stops the page from scrolling on once it bottoms out. */
  max-height: calc(100vh - 88px - 24px);
  max-height: calc(100dvh - 88px - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Keeps the scrollbar off the link labels; the negative margin cancels the
     indent so the group labels stay flush with the content edge. */
  padding-right: 10px;
  margin-right: -10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.docs-sidebar::-webkit-scrollbar { width: 6px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.docs-sidebar:hover::-webkit-scrollbar-thumb { background: #d8d5cf; }

.docs-sidebar-home {
  display: block;
  font-weight: 800;
  color: var(--dark);
  text-decoration: none;
  font-size: 15px;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}
.docs-sidebar-home:hover { color: var(--accent); }

.docs-nav-group { margin-bottom: 22px; }

.docs-nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.docs-sidebar ul { list-style: none; margin: 0; padding: 0; }
.docs-sidebar li { margin: 0; }

.docs-sidebar li a {
  display: block;
  padding: 5px 10px;
  margin-left: -10px;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.45;
  transition: background 0.15s, color 0.15s;
}
.docs-sidebar li a:hover { background: rgba(0, 0, 0, 0.03); color: var(--dark); }
.docs-sidebar li a.is-current {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
}

/* ── Breadcrumb ── */
.docs-breadcrumb {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 20px;
}
.docs-breadcrumb a { color: var(--text-muted); font-weight: 500; text-decoration: none; }
.docs-breadcrumb a:hover { color: var(--accent); }

/* ── Body / prose ── */
.docs-body { max-width: 720px; }

.docs-body h1 {
  font-size: clamp(26px, 3.6vw, 36px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.8px;
  color: var(--dark);
  margin-bottom: 14px;
}

.docs-lead {
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.docs-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-faint);
  padding-bottom: 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.docs-badge {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 999px;
}

/* Plan badge. A reader who lands on a Pro-only page from a search result has no
   other way to know the feature is not in their plan, so it sits next to the
   category badge and is repeated as a banner above the article body. */
.docs-badge-plan {
  background: #fff2d9;
  color: #8a5a00;
}

.docs-plan-banner {
  display: flex;
  gap: 10px;
  align-items: baseline;
  background: #fff8e6;
  border: 1px solid #f5d98a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.docs-plan-banner strong { color: #8a5a00; white-space: nowrap; }

/* Same signal on the index cards, so the plan is visible before the click. */
.docs-card-plan {
  display: inline-block;
  background: #fff2d9;
  color: #8a5a00;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

/* ── Sprunglinks auf Überschriften ──
   Jede h2/h3 bekommt in .eleventy.js eine id und ein "#". Damit lässt sich ein
   einzelner Abschnitt teilen. scroll-margin-top hält das Ziel unter der
   klebenden Navigation (56 px) statt darunter zu verschwinden. */
.docs-body h2,
.docs-body h3 { scroll-margin-top: 76px; }

.docs-anchor {
  margin-left: 8px;
  color: var(--text-faint);
  text-decoration: none;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.docs-body h2:hover .docs-anchor,
.docs-body h3:hover .docs-anchor,
.docs-anchor:focus-visible { opacity: 1; }
.docs-anchor:hover { color: var(--accent); }
.docs-anchor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Touch-Geräte kennen kein Hover — dort bleibt das Zeichen dauerhaft sichtbar,
   nur zurückhaltend. */
@media (hover: none) {
  .docs-anchor { opacity: 0.4; }
}

/* Der angesprungene Abschnitt wird kurz markiert, damit klar ist, wo man
   gelandet ist. */
.docs-body h2:target,
.docs-body h3:target {
  background: var(--accent-light);
  box-shadow: -10px 0 0 var(--accent-light), 10px 0 0 var(--accent-light);
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .docs-anchor { transition: none; }
}

.docs-body h2 {
  font-size: 23px;
  font-weight: 800;
  color: var(--dark);
  margin: 40px 0 14px;
  letter-spacing: -0.4px;
  line-height: 1.25;
}
.docs-body h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
  margin: 30px 0 10px;
  line-height: 1.3;
}
.docs-body h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
  margin: 24px 0 8px;
}

.docs-body p { font-size: 16px; color: var(--text); line-height: 1.75; margin-bottom: 16px; }
.docs-body ul, .docs-body ol {
  margin: 12px 0 20px 22px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
}
.docs-body li { margin-bottom: 7px; }
.docs-body li > ul, .docs-body li > ol { margin-top: 7px; margin-bottom: 0; }
.docs-body strong { color: var(--dark); }
.docs-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.docs-body a:hover { color: var(--accent-dark); }
.docs-body hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }

/* Inline code + blocks — docs need these far more than blog posts do. */
.docs-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.045);
  color: var(--dark);
  padding: 2px 6px;
  border-radius: 5px;
  word-break: break-word;
}
.docs-body pre {
  background: var(--dark);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 13.5px;
  line-height: 1.6;
}
.docs-body pre code {
  background: none;
  color: #e6e6e6;
  padding: 0;
  font-size: inherit;
}

.docs-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 14px 20px;
  margin: 22px 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.docs-body blockquote p { margin: 0; color: var(--dark); }
.docs-body blockquote p + p { margin-top: 10px; }

.docs-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 15px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.docs-body thead { background: var(--dark); }
.docs-body thead th {
  color: var(--white);
  font-weight: 700;
  padding: 12px 15px;
  text-align: left;
  font-size: 14px;
}
.docs-body tbody tr { border-bottom: 1px solid var(--border); background: var(--white); }
.docs-body tbody tr:nth-child(even) { background: var(--bg); }
.docs-body tbody td { padding: 11px 15px; vertical-align: top; }
.docs-body tbody td:first-child { font-weight: 600; color: var(--dark); }
/* The first column of a reference table holds identifiers (ORDER_CREATED,
   payload.order.isTest). The global `word-break: break-word` on inline code
   splits them mid-word — "ORDER_CREA / TED" — which is unreadable and looks
   like two different values. Keeping them unbreakable also makes the table
   layout reserve a wide enough first column instead of squeezing it. */
.docs-body tbody td:first-child code { word-break: normal; }

.docs-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* ── Callouts (authored as blockquotes starting with **Achtung**/**Hinweis**) ── */
.docs-note, .docs-warn {
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 22px 0;
  font-size: 15px;
  line-height: 1.7;
}
.docs-note { background: var(--accent-light); border: 1px solid rgba(58, 168, 157, 0.2); }
.docs-warn { background: #fff8e6; border: 1px solid #f5d98a; }
.docs-note p:last-child, .docs-warn p:last-child { margin-bottom: 0; }

/* ── FAQ (reuses the global accordion behaviour in scripts.js) ── */
.docs-faq { margin: 44px 0 0; }
.docs-faq h2 { margin-bottom: 16px; }

/* ── Related / AI note / CTA ── */
.docs-related { margin-top: 44px; }
.docs-related h2 { font-size: 19px; margin-bottom: 12px; }
.docs-related ul { margin-left: 20px; }

.docs-ai-note {
  margin-top: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  font-size: 14px;
}
.docs-ai-note strong { display: block; color: var(--dark); margin-bottom: 6px; font-size: 13px; }
.docs-ai-note p { font-size: 14px; color: var(--text-muted); line-height: 1.65; margin: 0; }
.docs-ai-note code { font-size: 13px; }

.docs-help-cta {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.docs-help-cta p { font-size: 14px; color: var(--text-muted); margin: 0; }

/* ── Index page (/hilfe/) ── */
.docs-index-hero { max-width: 720px; }
.docs-index-hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--dark);
  margin-bottom: 14px;
  line-height: 1.15;
}
.docs-index-hero .docs-lead { margin-bottom: 32px; }

.docs-cat { margin-bottom: 40px; }
.docs-cat-head { margin-bottom: 14px; }
.docs-cat-head h2 { font-size: 20px; font-weight: 800; color: var(--dark); margin-bottom: 4px; }
.docs-cat-head p { font-size: 14px; color: var(--text-muted); margin: 0; }

.docs-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.docs-card {
  display: block;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.docs-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
  border-color: rgba(58, 168, 157, 0.35);
}
.docs-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 5px;
  line-height: 1.35;
}
.docs-card p { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; margin: 0; }

/* ── Responsive ── */
@media (max-width: 1023px) {
  /* minmax(0, …), nicht 1fr: eine Grid-Spalte ist sonst mindestens so breit
     wie ihr breitester Inhalt, und die Suchzeile schiebt die Seite auf dem
     Telefon seitlich auf. */
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 24px; }
  .docs-sidebar {
    position: static;
    top: auto;
    /* Full height in the flow — the scroll box above is a desktop-only fix. */
    max-height: none;
    overflow: visible;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    margin-right: 0;
    background: var(--white);
  }
  .docs-nav-group { margin-bottom: 16px; }
  .docs-nav-group:last-child { margin-bottom: 0; }
}

@media (max-width: 767px) {
  .docs-shell { padding: 20px 20px 56px; }
  .docs-card-grid { grid-template-columns: 1fr; }
  .docs-body table { font-size: 14px; }
  .docs-body thead th, .docs-body tbody td { padding: 10px 12px; }
  .docs-body pre { margin-left: -20px; margin-right: -20px; border-radius: 0; }
}

/* ── Screenshots ──
   Authored as plain Markdown (![alt](src "caption")); .eleventy.js turns a
   lone-image paragraph into <figure class="docs-fig"> + <figcaption> and adds
   the intrinsic width/height. The frame keeps a light-UI screenshot from
   bleeding into the page background. */
.docs-fig {
  margin: 26px 0 30px;
}
.docs-fig img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.05), 0 8px 24px rgba(26, 26, 26, 0.05);
}
.docs-fig figcaption {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}
/* Kleine Detailaufnahmen (ein einzelner Schalter, ein Feld) rendern in ihrer
   echten Bildschirmgröße statt über die Textspalte gezogen — sonst werden sie
   unscharf. Die konkrete Breite setzt .eleventy.js inline auf das <figure>,
   weil sie aus den Bildmaßen kommt; die Bildunterschrift folgt ihr dadurch. */
.docs-fig-detail img {
  width: 100%;
}

/* Tall, narrow captures (e.g. the full dashboard sidebar) render near their
   real on-screen size rather than stretched across the text column. */
.docs-fig-tall img {
  max-width: 300px;
}

@media (max-width: 720px) {
  .docs-fig { margin: 20px 0 24px; }
  .docs-fig-tall img { max-width: 240px; }
}

/* ──────────────────────────────────────────────────────────────
   Suche (/hilfe/)

   Ein Auslöser im Seitenmenü (und größer im Kopf der Hilfe-
   Startseite) öffnet eine Overlay-Suche über die gesamte
   Dokumentation. Markup: src/_includes/docs-search.njk,
   Verhalten: /assets/js/docs-search.js.
   ────────────────────────────────────────────────────────────── */

/* ── Auslöser ── */
.docs-search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin: 0 0 24px;
  padding: 9px 10px 9px 11px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-faint);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.docs-search-trigger:hover {
  border-color: rgba(58, 168, 157, 0.5);
  color: var(--text-muted);
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.05);
}
.docs-search-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.docs-search-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-search-icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--accent);
}

.docs-search-kbd {
  flex: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  line-height: 1.4;
}

/* Große Variante im Kopf der Hilfe-Startseite: dort ist die Suche der
   erste Weg in die Dokumentation, nicht ein Werkzeug am Rand. */
.docs-search-trigger-hero {
  margin: 0 0 32px;
  padding: 15px 16px 15px 18px;
  border-radius: var(--radius-sm);
  font-size: 15.5px;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.04), 0 10px 30px rgba(26, 26, 26, 0.05);
}
.docs-search-trigger-hero .docs-search-icon { width: 20px; height: 20px; }
.docs-search-trigger-hero .docs-search-kbd { font-size: 12px; padding: 3px 8px; }

/* ── Overlay ── */
.docs-search-overlay {
  position: fixed;
  inset: 0;
  /* Über dem Cookie-Banner (9998), sonst steht der Hinweis über einem
     Dialog, den der Besucher gerade selbst geöffnet hat. */
  z-index: 9999;
  background: rgba(26, 26, 26, 0.42);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 20px 20px;
  opacity: 0;
  transition: opacity 0.14s ease;
}
.docs-search-overlay.is-open { opacity: 1; }
.docs-search-overlay[hidden] { display: none; }

body.docs-search-open { overflow: hidden; }

.docs-search-panel {
  width: 100%;
  max-width: 620px;
  max-height: 76vh;
  max-height: 76dvh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(26, 26, 26, 0.28);
  overflow: hidden;
  transform: translateY(-6px);
  transition: transform 0.16s ease;
}
.docs-search-overlay.is-open .docs-search-panel { transform: translateY(0); }

/* ── Eingabefeld ── */
.docs-search-field {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}
.docs-search-field .docs-search-icon { width: 19px; height: 19px; }

.docs-search-field input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 17px;
  color: var(--dark);
  padding: 0;
}
.docs-search-field input::placeholder { color: var(--text-faint); }

.docs-search-esc {
  flex: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 7px;
  cursor: pointer;
}
.docs-search-esc:hover { color: var(--text-muted); border-color: #d8d5cf; }

/* ── Trefferliste ── */
.docs-search-results {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  flex: 1;
  min-height: 90px;
}

.docs-search-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-weight: 700;
  color: var(--text-faint);
  padding: 8px 10px 6px;
}

.docs-search-hit {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid transparent;
}
.docs-search-hit.is-active {
  background: var(--accent-light);
  border-color: rgba(58, 168, 157, 0.25);
}

.docs-search-hit-crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.docs-search-hit-plan {
  background: #fff2d9;
  color: #8a5a00;
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 999px;
}

.docs-search-hit-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.35;
  margin-bottom: 3px;
}

.docs-search-hit-snip {
  display: block;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  /* Zwei Zeilen reichen, um einen Treffer einzuordnen; mehr macht aus der
     Liste eine Textwand, durch die man wieder suchen muss. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.docs-search-hit mark {
  background: rgba(58, 168, 157, 0.22);
  color: inherit;
  font-weight: 700;
  border-radius: 2px;
  padding: 0 1px;
}

.docs-search-empty {
  padding: 26px 14px 30px;
  text-align: center;
}
.docs-search-empty p { font-size: 14.5px; color: var(--text); margin: 0; }
.docs-search-empty strong { color: var(--dark); }
.docs-search-empty-hint {
  margin-top: 6px !important;
  font-size: 13.5px !important;
  color: var(--text-muted) !important;
}
.docs-search-empty a { color: var(--accent); }

/* ── Fußzeile ── */
.docs-search-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 11.5px;
  color: var(--text-faint);
}
.docs-search-foot kbd {
  font-family: inherit;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 3px;
  font-size: 10.5px;
}
.docs-search-foot-end { margin-left: auto; }
.docs-search-foot-end a { color: var(--accent); text-decoration: none; }
.docs-search-foot-end a:hover { text-decoration: underline; }

@media (max-width: 767px) {
  .docs-search-overlay { padding: 0; }
  .docs-search-panel {
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }
  .docs-search-trigger-hero { font-size: 14.5px; padding: 13px 14px; }
  /* Kein Tastenkürzel ohne Tastatur. */
  .docs-search-kbd { display: none; }
  /* Auf dem Telefon ist der Platz in der Fußzeile für Tastenkürzel zu
     schade — dort zählt nur der Weg zum Support. */
  .docs-search-foot span:not(.docs-search-foot-end) { display: none; }
  .docs-search-foot-end { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .docs-search-overlay,
  .docs-search-panel { transition: none; }
}
