/* === ШРИФТЫ === */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Cormorant+Garamond:wght@300;400;500;600&family=Inter:wght@300;400;500;600&display=swap');

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: #0a0a0c;
  color: #e8e3d8;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* === ЗВЁЗДНОЕ НЕБО (фоновый эффект) === */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}
.star {
  position: absolute;
  background: #c8a876;
  border-radius: 50%;
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.5); }
}

/* === ПРОГРЕСС ЧТЕНИЯ === */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: linear-gradient(to right, #c8a876, #f4ecd8);
  z-index: 100;
  width: 0;
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px rgba(200, 168, 118, 0.5);
}

/* === ШАПКА === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(200, 168, 118, 0.1);
  padding: 20px 40px;
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #f4ecd8;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border: 1.5px solid #c8a876;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  color: #c8a876;
  font-size: 20px;
  transition: all 0.4s ease;
  position: relative;
}
.brand-mark::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: linear-gradient(45deg, #c8a876, transparent, #c8a876) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.brand:hover .brand-mark::before { opacity: 1; }
.brand:hover .brand-mark { transform: rotate(15deg); }
.brand-name {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.site-nav { display: flex; gap: 28px; }
.site-nav a {
  color: #8a7654;
  text-decoration: none;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: color 0.3s;
  position: relative;
  padding-bottom: 4px;
}
.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: #c8a876;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s ease;
}
.site-nav a:hover { color: #f4ecd8; }
.site-nav a:hover::after { transform: scaleX(1); transform-origin: left; }

/* === LAYOUT С САЙДБАРОМ === */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 60px;
  padding: 60px 40px;
  position: relative;
  z-index: 1;
}
.sidebar {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 20px;
  opacity: 0;
  animation: fadeUp 0.8s ease-out 0.2s forwards;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(200, 168, 118, 0.2); border-radius: 2px; }

