/* ============================================================
   CYBER//TYPE — экран практики курса git («терминал с рентгеном»)
   Режим git на #screen-challenge, теория с симулятором на #screen-console, живая демонстрация
   лендинга /git (стили грузятся там по щелчку). Компоненты — modules/lib/git-*.js, классы gl-*.
   Палитра — переменные theme.css, терминал — как console.css.
   ============================================================ */

/* ==================== МАКЕТ РЕЖИМА GIT ==================== */
body:has(#screen-challenge.active[data-mode="git"]) .container,
body:has(#screen-console.active.console-with-git) .container { max-width: 1680px; }

.challenge-screen[data-mode="git"] .code-window { display: none; }
.challenge-screen[data-mode="git"] .challenge-task { max-width: none; margin: 4px 0 0; font-size: 13px; color: rgba(219, 230, 255, 0.6); }
.challenge-screen[data-mode="git"] .challenge-answer { max-width: none; margin-top: 12px; }
.challenge-screen[data-mode="git"] .challenge-feedback,
.challenge-screen[data-mode="git"] .challenge-explanation,
.challenge-screen[data-mode="git"] .challenge-theory,
.challenge-screen[data-mode="git"] .challenge-actions { max-width: none; }
.challenge-screen[data-mode="git"] .challenge-mode-badge { color: #ff9a3c; border-color: rgba(255, 154, 60, 0.5); background: rgba(255, 154, 60, 0.08); }

.gl-lab {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    font-family: 'Share Tech Mono', monospace;
}
.gl-lab-main,
.gl-lab-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gl-result { grid-column: 1 / -1; }
.gl-lab:not(.gl-demo-lab) .gl-lab-side { position: sticky; top: 12px; }

/* 1024–1200: граф и области — под терминалом */
@media (max-width: 1200px) {
    .gl-lab { grid-template-columns: minmax(0, 1fr); }
}

.gl-panel-label {
    margin-bottom: 8px;
    font-size: 11px;
    letter-spacing: 1.5px;
    color: rgba(0, 255, 200, 0.6);
}

.gl-task-panel,
.gl-graph-box,
.gl-areas-box,
.gl-result {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(18, 18, 26, 0.92);
}

/* ==================== ЗАГРУЗКА ==================== */
.gl-lab-loading {
    padding: 48px 16px;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    letter-spacing: 3px;
    color: var(--primary);
    border: 1px dashed var(--border);
    border-radius: 8px;
    animation: gl-pulse 1.4s ease-in-out infinite;
}
.gl-lab-load-failed {
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.5px;
    color: #ffb3c9;
    border-color: rgba(255, 0, 100, 0.5);
    animation: none;
}
.gl-lab-retry { margin-top: 14px; }

@keyframes gl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ==================== ЗАДАЧА ==================== */
.gl-task-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.gl-kind-badge {
    padding: 3px 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--bg-dark);
    background: var(--primary);
    border-radius: 3px;
}
.gl-lab[data-kind="drill"] .gl-kind-badge { background: var(--warning); }
.gl-lab[data-kind="boss"] .gl-kind-badge { background: var(--secondary); color: #fff; }
.gl-lab[data-kind="exam"] .gl-kind-badge { background: #b388ff; }
.gl-par { font-size: 13px; color: rgba(219, 230, 255, 0.55); }

.gl-steps-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.gl-step { padding: 2px 0; }
.gl-steps-list:not(.gl-steps-single) .gl-step { padding: 8px 10px; border-left: 2px solid rgba(219, 230, 255, 0.15); }
.gl-steps-list:not(.gl-steps-single) .gl-step-current { border-left-color: var(--primary); background: rgba(0, 255, 200, 0.04); }
.gl-steps-list .gl-step-reached { border-left-color: var(--success); }
.gl-step-num { display: block; margin-bottom: 2px; font-size: 11px; letter-spacing: 1.5px; color: rgba(0, 255, 200, 0.6); }
.gl-step-reached .gl-step-num { color: var(--success); }
.gl-step-task { color: #e8eeff; font-size: 15px; line-height: 1.55; white-space: pre-line; }

.gl-checks { margin: 8px 0 0; padding: 0; list-style: none; }
.gl-check {
    position: relative;
    padding: 2px 0 2px 24px;
    font-size: 14px;
    color: rgba(219, 230, 255, 0.8);
}
.gl-check::before {
    content: '○';
    position: absolute;
    left: 4px;
    color: rgba(219, 230, 255, 0.4);
}
.gl-check.ok { color: #b8ffc6; }
.gl-check.ok::before { content: '✓'; color: var(--success); }
.gl-check.fail { color: #ffb3c9; }
.gl-check.fail::before { content: '✗'; color: var(--secondary); }

.gl-exam-score { margin: 10px 0 0; font-size: 14px; color: rgba(219, 230, 255, 0.75); }
.gl-exam-score.ok { color: var(--success); }
.gl-exam-score.fail { color: #ffb3c9; }

/* Рефлекс: «3 / 7», полоса и часы */
.gl-drill-meter { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.gl-drill-count { font-family: 'Orbitron', sans-serif; font-size: 13px; color: var(--warning); }
.gl-drill-bar { width: 120px; height: 6px; border-radius: 3px; background: rgba(255, 204, 0, 0.15); overflow: hidden; }
.gl-drill-fill { display: block; width: 0; height: 100%; background: var(--warning); transition: width 0.35s ease; }
.gl-drill-clock { font-family: 'Orbitron', sans-serif; font-size: 13px; color: rgba(219, 230, 255, 0.8); }
.gl-drill-clock.gl-over-time { color: var(--secondary); }

/* ==================== ТЕРМИНАЛ ==================== */
.gl-term {
    border: 1px solid rgba(0, 255, 128, 0.35);
    border-radius: 8px;
    background: #0a0e0a;
    box-shadow: 0 0 24px rgba(0, 255, 128, 0.1), inset 0 0 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
}
.gl-term-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: rgba(0, 255, 128, 0.06);
    border-bottom: 1px solid rgba(0, 255, 128, 0.2);
}
.gl-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.gl-dot-red { background: #ff5f56; }
.gl-dot-yellow { background: #ffbd2e; }
.gl-dot-green { background: #27c93f; }
.gl-term-title { margin-left: 8px; font-size: 12px; color: rgba(0, 255, 128, 0.6); }
.gl-term-body {
    height: 360px;
    padding: 12px 14px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.55;
    color: #b9ffce;
    cursor: text;
}
.gl-term-cmd { white-space: pre-wrap; word-break: break-all; color: #e6fff0; }
.gl-term-cancelled { color: rgba(230, 255, 240, 0.55); }
.gl-term-out {
    margin: 0 0 6px;
    font: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(200, 235, 212, 0.8);
}
.gl-term-err { color: #ff7a9a; }
.gl-term-line { display: flex; align-items: baseline; cursor: text; }
.gl-term-prompt { white-space: pre; user-select: none; }
.gl-term-user { color: #2bd66f; font-weight: 600; }
.gl-term-path { color: #4fc3ff; font-weight: 600; }
.gl-term-branch { color: #ffcc00; }
.gl-term-sep { color: #b9ffce; }
.gl-term-input {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: none;
    font: inherit;
    color: #e6fff0;
    background: transparent;
    caret-color: #2bd66f;
}
.gl-term-input:disabled { opacity: 0.4; }
.gl-term-hint { margin-top: 6px; font-size: 13px; color: #7fd7ff; white-space: pre-wrap; }
.gl-term-hint-warn { color: var(--warning); }
.gl-term-hint-list { color: rgba(185, 255, 206, 0.7); }

.gl-lab-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.gl-reset-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--warning); }
.gl-lab-keys { margin: 0; font-size: 12px; line-height: 1.5; text-align: right; color: rgba(219, 230, 255, 0.45); }
.gl-lab-tools .gl-lab-keys { flex: 1 1 260px; }

/* ==================== ГРАФ ==================== */
.gl-graph-local,
.gl-graph-remote-body { max-height: 380px; overflow: auto; }
.gl-graph-remote { margin-top: 14px; padding-top: 12px; border-top: 1px dashed rgba(255, 107, 107, 0.35); }
.gl-remote-label { color: rgba(255, 140, 140, 0.8); }
.gl-graph-empty { margin: 8px 0; font-size: 13px; color: rgba(219, 230, 255, 0.45); }
.gl-graph-svg { display: block; font-family: 'Share Tech Mono', monospace; font-size: 12px; }

.gl-lane-0 { color: #00ffc8; }
.gl-lane-1 { color: #ff4fa0; }
.gl-lane-2 { color: #ffcc00; }
.gl-lane-3 { color: #b388ff; }
.gl-lane-4 { color: #4fc3ff; }
.gl-lane-5 { color: #ff8c42; }

.gl-edge { fill: none; stroke: currentColor; stroke-width: 2; opacity: 0.75; }
.gl-edge-orphan { stroke-dasharray: 4 4; opacity: 0.35; }
.gl-edge-cut { stroke-dasharray: 2 3; }
.gl-node { fill: #0a0a0f; stroke: currentColor; stroke-width: 2.5; }
.gl-commit-shared .gl-node { fill: currentColor; }
.gl-node-ring { fill: none; stroke: var(--primary); stroke-width: 1.5; stroke-dasharray: 3 2; }
.gl-g-hash { fill: #ffcc00; opacity: 0.85; }
.gl-g-subject { fill: #dbe6ff; }
.gl-g-more { fill: rgba(219, 230, 255, 0.45); }
.gl-commit-orphan { opacity: 0.4; }
.gl-commit-orphan .gl-node { stroke-dasharray: 2 2; }
.gl-commit[role="button"] { cursor: pointer; outline: none; }
.gl-commit[role="button"]:hover .gl-g-hash,
.gl-commit[role="button"]:focus-visible .gl-g-hash { fill: #fff; text-decoration: underline; }
.gl-commit-hover .gl-node { stroke-width: 4; filter: drop-shadow(0 0 4px currentColor); }

.gl-ref rect { stroke-width: 1; }
.gl-ref text { font-size: 11px; }
.gl-ref-branch rect { fill: rgba(43, 214, 111, 0.12); stroke: #2bd66f; }
.gl-ref-branch text { fill: #7dffab; }
.gl-ref-head rect { fill: var(--primary); stroke: var(--primary); }
.gl-ref-head text { fill: #0a0a0f; font-weight: 700; }
.gl-ref-detached rect { fill: var(--secondary); stroke: var(--secondary); }
.gl-ref-detached text { fill: #fff; font-weight: 700; }
.gl-ref-remote rect { fill: rgba(255, 107, 107, 0.1); stroke: #ff6b6b; }
.gl-ref-remote text { fill: #ff9b9b; }
.gl-ref-tag rect { fill: rgba(255, 204, 0, 0.1); stroke: #ffcc00; }
.gl-ref-tag text { fill: #ffcc00; }
.gl-ref-stash rect { fill: rgba(179, 136, 255, 0.12); stroke: #b388ff; }
.gl-ref-stash text { fill: #cdb4ff; }

.gl-node-new .gl-node,
.gl-node-new .gl-node-ring { transform-box: fill-box; transform-origin: center; animation: gl-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
.gl-node-new text { animation: gl-fade 0.5s ease; }
.gl-ref-moved { animation: gl-ref-flash 0.9s ease; }

@keyframes gl-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes gl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gl-ref-flash {
    0% { opacity: 0; transform: translateX(-8px); }
    40% { opacity: 1; filter: drop-shadow(0 0 6px currentColor); }
    100% { transform: none; filter: none; }
}

/* ==================== ТРИ ОБЛАСТИ ==================== */
.gl-areas-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: stretch; }
.gl-area { min-width: 0; padding: 8px; border: 1px solid rgba(219, 230, 255, 0.1); border-radius: 6px; background: rgba(0, 0, 0, 0.25); }
.gl-area-title { margin-bottom: 6px; font-size: 11px; letter-spacing: 1px; color: rgba(0, 255, 200, 0.7); text-transform: uppercase; }
.gl-area-arrow { align-self: center; color: rgba(0, 255, 200, 0.45); }
.gl-area-empty { margin: 0; font-size: 12px; color: rgba(219, 230, 255, 0.3); }
.gl-files { margin: 0; padding: 0; list-style: none; }
.gl-file { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 3px; font-size: 13px; }
.gl-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border: 0;
    font: inherit;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
    background: none;
}
button.gl-file-name { cursor: pointer; }
button.gl-file-name:hover,
button.gl-file-name:focus-visible { text-decoration: underline; outline: none; }
.gl-file-mark { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.gl-mark-clean { color: rgba(219, 230, 255, 0.55); }
.gl-mark-untracked { color: #ff8a8a; }
.gl-mark-modified { color: #ffcc00; }
.gl-mark-deleted,
.gl-mark-staged-deleted { color: #ff6b8b; text-decoration: line-through; text-decoration-color: rgba(255, 107, 139, 0.6); }
.gl-mark-staged-new,
.gl-mark-staged-modified { color: #4fe38a; }
.gl-mark-conflict { color: #fff; background: rgba(255, 0, 100, 0.35); }
.gl-file-changed { animation: gl-file-flash 1.4s ease; }

@keyframes gl-file-flash {
    0% { background: rgba(0, 255, 200, 0.35); }
    100% { background: transparent; }
}

.gl-operation {
    margin-bottom: 10px;
    padding: 6px 10px;
    font-size: 13px;
    color: #0a0a0f;
    background: repeating-linear-gradient(135deg, var(--warning) 0 10px, #ffd84d 10px 20px);
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ==================== ИТОГ ==================== */
.gl-result { border-color: rgba(0, 255, 0, 0.35); }
.gl-clean-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 16px;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    letter-spacing: 4px;
    color: #0a0a0f;
    background: var(--success);
    box-shadow: 0 0 18px rgba(0, 255, 0, 0.45);
    border-radius: 4px;
}
.gl-path-compare { margin: 0 0 12px; color: #dbe6ff; }
.gl-path-compare b { color: var(--primary); font-weight: normal; }
.gl-solution { margin: 0; padding-left: 26px; color: rgba(219, 230, 255, 0.6); }
.gl-solution li { margin: 4px 0; }
.gl-solution code {
    padding: 2px 8px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
    color: #b9ffce;
    background: #0a0e0a;
    border: 1px solid rgba(0, 255, 128, 0.25);
    border-radius: 3px;
}
.gl-solution-note { font-size: 12px; color: rgba(219, 230, 255, 0.45); }

/* ==================== ТЕОРИЯ (панель уровней-задач, challenge-theory.js) ==================== */
.challenge-theory {
    max-width: 900px;
    margin: 14px auto 0;
    padding: 14px 16px;
    border: 1px solid rgba(127, 215, 255, 0.35);
    border-left: 3px solid #7fd7ff;
    border-radius: 6px;
    background: var(--bg-card);
}
.challenge-theory-text { margin: 0 0 10px; color: #dbe6ff; line-height: 1.6; white-space: pre-line; }
.challenge-theory-levels { margin: 0; padding: 0; list-style: none; }
.challenge-theory-link {
    padding: 4px 0;
    border: 0;
    font: inherit;
    font-size: 14px;
    color: #7fd7ff;
    background: none;
    cursor: pointer;
    text-align: left;
}
.challenge-theory-link:hover,
.challenge-theory-link:focus-visible { text-decoration: underline; outline: none; }
.challenge-theory-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--warning); }
#btn-challenge-theory.challenge-theory-new { animation: gl-pulse 1.2s ease-in-out 3; border-color: #7fd7ff; color: #7fd7ff; }

/* ==================== РЕДАКТОР (окно) ==================== */
.modal.gl-editor { max-width: 780px; width: 94%; padding: 26px 28px; }
.gl-editor .modal-title { margin-bottom: 6px; }
.gl-editor-sub { margin: 0 0 12px; font-size: 13px; color: rgba(219, 230, 255, 0.65); word-break: break-all; }
.gl-editor-text {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 320px;
    padding: 12px 14px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.55;
    color: #d7ffe4;
    background: #0a0e0a;
    border: 1px solid rgba(0, 255, 128, 0.35);
    border-radius: 6px;
    resize: vertical;
    tab-size: 4;
    outline: none;
}
.gl-editor-text:focus { border-color: var(--primary); box-shadow: 0 0 0 1px rgba(0, 255, 200, 0.3); }
.gl-editor-hunk {
    max-height: 320px;
    margin: 0;
    padding: 12px 14px;
    overflow: auto;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
    color: #d7ffe4;
    background: #0a0e0a;
    border: 1px solid rgba(0, 255, 128, 0.35);
    border-radius: 6px;
}
.gl-editor-keys { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.gl-hunk-key b { color: var(--primary); }
.gl-editor-actions { display: flex; gap: 12px; margin-top: 14px; }
.gl-editor-help { margin: 10px 0 0; font-size: 12px; color: rgba(219, 230, 255, 0.45); }

/* ==================== ТЕОРИЯ С СИМУЛЯТОРОМ (#screen-console) ==================== */
.console-with-git .console-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.console-with-git .terminal-window,
.console-with-git .console-info-panel { max-width: none; }
.console-with-git .terminal-window { margin-top: 16px; }
.console-git-panel { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; min-width: 0; }
.console-git-panel .gl-graph-local { max-height: 300px; }
@media (max-width: 1200px) {
    .console-with-git .console-body { grid-template-columns: minmax(0, 1fr); }
}

pre.terminal-history-output { margin: 0 0 6px; font: inherit; white-space: pre-wrap; word-break: break-word; }
.console-with-git .terminal-history-output { font-size: 15px; line-height: 1.5; color: rgba(200, 235, 212, 0.85); }
.console-with-git .terminal-history-error { color: #ff7a9a; }
.console-with-git .terminal-history-expected-fail { color: #ffb37a; }

/* Карточка понятия перед уровнем теории (game.js, level-engines.js) */
.level-hint-modal.concept-card { max-width: 640px; text-align: left; }
.concept-card .level-hint-text { white-space: pre-line; line-height: 1.65; }
.concept-card .modal-title,
.concept-card .level-hint-icon { text-align: center; }

/* ==================== ЛЕНДИНГ /git: живая демонстрация ==================== */
.git-demo-try { display: block; margin: 16px auto 0; }
/* Демонстрация ожила: первый экран — в один столбец, терминал с графом — сверху во всю ширину */
.git-hero:has(.git-demo-live) { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 32px; }
.git-hero:has(.git-demo-live) .git-hero-demo { order: -1; }
.git-demo-live { max-width: none; }
.gl-demo-lab { text-align: left; }
.gl-demo-lab .gl-term-body { height: 320px; }
.gl-demo-hints { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: rgba(219, 230, 255, 0.7); }
.gl-demo-hints-title { color: var(--primary); letter-spacing: 1px; }
.gl-demo-hint code {
    padding: 2px 8px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    color: #b9ffce;
    background: #0a0e0a;
    border: 1px solid rgba(0, 255, 128, 0.25);
    border-radius: 3px;
}
.gl-demo-hint small { color: rgba(219, 230, 255, 0.45); }

@media (prefers-reduced-motion: reduce) {
    .gl-lab-loading,
    .gl-node-new .gl-node,
    .gl-node-new .gl-node-ring,
    .gl-node-new text,
    .gl-ref-moved,
    .gl-file-changed,
    #btn-challenge-theory.challenge-theory-new { animation: none; }
    .gl-drill-fill { transition: none; }
}
