/* AIOOS legal folio (AGB, AVV, Datenschutz, Impressum, KI-Transparenz).
   Loaded after shell.css. It only refines the shell's legal classes (.page-article--doc, .page-doc, .page-toc,
   .page-docnav, .draft, .ph, .doc-tools) and adds what the legal design needs on top: kicker, version slip, reading
   actions, the moving bookmark in the contents rail, the contents sheet on phones, stacked tables on phones and the
   signature blocks. Every selector starts with body.aioos-page--doc, so no other page is touched.
   Content is readable without legal.js: kicker, slip, rail, mobile disclosure, tables and signatures are plain markup. */

body.aioos-page--doc {
  --page-rail: 208px;
  --page-gap: 32px;
  --page-reading: 832px;
  --doc-bar: 56px;
  --doc-anchor: 108px;
}
@media (min-width: 1280px) {
  body.aioos-page--doc { --page-rail: 248px; --page-gap: 56px; }
}

/* Anchor jumps are instant; the bookmark gives the orientation. */
html:has(body.aioos-page--doc) { scroll-behavior: auto; scroll-padding-top: 0; }
/* With no scroll padding, non-heading targets get their own clearance under the sticky header. */
body.aioos-page--doc main#inhalt { scroll-margin-top: var(--navigation-height, 66px); }
body.aioos-page--doc #anfang { scroll-margin-top: 720px; } /* the title sits within the first 600px, so this lands at the very top: header, document navigation, kicker */
/* The document ends with the footer's own "Zurück nach oben"; the floating button would cover rail entries and prose. */
body.aioos-page--doc .back-to-top { display: none !important; }
body.aioos-page--doc .site-footer { margin-top: 64px; }

/* ---------- folio ---------- */
body.aioos-page--doc .page-doc { padding: 56px clamp(32px, 4.5vw, 64px) 48px; box-shadow: 4px 0 0 var(--tint); }
body.aioos-page--doc .page-doc > :first-child { margin-top: 0; }
body.aioos-page--doc .page-doc.page-prose { font-size: 1.125rem; line-height: 1.7; }
body.aioos-page--doc .page-doc h1 {
  margin: 0 0 24px; font-size: clamp(1.75rem, 1.2rem + 2.4vw, 3.25rem); line-height: 1.12; font-weight: 600; letter-spacing: -.045em; text-wrap: balance;
}
body.aioos-page--doc .page-doc :is(p, ul, ol) { margin: 0 0 18px; }
body.aioos-page--doc .page-doc ul { padding-left: 24px; }
body.aioos-page--doc .page-doc li + li { margin-top: 6px; }
body.aioos-page--doc .page-doc p, body.aioos-page--doc .page-doc li { hyphens: auto; -webkit-hyphens: auto; }
body.aioos-page--doc .page-doc a { hyphens: manual; -webkit-hyphens: manual; overflow-wrap: normal; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; color: var(--accent); transition: text-decoration-color 160ms var(--ease), color 160ms var(--ease); }
body.aioos-page--doc .page-doc a:hover { text-decoration-thickness: 2px; }
body.aioos-page--doc .page-doc a:is([href^="mailto:"], [href^="tel:"], .url) { overflow-wrap: anywhere; }
body.aioos-page--doc .page-doc h2 {
  margin: 48px 0 24px; padding-top: 40px; border-top: 1px solid var(--line); font-size: 1.625rem; line-height: 1.3; font-weight: 650; letter-spacing: -.025em; scroll-margin-top: var(--doc-anchor);
}
body.aioos-page--doc .page-doc h3 { margin: 32px 0 12px; font-size: 1.25rem; line-height: 1.4; font-weight: 650; scroll-margin-top: var(--doc-anchor); }
body.aioos-page--doc .page-doc h2:target, body.aioos-page--doc .page-doc h3:target { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 8px; }
body.aioos-page--doc .page-doc h2:focus, body.aioos-page--doc .page-doc h3:focus { outline: none; }
body.aioos-page--doc .page-doc h2:focus-visible, body.aioos-page--doc .page-doc h3:focus-visible { outline: 3px solid var(--accent); outline-offset: 6px; }
body.aioos-page--doc .page-doc .muted { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); font-size: .8125rem; line-height: 1.6; color: var(--muted); }
body.aioos-page--doc .page-doc .muted a { color: var(--accent); }
body.aioos-page--doc .page-doc .draft {
  margin: 0 0 32px; padding: 16px 20px; border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; background: var(--tint); font-size: .875rem; line-height: 1.55; font-weight: 600; color: var(--ink);
}
body.aioos-page--doc .page-doc .ph { padding: 1px 6px; border-radius: var(--radius-xs); background: var(--tint); color: var(--ink); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 4px; }