.sidebar-section { margin-bottom: 32px; }
.sidebar-title {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #8a7654;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 20px;
  position: relative;
}
.sidebar-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 12px;
  height: 1px;
  background: #c8a876;
}
.sidebar a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0 6px 20px;
  color: #8a8278;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s;
  position: relative;
}
.sidebar a::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background 0.3s;
}
.sidebar a:hover { color: #f4ecd8; transform: translateX(4px); }
.sidebar a:hover::before { background: rgba(200, 168, 118, 0.3); }
.sidebar a.active { color: #c8a876; }
.sidebar a.active::before { background: #c8a876; }
.sidebar a .num {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  color: #555;
  min-width: 18px;
}
.sidebar a.active .num { color: #c8a876; }

/* === КОНТЕНТ === */
.content {
  max-width: 720px;
  opacity: 0;
  animation: fadeUp 1s ease-out 0.4s forwards;
}
.crumb {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: #8a7654;
  text-transform: uppercase;
  margin-bottom: 24px;
  position: relative;
  display: inline-block;
}
.crumb::after {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: #c8a876;
  margin-top: 8px;
  animation: drawLine 1.2s ease-out 0.8s both;
}
@keyframes drawLine {
  from { width: 0; }
  to { width: 40px; }
}

h1 {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: clamp(36px, 5vw, 52px);
  line-height: 1.1;
  color: #f4ecd8;
  margin-bottom: 32px;
  letter-spacing: -0.005em;
  text-shadow: 0 0 30px rgba(200, 168, 118, 0.1);
}
h1::first-letter {
  color: #c8a876;
}

h2 {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 22px;
  color: #c8a876;
  margin: 60px 0 20px;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(20px);
}
h2.in-view {
  animation: fadeUp 0.6s ease-out forwards;
}

p {
  font-size: 17px;
  color: #d8d2c4;
  margin-bottom: 20px;
}
.lead {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  line-height: 1.55;
  color: #e8e3d8;
  font-weight: 400;
  margin-bottom: 28px;
}

ul, ol { list-style: none; margin-bottom: 24px; }
li {
  font-size: 17px;
  color: #d8d2c4;
  padding: 8px 0 8px 28px;
  position: relative;
}
li::before {
  content: '◆';
  position: absolute;
  left: 0;
  top: 11px;
  color: #c8a876;
  font-size: 11px;
  transition: transform 0.3s;
}
li:hover::before { transform: scale(1.3) rotate(45deg); }

strong { color: #f4ecd8; font-weight: 500; }
em { color: #c8a876; font-style: italic; }
a { color: #c8a876; text-decoration: none; border-bottom: 1px solid rgba(200, 168, 118, 0.3); transition: border-color 0.3s; }
a:hover { border-bottom-color: #c8a876; }

code {
  font-family: 'Menlo', 'Consolas', monospace;
  background: #1a1a1f;
  padding: 2px 8px;
  border-radius: 4px;
  color: #c8a876;
  font-size: 14px;
  border: 1px solid rgba(200, 168, 118, 0.15);
}
pre {
  background: #14141a;
  padding: 20px 24px;
  border-radius: 6px;
  border-left: 2px solid #c8a876;
  overflow-x: auto;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.7;
}
pre code { background: none; border: none; padding: 0; color: #d8d2c4; }

/* === МЕАНДР (греческий узор) === */
.meander {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 70px auto;
  height: 24px;
  position: relative;
}
.meander svg {
  width: 200px;
  height: 24px;
  opacity: 0.4;
}
.meander svg path { stroke: #c8a876; stroke-width: 1.2; fill: none; }

/* === БЛОК "ОТ РАЗРАБОТЧИКА" === */
.author {
  background: linear-gradient(135deg, rgba(200, 168, 118, 0.06), rgba(200, 168, 118, 0.02));
  border-left: 2px solid #c8a876;
  padding: 32px 36px;
  margin-top: 40px;
  border-radius: 0 8px 8px 0;
  position: relative;
  overflow: hidden;
}
.author::before {
  content: '"';
  position: absolute;
  top: -20px;
  right: 20px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 120px;
  color: rgba(200, 168, 118, 0.1);
  line-height: 1;
}
.author-label {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.25em;
  color: #c8a876;
  text-transform: uppercase;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.author-label::before {
  content: '';
  width: 18px;
  height: 1px;
  background: #c8a876;
}
.author p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px;
  line-height: 1.65;
  color: #d8d2c4;
  font-style: italic;
  font-weight: 400;
}

/* === НАВИГАЦИЯ ПО СТРАНИЦАМ === */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 90px;
  padding-top: 40px;
  border-top: 1px solid rgba(200, 168, 118, 0.1);
  gap: 20px;
}
.page-nav a {
  color: #8a7654;
  text-decoration: none;
  border: none;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: all 0.3s;
  padding: 12px 0;
  flex: 1;
  max-width: 280px;
}
.page-nav a:hover { color: #c8a876; }
.page-nav .next { text-align: right; }
.page-nav .label {
  display: block;
  color: #555;
  font-size: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.3em;
}
.page-nav .title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 18px;
  color: #d8d2c4;
  letter-spacing: 0;
  text-transform: none;
  transition: color 0.3s;
}
.page-nav a:hover .title { color: #f4ecd8; }

/* === ГЛАВНАЯ === */
.hero {
  text-align: center;
  padding: 100px 40px 60px;
  position: relative;
  z-index: 1;
}
.hero-mark {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 56px;
  color: #c8a876;
  display: inline-block;
  width: 110px;
  height: 110px;
  line-height: 110px;
  border: 1.5px solid #c8a876;
  border-radius: 50%;
  margin-bottom: 36px;
  animation: floatMark 6s ease-in-out infinite, shimmer 4s ease-in-out infinite;
  text-shadow: 0 0 30px rgba(200, 168, 118, 0.5);
}
@keyframes floatMark {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes shimmer {
  0%, 100% { box-shadow: 0 0 20px rgba(200, 168, 118, 0.2); }
  50% { box-shadow: 0 0 50px rgba(200, 168, 118, 0.5); }
}
.hero h1 {
  font-size: clamp(48px, 7vw, 80px);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}
.hero h1::first-letter { color: inherit; }
.hero-sub {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-style: italic;
  color: #c8a876;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}
.hero-desc {
  max-width: 540px;
  margin: 0 auto;
  font-size: 17px;
  color: #a8a298;
}

.toc {
  max-width: 1000px;
  margin: 0 auto;
  padding: 60px 40px 120px;
  position: relative;
  z-index: 1;
}
.toc-section {
  margin-bottom: 60px;
  opacity: 0;
  transform: translateY(30px);
}
.toc-section.visible { animation: fadeUp 0.7s ease-out forwards; }
.toc-section-title {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: #8a7654;
  text-transform: uppercase;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.toc-section-title::before, .toc-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(200, 168, 118, 0.15);
}
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.toc-card {
  display: block;
  padding: 24px 28px;
  background: linear-gradient(135deg, rgba(200, 168, 118, 0.03), transparent);
  border: 1px solid rgba(200, 168, 118, 0.1);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.toc-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(200, 168, 118, 0.15), transparent);
  opacity: 0;
  transition: opacity 0.4s;
}
.toc-card:hover {
  transform: translateY(-4px);
  border-color: rgba(200, 168, 118, 0.4);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 0 20px rgba(200, 168, 118, 0.1);
}
.toc-card:hover::before { opacity: 1; }
.toc-card-num {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: #c8a876;
  letter-spacing: 0.2em;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}
.toc-card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  color: #f4ecd8;
  font-weight: 500;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}
.toc-card.disabled { opacity: 0.4; pointer-events: none; }
.toc-card.disabled .toc-card-num::after { content: ' · скоро'; color: #555; }

/* === АНИМАЦИИ === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Reveal-on-scroll базовый класс */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.reveal.in-view { opacity: 1; transform: translateY(0); }

/* === АДАПТИВ === */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 30px 20px;
  }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 20px;
    background: rgba(200, 168, 118, 0.03);
    border-radius: 8px;
  }
  .site-nav { display: none; }
  .site-header { padding: 16px 20px; }
  h1 { font-size: 36px; }
  .hero { padding: 60px 20px 40px; }
  .hero h1 { font-size: 44px; }
  .toc { padding: 40px 20px 80px; }
  .toc-grid { grid-template-columns: 1fr; }
}

/* === ФУТЕР === */
.site-footer {
  text-align: center;
  padding: 60px 40px;
  border-top: 1px solid rgba(200, 168, 118, 0.1);
  position: relative;
  z-index: 1;
}
.site-footer p {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #555;
  text-transform: uppercase;
}

/* === АПГРЕЙД АНИМАЦИЙ === */
.toc-grid { perspective: 1200px; }
.toc-card {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s, box-shadow 0.3s;
}

/* Меандр анимирован */
.meander svg path {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: drawMeander 3s ease-out forwards;
}
.meander.in-view svg path { animation: drawMeander 3s ease-out forwards; }
@keyframes drawMeander {
  to { stroke-dashoffset: 0; }
}

/* Hero парящие лучи */
.hero::before, .hero::after {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 168, 118, 0.08), transparent 70%);
  filter: blur(40px);
  z-index: -1;
  animation: floatGlow 12s ease-in-out infinite;
}
.hero::before { top: 0; left: -200px; }
.hero::after { bottom: 0; right: -200px; animation-delay: -6s; }
@keyframes floatGlow {
  0%, 100% { transform: translate(0, 0); opacity: 0.6; }
  50% { transform: translate(100px, -50px); opacity: 1; }
}

/* Body fade in переходы */
body { opacity: 1 !important; }

/* Курсор обычный остаётся (наш дот поверх) */
body { cursor: auto; }
a, button, .toc-card { cursor: pointer; }

/* H1 первая буква в обычном цвете при анимации по буквам */
h1 span { color: inherit; }
h1 span:first-child { color: #c8a876; }

/* Tilt-эффект работает с perspective parent */
@media (hover: hover) {
  .toc-card:hover {
    box-shadow:
      0 25px 60px rgba(0, 0, 0, 0.4),
      0 0 40px rgba(200, 168, 118, 0.15),
      inset 0 0 0 1px rgba(200, 168, 118, 0.3);
  }
}
