/* Denkzettel Ratgeber — geteiltes Stylesheet für alle Ratgeber-/Handbuch-Seiten.
   Farben gespiegelt aus src/lib/theme.ts. Hell = :root, Dunkel = :root[data-theme="dark"].
   Das Theme-Attribut setzt theme-init.js vor dem ersten Paint (kein Flash). */

:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface2: #f1f3ef;
  --border: rgba(15, 23, 17, 0.08);
  --text: #0f1711;
  --muted: #46504b;
  --soft: #9aa39e;
  --brand: #1f8f5e;
  --brandSoft: #e6f4ec;
  --gold: #b89968;
  --goldSoft: #f5eddc;
  --danger: #d9534f;
  --warn: #e0a82e;
  --cool: #3e7cb1;
  --onBrand: #ffffff;
  --chipBg: rgba(15, 23, 17, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 17, 0.04), 0 8px 24px rgba(15, 23, 17, 0.05);
}

:root[data-theme='dark'] {
  --bg: #0e1411;
  --surface: #171f1b;
  --surface2: #1f2823;
  --border: rgba(255, 255, 255, 0.07);
  --text: #f1f4f2;
  --muted: #9ca8a2;
  --soft: #6b7570;
  --brand: #3fb682;
  --brandSoft: rgba(63, 182, 130, 0.13);
  --gold: #d4b582;
  --goldSoft: rgba(212, 181, 130, 0.13);
  --danger: #e07570;
  --warn: #e8c04f;
  --cool: #7aaed7;
  --onBrand: #08110d;
  --chipBg: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

/* [hidden] muss .card/.rg-grid (display:block/grid) schlagen — sonst greift der
   Filter/die Suche nicht, weil die Klassen-Regel das UA-[hidden] überstimmt. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Layout-Shell (von ratgeber.js aufgebaut) ---------- */

body.rg-has-nav {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  align-items: start;
}

.rg-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  /* kein padding-top: sonst scrollt über den sticky-Kategorien ein Streifen durch.
     Der obere Abstand sitzt stattdessen am Brand-Block. */
  padding: 0 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rg-main {
  min-width: 0;
}

.rg-side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  padding: 18px 10px 14px;
}

.rg-side-brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--onBrand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.rg-side-brand b {
  font-family: Georgia, serif;
  font-size: 17px;
}

.rg-nav-overview {
  display: block;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  padding: 9px 12px;
  border-radius: 12px;
  margin-bottom: 4px;
}

.rg-nav-overview:hover {
  background: var(--surface2);
}

.rg-nav-group {
  margin-top: 10px;
}

.rg-nav-group > h4 {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--soft);
  margin: 0 0 4px;
  padding: 8px 12px 6px;
  font-weight: 700;
  background: var(--surface);
}

.rg-nav-group a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  padding: 7px 12px;
  border-radius: 10px;
}

.rg-nav-group a:hover {
  background: var(--surface2);
  color: var(--text);
}

.rg-nav-group a.is-current {
  background: var(--brandSoft);
  color: var(--brand);
  font-weight: 700;
}

.rg-side-foot {
  margin-top: auto;
  padding: 12px 10px 0;
}

/* Theme-Umschalter + Menü-Knopf */
.rg-theme-btn,
.rg-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.rg-theme-btn:hover,
.rg-menu-btn:hover {
  border-color: var(--brand);
}

.rg-theme-btn svg,
.rg-menu-btn svg {
  width: 18px;
  height: 18px;
}

.rg-theme-btn .rg-ico-sun {
  display: none;
}
:root[data-theme='dark'] .rg-theme-btn .rg-ico-sun {
  display: block;
}
:root[data-theme='dark'] .rg-theme-btn .rg-ico-moon {
  display: none;
}

/* Mobile-Topbar (nur < 900px sichtbar) */
.rg-topbar {
  display: none;
}

/* In den Content eingebetteter Brand-Header wird durch die Shell ersetzt */
body.rg-has-nav .wrap > header.brand {
  display: none;
}

