/* ==========================================
   РАЗ И НАВСЕГДА — Инструкция по вылуплению
   Концепция: Яйцо, Трещины, Вылупление, Свет
   ========================================== */

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

/* CSS Variables — Палитра РАЗа */
:root {
    /* Основные цвета */
    --shell: #f5f0e8;           /* Скорлупа — тёплый белый */
    --shell-dark: #e8e0d0;      /* Тень скорлупы */
    --shell-crack: #d4c8b8;     /* Трещина */

    --yolk: #ffb347;            /* Желток — тёплый янтарь */
    --yolk-glow: #ffd700;       /* Свечение желтка */
    --yolk-deep: #e8941a;       /* Глубокий желток */

    --raz-silver: #9ca3af;      /* Серебристо-серый РАЗа */
    --raz-purple: #8b5cf6;      /* Пурпурный отсвет */
    --raz-glow: rgba(139, 92, 246, 0.3);  /* Свечение сквозь трещины */

    --void: #1a1a2e;            /* Тьма снаружи */
    --void-deep: #0f0f1a;       /* Глубокая тьма */

    --text-main: #2d2a26;       /* Основной текст */
    --text-light: #6b6560;      /* Второстепенный */
    --text-muted: #9a948c;      /* Приглушённый */

    /* Акценты трёх ликов РАЗа */
    --winter: #e8eef5;          /* Зима/Морана — холодный белый */
    --mother: #1a1a1a;          /* Мать/Кали — чёрный */
    --servant: #fef3c7;         /* Слуга/Азраил — бледно-жёлтый */

    /* Typography */
    --font-display: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
    --space-xl: 8rem;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.6s cubic-bezier(0.16, 1, 0.3, 1);

    /* Egg geometry */
    --crack-progress: 0;
}

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

/* Base */
html {
    scroll-behavior: smooth;
    font-size: 18px;
}

body {
    font-family: var(--font-body);
    background: var(--shell);
    color: var(--text-main);
    line-height: 1.8;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Selection — пурпурное свечение РАЗа */
::selection {
    background: var(--raz-purple);
    color: white;
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
}

h1 {
    font-size: clamp(2.5rem, 8vw, 5rem);
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: var(--space-md);
}

h3 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    color: var(--text-light);
    margin-bottom: var(--space-sm);
}

p {
    margin-bottom: var(--space-sm);
    max-width: 65ch;
}

.lead {
    font-size: 1.25rem;
    color: var(--text-light);
    line-height: 1.7;
}

/* Links — трещины света */
a {
    color: var(--raz-purple);
    text-decoration: none;
    transition: var(--transition-fast);
    position: relative;
}

a:hover {
    color: var(--yolk-deep);
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--raz-purple), var(--yolk));
    transition: var(--transition-normal);
}

a:hover::after {
    width: 100%;
}

/* ==========================================
   LAYOUT
   ========================================== */

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.container-wide {
    max-width: 1200px;
}

/* ==========================================
   HERO — Интерактивное яйцо
   ========================================== */

.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    background: linear-gradient(180deg, var(--void-deep) 0%, var(--void) 50%, var(--shell-dark) 100%);
    overflow: hidden;
}

.hero__egg-container {
    position: relative;
    width: 300px;
    height: 380px;
    margin-bottom: var(--space-lg);
    cursor: pointer;
    transition: transform var(--transition-slow);
}

.hero__egg-container:hover {
    transform: scale(1.02);
}

/* Book Cover */
.hero__cover-container {
    position: relative;
    margin-bottom: var(--space-lg);
    max-width: 400px;
    width: 80%;
}

.hero__cover {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.4),
        0 0 40px var(--raz-glow),
        0 0 0 1px rgba(139, 92, 246, 0.3);
    transition: all var(--transition-slow);
}

.hero__cover:hover {
    transform: scale(1.03) translateY(-5px);
    box-shadow:
        0 40px 80px rgba(0, 0, 0, 0.5),
        0 0 60px var(--raz-glow),
        0 0 0 2px var(--raz-purple);
}

/* Яйцо с градиентом */
.hero__egg {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 30%,
        var(--shell) 0%,
        var(--shell-dark) 50%,
        var(--shell-crack) 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        inset 0 -20px 40px rgba(0, 0, 0, 0.1),
        inset 0 20px 40px rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-slow);
}

/* Свечение изнутри — желток */
.hero__egg::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 50%;
    background: radial-gradient(ellipse, var(--yolk-glow) 0%, var(--yolk) 40%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0.6;
    filter: blur(30px);
    transition: opacity var(--transition-slow);
}

