/* «Regulamin», «O nas», «Jak liczymy» (task 204, Pages/Info/_Document) — a text to read, not a screen to work. Linked
   by those three pages only (@section Styles), after 13-accounts.css. One column of ~68 characters on the text's own
   tokens; the terms' table of contents in a 15 rem column beside it from 1 100 px, held under the header as the text
   scrolls, and above the text below that. The one mark of the brand: the «§ N» numbers in the accent, set as figures.
   Print: the text alone, black on white, a link's address after it. */

.doc {
  --doc-measure: 68ch;
  max-width: var(--doc-measure);
  margin: var(--space-4) auto var(--space-8);
  color: var(--text);
  font-size: var(--text-lg);
  line-height: 1.65;
}

.doc ::selection {
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  color: var(--text);
}

.doc__head {
  grid-area: head;
  margin-bottom: var(--space-6);
}

.doc__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.doc__lead {
  margin: var(--space-3) 0 0;
  color: var(--text);
  font-size: 1.125rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.doc__meta {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

/* «Це переклад …; обов'язковою є польська версія» — a whole box, never a bar down one side. */
.doc__note {
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  background: var(--surface-2);
  font-size: var(--text-md);
  line-height: 1.5;
}

.doc a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.doc a:hover {
  text-decoration-thickness: 2px;
}

.doc a:focus-visible,
.doc-toc__title:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-1);
}

.doc-no {
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* The table of contents: the terms' twelve paragraphs. */
.doc-toc {
  grid-area: toc;
  margin: 0 0 var(--space-6);
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  background: var(--surface-1);
  font-size: var(--text-md);
  line-height: 1.4;
}

/* A flex summary loses its marker: the chevron is drawn, turned down when open. */
.doc-toc__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  color: var(--text);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.doc-toc__title::-webkit-details-marker {
  display: none;
}

.doc-toc__title::after {
  content: "";
  width: 0.5em;
  height: 0.5em;
  margin-left: auto;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 160ms var(--ease-out);
}

.doc-toc[open] > .doc-toc__title::after {
  transform: translateY(0.1em) rotate(-135deg);
}

.doc-toc__count {
  color: var(--text-muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.doc-toc[open] .doc-toc__list {
  padding-bottom: var(--space-3);
}

.doc-toc__list {
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
}

.doc-toc__list a {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  min-height: var(--control-sm);
  padding-block: var(--space-1);
  color: var(--text-muted);
  text-decoration: none;
}

.doc-toc__list a:hover {
  color: var(--text);
  text-decoration: underline;
}

.doc-toc__list .doc-no {
  flex: none;
  min-width: 2.6em;
}

.doc__body {
  grid-area: body;
  min-width: 0;
}

.doc-section {
  scroll-margin-top: calc(var(--app-header) + var(--space-4));
}

.doc-section + .doc-section {
  margin-top: var(--space-8);
}

.doc-section__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
}

.doc-section p {
  margin: 0 0 var(--space-3);
  text-wrap: pretty;
}

/* The terms' paragraphs (ustępy) «1.», their points «1)» — the numbers a lawyer cites, in the margin as figures. */
.doc-section__items,
.doc-points,
.doc-list {
  margin: 0;
  padding-left: 1.75em;
}

.doc-section__items > li {
  margin-bottom: var(--space-3);
  padding-left: var(--space-1);
  text-wrap: pretty;
}

.doc-section__items > li::marker,
.doc-points > li::marker {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.doc-points {
  margin-top: var(--space-2);
}

.doc-points > li::marker {
  content: counter(list-item) ")\00a0\00a0";
}

.doc-points > li + li,
.doc-list > li + li {
  margin-top: var(--space-2);
}

.doc-list {
  margin-bottom: var(--space-3);
}

/* From 1 100 px the contents stand beside the text, held under the header; the head over the text's column. */
@media (min-width: 1100px) {
  .doc--contents {
    display: grid;
    grid-template-columns: 15rem minmax(0, var(--doc-measure));
    grid-template-areas:
      "toc head"
      "toc body";
    align-items: start;
    column-gap: var(--space-8);
    max-width: calc(15rem + var(--space-8) + var(--doc-measure));
  }

  .doc--contents .doc-toc {
    position: sticky;
    top: calc(var(--app-header) + var(--space-4));
    max-height: calc(100dvh - var(--app-header) - var(--space-8));
    margin: 0;
    overflow-y: auto;
    padding: 0;
    border: 0;
    background: none;
  }

  /* Open beside the text, nothing to fold: the summary is its heading. */
  .doc--contents .doc-toc__title {
    min-height: 0;
    margin-bottom: var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-sm);
    pointer-events: none;
  }

  .doc--contents .doc-toc__title::after,
  .doc--contents .doc-toc__count {
    display: none;
  }

  .doc--contents .doc-toc__list a {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .doc-toc__title::after {
    transition: none;
  }
}

@media (max-width: 480px) {
  .doc {
    margin-top: var(--space-2);
  }

  .doc__title {
    font-size: 1.5rem;
  }
}

@media print {
  .app-header,
  .ui-footer,
  .ui-tabbar,
  .app-tabbar,
  .ui-consent,
  .doc-toc,
  [data-toasts] {
    display: none !important;
  }

  .doc {
    max-width: none;
    margin: 0;
    color: #000;
    font-size: 11pt;
    line-height: 1.5;
  }

  .doc a {
    color: #000;
  }

  /* An address the paper cannot follow is printed after its words; an e-mail is its own words. */
  .doc a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.9em;
  }

  .doc-no,
  .doc-section__items > li::marker,
  .doc-points > li::marker {
    color: #000;
  }

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

  .doc-section__title {
    break-after: avoid;
  }

  .doc__note {
    border-color: #000;
    background: none;
  }
}
