@layer tokens, base, layout, components, pages, utilities;

/* base.css */
/* Grundstil jeder Seite (base.html): Elemente, Seitenlayout, Sprunglink, Ladeanzeige, Hilfsklassen. */

/* 2. Basis ---------------------------------------------------------------- */
@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Auch auf <html>, nicht nur auf <body>: Safari färbt Tab- und Adressleiste nach dem Seitenhintergrund
       und beim Überscrollen ist darüber sonst die Standardfarbe zu sehen. */
    background-color: var(--color-bg);
    /* Anker und scrollIntoView enden unter der klebenden Kopfzeile, nicht dahinter. --header-height setzt
       main.js aus der gemessenen Höhe (mobil mit offenem Menü höher). */
    scroll-padding-top: var(--header-height, 4.5rem);

    @media (prefers-reduced-motion: no-preference) {
      scroll-behavior: smooth;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      transition-duration: 0.01ms !important;
    }
  }

  [id] {
    scroll-margin-top: var(--space-lg);
  }

  body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-serif);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    font-kerning: normal;
    text-rendering: optimizeLegibility;
  }

  /* Bedienung in der serifenlosen Schrift: Kopf, Navigation, Footer, Formulare, Metadaten. */
  button,
  input,
  select,
  textarea,
  .site-header,
  .site-footer,
  .label,
  .breadcrumb,
  .pagination {
    font-family: var(--font-sans);
  }

  h1,
  h2,
  h3,
  h4 {
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: -0.005em;
    text-wrap: balance;
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: var(--color-accent);
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;

    /* Nur für Links ohne eigene Farbe: setzt eine Komponente color, braucht sie auch ihr eigenes &:hover. */
    &:hover {
      color: var(--color-accent-strong);
    }
  }

  :focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  img {
    max-width: 100%;
    height: auto;
  }

  code,
  kbd,
  pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
  }
}

