/* Pilish-Wiki — gemeinsames Stylesheet */
:root {
  --bg: #fbfaf6;
  --surface: #ffffff;
  --ink: #1f2233;
  --muted: #5b6075;
  --accent: #5a3a8c;
  --accent-soft: #ede6f7;
  --rule: #e3ddd0;
  --code-bg: #f3efe6;
  --warn: #b8860b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
  font-size: 17px;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
a:hover { background: var(--accent-soft); }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

aside.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 24px 20px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

aside.sidebar h1 {
  font-size: 1.25rem;
  margin: 0 0 4px;
  color: var(--accent);
}
aside.sidebar .subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 18px;
}

aside.sidebar nav ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: chapter;
}
aside.sidebar nav li {
  margin: 6px 0;
  counter-increment: chapter;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
aside.sidebar nav li::before {
  content: counter(chapter, decimal-leading-zero);
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.78rem;
  color: var(--muted);
  width: 1.6em;
  flex-shrink: 0;
}
/* "Übersicht" (erstes Listenelement) zählt nicht als Kapitel mit:
   So entsprechen die Sidebar-Nummern wieder den Datei- und Kapitel-Tags. */
aside.sidebar nav li:first-child {
  counter-increment: none;
}
aside.sidebar nav li:first-child::before {
  content: "·";
  text-align: center;
  color: var(--muted);
}
aside.sidebar nav a {
  border-bottom: none;
  font-size: 0.95rem;
}
aside.sidebar nav a.current {
  font-weight: 600;
  color: var(--ink);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 3px;
}

#searchbox {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  margin-bottom: 16px;
}
#searchbox:focus { outline: 2px solid var(--accent); border-color: transparent; }

#search-results {
  list-style: none;
  padding: 0;
  margin: 8px 0 16px;
  font-size: 0.85rem;
}
#search-results li {
  margin: 4px 0;
  padding: 6px 8px;
  background: var(--accent-soft);
  border-radius: 3px;
}
#search-results li small { color: var(--muted); }
#search-results:empty { display: none; }

main.content {
  padding: 48px clamp(20px, 5vw, 64px);
  max-width: 820px;
}

main.content h1 {
  font-size: 2.1rem;
  margin: 0 0 8px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
main.content .chapter-tag {
  display: inline-block;
  font-family: "SF Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
main.content h2 {
  font-size: 1.35rem;
  margin-top: 2.4em;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}
main.content h3 {
  font-size: 1.1rem;
  margin-top: 1.8em;
  color: var(--accent);
}

main.content p { margin: 0.8em 0; }

blockquote {
  margin: 1.4em 0;
  padding: 0.8em 1.2em;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  font-style: italic;
  color: #2c2640;
}
blockquote .digits {
  display: block;
  margin-top: 8px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.85rem;
  font-style: normal;
  color: var(--muted);
  letter-spacing: 0.1em;
}

code, .mono {
  font-family: "SF Mono", "Menlo", monospace;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}

table {
  border-collapse: collapse;
  margin: 1.2em 0;
  width: 100%;
  font-size: 0.95rem;
}
th, td {
  border: 1px solid var(--rule);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--accent-soft); font-weight: 600; }

ul.sources {
  list-style: none;
  padding: 0;
  margin-top: 8px;
  font-size: 0.92rem;
}
ul.sources li {
  margin: 4px 0;
  padding-left: 1.4em;
  position: relative;
}
ul.sources li::before {
  content: "↗";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.callout {
  margin: 1.6em 0;
  padding: 14px 18px;
  background: #fff7e0;
  border: 1px solid #f0d68c;
  border-left: 4px solid var(--warn);
  border-radius: 4px;
  font-size: 0.95rem;
}
.callout strong { color: var(--warn); }

.pi-strip {
  font-family: "SF Mono", monospace;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--code-bg);
  padding: 6px 10px;
  border-radius: 3px;
  margin: 1em 0;
  overflow-x: auto;
  white-space: nowrap;
}

footer.page-footer {
  margin-top: 4em;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ----- Mobile Top-Bar & Burger-Drawer ----- */
.mobile-bar {
  display: none;
}

/* Close-Button nur auf Mobile sichtbar */
.sidebar-close-btn {
  display: none;
}

@media (max-width: 800px) {
  /* Top-Bar */
  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    padding: 0 16px;
    height: 52px;
  }
  .mobile-bar .mobile-title {
    font-family: "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    border-bottom: none;
  }
  .mobile-bar .mobile-title:hover { background: none; }

  /* Burger-Button */
  .burger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-radius: 4px;
  }
  .burger-btn:hover { background: var(--accent-soft); }
  .burger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
    transform-origin: center;
  }
  /* X-Animation wenn Drawer offen */
  .burger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .burger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .burger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 300;
  }
  .sidebar-backdrop.visible { display: block; }

  /* Layout */
  .layout {
    grid-template-columns: 1fr;
    padding-top: 0;
  }

  /* Sidebar als Drawer */
  aside.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 88vw);
    height: 100dvh;
    height: 100vh; /* Fallback */
    z-index: 400;
    border-right: 1px solid var(--rule);
    border-bottom: none;
    overflow-y: auto;
    padding: 24px 20px 32px;
    transform: translateX(-110%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  }
  aside.sidebar.drawer-open {
    transform: translateX(0);
  }

  /* Schließen-X oben rechts in der Sidebar — nur auf Mobile */
  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.3rem;
    border-radius: 4px;
    line-height: 1;
  }
  .sidebar-close-btn:hover { background: var(--accent-soft); color: var(--ink); }

  /* Desktop-Sidebar hat keinen Close-Button */

  main.content {
    padding: 28px 18px 48px;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
  }

  body {
    overflow-x: hidden;
  }

  /* Body scroll sperren wenn Drawer offen */
  body.drawer-open { overflow: hidden; }

  /* Tabellen auf Mobile scrollbar */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Checker auf Mobile stapeln */
  .checker-controls { flex-direction: column; align-items: stretch; }

  /* Schriftgröße etwas kleiner */
  html, body { font-size: 16px; }
  main.content h1 { font-size: 1.7rem; }
}

