/* Leitfaden — TSF Ditzingen × Clubway Print Design */

@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400&display=swap");

:root {
  /* TSF Vereinsfarben Grün-Weiß */
  --tsf-green: #009640;
  --tsf-green-dark: #007a33;
  --tsf-green-light: #e8f5ec;
  --tsf-green-muted: #d4eadc;

  /* Clubway Brand (login.tsf-ditzingen.clubway.de) */
  --clubway-cyan: #0091a5;
  --clubway-cyan-dark: #006f7f;
  --clubway-cyan-light: #e6f4f6;
  --clubway-orange: #f4980b;
  --clubway-orange-light: #fef6e8;

  /* Neutrals */
  --ink: #1a1f24;
  --ink-secondary: #4a5560;
  --ink-muted: #6b7785;
  --surface: #ffffff;
  --surface-subtle: #f7f9fa;
  --border: #dde3e8;
  --border-strong: #c5ced6;

  /* Typography */
  --font-sans: "Open Sans", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --line-height: 1.55;
  --measure: 42rem;
}

/* ── Reset & base ─────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--surface-subtle);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 10.5pt;
  line-height: var(--line-height);
  hyphens: auto;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
}

/* Hide pandoc auto title block (technical filename) */
#title-block-header {
  display: none !important;
}

/* ── Cover page ───────────────────────────────────────────── */

.doc-cover {
  page-break-after: always;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 3rem 2.5rem;
  background: linear-gradient(165deg, var(--tsf-green) 0%, var(--tsf-green-dark) 55%, #0f3d22 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.doc-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(0, 145, 165, 0.15) 0%, transparent 40%);
  pointer-events: none;
}

.doc-cover__inner {
  position: relative;
  z-index: 1;
  max-width: 28rem;
}

.doc-cover__logo {
  max-width: 160px;
  height: auto;
  margin: 0 auto 2rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
  background: rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.5rem;
}

.doc-cover__badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clubway-cyan-light);
  background: rgba(0, 145, 165, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.doc-cover__title {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.doc-cover__subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  opacity: 0.92;
  margin: 0 0 2rem;
}

.doc-cover__org--full {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.75;
  margin-top: 0;
}

.doc-cover__org:not(.doc-cover__org--full) {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.92;
  margin: 0 0 0.15rem;
}

.doc-cover__meta {
  font-size: 0.75rem;
  opacity: 0.7;
  margin: 0;
}

.doc-cover__accent {
  width: 4rem;
  height: 4px;
  background: var(--clubway-orange);
  border-radius: 2px;
  margin: 1.75rem auto 0;
}

/* ── Document shell ───────────────────────────────────────── */

.doc-body {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 2.2rem 3rem;
  background: var(--surface);
}

/* ── Table of contents ────────────────────────────────────── */

#TOC {
  page-break-after: always;
  padding: 2.5rem 2.2rem 2rem;
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--surface);
}

#TOC::before {
  content: "Inhalt";
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tsf-green-dark);
  margin-bottom: 0.35rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--tsf-green);
}

#TOC > ul {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
}

#TOC > ul > li {
  margin-bottom: 0.85rem;
}

#TOC > ul > li > a {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border-left: 4px solid var(--tsf-green);
  background: var(--tsf-green-light);
}

#TOC ul ul {
  list-style: none;
  padding: 0.35rem 0 0 1.25rem;
  margin: 0;
}

#TOC ul ul li {
  margin: 0.2rem 0;
}

#TOC ul ul a {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--ink-secondary);
  text-decoration: none;
  padding: 0.2rem 0;
  display: block;
}

#TOC a::after {
  content: none !important;
}

/* TOC uses ul for structure — do not draw body-text list bullets here */
#TOC li {
  padding-left: 0;
}

#TOC ul > li::before,
#TOC ol > li::before {
  content: none !important;
  display: none !important;
}

/* ── Intro section (before Teil 1) ────────────────────────── */

