/* AGB / Terms and Conditions: table of contents (see site/templates/agb.php) */

.agb #overview,
.agb-content h2,
.agb-content h3,
.agb-content h4,
.agb-content a[name] {
  scroll-margin-top: 1.5rem;
}

/* Intro block (company, date, translation notice): evenly balanced lines */
.agb-intro h2,
.agb-intro h3,
.agb-intro p {
  text-wrap: balance;
}

/* Lists numbered in the text itself, e.g. "a) …" in Teil VI */
.agb-alpha-list {
  list-style: none;
  padding-left: 1.5rem;
}

.agb-toc {
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 2rem;
}

.agb-toc__summary {
  padding: 1rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

.agb-toc__nav {
  padding: 0 1.25rem 1rem;
}

.agb-toc__list,
.agb-toc__sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.agb-toc__overview,
.agb-toc__part {
  margin-top: 0.75rem;
}

.agb-toc__link,
.agb-toc__part-link {
  display: block;
  padding: 0.25rem 0 0.25rem 0.75rem;
  border-left: 3px solid transparent;
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.3;
  text-decoration: none;
  /* Long single words such as "Verwerkingsverantwoordelijken" must not run into the box border */
  hyphens: auto;
  overflow-wrap: break-word;
}

.agb-toc__part-link,
.agb-toc__overview .agb-toc__link {
  font-weight: 700;
}

.agb-toc__sub .agb-toc__link {
  font-size: 0.85rem;
}

.agb-toc__link:hover,
.agb-toc__part-link:hover {
  color: var(--color-code-primary-blue);
}

.agb-toc__link.is-active,
.agb-toc__part-link.is-active {
  border-left-color: var(--color-code-primary-blue);
  color: var(--color-code-primary-blue);
  font-weight: 600;
}

.agb-toc a:focus-visible,
.agb-toc button:focus-visible,
.agb-toc summary:focus-visible {
  outline: 2px solid var(--color-code-primary-blue);
  outline-offset: 2px;
}

/* Accordion, only once agb.js is running */
button.agb-toc__part-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  text-align: left;
  cursor: pointer;
}

.agb-toc__chevron {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.agb-toc__part.is-open .agb-toc__chevron {
  transform: rotate(-135deg);
}

.agb-toc--js .agb-toc__part:not(.is-open) > .agb-toc__sub {
  display: none;
}

.agb-toc__sub {
  margin: 0.25rem 0 0 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
  .agb-toc__chevron {
    transition: none;
  }
}

@media (max-width: 991.98px) {
  /* Long words such as "Geschäftsbedingungen" must not break the layout */
  .agb h1,
  .agb-intro h2,
  .agb-intro h3,
  .agb-guide td,
  .agb-content h2,
  .agb-content h3,
  .agb-content h4 {
    hyphens: auto;
    hyphenate-limit-chars: 12 5 5;
    overflow-wrap: break-word;
  }

  /* Wegweiser: stacked cells per service instead of three narrow columns */
  .agb-guide thead {
    display: none;
  }

  .agb-guide,
  .agb-guide tbody,
  .agb-guide tr,
  .agb-guide td {
    display: block;
    width: 100%;
  }

  .agb-guide {
    border: 0;
  }

  .agb-guide td {
    margin: 0;
    padding: 0.4rem 0.75rem;
    border: 1px solid #dee2e6;
    border-top: 0;
    font-size: 0.875rem;
  }

  .agb-guide tr {
    margin: 0;
  }

  .agb-guide tr + tr {
    margin-top: 0.75rem;
  }

  .agb-guide td:first-child {
    border-top: 1px solid #dee2e6;
  }

  .agb-guide td:first-child {
    background: #f8f9fa;
    font-weight: 700;
  }

  .agb-guide td + td::before {
    content: attr(data-label) ": ";
    color: var(--color-grey);
  }

  /* The collapsed "Contents" block stays at the top while reading */
  .agb-toc-col {
    position: sticky;
    top: 0;
    z-index: 10;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
    background: var(--color-background);
  }

  .agb-toc {
    margin-bottom: 0;
  }

  .agb-toc[open] .agb-toc__nav {
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
  }

  /* Leave room for the sticky block above jumped-to headings */
  .agb #overview,
  .agb-content h2,
  .agb-content h3,
  .agb-content h4,
  .agb-content a[name] {
    scroll-margin-top: 5rem;
  }
}

@media (min-width: 992px) {
  .agb-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
  }

  .agb-toc-col {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
  }

  .agb-toc {
    margin-bottom: 0;
  }

  .agb-toc__summary {
    display: none;
  }

  .agb-toc__nav {
    padding-top: 0.5rem;
  }
}
