/* ========== ПОДКЛЮЧЕНИЕ ШРИФТОВ ========== */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ========== БАЗОВЫЕ СТИЛИ ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    font-weight: 400;
    min-height: 100vh;
    padding: 16px;
    transition: all 0.3s ease;
    position: relative;
}

/* Увеличение размера шрифта на телефонах */
@media (max-width: 768px) {
    body {
        font-size: 15px;
        padding: 12px;
    }
    
    h1 {
        font-size: 1.8em !important;
    }
    
    h2 {
        font-size: 1.4em !important;
    }
    
    h3 {
        font-size: 1.2em !important;
    }
}

/* Мониторы и ноутбуки */
@media (min-width: 1200px) {
    body {
        font-size: 17px;
    }
}
/* ========== КНОПКИ КОПИРОВАНИЯ ========== */
.code-block {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    font-weight: 500;
}

/* Светлая тема — до копирования */
body.light-theme .copy-btn {
    background: #b8d4e8;
    color: #333;
}

body.light-theme .copy-btn:hover {
    background: #a8c8dc;
    transform: scale(1.02);
}

/* Тёмная тема — до копирования */
body.dark-theme .copy-btn {
    background: #5c6bc0;
    color: #fff;
}

body.dark-theme .copy-btn:hover {
    background: #6a79cc;
    transform: scale(1.02);
}

/* После копирования — светлая тема */
body.light-theme .copy-btn.copied {
    background: #a8d5a2;
    color: #333;
}

body.light-theme .copy-btn.copied:hover {
    background: #9ac894;
}

/* После копирования — тёмная тема */
body.dark-theme .copy-btn.copied {
    background: #8baa88;
    color: #fff;
}

body.dark-theme .copy-btn.copied:hover {
    background: #7a9a77;
}

