/* ============================================
   Прощай, Вестфалия — Russian Translation
   Dark theme, cypherpunk aesthetic
   ============================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Literata:ital,wght@0,400;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

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

/* --- Variables --- */
:root {
  --bg: #0a0a0a;
  --bg-elevated: #111;
  --bg-surface: #1a1a1a;
  --text: #e8e8e8;
  --text-muted: #666;
  --text-dim: #888;
  --accent: #c8a96e;
  --accent-hover: #dbbf85;
  --border: #222;
  --font-serif: 'Literata', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --measure: 65ch;
  --content-width: 800px;
  --line-height: 1.8;
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* --- Links --- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* --- Layout --- */
.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px;
}

.wide-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- WIP Banner --- */
.wip-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.wip-banner a {
  color: var(--accent);
  margin-left: 4px;
}

/* --- Site Header --- */
.site-header {
  padding: 16px 0;
}

.site-header .wide-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.site-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 24px;
  font-family: var(--font-sans);
  font-size: 14px;
}

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

.site-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

/* --- Hero (Landing) --- */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(10, 10, 10, 0.55) 0%, rgba(10, 10, 10, 0.9) 100%),
    url('hero-bg.jpg') center/cover no-repeat;
}

.hero-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #bbb;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 16px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
  font-family: var(--font-serif);
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 400;
  color: #ccc;
  line-height: 1.4;
  margin-bottom: 12px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.hero-authors {
  font-family: var(--font-mono);
  font-size: 14px;
  color: #bbb;
  margin-bottom: 48px;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 12px 24px;
  transition: all 0.2s;
}

.hero-cta:hover {
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}

.hero-cta .arrow {
  transition: transform 0.2s;
}

.hero-cta:hover .arrow {
  transform: translateX(4px);
}

/* --- Epigraph --- */
.epigraph-section {
  padding: 64px 0;
  border-bottom: 1px solid var(--border);
}

.epigraph {
  border-left: 2px solid var(--accent);
  padding-left: 24px;
  margin: 0;
  font-style: italic;
}

.epigraph p {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.6;
  color: var(--text-muted);
}

.epigraph-author {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 16px;
  padding-left: 26px;
}

/* --- Chapter List --- */
.chapter-list-section {
  padding: 80px 0;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.chapter-list {
  list-style: none;
}

.chapter-list li {
  border-bottom: 1px solid var(--border);
}

.chapter-list li:first-child {
  border-top: 1px solid var(--border);
}

.chapter-list a {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 20px 0;
  color: var(--text);
  transition: all 0.2s;
}

.chapter-list a:hover {
  color: var(--accent);
  text-decoration: none;
  padding-left: 8px;
}

.chapter-num {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  min-width: 32px;
}

.chapter-title {
  font-size: 18px;
}

.chapter-arrow {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}

.chapter-list a:hover .chapter-arrow {
  opacity: 1;
}

/* --- About Section (Landing) --- */
.about-section {
  padding: 80px 0;
  border-bottom: 1px solid var(--border);
}

.about-section p {
  color: var(--text-muted);
  max-width: var(--measure);
  margin-bottom: 16px;
}

.license-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 12px;
  margin-top: 16px;
}

/* --- Footer --- */
.site-footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* --- Chapter Page --- */
.chapter-header {
  padding: 60px 0 24px;
  margin-bottom: 0;
}

.chapter-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  display: flex;
  gap: 24px;
}

.chapter-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
}

.reading-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Chapter Content --- */
.chapter-content {
  padding-bottom: 80px;
}

.chapter-content {
  border-top: 1px solid var(--border);
  padding-top: 40px;
}

.chapter-content h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  margin-top: 56px;
  margin-bottom: 24px;
  color: var(--text);
}

.chapter-content h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  margin-top: 40px;
  margin-bottom: 16px;
  color: var(--text);
}

.chapter-content p {
  margin-bottom: 24px;
}

.chapter-content blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 24px;
  margin: 32px 0;
  color: var(--text-muted);
  font-style: italic;
}

.chapter-content blockquote p {
  margin-bottom: 12px;
}