/* 3. Layout --------------------------------------------------------------- */
@layer layout {
  .site-header__inner,
  .site-main,
  .site-footer__inner {
    width: 100%;
    max-width: var(--width-page);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  .site-main {
    flex: 1;
    padding-block: var(--space-xl) var(--space-2xl);

    @media (max-width: 40rem) {
      padding-block: var(--space-lg) var(--space-xl);
    }
  }
}

/* 4. Komponenten ---------------------------------------------------------- */
@layer components {
  /* Sprunglink */
  .skip-link {
    position: absolute;
    left: var(--space-md);
    top: -100%;
    z-index: 10;
    padding: var(--space-xs) var(--space-md);
    background: var(--color-accent);
    color: var(--color-on-accent);
    border-radius: var(--radius-sm);

    &:focus {
      top: var(--space-md);
    }
  }

  /* Ladeanzeige (Sichtbarkeit steuert HTMX 4 über .htmx-indicator / .htmx-request) */
  .loading {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
  }
}

/* 5. Hilfsklassen --------------------------------------------------------- */
@layer utilities {
  /* x-cloak nur mit JS: ohne JS bleiben diese Elemente sichtbar (Progressive Enhancement). */
  .js [x-cloak],
  [hidden] {
    display: none !important;
  }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}


/* tokens.css */
/* ==========================================================================
   Gestaltungsgrößen jeder Seite: Schriften, Farben, Abstände, Größen.
   Hell oder dunkel nach System; <html data-theme="light|dark"> legt es fest.

   Wie das CSS aufgebaut ist, steht in app/styles.py: jede Datei liegt neben dem Template, das sie gestaltet,
   und alle zusammen ergeben site.css.

   Kaskaden-Schichten (Reihenfolge in app/styles.py): tokens, base, layout, components, pages, utilities.
   Eine spätere Schicht gewinnt immer, egal wie spezifisch die Selektoren sind. Eine Komponente überschreibt
   also die Basis auch dann, wenn die Basis-Regel spezifischer ist (a:hover gegen .card__link).

   Verschachtelt wird nur mit &: &:hover, &[aria-current], & .icon, .js &. BEM-Teile
   wie &__title gibt es in nativem CSS nicht; .card__title bleibt eine eigene Regel.
   ========================================================================== */

/* 1. Tokens --------------------------------------------------------------- */
@layer tokens {
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-ext-400-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-ext-400-italic.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-400-italic.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-ext-500-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-ext-600-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-mono-latin-ext-500-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
  @font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

  /* Farben: je Token hell und dunkel mit light-dark(). Ohne Wahl folgt die Seite dem System (color-scheme: light dark),
     <html data-theme="light|dark"> legt sie fest (Umschalter, gespeichert in localStorage, siehe base.html). */
  :root {
    color-scheme: light dark;

    --color-bg: light-dark(#faf8f4, #161618);
    --color-surface: light-dark(#f3f0ea, #1c1c1f);
    --color-surface-raised: light-dark(#ffffff, #232327);
    --color-border: light-dark(#e5e0d6, #2c2c31);
    --color-border-strong: light-dark(#cdc6b9, #3d3d44);
    --color-text: light-dark(#1f1d1a, #e8e4dc);
    --color-text-muted: light-dark(#5a554e, #a9a49b);
    /* Für Metadaten (Datum, Art, Quelle); erfüllt noch 4.5:1 auf dem Hintergrund. */
    --color-text-faint: light-dark(#6b655c, #8f8a81);
    --color-accent: light-dark(#9c4417, #e3a06d);
    --color-accent-strong: light-dark(#7a330e, #f0b98d);
    --color-on-accent: light-dark(#ffffff, #1a1206);
    --color-focus: light-dark(#1a5fd0, #8ab4f8);
    --color-code-bg: light-dark(#f0ece4, #1f1f23);
    --color-error: light-dark(#b3261e, #f28b82);
    --color-success: light-dark(#1e7a3c, #81c995);

    /* Schrift: Text in einer Serifenschrift des Systems (nichts zu laden), Bedienung und Daten in IBM Plex
       (selbst gehostet, static/fonts/ibm-plex, OFL). */
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --text-xs: 0.8125rem;
    --text-sm: 0.9375rem;
    --text-base: 1.1875rem;
    --text-lg: 1.3125rem;
    --text-xl: clamp(1.5rem, 1.3rem + 0.8vw, 1.875rem);
    --text-2xl: clamp(2rem, 1.6rem + 1.8vw, 2.75rem);
    --leading-tight: 1.2;
    --leading-normal: 1.65;

    /* Abstände */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.75rem;
    --space-2xl: 4.5rem;

    /* Layout und Formen: eine ruhige Spalte. Fotos und Graph nutzen --width-wide. */
    --width-page: 46rem;
    --width-wide: 72rem;
    --width-prose: 40rem;
    --gutter: clamp(1.25rem, 5vw, 2rem);
    --radius-sm: 3px;
    --radius-md: 6px;
    --duration-fast: 120ms;

    @media (max-width: 40rem) {
      --text-base: 1.0625rem;
    }
  }

  /* Fotos und Graph brauchen Platz: dort wird die Seite breit. */
  :root:has(.photos, .photos-subnav, .kg-graph-page) {
    --width-page: var(--width-wide);
  }

  :root[data-theme="light"] {
    color-scheme: light;
  }

  :root[data-theme="dark"],
  /* Die Graph-Seite bleibt dunkel (siehe graph.css). */
  :root:has(.kg-graph-page) {
    color-scheme: dark;
  }
}


/* components/controls/button.css */
/* Buttons, auf vielen Seiten. */

@layer components {
  /* Buttons */
  .button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    background: var(--color-accent);
    color: var(--color-on-accent);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;

    &:hover {
      background: var(--color-accent-strong);
      border-color: var(--color-accent-strong);
      color: var(--color-on-accent);
    }
  }

  .button--secondary {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);

    &:hover {
      background: var(--color-surface);
      border-color: var(--color-text-muted);
      color: var(--color-text);
    }
  }
}


/* components/layout/_footer.css */
/* Fußzeile (components/layout/_footer.html). */

@layer components {
  /* Fußzeile mit Spalten */
  .site-footer {
    margin-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .site-footer__inner {
    display: grid;
    gap: var(--space-xl);
    padding-block: var(--space-2xl) var(--space-lg);
  }

  .site-footer__columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xl) var(--space-lg);

    @media (min-width: 48rem) {
      grid-template-columns: repeat(4, 1fr);
    }
  }

  .footer-col__heading {
    margin: 0 0 var(--space-sm);
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .footer-col ul,
  .site-footer__links {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .footer-col li + li {
    margin-top: var(--space-2xs);
  }

  .site-footer a {
    color: inherit;
    text-decoration: none;

    &:hover {
      color: var(--color-text);
    }
  }

  .site-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-xs) var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-xs);

    & p {
      margin: 0;
    }
  }

  .site-footer__links {
    display: flex;
    gap: var(--space-md);
  }

  .site-footer__note {
    flex-basis: 100%;
    font-size: var(--text-xs);
  }
}


/* components/layout/_header.css */
/* Kopfzeile (components/layout/_header.html): Name mit Porträt, Menü-Button, Werkzeuge rechts, Theme-Schalter. */

@layer components {
  /* Kopfzeile */
  /* Kopfzeile bleibt beim Scrollen oben. Deckender Hintergrund in der Seitenfarbe: Safari (ab 26) färbt
     Tab- und Adressleiste nur vollflächig, wenn oben ein sticky/fixiertes Element mit Hintergrund anliegt;
     sonst legt es den Seitenhintergrund nur abgeschwächt unter die durchscheinende Leiste. */
  /* Kopfzeile: oben der Name, rechts Suche, Sprache und Design; ab Tablet darunter die Navigation als eigene Zeile.
     Mobil bleibt sie oben kleben (das Menü-Blatt hängt an ihr), ab Tablet scrollt sie mit der Seite. */
  .site-header {
    z-index: 9;
    background: var(--color-bg);

    @media (max-width: 47.99rem) {
      position: sticky;
      top: 0;
      border-bottom: 1px solid var(--color-border);
    }
  }

  .site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs) var(--space-md);
    padding-block: var(--space-sm);

    @media (min-width: 48rem) {
      padding-block: var(--space-xl) var(--space-lg);
      row-gap: var(--space-md);
    }
  }

  .site-header__brand {
    flex: none;
    margin-right: auto;
    color: var(--color-text);
    text-decoration: none;

    &:hover {
      color: var(--color-accent);
    }
  }

  .site-header__name {
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: -0.005em;

    @media (min-width: 48rem) {
      font-size: var(--text-xl);
    }
  }

  /* Kopfzeile rechts: Suche, Sprache, Design; mobil nur die Lupe (Sprache und Design stehen im Menü). */
  .site-header__tools {
    display: flex;
    align-items: center;
    gap: var(--space-xs);

    @media (min-width: 48rem) {
      order: 1;
    }
  }

  .site-header__prefs {
    display: flex;
    align-items: center;

    @media (max-width: 47.99rem) {
      .js & {
        display: none;
      }
    }
  }

  .lang-switch,
  .theme-toggle {
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--color-text-muted);
    font: inherit;
    cursor: pointer;
    transition: color var(--duration-fast) ease;

    &:hover {
      color: var(--color-text);
    }
  }

  /* Menü-Button (mobil): Wort und Symbol; ☰ und × tauschen mit Drehung. */
  .site-header__menu-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    order: 3;
    height: 2.25rem;
    padding: 0 var(--space-2xs) 0 var(--space-xs);
    background: transparent;
    border: 0;
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;

    @media (min-width: 48rem) {
      display: none;
    }

    &[hidden] {
      display: none;
    }
  }

  .site-header__menu-icons {
    display: inline-grid;
  }

  .site-header__menu-icon {
    display: grid;
    grid-area: 1 / 1;
    transition: transform 450ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 250ms ease;
  }

  .site-header__menu-icon--close,
  .site-header__menu-button[aria-expanded="true"] .site-header__menu-icon--open {
    opacity: 0;
    transform: rotate(-90deg) scale(0.4);
  }

  .site-header__menu-button[aria-expanded="true"] .site-header__menu-icon--close {
    opacity: 1;
    transform: none;
  }

  /* Theme-Schalter: quadratisch, Sonne und Mond liegen übereinander und tauschen mit Drehung. */
  .theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    overflow: hidden;

    &[hidden] {
      display: none;
    }
  }

  .theme-toggle__icon {
    grid-area: 1 / 1;
    transition: transform 450ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 250ms ease;
  }

  /* Dunkel (Standard): Mond sichtbar, Sonne hinausgedreht. */
  .theme-toggle__icon--sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.4);

    :root[data-theme="light"] & {
      opacity: 1;
      transform: none;
    }
  }

  :root[data-theme="light"] .theme-toggle__icon--moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.4);
  }
}


/* components/layout/_language_switcher.css */
/* Sprachumschalter in der Kopfzeile (components/layout/_language_switcher.html). */

@layer components {
  /* Sprachumschalter: Link zur anderen Sprache. Beide Fahnen liegen übereinander wie Vorder- und Rückseite
     einer Karte; beim Überfahren (oder Tastaturfokus) dreht sich die aktuelle weg und die Zielsprache herein. */
  .lang-switch {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    perspective: 120px;
    text-decoration: none;
  }

  .lang-switch__flag {
    grid-area: 1 / 1;
    backface-visibility: hidden;
    transition: transform 550ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .lang-switch__flag--target {
    transform: rotateY(180deg);
  }

  .lang-switch:hover .lang-switch__flag--current,
  .lang-switch:focus-visible .lang-switch__flag--current {
    transform: rotateY(-180deg);
  }

  .lang-switch:hover .lang-switch__flag--target,
  .lang-switch:focus-visible .lang-switch__flag--target {
    transform: none;
  }

  /* Fahnen: leicht gerundet, feine Kontur, damit Weiß und Schwarz auf jedem Grund sichtbar sind. */
  .flag {
    display: block;
    width: 1.25rem;
    height: 0.875rem;
    border-radius: 2px;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-text) 18%, transparent);
  }
}


/* components/layout/_site_nav.css */
/* Hauptnavigation (components/layout/_site_nav.html), mobil als Blatt mit Nachschlagen, Sprache und Design. */

@layer components {
  /* Hauptnavigation: ab Tablet eine Zeile Text-Links. Mobil mit JS ein Blatt über dem ganzen Bildschirm
     (unter der Kopfzeile), das der Menü-Button öffnet; ohne JS steht die Liste einfach unter der Kopfzeile. */
  .site-nav {
    @media (min-width: 48rem) {
      order: 2;
      flex-basis: 100%;
    }

    @media (max-width: 47.99rem) {
      order: 4;
      flex-basis: 100%;

      .js & {
        position: fixed;
        inset: var(--header-height, 3.5rem) 0 0;
        z-index: 8;
        display: flex;
        flex-direction: column;
        gap: var(--space-xl);
        padding: var(--space-lg) var(--gutter) var(--space-xl);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--color-bg);
      }

      .js &:not(.is-open) {
        display: none;
      }
    }
  }

  /* Kein Scrollen der Seite hinter dem offenen Menü */
  @media (max-width: 47.99rem) {
    :root:has(.site-nav.is-open) {
      overflow: hidden;
    }
  }

  .site-nav__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-lg);
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;


    @media (max-width: 47.99rem) {
      .js & {
        flex-direction: column;
        gap: 0;
      }
    }
  }

  .site-nav__link {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-decoration: none;
    text-underline-offset: 0.45em;
    transition: color var(--duration-fast) ease;

    &:hover,
    &[aria-current="page"] {
      color: var(--color-text);
    }

    &[aria-current="page"] {
      text-decoration: underline;
      text-decoration-color: var(--color-accent);
      text-decoration-thickness: 2px;
    }

    @media (max-width: 47.99rem) {
      .js & {
        display: block;
        padding-block: var(--space-sm);
        border-bottom: 1px solid var(--color-border);
        color: var(--color-text);
        font-family: var(--font-serif);
        font-size: var(--text-xl);
        font-weight: 600;
        letter-spacing: -0.01em;
        text-underline-offset: 0.3em;
      }
    }
  }

  /* Nur im mobilen Menü: Nachschlagen (zweispaltig), Sprache und Design */
  .site-nav__extra {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);

    @media (min-width: 48rem) {
      display: none;
    }

    :root:not(.js) & {
      display: none;
    }
  }

  .site-nav__group {
    margin: 0;
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .site-nav__more {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs) var(--space-md);
    margin: 0 0 var(--space-md);
    padding: 0;
    list-style: none;

    & a {
      color: var(--color-text-muted);
      text-decoration: none;

      &:hover {
        color: var(--color-text);
      }
    }
  }

  .site-nav__prefs {
    display: grid;
    gap: var(--space-sm);
    margin-top: auto;
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
  }

  .pref {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
  }

  .pref__label {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  /* Umschalter mit zwei Feldern (Sprache, Design): das aktive Feld ist gefüllt. */
  .segmented {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
  }

  .segmented__option {
    min-width: 4.5rem;
    padding: var(--space-2xs) var(--space-sm);
    border: 0;
    border-radius: calc(var(--radius-md) - 2px);
    background: transparent;
    color: var(--color-text-muted);
    font: inherit;
    font-size: var(--text-sm);
    text-align: center;
    text-decoration: none;
    cursor: pointer;

    &[aria-current="true"],
    &[aria-pressed="true"] {
      background: var(--color-surface-raised);
      color: var(--color-text);
      box-shadow: 0 0 0 1px var(--color-border-strong);
    }
  }
}


