/* ============================================================
   AA – Table of Contents
   ============================================================ */

/*
 * Damit sticky funktioniert, muss der Bricks-Shortcode-Wrapper
 * (brxe-shortcode) genauso hoch sein wie die Inhaltsspalte.
 * :has() stellt sicher, dass nur der Wrapper um das TOC betroffen ist.
 */
.brxe-shortcode:has(.aa-toc) {
  align-self: stretch;
}

.aa-toc {
  position: sticky;
  top: 6rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Header */
.aa-toc__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-primary, #e5e7eb);
}

.aa-toc__icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  color: var(--brand, #0069b4);
}

.aa-toc__title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-title, #111827);
  line-height: 1;
}

/* Liste */
.aa-toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: aa-toc;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.aa-toc__item {
  counter-increment: aa-toc;
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  list-style: none !important;
}

/* Link */
.aa-toc__link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem 0.375rem 0.5rem;
  border-left: 2px solid transparent;
  border-radius: 0 0.25rem 0.25rem 0;
  color: inherit;
  text-decoration: none;
  line-height: 1.45;
  transition: color 0.15s ease, background-color 0.15s ease, border-left-color 0.15s ease;
}

/* Nummerierung */
.aa-toc__link::before {
  content: counter(aa-toc) ".";
  flex-shrink: 0;
  min-width: 1.375rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--dark-brand, #004e87);
  line-height: inherit;
}

/* Hover */
.aa-toc__link:hover {
  color: var(--dark-brand, #004e87);
  background-color: var(--bg-light-accent, #f0f7fc);
  border-left-color: var(--brand, #0069b4);
}

/* Focus */
.aa-toc__link:focus-visible {
  outline: var(--focus-border, 2px solid #0069b4);
  outline-offset: var(--focus-offset, 2px);
  border-radius: 0.25rem;
}

/* Aktiver Abschnitt (gesetzt per JS via aria-current) */
.aa-toc__link[aria-current="location"] {
  color: var(--dark-brand, #004e87);
  background-color: var(--bg-light-accent, #f0f7fc);
  border-left-color: var(--brand, #0069b4);
  font-weight: 500;
}

/* Fortschrittsbalken */
.aa-toc__progress-bar {
  height: 3px;
  background-color: var(--border-primary, #e5e7eb);
  border-radius: 99px;
  margin-top: 1rem;
  overflow: hidden;
}

.aa-toc__progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand, #0069b4), var(--dark-brand, #004e87));
  border-radius: 99px;
  transition: width 0.1s linear;
  will-change: width;
}