/* ========== КОТИК В ПРАВОМ НИЖНЕМ УГЛУ ========== */
body.light-theme::after {
    content: '';
    position: fixed;
    bottom: 0;
    right: 0;
    width: min(150px, 20vw);
    height: min(150px, 20vw);
    background-image: url('images/cat-light.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom right;
    pointer-events: none;
    z-index: 999;
}

body.dark-theme::after {
    content: '';
    position: fixed;
    bottom: 0;
    right: 0;
    width: min(150px, 20vw);
    height: min(150px, 20vw);
    background-image: url('images/cat-dark.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom right;
    pointer-events: none;
    z-index: 999;
}

/* ========== ФОН ========== */
body.light-theme {
    background-color: #faf9f8;
    color: #333;
}

body.dark-theme {
    background-color: #1a1a2e;
    color: #e0e0e0;
}

/* ========== ПЕРЕКЛЮЧАТЕЛЬ ТЕМ ========== */
.theme-switch-wrapper {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 40px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.dark-theme .theme-switch-wrapper {
    background: rgba(30, 30, 50, 0.9);
}

.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "☀️";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    content: "🌙";
    transform: translateX(28px);
}

/* ========== ОБЩИЕ СТИЛИ ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 8px;
}

@media (max-width: 768px) {
    .container {
        padding: 0 4px;
    }
}

header {
    text-align: center;
    margin-bottom: 32px;
    padding: 16px;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    header {
        margin-bottom: 20px;
        padding: 12px;
    }
}

body.light-theme header {
    color: #333;
}

body.dark-theme header {
    color: #e0e0e0;
}

h1 {
    font-size: 2.2em;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

h2 {
    font-weight: 600;
    letter-spacing: -0.005em;
}

h3 {
    font-weight: 600;
}

p {
    font-weight: 400;
    line-height: 1.5;
}

/* ========== КАРТОЧКИ ========== */
.categories, .algorithms-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

@media (max-width: 640px) {
    .categories, .algorithms-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.category-card, .algorithm-card {
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
    .category-card, .algorithm-card {
        padding: 20px;
    }
}

body.light-theme .category-card,
body.light-theme .algorithm-card {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(171, 205, 239, 0.3);
}

body.dark-theme .category-card,
body.dark-theme .algorithm-card {
    background: rgba(30, 30, 50, 0.9);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    border: 1px solid rgba(29, 30, 51, 0.5);
}

.category-card:hover, .algorithm-card:hover {
    transform: translateY(-5px);
}

.category-card h2, .algorithm-card h3 {
    margin-bottom: 12px;
    font-weight: 600;
}

body.light-theme .category-card h2,
body.light-theme .algorithm-card h3 {
    color: #abcdef;
}

body.dark-theme .category-card h2,
body.dark-theme .algorithm-card h3 {
    color: #667eea;
}

.category-card p, .algorithm-card p {
    margin-bottom: 20px;
    font-size: 0.95em;
    line-height: 1.5;
}

/* ========== КНОПКИ ========== */
.btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 40px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
}

@media (max-width: 768px) {
    .btn, button {
        padding: 8px 20px;
        font-size: 0.9rem;
    }
}

body.light-theme .btn,
body.light-theme button {
    background: #abcdef;
    color: #333;
}

body.light-theme .btn:hover,
body.light-theme button:hover {
    background: #9bc8e8;
    transform: scale(1.03);
}

body.dark-theme .btn,
body.dark-theme button {
    background: #4a4aff;
    color: #ffffff;
    border: 1px solid #8888ff;
}

body.dark-theme .btn:hover,
body.dark-theme button:hover {
    background: #5c5cff;
    transform: scale(1.03);
}

/* Кнопка "Назад" */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    margin-bottom: 20px;
    padding: 8px 18px;
    border-radius: 40px;
    transition: background 0.3s;
    font-weight: 500;
    font-size: 0.9rem;
}

body.light-theme .back-btn {
    background: rgba(171, 205, 239, 0.8);
    color: #333;
}

body.light-theme .back-btn:hover {
    background: rgba(171, 205, 239, 1);
}

body.dark-theme .back-btn {
    background: rgba(74, 74, 255, 0.8);
    color: #ffffff;
}

body.dark-theme .back-btn:hover {
    background: #4a4aff;
}

/* ========== КОД ========== */
.code-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

@media (max-width: 768px) {
    .code-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.code-block {
    border-radius: 16px;
    overflow: hidden;
}

.code-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.9rem;
}

pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    pre {
        font-size: 11px;
        padding: 12px;
    }
}

/* ========== ОБЪЯСНЕНИЕ ========== */
.explanation {
    padding: 20px;
    border-radius: 16px;
    margin: 20px 0;
}

.explanation p, .explanation li {
    font-weight: 400;
    line-height: 1.6;
}

.explanation ul {
    padding-left: 24px;
    margin-top: 8px;
}

.explanation li {
    margin: 6px 0;
}

/* ========== ДЕМО-БЛОК ========== */
.demo {
    padding: 20px;
    border-radius: 16px;
    margin: 20px 0;
}

.demo input, .demo textarea {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    transition: border-color 0.2s;
}

@media (max-width: 768px) {
    .demo input, .demo textarea {
        font-size: 13px;
        padding: 10px;
    }
}