/* ---------- kicker, version slip and reading actions ---------- */
body.aioos-page--doc .page-doc p.doc-kicker { margin: 0 0 24px; font-size: .75rem; line-height: 1.5; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
body.aioos-page--doc .page-doc p.doc-meta {
  display: block; width: fit-content; max-width: 100%; margin: 0 0 24px; padding: 14px 20px; border: 1px solid var(--line); border-radius: var(--radius-chip); background: var(--panel);
  box-shadow: 5px 7px 0 var(--lilac); font-size: .9375rem; line-height: 1.5; font-weight: 500; color: var(--ink);
}
body.aioos-page--doc .page-doc .doc-tools { display: none; align-items: center; flex-wrap: wrap; gap: 4px 24px; margin: 0 0 32px; min-height: 44px; }
html.doc-js body.aioos-page--doc .page-doc .doc-tools { display: flex; }
body.aioos-page--doc .doc-tools__row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 24px; }
body.aioos-page--doc .doc-tools button {
  font: inherit; font-size: .875rem; line-height: 1.4; font-weight: 500; min-height: 44px; padding: 8px 18px; border-radius: var(--radius-chip); cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease), text-decoration-color 160ms var(--ease);
}
body.aioos-page--doc .doc-print { border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
body.aioos-page--doc .doc-print:hover { background: var(--tint); border-color: var(--accent); color: var(--accent); }
body.aioos-page--doc .doc-copy { border: 1px solid transparent; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; padding-inline: 6px; }
body.aioos-page--doc .doc-copy:hover { text-decoration-thickness: 2px; }
body.aioos-page--doc .page-doc .doc-status { flex: 1 1 0; min-width: 0; min-height: 22px; margin: 0; font-size: .875rem; line-height: 22px; color: var(--accent); font-weight: 600; }
body.aioos-page--doc .doc-status input { width: min(100%, 420px); font: inherit; font-size: .875rem; padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--panel); color: var(--ink); }

/* ---------- document navigation ---------- */
/* Phones: the five short labels wrap to a second row instead of scrolling out of sight. */
@media (max-width: 760px) {
  body.aioos-page.aioos-page--doc .page-docnav { flex-wrap: wrap; overflow: visible; gap: 0 20px; scroll-snap-type: none; }
  body.aioos-page.aioos-page--doc .page-docnav a { white-space: nowrap; }
}
body.aioos-page--doc .page-docnav { padding-top: 24px; gap: 0 28px; }
body.aioos-page--doc .page-article > :is(.page-docnav) { padding-bottom: 32px; }

