/* ==========================================================================
   Regelwerk-Seite (ergaenzt style.css)
   Jedes Kapitel setzt seine Farbe ueber --c.
   ========================================================================== */

:root {
  --red: #ff6b6b;
  --amber: #ffc857;
  --green: #6ee7a0;
  --mix: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent);
}

.site-nav a.is-current { color: var(--text); }

/* ---------- Kopf ---------- */

.page-hero {
  position: relative;
  padding: calc(var(--header-h) + clamp(40px, 7vw, 80px)) 0 clamp(28px, 4vw, 44px);
  background:
    radial-gradient(700px 320px at 15% 0%, rgba(24, 223, 207, 0.14), transparent 70%),
    radial-gradient(500px 260px at 90% 20%, rgba(76, 194, 255, 0.07), transparent 70%);
  overflow: hidden;
}
.page-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 46px;
  opacity: 0.5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='20' viewBox='0 0 120 20'%3E%3Cpath d='M0 10 Q15 0 30 10 T60 10 T90 10 T120 10' fill='none' stroke='%2318dfcf' stroke-opacity='.22' stroke-width='1.5'/%3E%3C/svg%3E") repeat-x bottom;
  pointer-events: none;
}
.page-hero .container { position: relative; z-index: 1; }
.page-hero h1 { max-width: 18ch; margin-bottom: 18px; font-size: clamp(2.1rem, 5vw, 3.6rem); }

.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; margin-top: 30px; }
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat strong { font-size: 2rem; font-weight: 800; font-style: italic; color: var(--accent); line-height: 1; }
.stat span { color: var(--muted); font-size: 0.9rem; letter-spacing: 0.06em; text-transform: uppercase; }

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 340px;
  max-width: 560px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 200, 87, 0.3);
  border-radius: 14px;
  background: rgba(255, 200, 87, 0.07);
  color: #f4dfae;
  font-size: 0.9rem;
  line-height: 1.5;
}
.notice svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--amber); stroke-width: 2; stroke-linecap: round; }

/* ---------- Kurzueberblick ---------- */

.quick { padding: 12px 0 clamp(32px, 5vw, 56px); }
.quick-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; margin-bottom: 20px; }
.quick-head h2 { font-size: 1.3rem; }
.quick-head p { color: var(--muted); font-size: 0.9rem; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.quick-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 18px 20px;
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  border-radius: 16px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--c) 13%, transparent), transparent 70%),
    var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.quick-card:hover {
  transform: translateY(-3px);
  border-color: var(--c);
  box-shadow: 0 16px 34px -20px var(--c);
}
.quick-card strong { font-size: 1.02rem; line-height: 1.25; }
.quick-card > span:last-child { color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.quick-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 6px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.quick-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--c); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.quick-no {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c);
  letter-spacing: 0.04em;
}

/* ---------- Layout ---------- */

.rules-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
  padding-bottom: clamp(64px, 9vw, 110px);
}