.doc-intro {
  padding-top: 2rem;
}

/* Intro title already on cover — skip duplicate heading */
.doc-intro > h1:first-child {
  display: none;
}

.doc-intro > p:first-of-type {
  font-size: 1.05rem;
  color: var(--ink-secondary);
  margin-top: 0;
}

/* Part headings */
h1[id^="teil-"] {
  page-break-before: always;
  margin: 0 -2.2rem 1.75rem;
  padding: 1.1rem 2.2rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, var(--tsf-green) 0%, var(--tsf-green-dark) 100%);
  border-bottom: 4px solid var(--clubway-orange);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1[id^="anhang"] {
  page-break-before: always;
  margin: 0 -2.2rem 1.5rem;
  padding: 1rem 2.2rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  background: var(--clubway-cyan-dark);
}

/* Section headings inside main content (Leitfaden, not FAQ topic rows) */
.doc-main h2:not([id^="kurz-erkl"]):not([id^="so-gehen"]):not([id^="was-danach"]):not([id^="was-sie-wissen"]):not([id^="wichtig"]):not([id^="hintergrund"]) {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--tsf-green-dark);
  margin: 2rem 0 0.85rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  page-break-after: avoid;
}

/* Real subsection titles (Abteilungs-Leitfaden: h3 für z. B. „Abteilungsebene …“) */
.doc-main h3:not([id^="kurz-erkl"]):not([id^="so-gehen"]):not([id^="was-danach"]):not([id^="was-sie-wissen"]):not([id^="wichtig"]):not([id^="hintergrund"]) {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  color: var(--tsf-green-dark);
  margin: 1.35rem 0 0.55rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-strong);
  page-break-after: avoid;
}

/* Schritt-Labels (Kurz erklärt, So gehen Sie vor, …) — gleiche Optik für h2 und h3 */
.doc-main h2[id^="kurz-erklärt"],
.doc-main h2[id^="kurz-erkl"],
.doc-main h2[id^="so-gehen"],
.doc-main h2[id^="was-danach"],
.doc-main h2[id^="was-sie-wissen"],
.doc-main h2[id^="wichtig"],
.doc-main h2[id^="hintergrund"],
.doc-main h3[id^="kurz-erklärt"],
.doc-main h3[id^="kurz-erkl"],
.doc-main h3[id^="so-gehen"],
.doc-main h3[id^="was-danach"],
.doc-main h3[id^="was-sie-wissen"],
.doc-main h3[id^="wichtig"],
.doc-main h3[id^="hintergrund"] {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 1.5rem 0 0.6rem;
  padding-bottom: 0;
  border-bottom: none;
  page-break-after: avoid;
}

.doc-main h2[id^="kurz-erklärt"],
.doc-main h2[id^="kurz-erkl"],
.doc-main h3[id^="kurz-erklärt"],
.doc-main h3[id^="kurz-erkl"] {
  color: var(--clubway-cyan-dark);
}

.doc-main h2[id^="so-gehen"],
.doc-main h3[id^="so-gehen"] {
  color: var(--tsf-green);
}

.doc-main h2[id^="was-danach"],
.doc-main h2[id^="was-sie-wissen"],
.doc-main h3[id^="was-danach"],
.doc-main h3[id^="was-sie-wissen"] {
  color: var(--ink-secondary);
}

.doc-main h2[id^="wichtig"],
.doc-main h2[id^="hintergrund"],
.doc-main h3[id^="wichtig"],
.doc-main h3[id^="hintergrund"] {
  color: var(--clubway-orange);
}

.doc-main h3 + p,
.doc-main h3 + ul,
.doc-main h3 + ol,
.doc-main h2 + p,
.doc-main h2 + ul,
.doc-main h2 + ol {
  margin-top: 0;
}

/* ── Body text ────────────────────────────────────────────── */

p {
  margin: 0.55em 0;
  color: var(--ink);
}