/* ---------- contents rail and the moving bookmark ---------- */
body.aioos-page--doc .page-toc { top: 104px; max-height: calc(100dvh - 128px); font-size: .875rem; }
body.aioos-page--doc .page-toc__title { letter-spacing: .06em; }
body.aioos-page--doc .page-toc.has-mark a::before { background: transparent !important; }
body.aioos-page--doc .toc-mark {
  position: absolute; left: 4px; top: 0; width: 3px; height: 1px; border-radius: 1px; background: var(--accent); transform-origin: 0 0; pointer-events: none; opacity: 0;
  transition: transform 200ms var(--ease), opacity 120ms var(--ease);
}
body.aioos-page--doc .toc-mark.is-on { opacity: 1; }
body.aioos-page--doc .toc-mark.is-far { transition: opacity 120ms var(--ease); }
body.aioos-page--doc .page-toc a[aria-current="location"] { background: var(--tint); }
/* Rail entries fit the rail and wrap; no entry is clipped or dropped. */
body.aioos-page--doc .page-toc ol { grid-template-columns: minmax(0, 1fr); }
body.aioos-page--doc .page-toc li { min-width: 0; }
body.aioos-page--doc .page-toc a { box-sizing: border-box; width: 100%; min-width: 0; }
body.aioos-page--doc .page-toc a > span:not(.page-toc__n) { min-width: 0; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
body.aioos-page--doc .page-toc a > .page-toc__n { font-variant-numeric: normal; }
@media (min-width: 1001px) and (max-width: 1279px) {
  body.aioos-page--doc .page-toc { font-size: .8125rem; }
  body.aioos-page--doc .page-toc a { font-size: .8125rem; padding-right: 6px; }
}

/* ---------- impressum, ki-transparenz: plain groups ---------- */
body.aioos-page--doc .doc-signatures { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; margin-top: 40px; }
body.aioos-page--doc .page-doc .doc-signatures > p { margin: 0; padding-top: 20px; border-top: 1px solid var(--line); }
@media (min-width: 761px) {
  body.aioos-page--doc .doc-signatures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 48px; }
  body.aioos-page--doc .doc-signatures > p:first-child { grid-column: 1 / -1; }
}

