/* =========================================================================
   Legal documents — imprint, privacy, terms, partner agreement, DPA, consents
   -------------------------------------------------------------------------
   Seven pages, one stylesheet, and almost no page-specific styling: a legal
   document is prose with numbered sections, and the less it is designed the
   better it reads. What is here is the part the shared components do not
   already cover.

   THE VERSION BLOCK IS NOT DECORATION. It is the first thing under the
   heading because it is the thing a reader has to be able to cite: the version
   in it is the value written into a consent record, and a reader who wants to
   know what they agreed to needs to find it without scrolling. It prints.

   THE DOCUMENT PRINTS, AND THAT IS A REQUIREMENT RATHER THAN A COURTESY.
   A partner's legal department prints these. `print.css` is linked on every one
   of them — it is what keeps the brand hero's white ink off white paper — and
   the rules at the bottom of this file add what is specific to a document:
   the table of contents goes (it is navigation, useless on paper), and a
   section is not split across a page break where that can be avoided.

   ONE TEMPLATE FOR EVERY DOCUMENT (U-2283, redesign R8g). Each of the fourteen
   pages is the same frame: the inner-page hero band of `marketing.css`, then
   `.doc-layout` — the list of every legal document beside the document itself,
   a `.doc-sheet` on the card surface holding the version block, the contents
   and the text. Only the text and the current entry of the list differ.
   ========================================================================= */

/* ---- The frame: the documents beside the document ------------------------- *
 * One column below 1024 px, where the list becomes one scrolling row above the
 * sheet; above it the list is a 240 px column that stays in sight under the
 * sticky header (66 px and its hairline, then 16 px of air).
 * ------------------------------------------------------------------------- */

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  align-items: start;
}

@media (min-width: 1024px) {
  .doc-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .doc-nav {
    position: sticky;
    top: 83px;
  }
}

/* ---- The list of documents ------------------------------------------------ */

/* The padding is split between the card and the list, so the focus ring of a
   link keeps room inside the list's scrolling box, which would clip it. */
.doc-nav {
  padding: var(--space-xs);
  border-radius: var(--radius);
  background: var(--sd-surface);
}

.doc-nav ul {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: var(--space-xs);
  list-style: none;
  overflow-x: auto;
}

@media (min-width: 1024px) {
  .doc-nav ul {
    flex-direction: column;
    overflow-x: visible;
  }
}

.doc-nav a {
  display: block;
  padding: var(--space-sm) 12px;
  border-radius: var(--radius-sm);
  color: var(--doc-ink);
  font-size: var(--text-body);
  line-height: var(--text-body-lh);
  white-space: nowrap;
  text-decoration: none;
}

@media (min-width: 1024px) {
  .doc-nav a {
    white-space: normal;
  }
}

.doc-nav a:hover {
  background: var(--sd-surface-alt);
  color: var(--doc-ink);
}

/* The current document: the muted plate, the link ink, the weight and the
   accent bar on its leading edge — the weight and the bar carry it for a
   reader who sees no colour (audit rule E-4), `aria-current` for one who
   sees no page. */
.doc-nav a[aria-current="page"] {
  background: var(--sd-surface-alt);
  color: var(--sd-secondary);
  font-weight: 600;
  box-shadow: inset var(--border-w-strong) 0 0 var(--accent-bar);
}

/* ---- The sheet ------------------------------------------------------------ */

.doc-sheet {
  padding: var(--space-lg);
  border-radius: var(--radius);
  background: var(--sd-surface);
}

@media (min-width: 640px) {
  .doc-sheet {
    padding: 48px;
  }
}

/* ---- The version block ---------------------------------------------------- */

/* A grid and not a wrapping row, so no count of entries closes on a lone one
   (U-1954): four close as 4, 2+2 or 1, three as 3 or 1. The sheet is narrower
   than the page, and a wrapping row of three can close there as 2+1. */
.doc-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm) var(--space-lg);
  margin: 0 0 var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  background: var(--sd-surface-alt);
}

@media (min-width: 1024px) {
  .doc-meta:has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(3, auto);
    justify-content: start;
  }
}

