/* ============================================================
   Basis: Reset, Typografie, Layout-Grundgerüst, Header/Footer
   ============================================================ */

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

* {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
audio {
  display: block;
  max-width: 100%;
}

/* --- Überschriften --- */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  text-wrap: balance;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p,
li {
  max-width: var(--measure);
}

a {
  color: var(--aegean);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--gold-soft);
}

/* Griechischer Text: Gentium, etwas größer für Lesbarkeit der Diakritika */
[lang="el"],
[lang="grc"] {
  font-family: var(--font-serif);
  font-style: normal;
}

.greek-display {
  font-family: var(--font-display);
}

/* --- Seitengerüst --- */
.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.page-header .brand {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.brand .brand-alpha {
  color: var(--terracotta);
}

.page-header .brand {
  white-space: nowrap;
}

.page-header nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  /* weiche Kante rechts als Wisch-Hinweis, wenn Links abgeschnitten sind */
  mask-image: linear-gradient(to right, black 82%, transparent);
}

.page-header nav::-webkit-scrollbar {
  display: none;
}

.page-header .theme-toggle {
  flex-shrink: 0;
}

@media (max-width: 56rem) {
  .page-header .brand-text {
    display: none;
  }

  .page-header .brand-alpha {
    font-size: var(--text-xl);
  }
}

.page-header nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.65rem var(--space-2); /* Touch-Ziel ≥ 40 px hoch */
  border-radius: var(--radius);
}

.page-header nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--bg-sunken);
}

.page-header nav a:hover {
  color: var(--ink);
}

main {
  min-height: 60vh;
}

.prose {
  width: min(100% - 2 * var(--space-4), var(--measure));
  margin-inline: auto;
}

.prose > * + * {
  margin-top: var(--space-3);
}

.prose > h2 {
  margin-top: var(--space-6);
}

.prose > h3 {
  margin-top: var(--space-5);
}

.section-wide {
  width: min(100% - 2 * var(--space-4), 72rem);
  margin-inline: auto;
}

/* Kapitel-Kopf */
.chapter-head {
  padding: var(--space-7) 0 var(--space-5);
  text-align: center;
}

.chapter-head .kicker {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--terracotta);
}

.chapter-head h1 {
  margin-top: var(--space-2);
}

.chapter-head .lede {
  margin: var(--space-3) auto 0;
  font-size: var(--text-lg);
  color: var(--ink-soft);
  font-style: italic;
  max-width: 36rem;
}

/* --- Footer / Kapitel-Navigation --- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  width: min(100% - 2 * var(--space-4), var(--measure));
  margin: var(--space-7) auto var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
}

.chapter-nav a {
  text-decoration: none;
  max-width: 45%;
}

.chapter-nav .dir {
  display: block;
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

.page-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink-faint);
  text-align: center;
}

.page-footer a {
  color: var(--ink-soft);
}

/* --- Theme-Umschalter --- */
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--ink-soft);
  font: inherit;
  width: 2.75rem;  /* 44 px Touch-Ziel */
  height: 2.75rem;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--ink);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

.theme-dark .theme-toggle .icon-sun { display: block; }
.theme-dark .theme-toggle .icon-moon { display: none; }

/* Ohne JS: Umschalter verstecken (System-Präferenz gilt trotzdem) */
.no-js .theme-toggle {
  display: none;
}

.file-hinweis {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--gold-soft);
  border-bottom: 1px solid var(--gold);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  max-width: none;
}

/* --- Skip-Link --- */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100%;
  z-index: 100;
  background: var(--bg-raised);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: var(--space-3);
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
