/* #tutorials – neues Design */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1b2230;
  --muted: #5a6577;
  --border: #dfe3ea;
  --accent: #1d64d8;
  --accent-soft: #e6effd;
  --accent-text: #1553b8;
  --circuit-opacity: .13;
  --code-bg: #0f141b;
  --code-head: #171e27;
  --code-text: #e3e9f0;
  --code-border: #232c38;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 4px 16px rgb(16 24 40 / .06);
  --radius: 12px;
  --topbar-h: 60px;
  --sidebar-w: 280px;
  --toc-w: 240px;
  --content-w: 780px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1217;
    --surface: #151b22;
    --surface-2: #1b232c;
    --text: #dde4ec;
    --muted: #98a4b3;
    --border: #262f3b;
    --accent: #5aa2ff;
    --accent-soft: #16263b;
    --accent-text: #7db6ff;
    --circuit-opacity: .2;
    --code-bg: #0a0e13;
    --code-head: #111820;
    --code-border: #222b36;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1217;
  --surface: #151b22;
  --surface-2: #1b232c;
  --text: #dde4ec;
  --muted: #98a4b3;
  --border: #262f3b;
  --accent: #5aa2ff;
  --accent-soft: #16263b;
  --accent-text: #7db6ff;
  --circuit-opacity: .2;
  --code-bg: #0a0e13;
  --code-head: #111820;
  --code-border: #222b36;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  color-scheme: dark;
}

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