/* components/lists/card.css */
/* Karten (Makro card in components/_macros.html). */

@layer components {
  /* Karte */
  .card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border-strong);

    &:hover .card__link {
      color: var(--color-accent);
    }

    &:focus-within {
      outline: 2px solid var(--color-focus);
      outline-offset: 2px;
    }
  }

  .card__media .picture__img {
    display: block;
    margin-bottom: var(--space-sm);
    border-radius: var(--radius-sm);
    width: 100%;
    aspect-ratio: 1200 / 630;
    object-fit: cover;
  }

  .card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: 0;
  }

  .card__title {
    margin: 0;
    font-size: var(--text-lg);
  }

  .card__link {
    color: var(--color-text);
    text-decoration: none;

    &:hover {
      color: var(--color-accent-strong);
    }

    &:focus-visible {
      outline: none;
    }

    /* Der Titel-Link macht die ganze Karte klickbar. */
    &::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 1;
    }
  }

  .card__meta {
    order: -1;
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
  }

  .card__text {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  /* Unterknoten in der Karte (Unterthemen); über dem Klickbereich des Titel-Links. */
  .card__children {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-sm);
    margin: var(--space-2xs) 0 0;
    padding: var(--space-xs) 0 0;
    border-top: 1px solid var(--color-border);
    list-style: none;
    font-size: var(--text-sm);

    & a {
      position: relative;
      z-index: 2;
    }
  }
}