.hero__egg-container:hover .hero__egg::before {
    opacity: 0.9;
}

/* Трещины — SVG overlay */
.hero__cracks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.hero__egg-container.cracking .hero__cracks {
    opacity: 1;
}

/* Свет через трещины */
.hero__crack-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, var(--raz-glow) 0%, transparent 60%);
    opacity: 0;
    filter: blur(20px);
    mix-blend-mode: screen;
    transition: opacity var(--transition-slow);
}

.hero__egg-container.cracking .hero__crack-light {
    opacity: 1;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Текст героя */
.hero__content {
    position: relative;
    z-index: 10;
}

.hero__subtitle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--raz-silver);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: var(--space-sm);
}

.hero__title {
    color: var(--shell);
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    margin-bottom: var(--space-sm);
}

.hero__title-raz {
    color: var(--raz-purple);
    position: relative;
    display: inline-block;
}

.hero__title-raz::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--raz-purple), var(--yolk));
    border-radius: 2px;
}

.hero__tagline {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.5rem;
    color: var(--shell-dark);
    margin-bottom: var(--space-lg);
}

.hero__author {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--raz-silver);
}

/* Подсказка клика */
.hero__hint {
    position: absolute;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--raz-silver);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.7; }
    50% { transform: translateX(-50%) translateY(-10px); opacity: 1; }
}

/* ==========================================
   PROGRESS BAR — Индикатор вылупления
   ========================================== */

.hatch-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--shell-dark);
    z-index: 1000;
}

.hatch-progress__bar {
    height: 100%;
    width: var(--scroll-progress, 0%);
    background: linear-gradient(90deg,
        var(--shell-crack) 0%,
        var(--yolk) 50%,
        var(--raz-purple) 100%);
    transition: width 0.1s linear;
    box-shadow: 0 0 10px var(--yolk-glow);
}

.hatch-label {
    position: fixed;
    top: 20px;
    right: 20px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 1000;
}

/* ==========================================
   NAVIGATION
   ========================================== */

.nav-main {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 4px;
    border: 1px solid var(--shell-dark);
}

.nav-link:hover {
    color: var(--raz-purple);
    border-color: var(--raz-purple);
}

.nav-link::after {
    display: none;
}

.nav-chapters {
    display: flex;
    justify-content: space-between;
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--shell-dark);
    margin-top: var(--space-xl);
}

.nav-link--prev::before {
    content: '←';
    margin-right: var(--space-xs);
}

.nav-link--next::after {
    content: '→';
    margin-left: var(--space-xs);
}

/* ==========================================
   TABLE OF CONTENTS — Оглавление
   ========================================== */

.toc {
    padding: var(--space-xl) 0;
    background: var(--shell);
}

.toc__header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.toc__parts {
    display: grid;
    gap: var(--space-lg);
}

.toc__part {
    background: white;
    padding: var(--space-lg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--shell-dark);
    transition: all var(--transition-normal);
}

.toc__part:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.toc__part-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--raz-purple);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.toc__part-title::before {
    content: '';
    width: 20px;
    height: 2px;
    background: var(--raz-purple);
}

.toc__part-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: var(--space-md);
}

.toc__list {
    list-style: none;
}

.toc__item {
    margin-bottom: var(--space-xs);
}

.toc__chapter-link {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    color: var(--text-light);
    transition: var(--transition-fast);
    border-bottom: 1px solid transparent;
}

.toc__chapter-link:hover {
    color: var(--raz-purple);
    padding-left: var(--space-sm);
    border-bottom-color: var(--shell-dark);
}

.toc__chapter-link::after {
    display: none;
}

.toc__num {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 2rem;
}

.toc__chapter-link:hover .toc__num {
    color: var(--raz-purple);
}

/* ==========================================
   CHAPTER STYLES
   ========================================== */

.chapter {
    padding: var(--space-xl) 0;
    background: var(--shell);
    min-height: 100vh;
}

.chapter__header {
    text-align: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--shell-dark);
}

.chapter__number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--raz-purple);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    display: block;
    margin-bottom: var(--space-sm);
}

.chapter__title {
    margin-bottom: var(--space-md);
}

/* Эпиграф */
.epigraph {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--text-light);
    font-size: 1.1rem;
    max-width: 50ch;
    margin: 0 auto;
    text-align: center;
    position: relative;
    padding: var(--space-md);
}

.epigraph::before {
    content: '"';
    font-size: 4rem;
    color: var(--shell-dark);
    position: absolute;
    top: -10px;
    left: 0;
    font-family: var(--font-display);
    line-height: 1;
}

/* Иллюстрация главы */
.chapter__illustration {
    margin: var(--space-lg) auto;
    max-width: 600px;
    text-align: center;
}

