/* Shared layout for Impressum and Datenschutz. */
html,
body {
  height: auto;
  overflow-x: clip !important;
  overflow-y: visible;
}

.legal-wrap {
  --legal-header-offset: var(--header-height);
  padding-top: 0;
}

/* Keep the document as the scroll container for the sticky navigation. */
.legal-wrap,
.legal-layout,
.legal-content {
  overflow: visible !important;
}

.legal-layout {
  grid-template-columns: 240px minmax(0, 1fr);
}

.legal-layout .toc {
  position: sticky;
  top: calc(var(--legal-header-offset) + var(--s-4));
  align-self: start;
  max-height: calc(100dvh - var(--legal-header-offset) - var(--s-6));
  overflow: auto !important;
  padding-inline: 0;
}

.legal-content > section {
  /* Override the global landing-page section padding. */
  padding: 0;
  margin-bottom: var(--s-7) !important;
  scroll-margin-top: calc(var(--legal-header-offset) + var(--s-6));
}

.legal-content > section:last-child,
.legal-content > section > :last-child {
  margin-bottom: 0 !important;
}

.legal-content h3 {
  margin-top: var(--s-5);
}

@media (max-width: 900px) {
  .legal-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .legal-layout .toc {
    top: var(--legal-header-offset);
    z-index: 10;
    width: 100% !important;
    margin: 0 !important;
    padding: var(--s-2) 0 !important;
    border-bottom: 1px solid var(--line-1);
  }

  .toc ol {
    display: flex;
    width: max-content;
    max-width: none;
  }

  .toc li {
    flex: 0 0 auto;
  }

  .legal-layout .toc a {
    white-space: nowrap !important;
  }

  .legal-content > section {
    margin-bottom: var(--s-6) !important;
    scroll-margin-top: calc(var(--legal-header-offset) + 6rem);
  }
}

@media (max-width: 768px) {
  #site-header.has-hours-notice ~ .legal-wrap {
    --legal-header-offset: calc(var(--header-height) + var(--fch-header-hours-strip-height));
  }
}
