
/* Fahrschule am ADAC, Rechtsseiten: Gestaltung aus Schritt 5 auf der echten eRecht24-Ausgabe.
   Haken im Divi-Inhalt (CSS-Klassen der Module, gesetzt unter Erweitert > Attribute):
     .recht-kopf    Hero-Sektion der Seite (wird zur niedrigen blauen Kopfzone)
     .recht-text    Textmodul(e) mit dem eRecht24-Shortcode bzw. ergänzendem Rechtstext
     .recht-text--anhang  zusätzliches Textmodul, das als eigener Abschnitt angehängt wird (Social Media)
   Ohne JavaScript greifen nur Typografie, Abstände und Kopfzone; der Text bleibt vollständig lesbar.
   Mit recht-live.js kommen Anschriftkarte, Abschnitte, Inhaltsverzeichnis und Sprungmarken dazu
   (Klassen rl-*). Der Rechtstext selbst wird nie verändert.
   Achtung: Das Divi-Code-Modul führt Shortcodes aus. In diesen Kommentaren keine eckigen Klammern
   mit Shortcode-Namen schreiben, sonst landet deren Ausgabe im Stylesheet. */

.recht-kopf, .et_pb_section:has(.recht-text), .recht-text {
  --rl-blau: #03045E;
  --rl-rot: #DC3632;
  --rl-rot-text: #B3241F;
  --rl-text: #131516;
  --rl-text-leise: #4A5058;
  --rl-linie: #DCE1E7;
  --rl-flaeche: #F3F5F8;
  --rl-blau-tint: #ECEEF8;
  --rl-schrift: "IBM Plex Sans", system-ui, sans-serif;
  --rl-schrift-titel: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --rl-rand: clamp(16px, 4vw, 40px);
  --rl-spalte: 68ch;
  --rl-karte-radius: 16px;
  --rl-innen-radius: 12px;
  --rl-sticky: 28px;              /* Live-Kopf ist nicht sticky: nur Luft über Sprungzielen */
  --rl-ease: cubic-bezier(0.23, 1, 0.32, 1);
}
html:has(.recht-text) { scroll-padding-top: 24px; }
@media (prefers-reduced-motion: no-preference) { html:has(.recht-text) { scroll-behavior: smooth; } }