/* components/lists/entry.css */
/* Einträge als Zeilen (Makro row in components/_macros.html): Titel, Teaser, darunter Datum und Art. */

@layer components {
  .entry-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .entry {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);

    &:hover .entry__link {
      color: var(--color-accent);
    }

    &:focus-within {
      outline: 2px solid var(--color-focus);
      outline-offset: 4px;
    }
  }

  /* Im DOM vor dem Titel (Lesereihenfolge für Screenreader: Datum, Art, Titel), sichtbar darunter. */
  .entry__meta {
    order: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-xs);
    margin: 0;
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);

    & > * + *::before {
      content: "·";
      margin-right: var(--space-xs);
    }
  }

  .entry__body {
    order: 1;
  }

  .entry__title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
  }

  .entry__link {
    color: var(--color-text);
    text-decoration: none;
    transition: color var(--duration-fast) ease;

    &:focus-visible {
      outline: none;
    }

    /* Der Titel-Link macht die ganze Zeile klickbar. */
    &::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 1;
    }
  }

  .entry__text {
    max-width: var(--width-prose);
    margin: var(--space-2xs) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-base);
    line-height: 1.5;
  }

  /* Unterknoten (Unterthemen) über dem Klickbereich des Titel-Links */
  .entry__children {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-md);
    margin: var(--space-xs) 0 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-sans);
    font-size: var(--text-sm);

    & a {
      position: relative;
      z-index: 2;
    }
  }
}


/* components/lists/list.css */
/* Listen: Tabs, Werkzeugleiste, Seitennavigation (Bereiche, Suche). */

@layer components {
  /* Listen: Tabs, Werkzeugleiste, Seitennavigation */

  .list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-lg);
  }

  .tabs__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .tabs__link {
    display: inline-block;
    padding: var(--space-2xs) var(--space-sm);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-decoration: none;
    transition: color var(--duration-fast) ease, border-color var(--duration-fast) ease, background-color var(--duration-fast) ease;

    &:hover {
      color: var(--color-text);
      border-color: var(--color-text-muted);
    }

    &[aria-current="page"] {
      background: var(--color-accent);
      border-color: var(--color-accent);
      color: var(--color-on-accent);
    }
  }

  .list-region {
    scroll-margin-top: var(--space-lg);
  }

  .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
    font-size: var(--text-sm);
  }

  .pagination__status {
    color: var(--color-text-muted);
  }

  .pagination__link[rel="next"] {
    margin-left: auto;
  }

  .empty {
    color: var(--color-text-muted);
  }
}


/* components/lists/photo-cards.css */
/* Foto-Kacheln: unter /photos und auf der Startseite. */

@layer components {
  /* Foto-Kacheln: Kollektionen und Sets unter /photos, die neuesten Sets auf der Startseite (--row: eine Reihe zu vier) */
  .photo-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
    gap: var(--space-lg);
    margin: 0 0 var(--space-xl);
    padding: 0;
    list-style: none;

    @media (max-width: 45rem) {
      grid-template-columns: repeat(2, 1fr);
      gap: var(--space-md);
    }
  }

  .photo-card {
    display: block;
    color: var(--color-text);
    text-decoration: none;

    &:hover .photo-card__title {
      color: var(--color-accent-strong);
    }
  }

  .photo-card__img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: var(--space-xs);
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--color-surface);
  }

  .photo-card__title {
    margin: 0 0 var(--space-2xs);
    font-size: var(--text-lg);
    transition: color var(--duration-fast) ease;
  }

  .photo-card__text {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .photo-cards--row {
    margin-bottom: 0;

    @media (min-width: 60rem) {
      grid-template-columns: repeat(4, 1fr);
    }
  }
}


/* components/lists/section.css */
/* Abschnitte mit Überschrift und Kartenraster, Links unter einem Abschnitt. */

@layer components {
  /* Sektionen und Kartenraster */
  .section {
    margin-top: var(--space-2xl);

    @media (max-width: 40rem) {
      margin-top: var(--space-xl);
    }
  }

  .section__heading {
    margin: 0 0 var(--space-lg);
    font-size: var(--text-xl);
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: var(--space-lg);
  }

  .section__more {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-lg);
    margin: var(--space-lg) 0 0;
    font-size: var(--text-sm);
  }
}


/* components/search/_search.css */
/* Suche in der Kopfzeile (components/search/_search.html) und ihre Trefferliste (_search_suggest.html). */

@layer components {
  /* Suche: Knopf mit Lupe, Wort und Tastenkürzel; mobil nur die Lupe. Das Feld steht in einem Dialog. */
  .site-search__toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    height: 2rem;
    padding-inline: var(--space-xs) var(--space-2xs);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-decoration: none;
    transition: color var(--duration-fast) ease, border-color var(--duration-fast) ease;

    &:hover {
      border-color: var(--color-border-strong);
      color: var(--color-text);
    }

    /* Bis 64rem nur die Lupe, damit Porträt, Name und Navigation in eine Zeile passen; mobil ohne Rahmen */
    @media (max-width: 47.99rem) {
      border-color: transparent;
    }

    @media (max-width: 63.99rem) {
      justify-content: center;
      width: 2.25rem;
      padding: 0;

      & .site-search__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
      }

      & .site-search__kbd {
        display: none;
      }
    }
  }

  .site-search__label {
    min-width: 4.5rem;
  }

  .site-search__kbd {
    padding: 1px 5px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-faint);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
  }

  .site-search__dialog {
    width: min(36rem, calc(100vw - 2 * var(--gutter)));
    max-height: min(36rem, calc(100dvh - 4rem));
    margin: 12vh auto auto;
    padding: 0;
    overflow: hidden;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 48px rgb(0 0 0 / 0.28);
    color: var(--color-text);

    &[open] {
      animation: search-in 180ms ease-out;
    }

    &::backdrop {
      background: rgb(0 0 0 / 0.35);
      backdrop-filter: blur(2px);
    }
  }

  @keyframes search-in {
    from {
      opacity: 0;
      transform: translateY(-8px) scale(0.98);
    }
  }

  .site-search__form {
    display: flex;
    flex-direction: column;
    max-height: inherit;
  }

  .site-search__bar {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    color: var(--color-text-muted);
  }

  .site-search__input {
    flex: 1;
    min-width: 0;
    padding: var(--space-2xs) 0;
    background: transparent;
    border: 0;
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-base);

    &:focus-visible {
      outline: none;
    }

    /* Das Löschkreuz des Browsers neben dem eigenen Schließen-Knopf wäre ein zweites ×. */
    &::-webkit-search-cancel-button {
      appearance: none;
    }
  }

  .site-search__close {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;

    &:hover {
      color: var(--color-text);
      background: var(--color-surface);
    }
  }

  .site-search__results {
    overflow-y: auto;
    padding: var(--space-2xs);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-sm);

    &:empty {
      display: none;
    }
  }

  .site-search__list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .site-search__hit,
  .site-search__all {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    text-decoration: none;

    &:hover {
      color: var(--color-accent-strong);
    }

    &:hover,
    &:focus-visible {
      background: var(--color-surface);
    }
  }

  .site-search__section {
    flex: none;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
  }

  .site-search__all {
    border-top: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    color: var(--color-accent);
  }

  .site-search__empty {
    margin: 0;
    padding: var(--space-xs) var(--space-sm);
    color: var(--color-text-muted);
  }
}


