/* =================================================================
   MODERN CODE BLOCKS - Блоки примеров кода
   Современный дизайн с поддержкой светлой и темной темы
   ================================================================= */

/* === СЕКЦИЯ С ПРИМЕРАМИ КОДА === */
.code-examples-section {
    padding: 120px 0 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
    min-height: 800px;
}

/* Темная тема для секции */
[data-theme="dark"] .code-examples-section {
    background: linear-gradient(135deg, #1a1f2e 0%, #2d1b3d 100%);
}

/* Заголовок секции */
.code-section-header {
    text-align: center;
    margin-bottom: 64px;
}

.code-section-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.code-section-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #e0f2fe 50%, #bae6fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.code-section-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: rgba(255, 255, 255, 0.85);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Сетка блоков кода */
.code-examples-grid {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 650px;
}

/* === БЛОК КОДА === */
.code-block {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 540px;
    max-width: 90%;
    position: absolute;
}

/* Первый блок - слева и выше */
.code-block:first-child {
    left: 0;
    top: 0;
    z-index: 2;
    transform: rotate(-2deg);
}

/* Второй блок - справа и ниже */
.code-block:last-child {
    right: 0;
    top: 140px;
    z-index: 1;
    transform: rotate(2deg);
}

.code-block:hover {
    transform: translateY(-8px) rotate(-2deg);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.code-block:last-child:hover {
    transform: translateY(-8px) rotate(2deg);
}

[data-theme="dark"] .code-block {
    background: rgba(10, 15, 30, 0.98);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Шапка блока кода (как у терминала) */
.code-block-header {
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

[data-theme="dark"] .code-block-header {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* Кнопки окна (красная, желтая, зеленая) */
.code-window-controls {
    display: flex;
    gap: 6px;
}

.code-window-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.code-window-btn.close { background: #ff5f56; }
.code-window-btn.minimize { background: #ffbd2e; }
.code-window-btn.maximize { background: #27ca3f; }

/* Название файла */
.code-filename {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', monospace;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

[data-theme="dark"] .code-filename {
    color: rgba(255, 255, 255, 0.6);
}

/* Контент блока кода */
.code-block-content {
    padding: 28px 24px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', monospace;
    font-size: 14px;
    line-height: 1.8;
    overflow-x: auto;
}

/* Строки кода */
.code-line {
    margin: 0;
    padding: 2px 0;
    white-space: pre;
}

/* === ПОДСВЕТКА СИНТАКСИСА === */

/* Комментарии */
.code-comment {
    color: #6b7280;
    font-style: italic;
}

[data-theme="dark"] .code-comment {
    color: #4b5563;
}

/* Ключевые слова (class, def, const, let, return) */
.code-keyword {
    color: #c792ea;
    font-weight: 600;
}

[data-theme="dark"] .code-keyword {
    color: #a78bfa;
}

/* Имена функций и классов */
.code-function {
    color: #82aaff;
    font-weight: 500;
}

[data-theme="dark"] .code-function {
    color: #60a5fa;
}

/* Строки */
.code-string {
    color: #c3e88d;
}

[data-theme="dark"] .code-string {
    color: #86efac;
}

/* Числа */
.code-number {
    color: #f78c6c;
}

[data-theme="dark"] .code-number {
    color: #fb923c;
}

/* Переменные и параметры */
.code-param {
    color: #f07178;
}

[data-theme="dark"] .code-param {
    color: #fca5a5;
}

/* Операторы и скобки */
.code-operator {
    color: #89ddff;
}

[data-theme="dark"] .code-operator {
    color: #67e8f9;
}

/* Имена переменных */
.code-variable {
    color: #ffcb6b;
}

[data-theme="dark"] .code-variable {
    color: #fde047;
}

/* Специальные ключевые слова (self, this) */
.code-special {
    color: #ff5370;
    font-style: italic;
}

[data-theme="dark"] .code-special {
    color: #f87171;
}

/* === КУРСОР ПЕЧАТИ === */
.code-cursor {
    display: inline-block;
    width: 8px;
    height: 18px;
    background: #60a5fa;
    margin-left: 2px;
    animation: cursor-blink 1s step-end infinite;
}

[data-theme="dark"] .code-cursor {
    background: #3b82f6;
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 1024px) {
    .code-examples-grid {
        min-height: 550px;
    }
    
    .code-block {
        width: 480px;
    }
    
    .code-block:last-child {
        top: 100px;
    }
}

@media (max-width: 768px) {
    .code-examples-section {
        padding: 80px 0 120px;
        min-height: auto;
    }
    
    .code-section-header {
        margin-bottom: 48px;
    }
    
    .code-examples-grid {
        position: relative;
        min-height: 850px;
        padding: 0 15px;
    }
    
    .code-block {
        position: relative;
        width: 100%;
        max-width: 100%;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        margin-bottom: 24px;
    }
    
    .code-block:first-child {
        position: relative;
    }
    
    .code-block:last-child {
        position: relative;
    }
    
    .code-block:hover {
        transform: translateY(-4px) !important;
    }
    
    .code-block-content {
        padding: 20px 16px;
        font-size: 13px;
    }
    
    .code-section-title {
        font-size: 2rem;
    }
}

/* === УЛУЧШЕНИЯ ДЛЯ СКРОЛЛБАРА === */
.code-block-content::-webkit-scrollbar {
    height: 8px;
}

.code-block-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.code-block-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.code-block-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .code-block-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .code-block-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}
