/* =================================================================
   VERFLIXT IM KOPF · Kapitel-Übersicht (Inhaltsverzeichnis)
   Baut auf style.css auf · reuse aller Tokens · Manual-Index-Tonalität
   ================================================================= */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* =================================================================
   INTRO / Hero der Übersicht
   ================================================================= */

.toc-hero {
  padding-top: clamp(2.75rem, 6vw, 4.5rem);
  padding-bottom: clamp(2.5rem, 5vw, 3.75rem);
  background:
    radial-gradient(ellipse 55% 60% at 12% 12%, rgba(26, 147, 166, 0.10) 0%, transparent 70%),
    radial-gradient(ellipse 55% 55% at 90% 30%, rgba(209, 68, 56, 0.09) 0%, transparent 70%);
  border-bottom: 1px solid var(--line);
}

.toc-hero-headline {
  margin-bottom: 1.5rem;
}

.toc-hero-sub {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 600px;
  margin: 0 0 2.5rem;
}

/* =================================================================
   INDEX-LAYOUT · Rail + Inhalt
   ================================================================= */

.toc-section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
  background: var(--bg-elev);
}

.toc-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
}

/* ---------- Sidebar-Index ---------- */

/* Sticky + Scroll auf dem Grid-Item selbst: Containing-Block ist dann die volle
   Grid-Zeilenhöhe (wie beim Autor-Portrait der Startseite), nicht die kurze Rail. */
.toc-rail {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.toc-rail::-webkit-scrollbar {
  display: none;
}
.toc-rail-inner {
  padding-right: 0;
}

.toc-rail-title {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 1.1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line-ink);
}

.toc-nav { list-style: none; margin: 0 0 1.75rem; padding: 0; }
.toc-sub { list-style: none; margin: 0; padding: 0; }

.toc-nav-group { margin-top: 1.4rem; }
.toc-nav-group--1 { --pa: var(--accent);   --pa-ink: var(--accent-deep); }
.toc-nav-group--2 { --pa: var(--accent-2); --pa-ink: var(--accent-2-deep); }
.toc-nav-group--3 { --pa: var(--accent-3); --pa-ink: #9C7A14; }

.toc-part-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  padding: 0.4rem 0 0.55rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}
.toc-part-no {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pa-ink);
}
.toc-part-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: 'wght' 600, 'wdth' 100, 'opsz' 18;
  font-size: 0.95rem;
  line-height: 1.2;
  color: var(--ink);
  transition: color var(--transition-fast);
}
.toc-part-link:hover .toc-part-name { color: var(--pa-ink); }

.toc-nav-row--intro { --pa: var(--ink-soft); --pa-ink: var(--ink); }

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  text-decoration: none;
  padding: 0.42rem 0.5rem 0.42rem 0.7rem;
  border-left: 2px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.toc-link-no {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  flex: 0 0 auto;
  padding-top: 0.05rem;
}
.toc-link-title {
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--ink-muted);
  transition: color var(--transition-fast);
}
.toc-link:hover { background: rgba(31, 26, 38, 0.035); }
.toc-link:hover .toc-link-title { color: var(--ink); }

.toc-link.is-active {
  border-left-color: var(--pa);
  background: rgba(31, 26, 38, 0.04);
}
.toc-link.is-active .toc-link-title { color: var(--ink); font-weight: 600; }
.toc-link.is-active .toc-link-no { color: var(--pa-ink); }

.toc-rail-cta {
  width: 100%;
  justify-content: center;
}

/* ---------- Mobile-Toggle des Index ---------- */
.toc-toggle { display: none; }

/* =================================================================
   PART · Teil-Trenner
   ================================================================= */

.part {
  margin: 0 0 2.25rem;
  padding-top: 0.5rem;
}
.chapter + .part { margin-top: 3.5rem; }

.part--1 { --pa: var(--accent);   --pa-ink: var(--accent-deep);   --pa-soft: var(--accent-soft); }
.part--2 { --pa: var(--accent-2); --pa-ink: var(--accent-2-deep); --pa-soft: var(--accent-2-soft); }
.part--3 { --pa: var(--accent-3); --pa-ink: #9C7A14;              --pa-soft: rgba(232, 185, 69, 0.16); }

.part-kicker {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1rem;
}
.part-no {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pa-ink);
  white-space: nowrap;
}
.part-rule {
  flex: 1 1 auto;
  height: 2px;
  background: var(--pa);
  opacity: 0.85;
}
.part-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-variation-settings: 'wght' 700, 'wdth' 100, 'opsz' 60;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 0.85rem;
}
.part-intro {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-variation-settings: 'wght' 400, 'wdth' 100, 'opsz' 24;
  font-size: clamp(1.0625rem, 1.6vw, 1.2rem);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0;
}

/* =================================================================
   CHAPTER · Kapitel-Block
   ================================================================= */

.chapter {
  --pa: var(--accent-2);
  --pa-ink: var(--accent-2-deep);
  --pa-soft: var(--accent-2-soft);
  border-top: 1px solid var(--line-ink);
  padding: 2.25rem 0 0.5rem;
  scroll-margin-top: 96px;
}
.part { scroll-margin-top: 96px; }
.chapter:first-of-type { border-top: none; }

.chapter-head { margin-bottom: 1.1rem; }
.chapter-kicker {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0 0 0.7rem;
}
.chapter-no {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pa-ink);
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
}
.chapter-no::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--pa);
  display: inline-block;
}

.chapter-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: 'wght' 600, 'wdth' 100, 'opsz' 40;
  font-size: clamp(1.4rem, 2.6vw, 1.95rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin: 0;
}