strong {
  font-weight: 700;
  color: var(--ink);
}

em {
  font-style: italic;
  color: var(--ink-secondary);
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  color: var(--clubway-cyan-dark);
}

a {
  color: var(--clubway-cyan);
  text-decoration: underline;
  text-decoration-color: rgba(0, 145, 165, 0.35);
  text-underline-offset: 2px;
  word-break: break-word;
}

a:hover {
  color: var(--clubway-cyan-dark);
}

hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2rem 0;
}

/* ── Lists ────────────────────────────────────────────────── */

ul, ol {
  margin: 0.5em 0 0.85em;
  padding-left: 0;
}

ul {
  list-style: none;
}

ul > li {
  position: relative;
  padding-left: 1.35rem;
  margin-bottom: 0.4em;
}

ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tsf-green);
}

ol {
  counter-reset: step var(--step-start, 0);
  list-style: none;
  padding-left: 0;
}

ol > li {
  counter-increment: step;
  position: relative;
  padding: 0.65rem 0 0.65rem 2.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

ol > li:last-child {
  border-bottom: none;
}

ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 1.85rem;
  height: 1.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--tsf-green);
  border-radius: 50%;
}

ol > li > p {
  margin: 0;
}

/* ── Blockquotes (Hinweise) ───────────────────────────────── */

blockquote {
  margin: 1.25rem 0;
  padding: 0.85rem 1.1rem;
  border-left: 4px solid var(--clubway-orange);
  background: var(--clubway-orange-light);
  border-radius: 0 8px 8px 0;
  color: var(--ink);
}

blockquote p {
  margin: 0;
  font-size: 0.95em;
}

blockquote strong {
  color: #9a5f00;
}