html { scroll-padding-top: calc(var(--topbar-h) + 16px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(1rem, .96rem + .2vw, 1.0625rem);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { top: 10px; }

/* ---------- Kopfzeile ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
  isolation: isolate;
}

/* Dezentes Platinen-Muster: SVG dient als Maske, die Farbe kommt aus --accent (passt in hell und dunkel) */
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--accent);
  opacity: var(--circuit-opacity);
  --circuit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='60' viewBox='0 0 160 60'%3E%3Cg fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M0 12h28l8 8h30M112 20h10l8-8h30M0 40h14l10-10h22l6 6h38M95 36h21l4 4h40M80 0v6l8 8h14M40 0v4.5M40 60v-6l6-6h40M80 60v-4.5'/%3E%3Ccircle cx='68.5' cy='20' r='2.5'/%3E%3Ccircle cx='109.5' cy='20' r='2.5'/%3E%3Ccircle cx='92.5' cy='36' r='2.5'/%3E%3Ccircle cx='104.5' cy='14' r='2.5'/%3E%3Ccircle cx='40' cy='7' r='2.5'/%3E%3Ccircle cx='88.5' cy='48' r='2.5'/%3E%3Ccircle cx='80' cy='53' r='2.5'/%3E%3Crect x='128' y='46' width='20' height='9' rx='1.5'/%3E%3Cpath d='M132 46v-2.5M138 46v-2.5M144 46v-2.5M132 55v2.5M138 55v2.5M144 55v2.5'/%3E%3C/g%3E%3Cg fill='black'%3E%3Ccircle cx='20' cy='52' r='1.6'/%3E%3Ccircle cx='150' cy='26' r='1.6'/%3E%3Ccircle cx='60' cy='6' r='1.6'/%3E%3Ccircle cx='8' cy='26' r='1.6'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask: var(--circuit) 0 0 / 160px 60px repeat, linear-gradient(90deg, rgb(0 0 0 / .45), #000 30%, #000 70%, rgb(0 0 0 / .45));
  -webkit-mask-composite: source-in;
  mask: var(--circuit) 0 0 / 160px 60px repeat, linear-gradient(90deg, rgb(0 0 0 / .45), #000 30%, #000 70%, rgb(0 0 0 / .45));
  mask-composite: intersect;
}

.logo {
  font-family: var(--mono); font-weight: 700; font-size: 1.15rem;
  color: var(--text); text-decoration: none; letter-spacing: -.02em; white-space: nowrap;
}
.logo-hash { color: var(--accent); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

/* Suche */
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input {
  width: 100%; height: 40px;
  padding: 0 40px 0 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .95rem;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { position: absolute; left: 12px; top: 10px; color: var(--muted); pointer-events: none; }
.search kbd {
  position: absolute; right: 10px; top: 9px;
  font: 600 .75rem var(--mono); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: var(--surface-2);
}
.search input:focus ~ kbd { display: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(70vh, 480px); overflow: auto;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-results a {
  display: block; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; line-height: 1.4;
}
.search-results a small { display: block; color: var(--muted); font-size: .8rem; }
.search-results [aria-selected="true"] a, .search-results a:hover { background: var(--accent-soft); }
.search-results .empty { padding: 10px; color: var(--muted); }
.search-results mark { background: none; color: var(--accent-text); font-weight: 600; }
.search-toggle { display: none; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: calc(var(--sidebar-w) + var(--content-w) + var(--toc-w) + 160px);
  margin: 0 auto;
}
@media (min-width: 1240px) {
  .layout:has(.toc) { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); }
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 16px 32px;
  border-right: 1px solid var(--border);
  font-size: .94rem;
}
.sidenav ul, .sidenav-meta { list-style: none; margin: 0; padding: 0; }
.sidenav > ul > li { margin-bottom: 2px; }
.sidenav a, .sidenav summary {
  display: block; padding: 6px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; line-height: 1.4;
}
.sidenav a:hover, .sidenav summary:hover { background: var(--surface-2); }
.sidenav summary {
  cursor: pointer; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
.sidenav summary::-webkit-details-marker { display: none; }
.sidenav summary::after {
  content: ""; width: 7px; height: 7px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
.sidenav details[open] > summary::after { transform: rotate(45deg); }
.sidenav details ul { margin: 2px 0 8px 12px; padding-left: 8px; border-left: 1px solid var(--border); }
.sidenav details a { color: var(--muted); font-size: .9rem; }
.sidenav details a:hover { color: var(--text); }
.sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sidenav > ul > li > a { font-weight: 600; }
.sidenav-meta { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .85rem; }
.sidenav-meta a { display: block; padding: 4px 10px; color: var(--muted); text-decoration: none; }
.sidenav-meta a:hover { color: var(--text); }

.main { min-width: 0; padding: 32px clamp(16px, 4vw, 56px) 64px; }
.prose { max-width: var(--content-w); margin: 0 auto; }
.main > .pager { max-width: var(--content-w); margin-left: auto; margin-right: auto; }

/* Inhaltsverzeichnis */
.toc { display: none; }
@media (min-width: 1240px) {
  .toc {
    display: block; position: sticky; top: var(--topbar-h);
    height: calc(100dvh - var(--topbar-h)); overflow-y: auto;
    padding: 32px 16px 32px 8px; font-size: .85rem;
  }
}
.toc-title { margin: 0 0 8px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a {
  display: block; padding: 4px 12px; margin-left: -1px;
  border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.4;
}
.toc .toc-l3 a { padding-left: 24px; font-size: .8rem; }
.toc a:hover { color: var(--text); }
.toc a.is-active { color: var(--accent-text); border-left-color: var(--accent); }

/* ---------- Typografie ---------- */

.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.25; letter-spacing: -.015em; color: var(--text); }
.prose h1 { font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem); margin: 0 0 .4em; font-weight: 750; }
.prose h2 { font-size: clamp(1.35rem, 1.2rem + .6vw, 1.65rem); margin: 2.2em 0 .6em; padding-top: .2em; }
.prose h3 { font-size: 1.2rem; margin: 1.8em 0 .5em; }
.prose h4 { font-size: 1.05rem; margin: 1.5em 0 .4em; }
.prose h2 + h3 { margin-top: 1em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 650; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }
.prose :not(pre) > code {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere;
}
.prose a { overflow-wrap: anywhere; }

.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0 0 14px; padding: 0; font-size: .85rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 4px; opacity: .6; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent-text); }

.page-head { margin-bottom: 2em; padding-bottom: 1.2em; border-bottom: 1px solid var(--border); }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; font-size: .875rem; color: var(--muted); }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 600; font-size: .8rem;
}

/* Startseite */
.hero { padding: 24px 0 8px; margin-bottom: 8px; }
.eyebrow { margin: 0 0 8px; font: 700 .9rem var(--mono); color: var(--accent-text); }
.hero h1 { font-size: clamp(2rem, 1.5rem + 2.4vw, 3rem); line-height: 1.12; margin-bottom: .35em; }
.lead { font-size: 1.15em; color: var(--muted); margin: 0; max-width: 60ch; }
.main-home .cards-section h2 { margin-top: 1.4em; }

/* Karten */
.cards-section { margin: 2em 0; }
.prose ul.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 14px; list-style: none; padding: 0; margin: 0;
}
.prose .cards li { margin: 0; }
.card a {
  display: flex; flex-direction: column; gap: 6px; height: 100%;
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card a:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-title { font-weight: 650; line-height: 1.35; }
.card-title::after { content: " →"; color: var(--accent); }
.card-desc { font-size: .9rem; color: var(--muted); line-height: 1.5; }
.card-meta { margin-top: auto; padding-top: 4px; font-size: .8rem; font-weight: 600; color: var(--accent-text); }

/* Bilder */
.prose figure { margin: 1.8em 0; }
.prose img {
  display: block; max-width: 100%; height: auto;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow);
}
.prose figure img { cursor: zoom-in; margin: 0 auto; }
.prose figcaption { margin-top: .6em; font-size: .875rem; color: var(--muted); text-align: center; }