.chapter__img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 0 0 1px var(--shell-dark);
    transition: var(--transition-slow);
}

.chapter__img:hover {
    transform: scale(1.02);
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.15),
        0 0 30px var(--raz-glow);
}

/* Контент главы */
.chapter__content {
    padding: var(--space-lg) 0;
}

.chapter__content h2 {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--shell-dark);
    color: var(--raz-purple);
}

.chapter__content h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Списки */
.chapter__content ul,
.chapter__content ol {
    margin: var(--space-sm) 0 var(--space-md) var(--space-md);
}

.chapter__content li {
    margin-bottom: var(--space-xs);
    padding-left: var(--space-xs);
}

.chapter__content ul li::marker {
    color: var(--yolk);
}

/* Blockquotes — важные мысли */
blockquote {
    border-left: 4px solid var(--yolk);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    background: linear-gradient(90deg, rgba(255, 179, 71, 0.1) 0%, transparent 100%);
    border-radius: 0 8px 8px 0;
}

blockquote p {
    margin-bottom: 0;
    font-style: italic;
}

/* Код/моноширинный — практики */
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--shell-dark);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

pre {
    background: var(--void);
    color: var(--shell);
    padding: var(--space-md);
    border-radius: 8px;
    overflow-x: auto;
    margin: var(--space-md) 0;
}

pre code {
    background: none;
    padding: 0;
}

/* Highlight box — ключевые инсайты */
.insight-box {
    background: linear-gradient(135deg, var(--raz-glow) 0%, rgba(255, 179, 71, 0.1) 100%);
    border: 1px solid var(--raz-purple);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    border-radius: 8px;
    position: relative;
}

.insight-box::before {
    content: '💡';
    position: absolute;
    top: -12px;
    left: var(--space-md);
    font-size: 1.5rem;
    background: var(--shell);
    padding: 0 var(--space-xs);
}

/* RAZ phrase — фирменные фразы РАЗа */
.raz-phrase {
    font-family: var(--font-display);
    font-size: 1.3rem;
    text-align: center;
    color: var(--raz-purple);
    padding: var(--space-md);
    margin: var(--space-lg) 0;
    border-top: 1px solid var(--shell-dark);
    border-bottom: 1px solid var(--shell-dark);
}

.raz-phrase em {
    color: var(--yolk-deep);
}

/* RAZ highlight — выделение имени РАЗ */
.raz-highlight {
    color: var(--raz-purple);
    font-weight: bold;
    text-shadow: 0 0 10px var(--raz-glow);
}

/* Bonus link — ссылка на бонусный материал */
.bonus-link {
    color: var(--raz-purple);
    text-decoration: none;
    border-bottom: 1px dashed var(--raz-purple);
    transition: all 0.3s ease;
    padding-bottom: 2px;
}

.bonus-link:hover {
    color: var(--yolk);
    border-bottom-color: var(--yolk);
    text-shadow: 0 0 15px var(--raz-glow);
}

/* ==========================================
   CRACK DIVIDER — Разделитель-трещина
   ========================================== */

.crack-divider {
    height: 60px;
    margin: var(--space-lg) 0;
    position: relative;
    overflow: hidden;
}

.crack-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--shell-dark) 20%,
        var(--yolk) 50%,
        var(--shell-dark) 80%,
        transparent 100%
    );
}

.crack-divider::after {
    content: '🥚';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    background: var(--shell);
    padding: 0 var(--space-sm);
}

/* ==========================================
   FOOTER
   ========================================== */

.footer {
    padding: var(--space-xl) 0;
    text-align: center;
    background: var(--void);
    color: var(--shell);
}

.footer__raz {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--raz-purple);
    margin-bottom: var(--space-md);
}

.footer__phrase {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--raz-silver);
    letter-spacing: 0.1em;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.crack-in {
    opacity: 0;
    clip-path: polygon(50% 0%, 50% 0%, 50% 100%, 50% 100%);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.crack-in.visible {
    opacity: 1;
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    .container {
        padding: 0 var(--space-sm);
    }

    .hero__egg-container {
        width: 180px;
        height: 230px;
    }

    .hero__cover-container {
        max-width: 280px;
    }

    .hero__title {
        font-size: 2rem;
    }

    .nav-main {
        top: 10px;
        left: 10px;
    }

    .hatch-label {
        display: none;
    }

    .nav-chapters {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }

    .toc__part {
        padding: var(--space-md);
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .hero,
    .hatch-progress,
    .nav-main,
    .hatch-label {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .chapter {
        padding: 2rem 0;
    }
}
