/* --- ПОДКЛЮЧЕНИЕ ШРИФТОВ --- */

/* fira-code-300 - cyrillic_latin */
@font-face {
  font-display: swap; /* Шрифт подгрузится, когда скачается, до этого будет системный */
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 300;
  src: url('fonts/fira-code-v27-cyrillic_latin-300.woff2') format('woff2');
}

/* fira-code-regular - cyrillic_latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  src: url('fonts/fira-code-v27-cyrillic_latin-regular.woff2') format('woff2');
}

/* fira-code-600 - cyrillic_latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 600;
  src: url('fonts/fira-code-v27-cyrillic_latin-600.woff2') format('woff2');
}

:root {
    /* --- DARK THEME (Default) --- */
    --bg-dark: #1e1e1e;
    --bg-sidebar: #252526;
    --bg-active: #37373d;
    --bg-header: #333333;
    --text-main: #d4d4d4;
    --text-comment: #6a9955;
    --accent-cyan: #4ec9b0;
    --accent-blue: #569cd6;
    --accent-orange: #ce9178;
    --keyword: #c586c0;
    --border-color: #3e3e42;
    --scrollbar-bg: #1e1e1e;
    --scrollbar-thumb: #424242;
    --font-mono: 'Fira Code', 'Consolas', monospace;
    
    --color-json-key: #9cdcfe;
    --color-string: #ce9178;
    --color-number: #b5cea8;
    --prompt-color: #4ec9b0;
    
    --shadow-color: rgba(0,0,0,0.5);
    --art-link: rgb(0, 110, 255);
    --visited-link: #dca3e8; /* Светлый фиолетовый для посещенных */
}

/* --- LIGHT THEME --- */
[data-theme="light"] {
    --bg-dark: #eeeeee;
    --bg-sidebar: #f3f3f3;
    --bg-active: #e4e6f1;
    --bg-header: #dddddd;
    --text-main: #222222;
    --text-comment: #008000;
    --accent-cyan: #1bbd98;
    --accent-blue: #0000ff;
    --accent-orange: #a31515;
    --keyword: #0000ff;
    --border-color: #cccccc;
    --scrollbar-bg: #f0f0f0;
    --scrollbar-thumb: #cdcdcd;
    
    --color-json-key: #0451a5;
    --color-string: #a31515;
    --color-number: #098658;
    --prompt-color: #0000ff;
    
    --shadow-color: rgba(0,0,0,0.1);
    --art-link: rgb(0, 110, 255);
    --visited-link: #800080;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: #000;
    font-family: var(--font-mono);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s;
}

/* --- Window Structure --- */
.terminal-window {
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color 0.3s;
}