/* components/text/article.css */
/* Artikel und Leseseiten: Kopf, Metadaten, Titelbild, Badges und Schlagwörter. */

@layer components {
  /* Artikel und Leseseiten */
  /* Eine Spalte; das Inhaltsverzeichnis steht zwischen Kopf und Text (die Seite ist zu schmal für eine Seitenleiste). */
  .article {
    max-width: var(--width-prose);
  }

  .article--toc > .article__header,
  .article--toc > .article__body {
    grid-column: 1;
  }

  .article__lead {
    margin: var(--space-sm) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-lg);
    line-height: 1.45;
  }

  /* Website und Profile einer Person oder Organisation nebeneinander */
  .article__link {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-md);
  }

  .article__header {
    margin-bottom: var(--space-lg);
  }

  .article__back {
    margin: 0 0 var(--space-md);
    font-size: var(--text-sm);
  }

  .article__title {
    margin: 0;
    font-size: var(--text-2xl);
    letter-spacing: -0.02em;
  }

  .article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-md);
    margin: var(--space-md) 0 0;
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
  }

  .article__image .picture__img {
    display: block;
    margin-bottom: var(--space-lg);
    border-radius: var(--radius-md);
  }

  /* Titelbild aus der Wissensdatenbank (hero im Frontmatter), volle Breite des Textbereichs */
  .article__hero {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: var(--space-lg);
    border-radius: var(--radius-md);
  }

  .article__footer {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
  }

  .badge {
    padding: 0 var(--space-xs);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
  }

  .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-sans);
    font-size: var(--text-xs);
  }

  .tag-list__tag {
    color: var(--color-text-muted);
    text-decoration: none;

    &:hover {
      color: var(--color-accent-strong);
    }
  }
}


/* components/text/breadcrumb.css */
/* Brotkrumen über dem Titel einer Leseseite. */

@layer components {
  /* Brotkrumen über dem Titel: Bereich › Überknoten */
  .breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-xs);
    margin: 0 0 var(--space-md);
    padding: 0;
    list-style: none;
    font-size: var(--text-sm);

    & li + li::before {
      content: "›";
      margin-right: var(--space-xs);
      color: var(--color-text-faint);
    }

    & a {
      color: var(--color-text-muted);
      text-decoration: none;

      &:hover {
        color: var(--color-text);
      }
    }
  }
}


/* components/text/notice.css */
/* Hinweisbox. */

@layer components {
  /* Hinweisbox */
  .notice {
    margin: 0 0 var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
  }
}


/* components/text/page-header.css */
/* Seitenkopf mit Titel und Einleitung, auf fast allen Seiten. */

@layer components {
  .page-header {
    margin-bottom: var(--space-xl);
  }

  .page-header__title {
    margin: 0;
    font-size: var(--text-2xl);
    letter-spacing: -0.015em;
  }

  .page-header__lead {
    max-width: var(--width-prose);
    margin: var(--space-sm) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-lg);
    line-height: 1.5;
  }
}


/* components/text/prose.css */
/* Fließtext aus Markdown. */

@layer components {
  /* Fließtext aus Markdown */
  .prose {
    max-width: var(--width-prose);

    & > * + * {
      margin-top: var(--space-md);
    }

    & h2,
    & h3,
    & h4 {
      margin-top: var(--space-xl);
      margin-bottom: 0;
    }

    & h2 {
      font-size: var(--text-xl);
    }

    & h3 {
      font-size: var(--text-lg);
    }

    & h4 {
      font-size: var(--text-base);
    }

    & p,
    & ul,
    & ol {
      margin-bottom: 0;
    }

    & ul,
    & ol {
      padding-left: var(--space-lg);
    }

    & li + li {
      margin-top: var(--space-2xs);
    }

    & blockquote {
      margin-inline: 0;
      padding-left: var(--space-md);
      border-left: 3px solid var(--color-border);
      color: var(--color-text-muted);
    }

    & blockquote > :first-child {
      margin-top: 0;
    }

    & blockquote > :last-child {
      margin-bottom: 0;
    }

    & :not(pre) > code {
      padding: 0.1em 0.35em;
      background: var(--color-code-bg);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-sm);
    }

    /* Bilder und Screenshots aus der Wissensdatenbank (app/kb/render.py: with_images) */
    & img {
      max-width: 100%;
      height: auto;
    }

    & p > img {
      vertical-align: middle;
    }

    & .figure {
      margin: var(--space-lg) 0 0;
    }

    & .figure img {
      display: block;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
    }

    & .figure__link {
      display: block;
      width: fit-content;
      max-width: 100%;
      border-radius: var(--radius-md);
    }

    & .figure__link:hover img {
      border-color: var(--color-border-strong);
    }

    /* Videos aus der Wissensdatenbank (app/kb/render.py): Animationen in ihrer Größe, Clips mit Ton in 16:9 über
       die ganze Textbreite. Der Rahmen hält die Form, solange das Video lädt. */
    & .figure video {
      display: block;
      max-width: 100%;
      height: auto;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
    }

    & .figure--video video {
      width: 100%;
      aspect-ratio: 16 / 9;
      background: #000;
    }

    & .figure figcaption {
      margin-top: var(--space-xs);
      font-size: var(--text-sm);
      color: var(--color-text-muted);
    }

    & pre {
      overflow-x: auto;
      padding: var(--space-md);
      background: var(--color-code-bg);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      line-height: 1.5;
    }

    & table {
      width: 100%;
      border-collapse: collapse;
      font-size: var(--text-sm);
      display: block;
      overflow-x: auto;
    }

    & th,
    & td {
      padding: var(--space-xs) var(--space-sm);
      border-bottom: 1px solid var(--color-border);
      text-align: left;
    }

    & th {
      color: var(--color-text-muted);
      font-weight: 600;
    }

    & hr {
      margin-block: var(--space-xl);
      border: 0;
      border-top: 1px solid var(--color-border);
    }

    & img {
      border-radius: var(--radius-md);
    }
  }
}