/* ---------- tables (datenschutz sections 4 and 6) ---------- */
body.aioos-page--doc .page-table { margin: 0 0 28px; border: 0; border-radius: 0; background: none; box-shadow: none; }
body.aioos-page--doc .page-doc table { width: 100%; border-collapse: collapse; font-size: .9375rem; line-height: 1.6; }
body.aioos-page--doc .page-doc th { padding: 16px 12px; background: var(--tint); font-weight: 650; text-align: left; vertical-align: bottom; color: var(--ink); }
body.aioos-page--doc .page-doc td { padding: 16px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
body.aioos-page--doc .page-doc table :is(th, td) { min-width: 0; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
/* Three columns fit the measure; the shell's 640px minimum would clip the third one. */
body.aioos-page.aioos-page--doc .page-prose .page-table--wide table { min-width: 0; }
body.aioos-page--doc .page-table { overflow-x: visible; }
@media (max-width: 600px) {
  /* A table stacks from the first paint when its markup carries data-stack and a data-label on each cell (datenschutz.html does);
     legal.js only keeps the labels in step with the language. A table without them scrolls inside its own box instead of widening the page. */
  body.aioos-page--doc .page-table:not(:has(table[data-stack])) { overflow-x: auto; }
  body.aioos-page--doc .page-table[data-stack], body.aioos-page--doc .page-table:has(table[data-stack]) { overflow: visible; }
  body.aioos-page.aioos-page--doc .page-prose .page-table--wide table[data-stack] { min-width: 0; }
  body.aioos-page--doc table[data-stack], body.aioos-page--doc table[data-stack] tbody, body.aioos-page--doc table[data-stack] tr, body.aioos-page--doc table[data-stack] td { display: block; width: 100%; min-width: 0; }
  body.aioos-page--doc table[data-stack] thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body.aioos-page--doc table[data-stack] tr { padding: 16px 0; border-bottom: 1px solid var(--line); }
  body.aioos-page--doc table[data-stack] td { padding: 0 0 10px; border: 0; font-size: .875rem; line-height: 1.7; }
  body.aioos-page--doc table[data-stack] td:last-child { padding-bottom: 0; }
  body.aioos-page--doc table[data-stack] td::before { content: attr(data-label); content: attr(data-label) / ""; display: block; font-size: .75rem; line-height: 1.5; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
}

/* ---------- phones and tablets: contents bar and sheet ---------- */
.doc-bar, .doc-sheet { display: none; }
@media (max-width: 1000px) {
  /* Matches shell.js's reading line (header + 40px): the heading's own top padding clears the sticky bar. */
  body.aioos-page--doc { --doc-anchor: calc(var(--navigation-height, 66px) + 40px); }
  body.aioos-page--doc .page-doc h3 { margin-top: 8px; padding-top: 24px; }
  html.doc-js body.aioos-page--doc .page-toc-mobile.is-replaced { display: none; }
  html.doc-js body.aioos-page--doc .page-article > .page-toc-mobile.is-replaced { display: none; }
  /* The bar replaces the closed contents disclosure (54px + 32px margin) when legal.js runs: 56px + 30px is the same 86px, so the article does not move (#182). */
  .doc-bar {
    position: sticky; top: var(--navigation-height, 66px); z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: var(--doc-bar); margin: 0 0 30px; background: var(--paper); border-bottom: 1px solid var(--line);
  }
  body.aioos-page--doc .page-article > .doc-bar { grid-area: toc; grid-column: 1; width: 100%; }
  .doc-bar button {
    display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 16px; border: 1px solid var(--ink); border-radius: var(--radius-chip); background: none; font: inherit; font-size: .9375rem; font-weight: 500; color: var(--ink); cursor: pointer;
    transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
  }
  .doc-bar button:hover { background: var(--tint); border-color: var(--accent); color: var(--accent); }
  .doc-bar__now { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; font-size: .875rem; color: var(--ink); }
  .doc-bar__now:empty { display: none; }
  .doc-bar__glyph { font-size: 1.25rem; line-height: 1; }
  .doc-sheet {
    display: none; position: fixed; inset: auto; left: 50%; top: 50%; width: min(480px, calc(100vw - 32px)); max-height: 80dvh; margin: 0; padding: 24px; transform: translate(-50%, calc(-50% + 8px));
    border: 1px solid var(--line); border-radius: var(--radius-surface); background: var(--panel); color: var(--ink); overflow: hidden; opacity: 0;
    transition: opacity 200ms var(--ease), transform 200ms var(--ease), display 200ms allow-discrete, overlay 200ms allow-discrete;
  }
  .doc-sheet[open] { display: flex; flex-direction: column; opacity: 1; transform: translate(-50%, -50%); }
  @starting-style { .doc-sheet[open] { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } }
  .doc-sheet::backdrop { background: #191b1b66; }
  .doc-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
  .doc-sheet__head h2 { margin: 0; font-size: 1.25rem; line-height: 1.4; font-weight: 650; }
  .doc-sheet__head button { min-height: 44px; padding: 6px 12px; border: 0; background: none; font: inherit; font-size: .9375rem; font-weight: 500; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
  .doc-sheet nav { overflow-y: auto; overscroll-behavior: contain; margin-inline: -8px; padding-inline: 8px; }
  .doc-sheet ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
  .doc-sheet a { position: relative; display: flex; align-items: baseline; gap: 4px; min-height: 44px; padding: 10px 12px 10px 16px; border-radius: var(--radius-xs); color: var(--ink); font-size: .9375rem; line-height: 1.45; text-decoration: none; transition: background 160ms var(--ease), color 160ms var(--ease); }
  .doc-sheet a > .page-toc__n { flex: 0 0 2.5em; font-variant-numeric: normal; color: var(--muted); }
  .doc-sheet a > span:not(.page-toc__n) { flex: 1 1 auto; min-width: 0; }
  .doc-sheet ol:has(.page-toc__n) a:not(:has(> .page-toc__n)) { padding-left: calc(16px + 2.5em); }
  .doc-sheet a:hover { background: var(--tint); color: var(--accent); }
  .doc-sheet a:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
  .doc-sheet a[aria-current="location"] { background: var(--tint); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
  .doc-sheet a[aria-current="location"] > .page-toc__n { color: inherit; }
  body.aioos-page--doc .page-doc { padding: 48px 48px 40px; }
}
@media (max-width: 767px) { body.aioos-page--doc .page-doc { padding: 40px 28px 32px; } }
@media (max-width: 1000px) and (min-width: 601px) { body.aioos-page--doc .page-doc { max-width: none; } }

/* ---------- phones: the folio dissolves into the paper ---------- */
@media (max-width: 600px) {
  body.aioos-page--doc .page-doc { padding: 0 0 24px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  body.aioos-page--doc .page-doc.page-prose { font-size: 1rem; line-height: 1.7; }
  body.aioos-page--doc .page-doc h1 { font-size: clamp(1.75rem, 1.2rem + 2.8vw, 2rem); line-height: 1.15; }
  body.aioos-page--doc .page-doc h2 { margin-top: 40px; padding-top: 32px; font-size: 1.4375rem; }
  body.aioos-page--doc .page-doc p.doc-meta { box-shadow: none; background: var(--tint); border-color: transparent; width: 100%; }
  body.aioos-page--doc .page-doc .doc-tools { gap: 0 16px; }
  body.aioos-page--doc .page-article { width: min(100% - 36px, 1440px); }
}
@media (min-width: 371px) and (max-width: 600px) { body.aioos-page--doc .page-article { width: min(100% - var(--gutter) * 2, 1440px); } }
@media (max-width: 359px) {
  body.aioos-page--doc .page-doc h1 { font-size: 1.75rem; line-height: 1.15; hyphens: auto; }
  body.aioos-page--doc .doc-tools .doc-print, body.aioos-page--doc .doc-tools .doc-copy { padding-inline: 12px; }
}

/* ---------- forced colours, reduced motion ---------- */
@media (forced-colors: active) {
  body.aioos-page--doc .doc-meta, body.aioos-page--doc .doc-print, body.aioos-page--doc .doc-bar button { border: 1px solid ButtonText; }
  body.aioos-page--doc .toc-mark { display: none; }
  body.aioos-page--doc .page-toc a[aria-current="location"], .doc-sheet a[aria-current="location"] { border-left: 3px solid Highlight; outline: 1px solid Highlight; }
  body.aioos-page--doc .page-doc .draft { border: 1px solid CanvasText; }
}
@media (prefers-reduced-motion: reduce) {
  body.aioos-page--doc .toc-mark, .doc-sheet { transition: none !important; }
  html:has(body.aioos-page--doc) { scroll-behavior: auto; }
}

/* ---------- print: A4, the document and its record, no chrome ---------- */
@media print {
  @page { size: A4; margin: 18mm; }
  body.aioos-page--doc .doc-tools, body.aioos-page--doc .doc-bar, .doc-sheet, body.aioos-page--doc .toc-mark, body.aioos-page--doc .page-docnav, body.aioos-page--doc .site-footer { display: none !important; }
  body.aioos-page--doc .page-doc.page-prose { font-size: 10.5pt; line-height: 1.5; padding: 0; }
  body.aioos-page--doc .page-doc h1 { font-size: 24pt; line-height: 1.2; letter-spacing: 0; }
  body.aioos-page--doc .page-doc h2 { font-size: 14pt; margin: 8mm 0 3mm; padding-top: 4mm; border-top: 1px solid #000; line-height: 1.3; break-after: avoid; }
  body.aioos-page--doc .page-doc h3 { font-size: 12pt; break-after: avoid; }
  body.aioos-page--doc .page-doc :is(p, li) { orphans: 3; widows: 3; }
  body.aioos-page--doc .page-doc a { color: #000; text-decoration: underline; }
  body.aioos-page--doc .doc-kicker { color: #000; }
  body.aioos-page--doc .doc-meta, body.aioos-page--doc .page-doc .draft, body.aioos-page--doc .page-doc .ph, body.aioos-page--doc .page-doc th { background: none; box-shadow: none; }
  body.aioos-page--doc .doc-meta { border: 1px solid #000; }
  body.aioos-page--doc .page-doc .draft { border: 1px solid #000; border-left-width: 3px; }
  body.aioos-page--doc .page-doc table { font-size: 9pt; }
  body.aioos-page--doc .page-doc thead { display: table-header-group; }
  body.aioos-page--doc .page-doc tr { break-inside: avoid; }
  body.aioos-page--doc .page-doc th { border-bottom: 1px solid #000; }
  /* Stacked phone tables print as tables again. */
  body.aioos-page--doc table[data-stack] { display: table; width: 100%; }
  body.aioos-page--doc table[data-stack] tbody { display: table-row-group; width: auto; }
  body.aioos-page--doc table[data-stack] tr { display: table-row; padding: 0; }
  body.aioos-page--doc table[data-stack] td { display: table-cell; width: auto; padding: 6px 8px; border-bottom: 1px solid #999; font-size: 9pt; }
  body.aioos-page--doc table[data-stack] td::before { content: none; }
  body.aioos-page--doc table[data-stack] thead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
}