/* ----- Werkzeuge-Sektion in der Sidebar ----- */
aside.sidebar .tools {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
aside.sidebar .tools-heading {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}
aside.sidebar .tools ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
aside.sidebar .tools li {
  margin: 6px 0;
  counter-increment: none;
}
aside.sidebar .tools li::before {
  content: "·";
  text-align: center;
  color: var(--muted);
}
aside.sidebar .tools a {
  border-bottom: none;
  font-size: 0.95rem;
  display: inline-block;
}
aside.sidebar .tools a.current {
  font-weight: 600;
  color: var(--ink);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 3px;
}
aside.sidebar .tools a::before {
  content: "🛠 ";
  margin-right: 2px;
}

/* ----- Pilish-Checker UI ----- */
.checker-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 1em 0 0.6em;
}
.checker-controls label {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.checker-controls select {
  font: inherit;
  font-size: 0.95rem;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
}

#input-text {
  width: 100%;
  min-height: 160px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.55;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  resize: vertical;
}
#input-text:focus { outline: 2px solid var(--accent); border-color: transparent; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 1.2em 0;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 10px 12px;
}
.stat-label {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-value {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}
.stat.ok .stat-value { color: #1f8a3a; }
.stat.bad .stat-value { color: #b8242b; }

.verdict {
  margin: 1em 0;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
}
.verdict.ok  { background: #e6f4ec; color: #1f6f3a; border-left: 4px solid #1f8a3a; }
.verdict.bad { background: #fcebec; color: #8a242b; border-left: 4px solid #b8242b; }

.word-stream {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.92rem;
  line-height: 1.4;
  max-height: 320px;
  overflow-y: auto;
}
.word-chip {
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--bg);
  white-space: nowrap;
}
.word-chip .digit-pair {
  font-weight: 600;
  margin-left: 6px;
  font-size: 0.85rem;
}
.word-chip.ok       { background: #e6f4ec; border-color: #b8e3c5; }
.word-chip.ok .digit-pair { color: #1f6f3a; }
.word-chip.bad      { background: #fcebec; border-color: #f0c0c4; }
.word-chip.bad .digit-pair { color: #8a242b; }
.word-chip.invalid  { background: #fff7e0; border-color: #f0d68c; }
.word-chip.invalid::after { content: " ⚠"; color: var(--warn); }

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 1em 0;
}
.examples button {
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
}
.examples button:hover { background: var(--accent); color: white; }
.examples button.reset { background: transparent; color: var(--muted); border-color: var(--rule); }

.mismatch-detail {
  margin: 1em 0;
  padding: 10px 14px;
  background: var(--code-bg);
  border-left: 3px solid var(--muted);
  border-radius: 0 4px 4px 0;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.88rem;
  white-space: pre;
  overflow-x: auto;
}
.mismatch-detail .at-fault { color: #b8242b; font-weight: 700; }