/* components/text/protected.css */
/* Geschützte Kontaktangaben (app/security/contact.py): nicht markier- und kopierbar, Täuschzeichen ausgeblendet. */

@layer components {
  .protected {
    -webkit-user-select: none;
    user-select: none;
  }

  .protected__x {
    display: none;
  }
}


/* pages/archive/archive.css */
/* Archiv (pages/archive/index.html): Filter nach Art, Sprungmarken je Jahr, Monate als Zeilenlisten. */

@layer components {
  .archive-filter,
  .archive-years {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-md);
    margin-block: var(--space-md);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
  }

  .archive-filter__link {
    color: var(--color-text-muted);
    text-decoration: none;

    & span {
      color: var(--color-text-faint);
      font-family: var(--font-sans);
      font-size: 0.85em;
    }

    &:hover,
    &[aria-current] {
      color: var(--color-accent-strong);
    }

    &[aria-current] {
      text-decoration: underline;
      text-underline-offset: 0.25em;
    }
  }

  .archive-years {
    font-family: var(--font-sans);
  }

  .archive-year {
    margin-top: var(--space-xl);
    scroll-margin-top: var(--space-xl);
  }

  .archive-year__heading,
  .archive-month__heading {
    & span {
      color: var(--color-text-faint);
      font-family: var(--font-sans);
      font-size: 0.6em;
      font-weight: 400;
    }
  }

  .archive-month {
    margin-top: var(--space-lg);
  }

  .archive-month__heading {
    margin-bottom: var(--space-xs);

    & span {
      font-size: 1em;
    }
  }
}


/* pages/error.css */
/* Fehlerseite (pages/error.html). */

@layer components {
  /* Fehlerseite */
  .error-page {
    max-width: var(--width-prose);
    padding-block: var(--space-xl);
  }

  .error-page__code {
    margin: 0;
    color: var(--color-accent);
    font-family: var(--font-mono);
    font-size: var(--text-lg);
  }

  .error-page__title {
    margin: var(--space-xs) 0 var(--space-md);
    font-size: var(--text-2xl);
  }
}


/* pages/home.css */
/* Startseite (pages/home.html). */

@layer components {
  /* Startseite: Abschnitte */
  /* Startseite: Einstieg mit Überschrift und Satz, daneben Artikel für den Anfang */
  .hero {
    display: grid;
    gap: var(--space-xl) var(--space-2xl);
    padding-block: var(--space-lg) var(--space-xl);

    @media (min-width: 60rem) {
      &.hero--aside {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        align-items: end;
      }
    }
  }

  .hero__title {
    max-width: 22ch;
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.025em;
    hyphens: manual;
    text-wrap: balance;
  }

  .hero__lead {
    margin: var(--space-md) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-lg);
    line-height: 1.5;
  }

  .hero__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-lg);
    margin: var(--space-lg) 0 0;
    font-size: var(--text-sm);
  }

  .hero__aside {
    padding-left: var(--space-lg);
    border-left: 1px solid var(--color-border);
  }

  /* Kleine Überschrift in Versalien: Nachschlagen, Werkzeuge */
  .label {
    margin: 0 0 var(--space-sm);
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .start-list {
    display: grid;
    gap: var(--space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: start;

    & li {
      display: grid;
      grid-template-columns: 1.5rem auto 1fr;
      align-items: baseline;
      counter-increment: start;

      &::before {
        content: counter(start, decimal-leading-zero);
        color: var(--color-text-faint);
        font-family: var(--font-sans);
        font-size: var(--text-xs);
        line-height: 2;
      }
    }

    & a {
      color: var(--color-text);
      text-decoration: none;

      &:hover {
        color: var(--color-accent-strong);
      }
    }
  }

  /* Feature-Link ohne Übersetzung: zeigt auf die englische Fassung */
  .start-list__lang {
    margin-left: var(--space-xs);
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
  }

  .home-section {
    margin-top: var(--space-2xl);

    /* Der erste Abschnitt steht direkt oben, ohne Abstand darüber. */
    &:first-of-type {
      margin-top: 0;
    }
  }

  .hero + .home-section,
  .hero + .notice + .home-section {
    margin-top: var(--space-xl);
  }

  .home-section__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-md);
    margin-bottom: var(--space-sm);

    & .section__heading,
    & .label {
      margin: 0;
    }
  }

  .home-section__all {
    font-size: var(--text-sm);
  }

  .home-section__lead {
    max-width: 38rem;
    margin: 0 0 var(--space-lg);
    color: var(--color-text-muted);
  }

  .home-section__reference {
    margin: var(--space-lg) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  /* Themen: Raster mit Haarlinien statt Karten */
  .topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
    list-style: none;
  }

  .topic-grid__item {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }

  .topic-grid__title {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 600;

    & a {
      color: var(--color-text);
      text-decoration: none;

      &:hover {
        color: var(--color-accent-strong);
      }
    }
  }

  .topic-grid__text {
    margin: var(--space-xs) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .topic-grid__more {
    margin: var(--space-sm) 0 0;
    color: var(--color-text-faint);
    font-size: var(--text-xs);
  }

  /* Hinweis auf die Karte: Text links, angedeutete Karte auf dem Leuchten der Graph-Bühne rechts */
  .map-teaser {
    display: grid;
    gap: var(--space-xl);
    align-items: center;
    padding: var(--space-xl);
    border: 1px solid #1f2742;
    border-radius: var(--radius-md);
    background: radial-gradient(ellipse at 70% 50%, #141d3a, #0a0e1a 70%);
    color: #c9d1e8;

    @media (min-width: 48rem) {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    }

    & .section__heading {
      color: #eef1fa;
    }

    & p {
      color: #8a93ad;
    }
  }

  .map-teaser__text p:last-child {
    margin-bottom: 0;
  }

  .map-teaser__svg {
    display: block;
    width: 100%;
    height: auto;

    & line {
      stroke: #3a4466;
      stroke-width: 1;
    }
  }

  .map-teaser__legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-md);
    margin: var(--space-sm) 0 0;
    padding: 0;
    list-style: none;
    color: #c9d1e8;
    font-size: var(--text-xs);

    & span:last-child {
      color: #8a93ad;
      font-family: var(--font-mono);
    }
  }

  .map-teaser__dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: var(--space-2xs);
    border-radius: 50%;
  }
}