.chapter-desc {
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 680px;
  margin: 0 0 1.75rem;
}
.chapter-desc--lead {
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--ink);
  font-weight: 500;
  max-width: 720px;
}

/* Kapitel erben die Akzentfarbe ihres Teils (höhere Spezifität als .chapter-Default) */
.chapter.part--1 { --pa: var(--accent);   --pa-ink: var(--accent-deep);   --pa-soft: var(--accent-soft); }
.chapter.part--2 { --pa: var(--accent-2); --pa-ink: var(--accent-2-deep); --pa-soft: var(--accent-2-soft); }
.chapter.part--3 { --pa: var(--accent-3); --pa-ink: #9C7A14;              --pa-soft: rgba(232, 185, 69, 0.16); }

.chapter--intro {
  --pa: var(--ink-soft);
  --pa-ink: var(--ink);
}

/* ---------- Unterkapitel ---------- */

.subchapters {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pa);
  padding: 1.5rem clamp(1.25rem, 3vw, 2rem) 0.5rem;
  margin-bottom: 0.5rem;
}
.sub-label {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
}

.sub-list {
  counter-reset: sub;
  list-style: none;
  margin: 0;
  padding: 0;
}
.sub-item {
  counter-increment: sub;
  position: relative;
  padding: 1.05rem 0 1.05rem 2.9rem;
  border-top: 1px solid var(--line);
}
.sub-item::before {
  content: counter(sub, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--pa-ink);
}
.sub-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: 'wght' 600, 'wdth' 100, 'opsz' 20;
  font-size: 1.0625rem;
  line-height: 1.25;
  letter-spacing: -0.008em;
  color: var(--ink);
  margin: 0 0 0.3rem;
}
.sub-desc {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 640px;
}

/* =================================================================
   ABSCHLUSS · Claim + CTA (inverted)
   ================================================================= */

.closing {
  position: relative;
  color: var(--bg-elev);
  border-top: 1px solid var(--line);
  background:
    radial-gradient(ellipse 50% 50% at 15% 0%, rgba(26, 147, 166, 0.20) 0%, transparent 65%),
    radial-gradient(ellipse 60% 60% at 85% 100%, rgba(209, 68, 56, 0.20) 0%, transparent 65%),
    var(--bg-inverse);
}
.closing .section-label { color: rgba(255,255,255,0.55); }
.closing .section-label .rule { background: rgba(255,255,255,0.4); }
.closing .section-label .title { color: var(--bg-elev); }

.closing-quote {
  margin: 0 auto 2.25rem;
  padding: 0;
  max-width: 760px;
}
.closing-quote p {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: 'wght' 500, 'wdth' 100, 'opsz' 72;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--bg-elev);
  margin: 0;
}

.closing-headline {
  color: var(--bg-elev);
  margin-bottom: 0.5rem;
}
.closing-headline em { border-bottom-color: var(--accent); }
.closing-sub {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-variation-settings: 'wght' 400, 'wdth' 100, 'opsz' 24;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  color: rgba(255,255,255,0.72);
  margin: 0 0 2.5rem;
}

.closing-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}
.closing .btn-primary {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--bg-elev);
}
.closing .btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-elev);
}
.closing-back {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}
.closing-back:hover { color: var(--bg-elev); }

/* =================================================================
   Reveal (nutzt .reveal/.is-visible aus style.css)
   ================================================================= */

.chapter.reveal, .part.reveal { will-change: opacity, transform; }

/* =================================================================
   Responsive
   ================================================================= */

@media (max-width: 1023px) {
  .toc-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .toc-rail {
    position: sticky;
    top: 64px;
    z-index: 30;
    margin: 0 calc(-1 * var(--pad-x));
    background: rgba(251, 246, 234, 0.96);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line-ink);
    max-height: none;
    overflow: visible;
  }
  .toc-rail-inner {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0 var(--pad-x);
  }

  .toc-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 0;
    background: transparent;
    border: none;
    text-align: left;
  }
  .toc-toggle-label {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
    flex: 0 0 auto;
  }
  .toc-toggle-current {
    flex: 1 1 auto;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .toc-toggle-icon {
    position: relative;
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
  }
  .toc-toggle-icon::before,
  .toc-toggle-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    background: var(--ink);
    transition: transform var(--transition-base), opacity var(--transition-fast);
  }
  .toc-toggle-icon::before { width: 12px; height: 1.5px; transform: translate(-50%, -50%); }
  .toc-toggle-icon::after  { width: 1.5px; height: 12px; transform: translate(-50%, -50%); }
  .toc-toggle[aria-expanded="true"] .toc-toggle-icon::after { transform: translate(-50%, -50%) rotate(90deg); opacity: 0; }

  .toc-list {
    display: none;
    padding-bottom: 1.25rem;
    max-height: 68vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  .toc-list::-webkit-scrollbar {
    display: none;
  }
  .toc-rail.is-open .toc-list { display: block; }
  .toc-rail-title { display: none; }

  .chapter { scroll-margin-top: 132px; }
  .part { scroll-margin-top: 124px; }
}

@media (max-width: 768px) {
  .toc-rail { top: 64px; }
  .subchapters { padding-left: clamp(1rem, 4vw, 1.25rem); padding-right: clamp(1rem, 4vw, 1.25rem); }
  .sub-item { padding-left: 2.4rem; }
}


@media (prefers-reduced-motion: reduce) {
  .chapter, .part { transition: none; }
}

@media print {
  .toc-rail, .closing-actions, .site-header, .nav-toggle, .primary-nav, .bw3d-footer { display: none; }
  .toc-layout { grid-template-columns: 1fr; }
  body { background: white; color: black; }
  .closing { background: white; color: black; }
}