.output {
    padding: 12px;
    border-radius: 12px;
    margin-top: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

/* Лапка */
.paw {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url('images/paw.png');
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: 6px;
    vertical-align: middle;
}

/* ========== АДАПТИВНОСТЬ ДЛЯ ТЕЛЕФОНОВ ========== */
@media (max-width: 768px) {
    .theme-switch-wrapper {
        top: 12px;
        right: 12px;
        padding: 4px 8px;
    }
    
    .switch {
        width: 50px;
        height: 26px;
    }
    
    .slider:before {
        height: 22px;
        width: 22px;
        font-size: 11px;
    }
    
    input:checked + .slider:before {
        transform: translateX(24px);
    }
    
    button, .btn {
        min-height: 44px; /* Удобно для нажатия пальцем */
    }
    
    input, textarea, select {
        font-size: 16px !important; /* Предотвращает зум на iPhone */
    }
}
/* ========== РАМОЧКИ ДЛЯ КОДА И ТЕКСТА ========== */

/* Блоки с кодом */
.code-block {
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

body.light-theme .code-block {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

body.dark-theme .code-block {
    background: #1e1e1e;
    border: 1px solid #3a3a4a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Заголовки блоков кода */
.code-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid;
}

body.light-theme .code-header {
    background: #e9ecef;
    color: #333;
    border-bottom-color: #dee2e6;
}

body.dark-theme .code-header {
    background: #2d2d3a;
    color: #fff;
    border-bottom-color: #3a3a4a;
}

/* Сам код */
pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
}

body.light-theme pre {
    color: #333;
    background: #f8f9fa;
}

body.dark-theme pre {
    color: #d4d4d4;
    background: #1e1e1e;
}

/* Блоки объяснения */
.explanation {
    padding: 20px;
    border-radius: 16px;
    margin: 20px 0;
    transition: all 0.3s ease;
}

body.light-theme .explanation {
    background: rgba(171, 205, 239, 0.15);
    border-left: 4px solid #abcdef;
    border-top: 1px solid rgba(171, 205, 239, 0.3);
    border-right: 1px solid rgba(171, 205, 239, 0.3);
    border-bottom: 1px solid rgba(171, 205, 239, 0.3);
}

body.dark-theme .explanation {
    background: rgba(29, 30, 51, 0.4);
    border-left: 4px solid #667eea;
    border-top: 1px solid rgba(102, 126, 234, 0.2);
    border-right: 1px solid rgba(102, 126, 234, 0.2);
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

/* Демо-блоки */
.demo {
    padding: 20px;
    border-radius: 16px;
    margin: 20px 0;
    transition: all 0.3s ease;
}

body.light-theme .demo {
    background: white;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

body.dark-theme .demo {
    background: rgba(30, 30, 50, 0.8);
    border: 1px solid #3a3a4a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Поля ввода и textarea */
.demo input, .demo textarea {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    transition: all 0.2s;
}

body.light-theme .demo input,
body.light-theme .demo textarea {
    background: white;
    border: 1px solid #ddd;
    color: #333;
}

body.light-theme .demo input:focus,
body.light-theme .demo textarea:focus {
    border-color: #abcdef;
    outline: none;
    box-shadow: 0 0 0 3px rgba(171, 205, 239, 0.2);
}

body.dark-theme .demo input,
body.dark-theme .demo textarea {
    background: #2a2a3a;
    border: 1px solid #4a4a5a;
    color: #e0e0e0;
}

body.dark-theme .demo input:focus,
body.dark-theme .demo textarea:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Вывод результатов */
.output {
    padding: 12px;
    border-radius: 12px;
    margin-top: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

body.light-theme .output {
    background: #f4f4f4;
    color: #333;
    border: 1px solid #e0e0e0;
}

body.dark-theme .output {
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #3a3a4a;
}

/* Статус алгоритмов */
.algo-status {
    margin-top: 10px;
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
}

body.light-theme .algo-status {
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
}

body.dark-theme .algo-status {
    background: #1a1a2e;
    border: 1px solid #3a3a4a;
}

/* Карточки на главной */
.category-card, .algorithm-card {
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    backdrop-filter: blur(10px);
}

body.light-theme .category-card,
body.light-theme .algorithm-card {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(171, 205, 239, 0.5);
}

body.dark-theme .category-card,
body.dark-theme .algorithm-card {
    background: rgba(30, 30, 50, 0.9);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    border: 1px solid rgba(102, 126, 234, 0.3);
}
/* ========== ЛАПКА ДЛЯ СВЕТЛОЙ И ТЁМНОЙ ТЕМЫ ========== */
.paw {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url('images/paw.png');
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: 6px;
    vertical-align: middle;
}

.paw-icon {
    display: inline-block;
    width: 28px;
    height: 28px;
    background-image: url('paw.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

body.dark-theme .paw,
body.dark-theme .paw-icon {
    filter: brightness(0) invert(1);
}