﻿/* ===== Базовые настройки ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Светлая тема (по умолчанию) */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-hover: #f0f3fa;
  --border: #e5e7eb;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.25);
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --success: #22c55e;
  --warning: #eab308;
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Тёмная тема */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #151515;
  --surface-hover: #1f1f1f;
  --border: #2a2a2a;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.25);
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --text-dim: #737373;
  --success: #22c55e;
  --warning: #eab308;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Шапка ===== */
.header {
  position: relative;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0;
  overflow: hidden;
}

.header__bg {
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(180deg, rgba(10,10,10,0) 0%, rgba(10,10,10,0.4) 40%, rgba(10,10,10,1) 100%),
    url('images/cover.jpg') center/cover no-repeat;
  z-index: 0;
}

.header__content {
  position: relative;
  z-index: 1;
  padding: 60px 48px 48px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.header__info {
  flex: 1;
}

.header__edition {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 6px 16px;
  margin-bottom: 24px;
  text-transform: uppercase;
}

.header__title {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  color: #fff;
  line-height: 1;
  letter-spacing: -2px;
  margin-bottom: 16px;
  text-shadow: 0 4px 24px rgba(0,0,0,0.6);
}

.header__subtitle {
  font-size: 1.15rem;
  color: rgba(255,255,255,0.85);
  font-weight: 400;
  max-width: 600px;
}

.header__meta {
  display: flex;
  gap: 24px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.85);
  font-size: 0.95rem;
}

.meta-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ===== Переключатель темы ===== */
.theme-toggle {
  flex-shrink: 0;
  margin-top: 12px;
}

