/* ---------- Farben (hell / dunkel) ----------
   Farben angelehnt an die Claude-Oberfläche (Hintergrund hell #fcfcfb, dunkel #151515).
   Standard folgt der Systemeinstellung. Der Umschalter unten rechts setzt
   data-theme="light" oder "dark" auf <html> und überschreibt sie. */
:root {
  color-scheme: light dark;
  --bg: #fcfcfb;
  --text: #1a1a1a;
  --muted: #6b6a66;
  --border: #e7e6e2;
  --accent: #1a1a1a;
  --tag-bg: #f1f0ed;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151515;
    --text: #e5e3de;
    --muted: #9e9c97;
    --border: #2b2b2a;
    --accent: #e5e3de;
    --tag-bg: #222221;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515;
  --text: #e5e3de;
  --muted: #9e9c97;
  --border: #2b2b2a;
  --accent: #e5e3de;
  --tag-bg: #222221;
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- Grundlayout ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}
main {
  position: relative;
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 20px 40px;
}
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
a:hover { text-decoration-color: var(--accent); }

/* ---------- Kopfbereich ---------- */
.header { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 28px; }
/* Namensblock füllt die Zeile und bricht nie unter das Profilbild; nur der PDF-Button darf umbrechen */
.header > div { flex: 1 1 0; min-width: 0; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--tag-bg); flex-shrink: 0; }
.header h1 { font-size: 22px; margin: 0; line-height: 1.2; }
.header .meta { color: var(--muted); font-size: 14px; }
.header .meta a { color: var(--muted); }
.back { display: inline-block; margin-bottom: 28px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }

/* ---------- Abschnitte ---------- */
section { margin-top: 44px; }
h2 { font-size: 16px; margin: 0 0 16px; }
h3 { font-size: 15px; margin: 24px 0 4px; }
.bullets { margin: 0 0 14px; padding-left: 20px; }
.bullets li { margin: 2px 0; }
p { margin: 0 0 14px; }

/* ---------- Listen (Publikationen, Blog, CV) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  padding: 14px 0; border-top: 1px solid var(--border);
  /* Zwei Spalten: Text links, Jahreszahl rechts. Text läuft nie unter die Jahreszahl. */
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px;
}
.item:last-child { border-bottom: 1px solid var(--border); }
.item-head { display: contents; }
.item-title { font-weight: 600; margin: 0; font-size: 15px; grid-column: 1; align-self: baseline; }
.item-year { color: var(--muted); font-size: 13px; white-space: nowrap; grid-column: 2; grid-row: 1; align-self: baseline; }
.item-sub { color: var(--muted); font-size: 14px; margin: 2px 0 0; grid-column: 1; }
.item > .tags, .item > p { grid-column: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 12px; padding: 1px 7px; border-radius: 6px; border: 1px solid transparent;
  background: var(--tag-bg); color: var(--text); text-decoration: none;
}
/* Klickbare Tags (Code, Demo, PDF): Rahmen und Pfeil, reine Info-Tags (Python …) ohne */
a.tag { border-color: var(--border); }
a.tag::after { content: "↗"; margin-left: 3px; color: var(--muted); }
a.tag:hover { border-color: var(--accent); }
a.tag:hover::after { color: var(--text); }