/* Inhaltsverzeichnis */
.toc-wrap {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.toc-title { margin-bottom: 10px; padding-left: 12px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.toc { display: grid; gap: 2px; }

.toc-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  font-size: 0.92rem;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.toc-link:hover { background: var(--surface); color: var(--text); }
.toc-no { min-width: 1.6em; font-size: 0.74rem; font-weight: 700; color: var(--c); opacity: 0.85; }
.toc-name { flex: 1; }
.toc-count { font-size: 0.75rem; opacity: 0.6; }
.toc-link.is-active { background: color-mix(in srgb, var(--c) 12%, transparent); border-left-color: var(--c); color: var(--text); }
.toc-link.is-empty { opacity: 0.35; pointer-events: none; }

/* ---------- Toolbar ---------- */

.toolbar {
  position: sticky;
  top: calc(var(--header-h) + 8px);
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(3, 24, 30, 0.86);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.8);
}
.toolbar-row { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 0;
}
.search > svg { position: absolute; left: 16px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%;
  height: 46px;
  padding: 0 84px 0 46px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(1, 16, 21, 0.7);
  color: var(--text);
  font: inherit;
  font-size: 0.96rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search input::placeholder { color: #6c8f8f; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(24, 223, 207, 0.15); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  position: absolute;
  right: 18px;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
}
.search:focus-within kbd { display: none; }
.search-clear {
  position: absolute;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-hover);
  cursor: pointer;
}
.search-clear[hidden] { display: none; }
.search-clear svg { width: 16px; height: 16px; fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; }
.search:has(.search-clear:not([hidden])) kbd { display: none; }

.expand-btns { display: flex; gap: 8px; }
.btn-mini {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.btn-mini:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.chip span { font-size: 0.75rem; opacity: 0.65; }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: rgba(24, 223, 207, 0.14); border-color: var(--accent); color: var(--accent); }
.chip-danger[aria-pressed="true"] { background: rgba(255, 107, 107, 0.14); border-color: var(--red); color: var(--red); }
.chip-warn[aria-pressed="true"] { background: rgba(255, 200, 87, 0.14); border-color: var(--amber); color: var(--amber); }

.result-count { margin-left: auto; color: var(--muted); font-size: 0.84rem; }

/* Legende */
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 16px 4px 22px; color: var(--muted); font-size: 0.82rem; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.lg { width: 10px; height: 10px; border-radius: 3px; }
.lg-no { background: #ff8f8f; }
.lg-sanction { background: var(--amber); }
.lg-perma { background: var(--red); }
.lg-ok { background: var(--green); }
.lg-key { background: var(--accent); }

/* ---------- Kapitel ---------- */

.rules-root { display: grid; gap: 16px; }

.cat {
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
  border-radius: 20px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--c) 7%, transparent), transparent 140px),
    var(--surface);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.cat.is-open { border-color: color-mix(in srgb, var(--c) 40%, transparent); box-shadow: 0 24px 50px -36px var(--c); }

.cat-head { margin: 0; font-size: inherit; font-style: normal; }
.cat-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 22px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cat-toggle:focus-visible { outline-offset: -3px; }

.cat-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border: 1px solid color-mix(in srgb, var(--c) 38%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  transition: transform 0.25s;
}
.cat-toggle:hover .cat-icon { transform: scale(1.06) rotate(-4deg); }
.cat-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--c); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.cat-title { display: grid; flex: 1; min-width: 0; line-height: 1.25; }
.cat-title small { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--c); }
.cat-title span { font-size: clamp(1.1rem, 2.2vw, 1.35rem); font-weight: 700; }

.cat-count {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
  font-size: 0.78rem;
  font-weight: 600;
}
.chev { display: grid; place-items: center; flex: none; width: 32px; height: 32px; }
.chev svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s; }
.cat.is-open .chev svg { transform: rotate(180deg); stroke: var(--c); }

/* Auf-/Zuklappen (grid-rows-Trick) */
.cat-body {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.38s cubic-bezier(0.3, 0.7, 0.2, 1), visibility 0s linear 0.38s;
}
.cat.is-open .cat-body { grid-template-rows: 1fr; visibility: visible; transition-delay: 0s; }
.cat-inner { min-height: 0; overflow: hidden; padding: 0 22px; }
.cat-inner > :first-child { margin-top: 2px; }
.cat-inner > :last-child { margin-bottom: 22px; }
.rules-root.no-anim .cat-body { transition: none; }

.cat-intro {
  margin-bottom: 14px;
  padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-left-width: 4px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 10%, transparent);
  font-weight: 500;
}

.rule-grid { display: grid; gap: 12px; }

/* ---------- Regel ---------- */

.rule {
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(1, 16, 21, 0.5);
  transition: border-color 0.2s, background 0.2s;
}
.rule:hover { border-color: color-mix(in srgb, var(--c) 35%, transparent); background: rgba(1, 16, 21, 0.72); }

.rule-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.rule-no {
  padding: 3px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--c);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.rule-no:hover { background: color-mix(in srgb, var(--c) 28%, transparent); }

.badge {
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-danger { background: rgba(255, 107, 107, 0.14); border-color: rgba(255, 107, 107, 0.35); color: var(--red); }
.badge-warn { background: rgba(255, 200, 87, 0.13); border-color: rgba(255, 200, 87, 0.32); color: var(--amber); }

.copy {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.copy svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rule:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { background: var(--surface-hover); color: var(--accent); }
@media (hover: none) { .copy { opacity: 0.7; } }

.rule-text p { line-height: 1.7; overflow-wrap: anywhere; }
.rule-text p + p { margin-top: 8px; }

/* Aufzaehlung */
.rule-list { display: grid; gap: 6px; margin-top: 12px; }
.rule-list li { position: relative; padding-left: 24px; line-height: 1.6; }
.rule-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--c);
  border-right: 2px solid var(--c);
  transform: rotate(45deg);
}