/* pages/kg/kg.css */
/* Seiten der Wissensdatenbank (pages/kg/): Node, Schlagwörter, Notizen, Ontologie. */

@layer components {
  /* Wissensdatenbank (/n/…, /type/…, /tag/…, /journal/…, /ontology/, /log/ und die Abschnittsseiten).
     Die Graph-Ansicht selbst (/graph-view/) steht in pages/kg/graph.page.css. */
  .kg-page {
    max-width: var(--width-prose);
  }

  .kg-page__title {
    margin: 0 0 var(--space-xs);
    font-size: var(--text-2xl);
    letter-spacing: -0.02em;
  }

  .kg-page__lead {
    margin: 0 0 var(--space-xl);
    color: var(--color-text-muted);
    font-size: var(--text-lg);
  }

  .kg-muted {
    color: var(--color-text-muted);
  }

  .kg-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-xs);
    margin: 0 0 var(--space-md);
    padding: 0;
    list-style: none;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .kg-breadcrumb li + li::before {
    content: "›";
    margin-right: var(--space-xs);
  }

  .kg-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-decoration: none;

    &::before {
      content: "";
      width: 0.7em;
      height: 0.7em;
      border-radius: 50%;
      background: var(--type-color, var(--color-text-muted));
    }
  }

  a.kg-badge:hover {
    color: var(--color-text);
  }

  .kg-meta,
  .kg-provenance {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs) var(--space-md);
    margin: 0 0 var(--space-md);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    color: var(--color-text-faint);
  }

  .kg-flag {
    padding: 0 var(--space-xs);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius-sm);
    color: var(--color-accent);
  }

  .kg-prose {
    margin-block: var(--space-lg);
  }

  .prose .footnote {
    margin-top: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--color-text-muted);

    & hr {
      border: 0;
      border-top: 1px solid var(--color-border);
    }
  }

  .prose .footnote-ref,
  .prose .footnote-backref {
    text-decoration: none;
  }

  .kg-sources,
  .kg-relations,
  .kg-tag-group {
    margin-top: var(--space-xl);
  }

  .kg-sources h2,
  .kg-relations h2 {
    font-size: var(--text-lg);
  }

  .kg-sources ul {
    padding-left: var(--space-lg);
    font-family: var(--font-sans);
    font-size: var(--text-sm);

    & code {
      color: var(--color-text-faint);
      font-size: 0.85em;
      overflow-wrap: anywhere;
    }
  }

  .kg-sources__id {
    margin-left: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--color-text-faint);
  }

  .kg-relations h3 {
    margin: var(--space-xl) 0 var(--space-sm);
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;

    & span {
      color: var(--color-text-muted);
      font-weight: 400;
    }
  }

  .kg-node-list,
  .kg-note-items {
    display: grid;
    gap: var(--space-sm);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .kg-node-list li,
  .kg-note-item {
    display: grid;
    gap: 0.1rem;
  }

  /* Verbindungen ruhig: Titel in Textfarbe, Akzent erst beim Darüberfahren. */
  .kg-node-list a {
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;

    &:hover {
      color: var(--color-accent);
      text-decoration: underline;
      text-underline-offset: 0.15em;
    }
  }

  .kg-node-list span,
  .kg-note-item span,
  .kg-note-item time {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .kg-actions {
    margin-top: var(--space-xl);
  }

  .kg-tag-index {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-md);
    padding: 0;
    list-style: none;
  }

  .kg-tag-index__count {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .kg-note-stream {
    display: grid;
    gap: var(--space-xl);
  }

  .kg-note-month + .kg-note-month {
    margin-top: var(--space-2xl);
  }

  .kg-note-month__heading {
    margin: 0 0 var(--space-md);
  }

  .kg-note__title {
    margin: 0 0 var(--space-2xs);
    font-size: var(--text-xl);

    & a {
      color: var(--color-text);
      text-decoration: none;

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

  /* Monatsüberschrift wie die Bereiche auf der Startseite: klein, mit Linie bis zum Rand. */
  .kg-note-month__heading {
    display: flex;
    align-items: center;
    gap: var(--space-md);

    &::after {
      content: "";
      flex: 1;
      border-top: 1px solid var(--color-border-strong);
    }
  }

  .kg-pager {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    font-size: var(--text-sm);
  }

  .kg-relation-type {
    margin-top: var(--space-lg);
  }
}

@layer components {
  .kg-note .tag-list {
    margin-top: var(--space-sm);
  }
}


/* pages/kg/log.css */
/* Änderungsprotokoll (pages/kg/log.html). */

@layer components {
  /* Änderungsprotokoll (/log/): eine Zeitleiste pro Tag, ein Punkt pro Eintrag in der Farbe seiner Art. */
  .kg-log-timeline {
    margin-top: var(--space-xl);
  }

  .kg-log-day + .kg-log-day {
    margin-top: var(--space-xl);
  }

  .kg-log-day__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-xs) var(--space-sm);
    margin: 0 0 var(--space-md);
    font-size: var(--text-lg);
  }

  .kg-log-day__count {
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--color-text-faint);
  }

  .kg-log {
    display: grid;
    gap: var(--space-lg);
    margin: 0;
    padding: 0 0 0 var(--space-lg);
    border-left: 2px solid var(--color-border);
    list-style: none;

    & code {
      overflow-wrap: anywhere;
    }
  }

  .kg-log__entry {
    --op-color: var(--color-text-muted);
    position: relative;

    /* Punkt auf der Linie: halbe Linienbreite plus halbe Punktbreite links vom Innenabstand */
    &::before {
      content: "";
      position: absolute;
      top: 0.3em;
      left: calc(-1 * var(--space-lg) - 6px);
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: var(--op-color);
      box-shadow: 0 0 0 3px var(--color-bg);
    }
  }

  .kg-log__entry--ingest { --op-color: var(--color-success); }
  .kg-log__entry--review { --op-color: var(--color-focus); }
  .kg-log__entry--setup { --op-color: var(--color-accent); }
  .kg-log__entry--query { --op-color: var(--color-accent-strong); }
  .kg-log__entry--lint { --op-color: var(--color-text-faint); }

  .kg-log__op {
    display: block;
    margin-bottom: 0.15rem;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--op-color);
  }

  .kg-log__lead {
    margin: 0;
    line-height: 1.55;
  }

  .kg-log__more {
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--color-text-muted);

    & summary {
      display: inline-flex;
      gap: 0.35rem;
      cursor: pointer;
      font-size: var(--text-xs);
      color: var(--color-text-faint);
      list-style: none;

      &::-webkit-details-marker {
        display: none;
      }

      &::before {
        content: "›";
        color: var(--color-accent);
        font-weight: 600;
        transition: transform var(--duration-fast) ease;
      }

      &:hover {
        color: var(--color-text);
      }
    }

    &[open] summary::before {
      transform: rotate(90deg);
    }

    & p {
      margin: var(--space-xs) 0 0;
      line-height: 1.6;
    }
  }
}