.theme-toggle__button {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  width: 64px;
  height: 34px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

.theme-toggle__button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.theme-toggle__slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

[data-theme="dark"] .theme-toggle__slider {
  transform: translateX(30px);
  background: var(--accent);
}

.theme-toggle__icon {
  transition: opacity 0.3s ease;
}

.theme-toggle__icon--sun {
  position: absolute;
  opacity: 0;
  color: var(--accent);
}

.theme-toggle__icon--moon {
  position: absolute;
  opacity: 1;
  color: #1f2937;
}

[data-theme="dark"] .theme-toggle__icon--sun {
  opacity: 1;
}

[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 0;
}

/* ===== Контейнер ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* ===== Блок части ===== */
.part {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 32px;
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

.part::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.part:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(249, 115, 22, 0.08);
  transform: translateY(-2px);
}

.part__header {
  padding: 28px 32px 20px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.part__number {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.part__title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

/* ===== Список глав ===== */
.chapters {
  list-style: none;
  padding: 8px 0;
}

.chapter {
  display: flex;
  align-items: center;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  gap: 20px;
}

.chapter:last-child {
  border-bottom: none;
}

.chapter:hover {
  background: var(--surface-hover);
  padding-left: 40px;
}

.chapter__number {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}

.chapter__link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  flex: 1;
  transition: var(--transition);
  font-size: 1.05rem;
}

.chapter__link:hover {
  color: var(--accent);
}

.chapter__link--disabled {
  color: var(--text-dim);
  cursor: not-allowed;
  font-style: italic;
}

.chapter__link--disabled:hover {
  color: var(--text-dim);
}

.chapter__badge {
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.badge--ready {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge--soon {
  background: rgba(234, 179, 8, 0.1);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

/* ===== Кнопка добавления ===== */
.add-page {
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  margin-top: 40px;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.add-page:hover {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.04);
}

.add-page__icon {
  font-size: 1.6rem;
  color: var(--accent);
  font-weight: 300;
}

.add-page__text {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1rem;
}

/* ===== Модальное окно ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal--open {
  display: flex;
}

.modal__content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.modal__title {
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: var(--text);
  font-weight: 700;
}

.modal__field {
  margin-bottom: 18px;
}

.modal__label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal__input,
.modal__select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
}

.modal__input:focus,
.modal__select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal__actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  justify-content: flex-end;
}

.btn {
  padding: 11px 24px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition);
  font-family: inherit;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn--secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ===== Подвал ===== */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-dim);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
  .header__content {
    flex-direction: column;
    align-items: flex-start;
    padding: 40px 24px 32px;
  }
  
  .theme-toggle {
    margin-top: 0;
    align-self: flex-end;
  }
  
  .header {
    min-height: 380px;
  }
  
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  box-sizing: border-box;
  width: 100%;
}
  
  .part__header,
  .chapter {
    padding-left: 24px;
    padding-right: 24px;
  }
  
  .part__title {
    font-size: 1.25rem;
  }
  
  .chapter {
    gap: 12px;
  }
  
  .chapter__link {
    font-size: 0.95rem;
  }
}


/* ===== Навигация по главам ===== */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.chapter-nav--bottom {
  border-bottom: none;
  border-top: 1px solid var(--border);
  position: static;
  margin-top: 48px;
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.nav-link.disabled {
  color: var(--text-dim);
  cursor: default;
}

.nav-link.disabled:hover {
  text-decoration: none;
}

.nav-title {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== Контент главы ===== */
.chapter-content {
  max-width: 800px;
  padding-top: 48px;
  padding-bottom: 48px;
  box-sizing: border-box;
  width: 100%;
}

.chapter-figure {
  margin: 32px 0;
  text-align: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.chapter-figure img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  display: block;
  margin: 0 auto;
  box-sizing: border-box;
}


.chapter-figure figcaption {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 0 16px;
}



.chapter-content h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 32px;
  line-height: 1.2;
  letter-spacing: -1px;
}

.chapter-content h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 48px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.chapter-content h3 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 36px;
  margin-bottom: 16px;
}

.chapter-content p {
  margin-bottom: 20px;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

.chapter-content .lead {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 400;
  border-left: 4px solid var(--accent);
  padding-left: 20px;
  margin-bottom: 32px;
}

.chapter-content ul, 
.chapter-content ol {
  margin-bottom: 24px;
  padding-left: 28px;
}

.chapter-content li {
  margin-bottom: 10px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
}

.chapter-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.chapter-content a:hover {
  border-bottom-color: var(--accent);
}

/* ===== Блок примечания ===== */
.note {
  background: rgba(249, 115, 22, 0.08);
  border-left: 4px solid var(--accent);
  padding: 20px 24px;
  margin: 32px 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
}

.note strong {
  color: var(--accent);
}

/* ===== Адаптивность для глав ===== */
@media (max-width: 640px) {
  .chapter-figure {
    margin: 20px 0;
  }
  
  .chapter-figure img {
    border-radius: 6px;
  }
  
  .chapter-figure figcaption {
    font-size: 0.8rem;
    padding: 0 8px;
  }
}

/* ===== Подсветка синтаксиса Delphi ===== */
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  overflow-x: auto;
  margin: 24px 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

pre code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  color: var(--text);
}

/* Базовые стили highlight.js */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

/* Ключевые слова Delphi */
.hljs-keyword {
  color: #569cd6;
  font-weight: 600;
}

[data-theme="dark"] .hljs-keyword {
  color: #569cd6;
}

/* Строки */
.hljs-string {
  color: #ce9178;
}

/* Комментарии */
.hljs-comment {
  color: #6a9955;
  font-style: italic;
}

/* Числа */
.hljs-number {
  color: #b5cea8;
}

/* Функции и методы */
.hljs-function .hljs-title,
.hljs-title {
  color: #dcdcaa;
}

/* Типы данных */
.hljs-built_in {
  color: #4ec9b0;
}

/* Атрибуты */
.hljs-meta {
  color: #c586c0;
}

/* Операторы */
.hljs-operator {
  color: #d4d4d4;
}

/* Переменные */
.hljs-variable {
  color: #9cdcfe;
}

/* Параметры */
.hljs-params {
  color: #9cdcfe;
}

/* Блоки кода в тексте */
code {
  background: rgba(249, 115, 22, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: var(--accent);
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}


/* ===== Таблица сравнения ===== */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.95rem;
}

.comparison-table thead {
  background: var(--accent);
  color: #fff;
}

.comparison-table th,
.comparison-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table tbody tr:hover {
  background: var(--surface-hover);
}

.comparison-table th {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.table-caption {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin-top: -16px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .comparison-table {
    font-size: 0.85rem;
  }
  .comparison-table th,
  .comparison-table td {
    padding: 8px 10px;
  }
}


/* ===== Иллюстрации ===== */
.figure {
  margin: 32px 0;
  text-align: center;
}

.figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.figure img:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

[data-theme="dark"] .figure img {
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.figure__caption {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}