/* Header */
.window-bar {
    height: 35px;
    background-color: var(--bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    flex-shrink: 0;
}

.window-controls { display: flex; gap: 8px; }
.control { width: 12px; height: 12px; border-radius: 50%; }
.control.close { background: #ff5f56; }
.control.minimize { background: #ffbd2e; }
.control.maximize { background: #27c93f; }

.window-title { font-size: 0.85rem; color: var(--text-main); opacity: 0.7; }

.window-actions { display: flex; align-items: center; gap: 15px; }

/* Theme Button */
.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.3s;
}
.theme-btn:hover { opacity: 1; }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.window-links a {
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.8rem;
    margin-left: 10px;
    opacity: 0.7;
    transition: 0.3s;
}
.window-links a:hover { color: var(--accent-cyan); opacity: 1; }

.workspace { display: flex; flex: 1; overflow: hidden; position: relative; }

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, background-color 0.3s;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.collapsed { width: 50px; }

.sidebar-header {
    padding: 10px 15px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0.7;
    height: 40px;
    overflow: hidden;
}

.sidebar.collapsed .folder-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }

.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px;
}
.icon-bar { width: 16px; height: 2px; background-color: var(--text-main); display: block; }

.nav-tree { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0; }
.nav-group { margin-bottom: 20px; }

.group-title {
    display: block;
    padding: 5px 15px;
    font-size: 0.7rem;
    color: var(--text-main);
    font-weight: bold;
    opacity: 0.5;
    white-space: nowrap;
}
.sidebar.collapsed .group-title { display: none; }

/* Nav Items */
.nav-item, .toc-link {
    display: flex;
    align-items: center;
    padding: 6px 15px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: background 0.2s;
    height: 30px;
}

/* Sub-links indentation */
.toc-link.sub-link {
    padding-left: 30px;
    font-size: 0.85rem;
    opacity: 0.9;
}

.nav-item .icon, .toc-link .icon {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-weight: bold;
    color: var(--accent-blue);
    flex-shrink: 0;
    font-size: 0.8rem;
}

/* Smaller icons for subsections */
.toc-link .icon.sm {
    font-size: 0.7rem;
    opacity: 0.7;
}

.nav-item .text, .toc-link .text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover, .toc-link:hover { background-color: var(--bg-active); }

/* Active State */
.nav-item.active-file {
    background-color: rgba(86, 156, 214, 0.1);
    color: var(--accent-blue);
}

.toc-link.active {
    background-color: rgba(78, 201, 176, 0.1);
    border-left-color: var(--accent-cyan);
    color: var(--accent-cyan);
}
.toc-link.active .icon { color: var(--accent-cyan); }

/* Collapsed behaviors */
.sidebar.collapsed .text { display: none; }
.sidebar.collapsed .nav-item, .sidebar.collapsed .toc-link {
    padding: 6px 0;
    justify-content: center;
}
.sidebar.collapsed .icon { margin-right: 0; font-size: 10px; }

/* --- Editor Area --- */
.editor-area {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-dark);
    padding: 0;
    scroll-behavior: smooth;
    position: relative;
    transition: background-color 0.3s;
}

.code-header {
    padding: 40px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 30px;
    background: linear-gradient(180deg, rgba(78,201,176,0.05) 0%, transparent 100%);
}

h1 { font-size: 1.8rem; color: var(--accent-blue); margin-bottom: 15px; }
h2 { color: var(--accent-cyan); margin-bottom: 20px; font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
h3 { color: var(--accent-blue); margin-top: 30px; margin-bottom: 15px; font-size: 1.2rem; border-left: 3px solid var(--border-color); padding-left: 10px; }

.comment { color: var(--text-comment); font-style: italic; margin-bottom: 5px; }
.variable { color: var(--text-main); margin-bottom: 8px; }
.keyword { color: var(--keyword); }
.string { color: var(--color-string); }

/* Link styling */
.link-string { color: var(--color-string); text-decoration: underline; text-decoration-style: dotted; }

.hash { color: var(--text-comment); opacity: 0.5; margin-right: 10px; }

.content-text {
    max-width: 950px;
    margin: 0 auto;
    padding: 0 40px 80px 40px;
    line-height: 1.6;
    font-size: 1rem;
}

.art-link {color: var(--art-link);}
.art-link:visited {color: var(--visited-link);}

/* Scroll margin fix for jumpy links */
section { 
    margin-bottom: 40px; 
    scroll-margin-top: 20px; /* Отступ сверху при клике по ссылке */
}

/* Elements */
.info-box {
    background: rgba(128,128,128,0.1);
    border-left: 3px solid var(--accent-orange);
    padding: 15px;
    margin: 20px 0;
}
.prompt { color: var(--prompt-color); }
.cmd { font-weight: bold; }

.code-block {
    background: var(--bg-active);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    margin: 20px 0;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: pre-wrap; 
}

.resume-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.skill-group {
    background: rgba(128,128,128,0.05);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.cmd-list { list-style: none; }
.cmd-list li { margin-bottom: 10px; }
.bullet { color: var(--accent-cyan); font-weight: bold; margin-right: 5px; }

.end-line { text-align: center; color: var(--border-color); margin-top: 50px; font-size: 0.8rem; }

.profile-section {
    display: flex;
    align-items: flex-start;
    gap: 40px;
}

.profile-photo {
    object-fit: cover;
    border: 4px solid var(--border-color);
    box-shadow: 10px 10px 0px rgba(0,0,0,0.3);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.profile-photo:hover {
    transform: scale(1.03);
}

/* Стили для медиа-блока */
.media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
    align-items: flex-start;
}

.video-frame {
    width: 360px; /* Фиксируем оптимальную ширину */
    max-width: 100%; /* Адаптивность для мобильных */
    padding: 4px;
    background-color: var(--bg-active); /* Цвет рамки как у активных элементов */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 6px var(--shadow-color);
}

.video-player {
    width: 100%;
    display: block;
    background: #000;
}

.media-info {
    flex: 1;
    min-width: 250px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-main);
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 4px;
    border-left: 2px solid var(--accent-cyan);
}

/* --- Collapsible Logic --- */

/* Контейнер */
.collapsible-container {
    transition: all 0.3s ease;
}

/* Заголовок (строка команды) */
.collapsible-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px 0;
    user-select: none; /* Чтобы текст не выделялся при кликах */
}