/* ---------- Content (Artikel) ---------- */

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 72px;
}

header.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 20px;
}
header.brand a {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--onBrand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.brand b {
  font-family: Georgia, serif;
  font-size: 17px;
}

h1 {
  font-family: Georgia, serif;
  font-size: 32px;
  line-height: 1.18;
  margin: 6px 0 12px;
}
h2 {
  font-family: Georgia, serif;
  font-size: 22px;
  margin: 34px 0 8px;
}
h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brand);
  margin: 18px 0 4px;
}
p {
  margin: 0 0 16px;
}
.lede {
  font-size: 18px;
  color: var(--muted);
}
ol,
ul {
  padding-left: 20px;
}
li {
  margin: 0 0 8px;
}
a {
  color: var(--brand);
}
strong {
  color: var(--text);
}

.kicker {
  display: inline-block;
  background: var(--brand);
  color: var(--onBrand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

.sech {
  font-family: Georgia, serif;
  font-size: 19px;
  margin: 30px 0 14px;
}

/* Übersicht: Filter + Suche + Karten-Grid */
.rg-search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-family: inherit;
  margin: 0 0 14px;
}
.rg-search:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.rg-search::placeholder {
  color: var(--soft);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--onBrand);
}

.rg-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.rg-grid .card {
  margin: 0;
}
.rg-grid .featured {
  grid-column: 1 / -1;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  margin: 0 0 12px;
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--brand);
}
.card h2 {
  font-family: Georgia, serif;
  font-size: 19px;
  margin: 0 0 5px;
}
.card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14.5px;
}
.featured {
  background: var(--brandSoft);
  border-color: transparent;
}
.badge {
  display: inline-block;
  background: var(--brand);
  color: var(--onBrand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tagpill {
  font-size: 12px;
  font-weight: 600;
  color: var(--soft);
  background: var(--chipBg);
  border-radius: 999px;
  padding: 3px 9px;
}

/* Inhaltsverzeichnis (handbuch & lange Seiten) */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 24px 0;
}
.toc a {
  display: block;
  color: var(--brand);
  text-decoration: none;
  margin: 4px 0;
  font-weight: 600;
  font-size: 15px;
}

.science {
  background: var(--goldSoft);
  border-radius: 14px;
  padding: 14px 18px;
  margin: 8px 0;
}
.science b {
  color: var(--gold);
}

.feature {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.tip {
  background: var(--brandSoft);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 22px 0;
}
.tip b {
  color: var(--brand);
}

.note {
  font-size: 14px;
  color: var(--soft);
  border-left: 3px solid var(--border);
  padding-left: 14px;
  margin: 28px 0;
}

.cta {
  display: inline-block;
  margin: 40px 0 24px;
  background: var(--brand);
  color: var(--onBrand);
  text-decoration: none;
  font-weight: 600;
  padding: 13px 22px;
  border-radius: 16px;
}
.cta:hover {
  filter: brightness(1.05);
}

.related {
  margin-top: 36px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.related a {
  display: block;
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  margin: 6px 0;
}

footer {
  margin-top: 40px;
  color: var(--soft);
  font-size: 13px;
}
footer a {
  color: var(--muted);
}

/* ---------- Mobile-Drawer ---------- */

.rg-overlay {
  display: none;
}

@media (max-width: 900px) {
  body.rg-has-nav {
    display: block;
  }

  .rg-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .rg-topbar .rg-side-brand {
    padding: 0;
  }
  .rg-topbar .rg-menu-btn {
    padding: 8px 10px;
  }
  .rg-topbar .rg-theme-btn {
    padding: 8px 10px;
  }

  .rg-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: 290px;
    max-width: 84vw;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.rg-nav-open .rg-sidebar {
    transform: translateX(0);
  }

  .rg-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  body.rg-nav-open .rg-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .rg-side-foot {
    display: none;
  }

  .wrap {
    padding: 22px 18px 64px;
  }
  h1 {
    font-size: 28px;
  }
  .rg-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