/* Blog-Einträge als ganze Zeile klickbar */
a.item { text-decoration: none; color: inherit; }
a.item:hover .item-title { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Social-Links ---------- */
.socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.socials a {
  font-size: 14px; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 999px; text-decoration: none;
}
.socials a:hover { border-color: var(--accent); }

/* ---------- Blogartikel ---------- */
article h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
article .date { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
article h2 { font-size: 18px; margin-top: 32px; }
article img { max-width: 100%; border-radius: 8px; }
article pre { background: var(--tag-bg); padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
article code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
/* Formeln (KaTeX): breite Block-Formeln horizontal scrollbar statt über den Rand */
article .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
article blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 3px solid var(--border); color: var(--muted); }

/* Vorheriger / nächster Beitrag */
.post-nav {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border);
}
.post-nav a { display: flex; flex-direction: column; max-width: 48%; font-weight: 600; text-decoration: none; }
.post-nav a:hover { text-decoration: underline; text-underline-offset: 3px; }
.post-nav span { color: var(--muted); font-size: 13px; font-weight: 400; }
.post-nav .next { margin-left: auto; text-align: right; }
@media (max-width: 520px) { .post-nav a { max-width: 100%; } }

/* Projekt-Icons vor dem Titel */
.item-icon { width: 40px; height: 40px; border-radius: 50%; vertical-align: middle; margin-right: 10px; }

/* ---------- Sprachumschalter oben rechts ---------- */
.lang { position: absolute; top: 16px; right: 20px; font-size: 13px; color: var(--muted); }
.lang a, .lang span { display: inline-block; padding: 6px 4px; }
.lang a { color: var(--muted); text-decoration: none; }
.lang a:hover { color: var(--text); }
.lang [aria-current] { color: var(--text); font-weight: 600; }

/* ---------- Menü oben links (Start/Home, CV, Tools, Blog), gleiche Optik wie .lang ---------- */
.nav { position: absolute; top: 16px; left: 20px; display: flex; gap: 10px; font-size: 13px; }
.nav a { display: inline-block; padding: 6px 4px; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }
.nav [aria-current] { color: var(--text); font-weight: 600; }

/* ---------- Unterseiten wie /tools/ ---------- */
.page-title { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
.page-intro { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.page-note { color: var(--muted); font-size: 13px; margin-top: 28px; }
.item-title a { text-decoration: none; }
.item-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Tool-Übersicht: Titel als erkennbarer Link (unterstrichen wie Textlinks, Pfeil → für interne Seite) */
.tool-list .item-title a { text-decoration: underline; text-decoration-color: var(--border); }
.tool-list .item-title a:hover { text-decoration-color: var(--accent); }
.tool-list .item-title a::after { content: "→"; display: inline-block; margin-left: 0.35em; color: var(--muted); text-decoration: none; }
.tool-list .item-title a:hover::after { color: var(--text); }

/* ---------- Button (z. B. 404-Seite) ---------- */
.button {
  display: inline-block; margin-top: 8px; font-size: 14px; padding: 6px 16px;
  border: 1px solid var(--border); border-radius: 999px; text-decoration: none;
}
.button:hover { border-color: var(--accent); }
.button[hidden] { display: none; }
button.button { font: inherit; font-size: 14px; background: none; color: var(--accent); cursor: pointer; }
/* PDF-Button im Lebenslauf: rechts im Kopfbereich, auf dem Handy darunter */
.print-button { margin: 0 0 0 auto; }
@media (max-width: 520px) {
  .header:has(.print-button) > div { flex-basis: calc(100% - 80px); }
  .print-button { margin-left: 80px; }
}
/* Hervorgehobener Button (z. B. Lebenslauf auf der Startseite) */
.button.primary { margin-top: 12px; background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 500; }
.button.primary:hover { opacity: 0.85; }

/* ---------- Fusszeile mit Hell/Dunkel/System-Umschalter ---------- */
footer {
  margin-top: 56px; color: var(--muted); font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
footer a { color: var(--muted); }
.theme { display: flex; gap: 2px; }
.theme[hidden] { display: none; }
.theme button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer;
}
.theme button:hover { color: var(--text); }
.theme button[aria-pressed="true"] { background: var(--tag-bg); color: var(--text); }
.theme svg { width: 16px; height: 16px; }

/* ---------- Druck / PDF (v. a. Lebenslauf) ---------- */
@page { margin: 16mm 16mm 14mm; }
@media print {
  /* Immer helle Farben, auch wenn das dunkle Design aktiv ist (:root dreifach für höhere Spezifität) */
  :root:root:root {
    color-scheme: light;
    --bg: #ffffff; --text: #1a1a1a; --muted: #555555; --border: #dddddd; --accent: #1a1a1a; --tag-bg: #f1f0ed;
  }
  body { font-size: 10.5pt; line-height: 1.45; }
  main { max-width: none; padding: 0; }
  .back, .socials, .lang, .nav, .print-button, footer { display: none !important; }
  .header { margin-bottom: 12pt; }
  section { margin-top: 16pt; }
  h2 { break-after: avoid; margin-bottom: 6pt; }
  .item { padding: 6pt 0; break-inside: avoid; }
  a { text-decoration: none; }
  /* LinkedIn-Adresse im PDF ausschreiben */
  .header .meta a[href^="http"]::after { content: " (" attr(href) ")"; }
  .tag { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- RSS-Link neben "Blog" ---------- */
.rss {
  font-size: 11px; font-weight: 500; margin-left: 6px; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); text-decoration: none; vertical-align: middle;
}
.rss:hover { color: var(--text); border-color: var(--accent); }