@media (min-width: 480px) {
  .doc-meta:has(> :nth-child(4):last-child) {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .doc-meta:has(> :nth-child(4):last-child) {
    grid-template-columns: repeat(4, 1fr);
  }
}

.doc-meta > div {
  display: flex;
  flex-direction: column;
}

.doc-meta dt {
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
  color: var(--sd-text-soft);
}

.doc-meta dd {
  margin: 0;
  font-size: var(--text-body);
  line-height: var(--text-body-lh);
  font-weight: 600;
  color: var(--sd-text);
}

/* ---- Table of contents ---------------------------------------------------- */

.doc-toc {
  margin: 0 0 var(--space-lg);
}

.doc-toc ol {
  margin: 0;
  padding-left: 20px;
  columns: 2;
  column-gap: var(--space-lg);
}

.doc-toc li {
  font-size: var(--text-body);
  line-height: 24px;
  break-inside: avoid;
}

/* ONE COLUMN ON A PHONE, and the reason is a German word (U-753).

   Two columns of a 390 px viewport are 143 px wide. `Unterauftragsverarbeiter`
   — clause 7 of the data processing agreement — renders 176 px, and a word has
   no break opportunity, so it left its column, left the page and gave
   `de/legal/dpa.html` 10 px of horizontal scroll that the English twin does not
   have. The column count is what is wrong here: at 390 px a two-column table of
   contents is unreadable before it is broken, and `columns: 1` removes both
   problems. 640 px is this SITE's narrow breakpoint: **nine**
   `@media (max-width: 640px)` rules under `assets/css/` on `main`, against three
   at 900 px and one each at 899, 760, 700 and 480. This file had no WIDTH query of
   its own before; it did have `@media print`.

   *Four editions of this one sentence, each wrong in a different way, and they are
   worth more than the rule they annotate: "this stylesheet's own breakpoint" (it had
   none), "thirteen" (counted after the branch, so the rule justified itself), "no
   media query" (there was `@media print`), "twelve" (`640px` as a STRING — three of
   those twelve are `max-width: 640px` container widths and not breakpoints at all).
   Every correction moved one thing and left the counting method alone.*

   It is the COLUMN and not the word: no `overflow-wrap` here, because breaking a
   legal term across lines to fit a layout that should not exist at this width
   hides the next such word instead of fitting it. */
@media (max-width: 640px) {
  .doc-toc ol {
    columns: 1;
  }
}

/* ---- The document body ---------------------------------------------------- */

.doc-body section {
  margin-top: 32px;
}

/* The contents' heading and every section heading: the page-title step,
   20/28, as the canvas sets the prose headings. */
.doc-body h2 {
  margin: 0 0 var(--space-md);
  font-size: var(--text-page-title);
  line-height: var(--text-page-title-lh);
}

.doc-body h3 {
  margin: var(--space-lg) 0 var(--space-sm);
  font-size: var(--text-title-lg);
  line-height: var(--text-title-lg-lh);
}

.doc-body section p,
.doc-body section li {
  font: var(--font-prose);
}

.doc-body section p {
  margin: 0 0 var(--space-md);
}

.doc-body ul,
.doc-body ol {
  padding-left: 20px;
}

.doc-body section li {
  margin-bottom: var(--space-xs);
}

/* A defined term, e.g. the first use of "business partner". Not a colour alone
   — audit rule E-4: the weight carries it for a reader who sees no colour. */
.doc-term {
  font-weight: 600;
  color: var(--sd-text);
}

/* ---- A data table inside a document --------------------------------------

   There is no rule here, and that is the point. The privacy policy's three
   tables use `components/table.css` — `.table` inside `.table-wrap` — like every
   other table on the site. This file carried a `.doc-scroll` that re-derived the
   wrapper's `position: relative` and its `overflow-x`, with the same reasoning
   written out again, while omitting the `overflow-y: hidden` that keeps the
   rounded corners clipping, the touch scrolling, and the caption's own ground.
   A second implementation of a component is a component that will be fixed once.
   ------------------------------------------------------------------------- */

/* ---- Print ---------------------------------------------------------------- */

@media print {
  /* Navigation is useless on paper, and the anchors it offers do not exist
     there. The headings it points at stay. */
  .doc-nav,
  .doc-toc {
    display: none;
  }

  /* The sheet is the page on paper: no card ground, no inset. */
  .doc-layout {
    display: block;
  }

  .doc-sheet {
    padding: 0;
    background: transparent;
  }

  .doc-meta {
    border: 1px solid var(--sd-border);
    background: transparent;
  }

  /* A section heading at the foot of a page, with its text overleaf, is the
     one layout defect that actually costs a reader something in a document
     they are checking clause by clause. */
  .doc-body h2,
  .doc-body h3 {
    break-after: avoid;
  }

  .doc-body section {
    break-inside: auto;
  }

  /* The document's own URL, printed once, so a paper copy says where it came
     from and which version it is. `content` here is generated text and it is
     the one place in this codebase that is acceptable: it is not user-facing
     copy that needs translating, it is the page's own address. */
  .doc-source::after {
    content: ' (' attr(data-url) ')';
    color: var(--sd-text-soft);
    font-size: 0.85em;
  }
}