.chapter-content ul,
.chapter-content ol {
  margin-bottom: 24px;
  padding-left: 24px;
}

.chapter-content li {
  margin-bottom: 8px;
}

.chapter-content em {
  font-style: italic;
}

.chapter-content strong {
  font-weight: 600;
}

/* --- Footnotes --- */
.footnotes {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding-top: 32px;
}

.footnotes-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.footnotes ol {
  list-style: none;
  counter-reset: footnote;
}

.footnotes li {
  counter-increment: footnote;
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 32px;
  position: relative;
}

.footnotes li::before {
  content: counter(footnote);
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.footnote-ref {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  vertical-align: super;
  line-height: 0;
}

.footnote-backref {
  font-size: 12px;
  margin-left: 4px;
  color: var(--text-dim);
}

/* --- Footnote Overlay + Popover --- */
.fn-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.fn-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.fn-popover {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  width: 90%;
  max-width: 560px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 32px 36px;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: var(--line-height);
  color: var(--text);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.fn-popover.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.fn-popover-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.fn-popover-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.fn-popover-close:hover {
  color: var(--text);
}

.fn-popover em {
  font-style: italic;
}

.fn-popover a {
  color: var(--accent);
}

/* --- Chapter Navigation --- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.chapter-nav a {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.chapter-nav .next {
  margin-left: auto;
}

/* --- Table of Contents (Sidebar) --- */
.chapter-layout {
  display: flex;
  gap: 48px;
  position: relative;
}

.chapter-main {
  flex: 1;
  min-width: 0;
  max-width: var(--content-width);
}

.toc-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
  align-self: flex-start;
  margin-top: 200px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  display: none;
}

@media (min-width: 1100px) {
  .toc-sidebar {
    display: block;
  }

  .chapter-layout {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
  }
}

.toc-sidebar .toc-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.toc-sidebar ul {
  list-style: none;
}

.toc-sidebar li {
  margin-bottom: 8px;
}

.toc-sidebar a {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  display: block;
  padding: 2px 0;
  border-left: 2px solid transparent;
  padding-left: 12px;
  transition: all 0.2s;
}

.toc-sidebar a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  cursor: pointer;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  text-decoration: none;
}

/* --- Search Page --- */
.search-page {
  padding: 60px 0;
  min-height: 70vh;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 40px;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 18px;
  padding: 16px 20px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
}

.search-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.search-results {
  list-style: none;
}

.search-result {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.search-result a {
  color: var(--text);
  display: block;
}

.search-result a:hover {
  text-decoration: none;
}

.search-result-chapter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.search-result-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.search-result-excerpt {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}

.search-result mark {
  background: rgba(200, 169, 110, 0.25);
  color: var(--accent);
  padding: 1px 2px;
}

.search-result.active {
  background: var(--bg-elevated);
  margin: 0 -12px;
  padding: 20px 12px;
}

.search-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* --- About Page --- */
.page-content {
  padding: 60px 0 80px;
}

.page-content h1 {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 40px;
}

.page-content h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
}

.page-content p {
  margin-bottom: 20px;
  color: var(--text-muted);
}

.page-content a {
  color: var(--accent);
}

/* --- Audiobook Page --- */
.audiobook-list {
  list-style: none;
}

.audiobook-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.audiobook-item:first-child {
  border-top: 1px solid var(--border);
}

.audiobook-num {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  min-width: 32px;
}

.audiobook-title {
  flex: 1;
  color: var(--text-muted);
}

.audiobook-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 20px 0;
  color: var(--text-muted);
}

.badge-soon {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 2px 8px;
  letter-spacing: 0.05em;
  margin-left: auto;
}

/* --- Share Button --- */
.share-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.share-btn.copied {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- English Link --- */
.english-link {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .hero {
    min-height: 60vh;
    padding: 48px 0;
  }

  .chapter-header {
    padding: 40px 0 24px;
  }

  .chapter-nav {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .chapter-nav .next {
    margin-left: 0;
  }

  .site-header .wide-container {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .footer-content {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
}
