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

.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;
}

:root {
  --bg: #faf7f0;
  --primary: #5c3a1e;
  --accent: #8b6914;
  --accent-light: #c8a84b;
  --border: #d4c4a0;
  --card-bg: #ffffff;
  --text: #2c1a0e;
  --text-muted: #7a6040;
  --sidebar-w: 340px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TYPOGRAPHY ── */
h1, h2, h3 {
  font-family: 'IM Fell English', Georgia, serif;
  color: var(--primary);
  line-height: 1.3;
}

h4 {
  font-family: 'Libre Baskerville', Georgia, serif;
  color: var(--primary);
  line-height: 1.3;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── HEADER ── */
.site-header {
  background: var(--primary);
  color: #f5ead0;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 64px;
}

.site-logo {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo .logo-title {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: #f5ead0;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.site-logo .logo-sub {
  font-size: 0.68rem;
  color: #c8a84b;
  letter-spacing: 0.08em;
  margin-top: 1px;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.site-nav a {
  color: #f5ead0;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a.active {
  background: rgba(255,255,255,0.15);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: #f5ead0;
  padding: 0.5rem;
  margin-left: auto;
}

.hamburger svg { display: block; }

/* ── FOOTER ── */
.site-footer {
  background: var(--primary);
  color: #c8a84b;
  text-align: center;
  padding: 1.25rem 1.5rem;
  font-size: 0.78rem;
  margin-top: auto;
  line-height: 1.8;
}

.site-footer p { margin: 0.1rem 0; }

/* ── CARDS ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #f5ead0;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: #3d2510;
  border-color: #3d2510;
  text-decoration: none;
  color: #f5ead0;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: #f5ead0;
  text-decoration: none;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover {
  background: #6b5010;
  border-color: #6b5010;
  text-decoration: none;
  color: #fff;
}

/* ── TAGS ── */
.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── SIDEBAR / PANEL ── */
.sidebar {
  position: fixed;
  top: 64px;
  right: 0;
  width: var(--sidebar-w);
  bottom: 0;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 500;
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
}

.sidebar-header h2 {
  font-size: 1.05rem;
  line-height: 1.35;
  flex: 1;
}

.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  flex-shrink: 0;
  line-height: 1;
  font-size: 1.4rem;
}
.sidebar-close:hover { color: var(--primary); }

.sidebar-body {
  padding: 1.25rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.sidebar-text {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
}

.sidebar-source {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}
.empty-state p { margin-top: 0.5rem; font-size: 0.9rem; }

/* ── MOBILE NAV ── */
@media (max-width: 700px) {
  .hamburger { display: flex; }

  .site-nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--primary);
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    gap: 0.25rem;
    z-index: 999;
  }

  .site-nav.open { display: flex; }

  .site-nav a {
    padding: 0.65rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
  }

  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 80vh;
    transform: translateY(100%);
    border-left: none;
    border-top: 2px solid var(--border);
  }

  .sidebar.open {
    transform: translateY(0);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  }
}

/* ── CATEGORY COLORS ── */
.cat-weisse-frau   { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.cat-teufelssage   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.cat-grundungssage { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }
.cat-natursage     { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.cat-schlosssage   { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.cat-kirchensage   { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.cat-heldensage    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── PAGE CONTENT ── */
.page-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  flex: 1;
}

.page-content h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.page-content .lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-style: italic;
}

.page-content h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.75rem;
}

.page-content p {
  line-height: 1.8;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── VOLLTEXT ── */
.volltext-original p {
  margin-bottom: 0.9rem;
  line-height: 1.8;
  font-size: 0.95rem;
  font-family: 'Libre Baskerville', serif;
  color: var(--text);
  hyphens: auto;
}

.volltext-original p:first-child::first-letter,
.sage-kurztext p:first-child::first-letter {
  font-size: 2.8rem;
  font-family: 'IM Fell English', serif;
  float: left;
  line-height: 0.8;
  margin: 0.05em 0.1em 0 0;
  color: var(--primary);
}

.sidebar-source-inline {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── BREADCRUMB ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--accent); }
.breadcrumb-sep { color: var(--border); }

/* ── SAGE INDIVIDUAL PAGE ── */
.sage-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.sage-kurztext p {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
}

.sage-page-actions {
  margin-top: 2rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── VOR ORT SECTION ── */
.vor-ort-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
  border-top: 1px solid var(--border);
}

.vor-ort-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-family: inherit;
  font-weight: 600;
}

.vor-ort-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vor-ort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.vor-ort-link:hover {
  border-color: var(--accent);
  background: #f3efe6;
}

.vor-ort-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ── PREV / NEXT NAV ── */
.sage-pagnav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
}

.sage-pagnav-link {
  font-size: 0.88rem;
  color: var(--accent);
  text-decoration: none;
  max-width: 48%;
  line-height: 1.4;
}
.sage-pagnav-link:hover { text-decoration: underline; }
.sage-pagnav-next { text-align: right; }