/* Wichtig sections — content after label heading */
.doc-main h2[id^="wichtig"] + ul,
.doc-main h2[id^="wichtig"] + p,
.doc-main h3[id^="wichtig"] + ul,
.doc-main h3[id^="wichtig"] + p {
  background: var(--clubway-orange-light);
  border: 1px solid #f5d9a0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.doc-main h2[id^="wichtig"] + ul,
.doc-main h3[id^="wichtig"] + ul {
  margin-top: 0;
  padding-left: 1rem;
}

.doc-main h2[id^="wichtig"] + ul > li::before,
.doc-main h3[id^="wichtig"] + ul > li::before {
  background: var(--clubway-orange);
}

/* Hintergrund boxes */
.doc-main h2[id^="hintergrund"] + p,
.doc-main h3[id^="hintergrund"] + p {
  background: var(--clubway-cyan-light);
  border: 1px solid #b8dfe6;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.95em;
  color: var(--ink-secondary);
}

/* ── Tables ───────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25rem 0;
  font-size: 0.92em;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

thead th,
tbody tr:first-child th {
  background: var(--tsf-green);
  color: #fff;
  font-weight: 700;
  text-align: left;
  padding: 0.65rem 0.9rem;
  border: none;
}

tbody td,
tbody th {
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) td {
  background: var(--surface-subtle);
}

tbody tr:hover td {
  background: var(--tsf-green-light);
}

/* ── Print footer (fixed) ─────────────────────────────────── */

.doc-print-footer {
  display: none;
}

/* ── Print media ──────────────────────────────────────────── */

@page {
  size: A4;
  margin: 18mm 16mm 22mm 16mm;
}

@media print {
  html {
    background: white;
  }

  body {
    font-size: 10pt;
    background: white;
  }

  .doc-cover {
    min-height: auto;
    height: 100vh;
  }

  .doc-body,
  #TOC {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }

  h1[id^="teil-"],
  h1[id^="anhang"] {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  h2, h3 {
    orphans: 3;
    widows: 3;
    page-break-after: avoid;
  }

  ol > li,
  blockquote,
  table {
    page-break-inside: avoid;
  }

  /* Links: subtle URL only for appendix table */
  a[href^="http"]::after {
    content: none;
  }

  #TOC a,
  .doc-cover a {
    text-decoration: none;
  }

  thead th,
  .doc-cover,
  h1[id^="teil-"],
  ol > li::before,
  #TOC > ul > li > a {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media screen {
  body {
    padding-bottom: 3rem;
  }

  .doc-body {
    box-shadow: 0 2px 24px rgba(0, 0, 0, 0.06);
    margin-top: 1rem;
    margin-bottom: 2rem;
    border-radius: 4px;
  }

  #TOC {
    box-shadow: 0 2px 24px rgba(0, 0, 0, 0.06);
    margin-top: 1rem;
    border-radius: 4px;
  }
}

/* ── Leitfaden screenshots ───────────────────────────────── */

.doc-figure {
  margin: 1.25rem 0 1.5rem;
  text-align: center;
}

.doc-figure img {
  max-width: 85%;
  max-height: 14cm;
  width: auto;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.doc-figure--compact img,
img.doc-figure--compact {
  max-width: 60%;
  max-height: 10cm;
}

.doc-figure figcaption {
  font-size: 0.88em;
  color: var(--ink-secondary);
  margin-top: 0.45rem;
  line-height: 1.45;
  text-align: center;
}

.doc-figure-series {
  margin: 1rem 0 1.5rem;
}

.doc-figure-series .doc-figure {
  margin: 0.75rem 0;
}

.doc-step-ref {
  font-size: 0.9em;
  color: var(--ink-secondary);
  margin: 1rem 0 0.35rem;
}

@media print {
  .doc-figure,
  .doc-figure-series {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  ol > li:has(+ .doc-figure),
  ol > li:has(+ .doc-figure-series) {
    page-break-after: avoid;
  }
}

/* ── FAQ mode ─────────────────────────────────────────────── */

body.doc-faq-mode .doc-intro > h1:first-child,
body.doc-faq-mode .doc-faq-intro > h1:first-child {
  display: none;
}

.doc-faq-intro {
  padding-top: 1.5rem;
  font-size: 1rem;
  color: var(--ink-secondary);
}

.doc-faq-intro::before {
  content: "So nutzen Sie dieses FAQ";
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--tsf-green-dark);
  margin-bottom: 0.75rem;
}

.doc-main.doc-faq h2.faq-topic {
  page-break-before: always;
  margin: 2.5rem 0 1.25rem;
  padding-bottom: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tsf-green-dark);
  border-bottom: 3px solid var(--tsf-green);
}

.doc-main.doc-faq h2.faq-topic:first-child {
  page-break-before: auto;
  margin-top: 0;
}

.doc-main.doc-faq h2.faq-scenario {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--clubway-cyan-dark);
  margin: 1.75rem 0 0.75rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--clubway-cyan);
}

.doc-main.doc-faq .faq-item {
  margin-bottom: 1.5rem;
}

.doc-main.doc-faq .faq-item > h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  margin: 0 0 0.65rem;
  padding: 0.75rem 1rem;
  background: var(--surface-subtle);
  border-left: 4px solid var(--clubway-cyan);
  border-radius: 0 8px 8px 0;
  page-break-after: avoid;
}

.doc-main.doc-faq .faq-answer-lead {
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.doc-main.doc-faq .faq-action {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--tsf-green-light);
  border: 1px solid var(--tsf-green-muted);
  border-left: 4px solid var(--tsf-green);
  border-radius: 0 8px 8px 0;
}

.doc-main.doc-faq .faq-action p {
  margin: 0 0 0.5rem;
  font-weight: 700;
  color: var(--tsf-green-dark);
}

.doc-main.doc-faq .faq-action ul {
  margin: 0;
}

.doc-main.doc-faq .faq-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  margin-top: 0.35rem;
}

@media print {
  .doc-main.doc-faq .faq-item,
  .doc-main.doc-faq .faq-action {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