/* ---------------------------------------------------------------- Kopfzone */
.et_pb_section.recht-kopf {
  background: var(--rl-blau) !important;
  background-image: none !important;
  padding: clamp(36px, 4.4vw, 60px) 0 clamp(36px, 4vw, 56px) !important;
}
.recht-kopf .et_pb_bottom_inside_divider, .recht-kopf .et_pb_top_inside_divider { display: none !important; }
.recht-kopf .et_pb_row {
  width: min(100% - 2 * var(--rl-rand), 1200px) !important; max-width: none !important;
  padding: 0 !important; margin-inline: auto !important;
}
.recht-kopf .et_pb_column { width: 100% !important; margin: 0 !important; padding: 0 !important; }
.recht-kopf .et_pb_column_empty { display: none !important; }
/* Überzeile der Hero-Vorlage entfällt in der Kopfzone (in Divi: Modul entfernen) */
.recht-kopf .et_pb_heading:not(:has(h1)) { display: none !important; }
.recht-kopf .et_pb_heading:has(h1) { margin: 0 !important; padding: 0 !important; }
.recht-kopf .et_pb_heading_container:has(h1) { display: flex; align-items: center; gap: clamp(20px, 2.4vw, 32px); }
.recht-kopf h1 {
  flex: none; max-width: 100%; margin: 0 !important; padding: 0 !important;
  font-family: var(--rl-schrift-titel) !important; font-weight: 600 !important; color: #fff !important;
  font-size: clamp(32px, 2.2vw + 22px, 52px) !important; line-height: 1.04 !important;
  letter-spacing: normal !important; text-transform: none !important;
  hyphens: manual; overflow-wrap: break-word;
}
.recht-kopf .et_pb_heading_container:has(h1)::after {
  content: ""; flex: 1 1 auto; min-width: 72px; height: 4px; margin-top: .2em;
  background: linear-gradient(to right, rgba(255, 255, 255, .92) 0 55%, transparent 55% 100%) left center / 40px 4px round;
}
@media (prefers-reduced-motion: no-preference) {
  .recht-kopf .et_pb_heading_container:has(h1)::after { animation: rl-linie-rein 900ms var(--rl-ease) 120ms both; }
  @keyframes rl-linie-rein { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
}

/* ---------------------------------------------------------------- Sektion und Reihe des Rechtstexts */
.et_pb_section:has(> .et_pb_row .recht-text) { padding: clamp(32px, 4.4vw, 64px) 0 clamp(56px, 7vw, 104px) !important; }
.et_pb_row:has(.recht-text) {
  width: min(100% - 2 * var(--rl-rand), 1200px) !important; max-width: none !important;
  padding: 0 !important; margin-inline: auto !important;
}
.et_pb_row:has(.recht-text--anhang) { margin-top: 56px !important; }
.et_pb_row:has(.rl-leer) { display: none !important; }
.recht-assets { display: none !important; }  /* Hülle des Code-Moduls: sonst 30 px Flex-Lücke in der Divi-Spalte */

/* ---------------------------------------------------------------- Lesespalte (auch ohne JS) */
.recht-text {
  max-width: var(--rl-spalte);
  font-family: var(--rl-schrift); color: var(--rl-text);
  font-size: 17px; line-height: 1.7; font-weight: 400;
  overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto;
  hyphenate-limit-chars: 10 4 4;
}
.recht-text:has(.rl-raster) { max-width: none; }
.recht-text .et_pb_text_inner { font: inherit; color: inherit; }
.recht-text .erecht24-legal-texts { word-wrap: normal !important; }
.recht-text :is(p, ul, ol, li) {
  font: inherit; color: inherit; padding: 0 !important; margin: 0;
  text-wrap: pretty;
}
.recht-text :is(h2, h3, h4, h5, h6) { padding: 0 !important; text-wrap: balance; hyphens: manual; letter-spacing: normal; text-transform: none; }
.recht-text :is(p, ul, ol, .rl-karte) + :is(p, ul, ol, .rl-karte) { margin-top: 1em; }
.recht-text h2 { font-family: var(--rl-schrift-titel); font-weight: 600; color: var(--rl-blau); font-size: clamp(27px, 1.1vw + 21px, 34px); line-height: 1.12; letter-spacing: -0.005em; margin: 0 0 18px; }
.recht-text :is(p, ul, ol) + h2 { margin-top: 56px; }
.recht-text h2 .rl-nr { color: var(--rl-rot-text); }
.recht-text h3 { font-family: var(--rl-schrift-titel); font-weight: 600; color: var(--rl-text); font-size: 22px; line-height: 1.2; margin: 40px 0 10px; }
.recht-text h4 { font-family: var(--rl-schrift); font-size: 17.5px; font-weight: 600; color: var(--rl-text); line-height: 1.35; margin: 28px 0 6px; }
.recht-text h5 { font-family: var(--rl-schrift); font-size: 16.5px; font-weight: 600; line-height: 1.35; color: var(--rl-blau); margin: 26px 0 6px; }
.recht-text h2 + h3 { margin-top: 0; }
.recht-text h3 + h4 { margin-top: 12px; }
.recht-text strong, .recht-text b { font-weight: 600; font-family: inherit; }
.recht-text a { color: var(--rl-blau); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: rgba(3, 4, 94, .45); transition: text-decoration-color 160ms ease; }
.recht-text a[href^="http"], .rl-karte a { overflow-wrap: anywhere; hyphens: none; }
.recht-text ul { display: grid; gap: 8px; list-style: none !important; }
.recht-text li { position: relative; padding-left: 24px !important; list-style: none !important; }
.recht-text li::before { content: ""; position: absolute; left: 2px; top: .8em; width: 12px; height: 2px; border-radius: 1px; background: var(--rl-rot); }

/* Anhangmodul ohne JS: Ebenen wie im Entwurf (h3 als Abschnittstitel, darunter eine Stufe höher) */
.recht-text--anhang h3, .rl-abschnitt--anhang > h3 { font-family: var(--rl-schrift-titel); font-weight: 600; color: var(--rl-blau); font-size: clamp(27px, 1.1vw + 21px, 34px); line-height: 1.12; letter-spacing: -0.005em; margin: 0 0 18px; }
.recht-text--anhang h4, .rl-abschnitt--anhang > h4 { font-family: var(--rl-schrift-titel); font-size: 22px; line-height: 1.2; margin: 40px 0 10px; }
.recht-text--anhang h3 + h4, .rl-abschnitt--anhang > h3 + h4 { margin-top: 0; }
.recht-text--anhang h5, .rl-abschnitt--anhang > h5 { font-family: var(--rl-schrift); font-size: 17.5px; color: var(--rl-text); line-height: 1.35; margin: 28px 0 6px; }
.recht-text--anhang h4 + h5, .rl-abschnitt--anhang > h4 + h5 { margin-top: 12px; }

/* ---------------------------------------------------------------- Ab hier nur mit JS (rl-*) */
.rl-raster { display: grid; gap: 28px; align-items: start; }
.rl-raster > * { min-width: 0; }
.rl-text { max-width: var(--rl-spalte); }

/* Datenschutz: Abschnitte */
.rl-abschnitt + .rl-abschnitt { margin-top: 56px; padding-top: 44px; border-top: 1px solid var(--rl-linie); }
.recht-text .rl-abschnitt > h2 { margin-top: 0; }
.recht-text .rl-nachoben { margin-top: 28px; }
.rl-nachoben a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 2px;
  font-size: 15px; font-weight: 500; color: var(--rl-text-leise) !important; text-decoration: none !important;
}
.rl-ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Karten: Anschrift und Kontakt */
.rl-karte { background: var(--rl-flaeche); border-radius: var(--rl-karte-radius); padding: 22px; font-size: 17px; line-height: 1.6; }
.rl-strich { display: block; width: 32px; height: 3px; background: var(--rl-rot); border-radius: 2px; margin-bottom: 16px; }
.rl-karte > p:first-of-type::first-line, .rl-karte__anschrift p::first-line { font-weight: 600; }
.rl-karte__innen { margin-top: 16px; background: #fff; border-radius: var(--rl-innen-radius); padding: 16px 18px; border: 1px solid var(--rl-linie); }
.recht-text .rl-karte__innen h2 { font-family: var(--rl-schrift-titel); font-weight: 600; font-size: 20px; line-height: 1.2; color: var(--rl-blau); margin: 0 0 6px; }
.rl-karte a { color: var(--rl-blau); font-weight: 500; }
.recht-text .rl-karte--im-text { margin-block: 1.2em; }
.rl-karte--im-text .rl-karte__innen { margin-top: 14px; }

/* Impressum: Angaben als ruhige Blöcke mit Haarlinie */
.rl-angabe { padding: 22px 0 24px; border-top: 1px solid var(--rl-linie); }
.rl-angabe:first-child { border-top: 0; padding-top: 0; }
.recht-text .rl-text--impressum h2 { font-size: 22px; line-height: 1.2; margin: 0 0 8px; }

/* Inhaltsverzeichnis: mobil aufklappbar, ab 1024 px feste Spalte */
.rl-inhalt { border: 1px solid var(--rl-linie); border-radius: var(--rl-karte-radius); background: #fff; }
.rl-inhalt summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 0 18px; cursor: pointer; list-style: none;
  font-family: var(--rl-schrift-titel); font-weight: 600; font-size: 19px; color: var(--rl-blau);
  border-radius: var(--rl-karte-radius);
}
.rl-inhalt summary::-webkit-details-marker { display: none; }
.rl-inhalt summary .rl-ico { width: 22px; height: 22px; transition: transform 200ms var(--rl-ease); }
.rl-inhalt[open] summary .rl-ico { transform: rotate(180deg); }
.rl-inhalt nav { padding: 0 8px 10px; }
.recht-text .rl-inhalt ol { display: grid; gap: 2px; list-style: none !important; margin: 0; padding: 0 !important; }
.recht-text .rl-inhalt li { padding: 0 !important; }
.recht-text .rl-inhalt li::before { content: none; }
.recht-text .rl-inhalt a {
  display: grid; grid-template-columns: 2.1ch minmax(0, 1fr); gap: 8px; align-items: baseline; align-content: center;
  min-height: 44px; padding: 8px 10px; border-radius: var(--rl-innen-radius);
  color: var(--rl-text); text-decoration: none; font-size: 16px; line-height: 1.3; hyphens: manual;
  transition: background-color 160ms ease, color 160ms ease;
}
.rl-inhalt .rl-nr { color: var(--rl-rot-text); font-weight: 600; }
.recht-text .rl-inhalt a[aria-current="true"] { background: var(--rl-blau-tint); color: var(--rl-blau); font-weight: 600; }
.recht-text :focus-visible { outline: 3px solid var(--rl-blau); outline-offset: 3px; border-radius: 4px; }
.rl-inhalt :focus-visible { outline-offset: 1px; }

@media (min-width: 1024px) {
  .rl-raster--datenschutz { grid-template-columns: 272px minmax(0, 1fr); gap: 72px; }
  .rl-raster--impressum { grid-template-columns: 364px minmax(0, 1fr); gap: 64px; }
  .rl-inhalt {
    position: sticky; top: var(--rl-sticky);
    max-height: calc(100vh - 56px); overflow-y: auto; overscroll-behavior: contain;
    border: 0; border-radius: 0; background: transparent;
  }
  .rl-inhalt::details-content { content-visibility: visible; height: auto; }
  .rl-inhalt summary { pointer-events: none; min-height: 0; padding: 4px 10px 12px; font-size: 18px; }
  .rl-inhalt summary .rl-ico { display: none; }
  .rl-inhalt nav { padding: 0; }
  .recht-text .rl-inhalt a { font-size: 15.5px; min-height: 44px; }
  .rl-raster--impressum .rl-karte { position: sticky; top: var(--rl-sticky); padding: 24px 22px; }
  .rl-raster--impressum .rl-karte__innen { font-size: 16px; padding: 16px; }
  /* Sticky braucht sichtbaren Überlauf in den Divi-Hüllen */
  .et_pb_row:has(.rl-raster), .et_pb_column:has(.rl-raster), .recht-text:has(.rl-raster), .recht-text:has(.rl-raster) .et_pb_text_inner { overflow: visible !important; }
}

@media (max-width: 640px) {
  .recht-kopf .et_pb_heading_container:has(h1) { flex-direction: column; align-items: flex-start; gap: 18px; }
  .recht-kopf .et_pb_heading_container:has(h1)::after { flex: none; width: 112px; min-width: 0; margin-top: 0; }
  .recht-text { font-size: 16.5px; line-height: 1.68; }
  .recht-text h3 { font-size: 21px; margin-top: 34px; }
  .rl-abschnitt + .rl-abschnitt { margin-top: 44px; padding-top: 36px; }
  .rl-karte { padding: 20px 18px; }
  .rl-karte__innen { padding: 14px 16px; }
}

@media (hover: hover) and (pointer: fine) {
  .recht-text a:hover { text-decoration-color: currentColor; text-decoration-thickness: 2px; }
  .recht-text .rl-inhalt a:hover { background: var(--rl-flaeche); color: var(--rl-blau); }
  .recht-text .rl-inhalt a[aria-current="true"]:hover { background: var(--rl-blau-tint); }
  .rl-nachoben a:hover { color: var(--rl-blau) !important; text-decoration: underline !important; text-underline-offset: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .rl-inhalt summary .rl-ico, .recht-text .rl-inhalt a, .recht-text a { transition: none; }
}