.collapsible-header:hover {
    background-color: rgba(255, 255, 255, 0.05); /* Легкая подсветка при наведении */
}

/* Состояние "Свернуто" */
.collapsible-container.collapsed .collapsible-content {
    display: none; /* Скрытие контента */
}

/* Добавляем троеточие, когда свернуто, чтобы было понятно, что там что-то есть */
.collapsible-container.collapsed .collapsible-header::after {
    content: " ...";
    color: var(--text-comment);
    margin-left: 10px;
    font-style: italic;
    opacity: 0.6;
}

/* Шапка с командой */
.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between; /* Разносим текст и кнопку по краям */
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
    margin-bottom: 10px;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-color);
}

/* Кнопка справа */
.toggle-btn-text {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--accent-cyan); /* Яркий цвет */
    opacity: 0.8;
    transition: opacity 0.2s;
    background: rgba(0,0,0,0.2);
    padding: 2px 8px;
    border-radius: 2px;
}

.collapsible-header:hover .toggle-btn-text {
    opacity: 1;
}

/* --- Анимация сворачивания (Grid Trick) --- */
.collapsible-wrapper {
    display: grid;
    grid-template-rows: 1fr; /* Полная высота */
    transition: grid-template-rows 0.4s ease-out, opacity 0.4s ease-out; /* Плавность */
    opacity: 1;
}

.inner-content {
    overflow: hidden; /* Важно: скрывает контент при схлопывании */
}

/* Состояние "Свернуто" */
.collapsible-container.collapsed .collapsible-wrapper {
    grid-template-rows: 0fr; /* Высота становится 0 */
    opacity: 0.5;
    margin-bottom: 0;
}

/* Меняем цвет и текст кнопки при сворачивании */
.collapsible-container.collapsed .toggle-btn-text {
    color: var(--text-comment); /* Зеленый/серый цвет */
}

/* Адаптив: на мобильных кнопку можно сделать меньше, если нужно */
@media (max-width: 500px) {
    .collapsible-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .header-right {
        align-self: flex-end;
    }
}

@media (max-width: 1000px) {
    .profile-section { 
        flex-direction: column; 
        align-items: center; 
    }
    .profile-photo { 
        width: 100%; 
        max-width: 360px; 
        height: auto; 
    }
}

/* Footer */
.status-bar {
    height: 25px;
    background-color: var(--accent-blue);
    color: #fff;
    display: flex;
    font-size: 0.75rem;
    align-items: center;
    padding: 0 10px;
    flex-shrink: 0;
}
.status-item { margin-right: 20px; }
.status-item.right { margin-left: auto; margin-right: 0; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #888; }

/* Mobile */
@media (max-width: 768px) {
    .window-controls {display: none;}
    
    .content-text { padding: 20px; }
}

@media (max-width: 580px) {
    .window-title {display: none;}
    .window-bar {justify-content: flex-end;}
}