/* Absaetze / Zusaetze */
.abs-list { display: grid; gap: 8px; margin-top: 12px; }
.abs {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0 8px 14px;
  border-left: 2px solid color-mix(in srgb, var(--c) 45%, transparent);
  color: #cfe6e5;
}
.abs-label {
  flex: none;
  padding: 1px 9px;
  border-radius: 6px;
  background: rgba(232, 247, 246, 0.08);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Beispiele */
.examples { display: grid; gap: 8px; margin-top: 12px; }
.ex {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 14px;
  border-left: 3px solid var(--ex);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ex) 9%, transparent);
  --ex: var(--accent);
}
.ex-ok { --ex: var(--green); }
.ex-no { --ex: var(--red); }
.ex-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  margin-top: 1px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ex) 20%, transparent);
  color: var(--ex);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ex-tag svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ex-info .ex-tag svg { fill: currentColor; stroke: none; width: 9px; height: 9px; }
.ex-text { line-height: 1.6; color: #d7ecea; overflow-wrap: anywhere; }

/* ---------- Markierungen im Text ---------- */

.hl-no { color: #ff8f8f; font-weight: 600; }
.hl-ok { color: var(--green); font-weight: 600; }
.hl-key { color: var(--accent); font-weight: 600; }
.hl-sanction, .hl-perma, .hl-num {
  padding: 0 0.32em;
  border-radius: 6px;
  font-weight: 600;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-sanction { background: rgba(255, 200, 87, 0.14); color: var(--amber); }
.hl-perma { background: rgba(255, 107, 107, 0.16); color: var(--red); font-weight: 700; }
.hl-num { background: rgba(24, 223, 207, 0.13); color: #b8fff8; white-space: nowrap; }

.ref { color: var(--accent); border-bottom: 1px dashed rgba(24, 223, 207, 0.6); white-space: nowrap; }
.ref:hover { border-bottom-style: solid; }

mark {
  padding: 0 3px;
  border-radius: 4px;
  background: #ffe066;
  color: #1a1400;
  font-weight: 600;
}

/* Sprung-Hervorhebung */
.rule.is-flash { animation: flash 2.3s ease; }
@keyframes flash {
  0%, 35% { border-color: var(--c); background: color-mix(in srgb, var(--c) 20%, rgba(1, 16, 21, 0.6)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- Leer / Fehler ---------- */

.empty { display: grid; justify-items: center; gap: 10px; padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: 20px; text-align: center; }
.empty p { max-width: 42ch; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--surface-hover); }
.empty-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.load-error { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Nach oben / Toast ---------- */

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(3, 24, 30, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, border-color 0.2s;
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); }
.to-top svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 120;
  padding: 11px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #06262c;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */

@media (max-width: 1040px) {
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .rules-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .toc-wrap, .rules-main { min-width: 0; }

  .toc-wrap { position: static; max-height: none; overflow: visible; padding: 0; }
  .toc-title { display: none; }
  .toc {
    display: flex;
    gap: 8px;
    margin-inline: -16px;
    padding: 2px 16px 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .toc::-webkit-scrollbar { display: none; }
  .toc-link {
    flex: none;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
  }
  .toc-link.is-active { border-color: var(--c); }
  .toc-count { display: none; }
}

@media (max-width: 640px) {
  .quick-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 12px; border-radius: 16px; }
  .expand-btns { display: none; }
  .chips { flex-wrap: nowrap; margin-inline: -12px; padding: 0 12px 2px; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .result-count { display: none; }
  .search kbd { display: none; }

  .cat-toggle { gap: 12px; padding: 14px 14px; }
  .cat-icon { width: 40px; height: 40px; }
  .cat-count { display: none; }
  .cat-inner { padding: 0 12px; }
  .cat-inner > :last-child { margin-bottom: 14px; }
  .rule { padding: 14px; }
  .abs { flex-direction: column; gap: 6px; }
  .ex { flex-direction: column; gap: 6px; }
}