/* Tabellen */
.table-wrap { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose thead th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.prose tbody th { background: var(--surface-2); font-weight: 600; }
.prose tbody tr:last-child > * { border-bottom: 0; }
.prose td.bg-red, .prose td.bg-yellow, .prose td.bg-green { border: 2px solid var(--surface); min-width: 64px; height: 44px; }
.bg-red { background: #d64545; color: #fff; }
.bg-yellow { background: #f2c94c; color: #222; }
.bg-green { background: #3aa76d; color: #fff; }

/* Code */
.code {
  margin: 1.4em 0; border-radius: var(--radius); overflow: hidden;
  background: var(--code-bg); border: 1px solid var(--code-border);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 36px; padding: 0 8px 0 14px;
  background: var(--code-head); border-bottom: 1px solid var(--code-border);
  font: 600 .72rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #8b98a8;
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 6px;
  border: 1px solid #2c3746; background: transparent; color: #b8c4d2;
  font: 500 .75rem var(--font); cursor: pointer; text-transform: none; letter-spacing: 0;
}
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn:hover { background: #1f2834; color: #fff; }
.copy-btn.copied { color: #7ee2a8; border-color: #2d6a4a; }
.prose pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  color: var(--code-text); font: .85rem/1.6 var(--mono); tab-size: 4;
  scrollbar-width: thin; scrollbar-color: #334155 transparent;
}
.prose pre code { font: inherit; background: none; border: 0; padding: 0; white-space: pre; }
.code[data-lang="bash"] pre code { color: #e8edf3; }

/* Hinweisboxen (optional im Content verwendbar) – bewusst nur in den Blautönen der Seite */
.note, .warning {
  position: relative;
  margin: 1.6em 0; padding: 12px 16px 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); border-left: 4px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--surface-2);
}
.warning {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.note::before, .warning::before {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
  font: 700 .72rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text);
}
.note::before { content: "ⓘ  Hinweis"; }
.warning::before { content: "⚠  Achtung"; }
.note > :last-child, .warning > :last-child { margin-bottom: 0; }

/* Vor/Zurück */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 3em; }
.pager a {
  display: block; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; line-height: 1.35;
}
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; margin-bottom: 2px; font-weight: 500; font-size: .8rem; color: var(--muted); }
.pager-prev small::before { content: "← "; }
.pager-next { grid-column: 2; text-align: right; }
.pager-next small::after { content: " →"; }

/* Footer */
.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding: 24px clamp(16px, 4vw, 40px); border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--muted);
}
.footer p { margin: 0; }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* Lightbox */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 24px; border: 0; background: transparent; color: #fff;
}
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox::backdrop { background: rgb(8 11 15 / .9); }
.lightbox img { max-width: 100%; max-height: calc(100% - 60px); object-fit: contain; border-radius: 8px; }
.lightbox-caption { margin: 12px 0 0; font-size: .9rem; color: #c6cfda; text-align: center; }
.lightbox-close {
  position: absolute; top: 12px; right: 16px; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgb(255 255 255 / .1); color: #fff;
  font-size: 1.8rem; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgb(255 255 255 / .2); }

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

.nav-toggle { display: none; }
.scrim { display: none; }

@media (max-width: 959px) {
  .nav-toggle { display: inline-grid; margin-left: -6px; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(85vw, 320px); height: 100dvh; padding-top: 20px;
    background: var(--surface); border-right: 1px solid var(--border);
    transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease, visibility 0s .22s;
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; box-shadow: var(--shadow); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); }
  .nav-open { overflow: hidden; }
  .main { padding-top: 24px; }
}

@media (max-width: 719px) {
  .search { display: none; }
  .search-toggle { display: inline-grid; margin-left: auto; }
  .search-open .search {
    display: block; position: absolute; left: 12px; right: 12px; top: 10px; max-width: none; margin: 0;
  }
  .search-open .search kbd { display: none; }
  .search-open .logo, .search-open .nav-toggle { visibility: hidden; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .prose pre { font-size: .8rem; }
  .footer { flex-direction: column; }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .footer, .copy-btn, .skip-link { display: none !important; }
  .layout { display: block; }
  .code { border: 1px solid #ccc; }
  .prose pre { white-space: pre-wrap; color: #000; background: #fff; }
}