/* pages/page.css */
/* Einzelseite (pages/page.html). */

@layer components {
  /* Seitenkopf und Einzelseite */
  .page {
    max-width: var(--width-prose);
  }

  .page__image .picture__img {
    display: block;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
  }

  /* Die neuesten Artikel aus der Wissensdatenbank mitten im Text einer Seite ([[articles]]) */
  .page__articles {
    max-width: var(--width-prose);
    margin-block: var(--space-md) var(--space-xl);
  }
}


/* pages/search.css */
/* Suchseite (pages/search.html). */

@layer components {
  /* Suche */
  .search-form {
    max-width: var(--width-prose);
    margin-bottom: var(--space-xl);
  }

  .search-form__label {
    font-family: var(--font-sans);
    display: block;
    margin-bottom: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .search-form__row {
    display: flex;
    gap: var(--space-xs);
  }

  .search-form__input {
    flex: 1;
    min-width: 0;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font: inherit;

    &:focus-visible {
      border-color: var(--color-focus);
    }
  }

  .search-results__count {
    font-family: var(--font-sans);
    margin: 0 0 var(--space-md);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }
}


/* pages/section/post.css */
/* Leseseite (pages/section/post.html): Unterknoten, Mehr dazu, Auf dieser Seite, aufklappbare Nodes. */

@layer components {
  /* Unterknoten auf der Leseseite */
  .article__children {
    margin-top: var(--space-xl);
  }

  /* Mehr dazu: Beziehung links (leise, Mono), Einträge rechts; mobil untereinander. */
  .more {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
  }

  .more__heading {
    margin: 0 0 var(--space-md);
    font-size: var(--text-lg);
  }

  .more__list {
    margin: 0;
  }

  .more__row {
    display: grid;
    gap: var(--space-2xs) var(--space-lg);
    padding-block: var(--space-sm);
    border-bottom: 1px solid var(--color-border);

    @media (min-width: 40rem) {
      grid-template-columns: 9rem 1fr;
    }

    & dt {
      padding-top: 0.2em;
      color: var(--color-text-faint);
      font-family: var(--font-sans);
      font-size: var(--text-xs);
    }

    & dd {
      margin: 0;
    }

    & dd > ul:not(.tag-list) {
      display: grid;
      gap: var(--space-xs);
      margin: 0;
      padding: 0;
      list-style: none;
    }
  }

  .more__summary {
    color: var(--color-text-muted);
    font-size: var(--text-sm);

    &::before {
      content: "– ";
    }
  }

  .more__map {
    margin: var(--space-md) 0 0;
    font-size: var(--text-sm);
  }

  /* Auf dieser Seite: zwischen Kopf und Text. */
  .toc {
    margin-bottom: var(--space-xl);
    padding: var(--space-sm) var(--space-md);
    border-left: 2px solid var(--color-border);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
  }

  .toc__heading {
    margin: 0 0 var(--space-xs);
    color: var(--color-text-faint);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .toc__list {
    display: grid;
    gap: var(--space-2xs);
    margin: 0;
    padding: 0;
    list-style: none;

    & a {
      color: var(--color-text-muted);
      text-decoration: none;

      &:hover {
        color: var(--color-text);
      }
    }
  }

  /* Aufklappbarer Node in den Verbindungen (Quellen): Titel wie ein Link, Pfeil dreht beim Öffnen. */
  .inline-node summary {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: var(--space-xs);
    cursor: pointer;
    list-style: none;

    &::-webkit-details-marker {
      display: none;
    }

    &::before {
      content: "›";
      grid-row: 1;
      color: var(--color-accent);
      font-weight: 600;
      transition: transform var(--duration-fast) ease;
    }
  }

  .inline-node[open] summary::before {
    transform: rotate(90deg);
  }

  .inline-node__title {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 0.15em;

    .inline-node summary:hover & {
      color: var(--color-accent-strong);
    }
  }

  .inline-node summary > span:last-child {
    grid-column: 2;
  }

  .inline-node__body {
    margin: var(--space-sm) 0 0 calc(var(--space-xs) + 0.5em);
    padding-left: var(--space-md);
    border-left: 2px solid var(--color-border);
    font-family: var(--font-sans);
    font-size: var(--text-sm);

    & > :first-child {
      margin-top: 0;
    }
  }

  .inline-node__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin: var(--space-sm) 0 0 calc(var(--space-xs) + 0.5em);
    padding-left: calc(var(--space-md) + 2px);
    font-size: var(--text-sm);
  }

  .subnode-list {
    display: grid;
    gap: var(--space-sm);
    margin: 0;
    padding: 0;
    list-style: none;

    & span {
      display: block;
      color: var(--color-text-muted);
      font-size: var(--text-sm);
    }

    & .subnode-list__via {
      font-size: var(--text-xs);
      font-style: italic;
    }
  }
}
