/* ─── Терминал-визитка v4 ─── */

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

:root {
    --bg: #0a0a0a;
    --term-bg: rgba(13, 18, 13, 0.85);
    --surface: rgba(212, 255, 192, 0.03);
    --text: #d4ffc0;
    --text-dim: rgba(212, 255, 192, 0.4);
    --prompt: #6fcf60;
    --accent: #ffb844;
    --accent-dim: rgba(255, 184, 68, 0.15);
    --border: rgba(212, 255, 192, 0.08);
    --border-hover: rgba(212, 255, 192, 0.2);
    --glow: rgba(111, 207, 96, 0.06);
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", "Courier New", monospace;
}

html, body {
    height: 100%;
    background: var(--bg);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(111, 207, 96, 0.03) 0%, transparent 70%);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ─── Background canvas ─── */
#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.9;
}

.mouse-glow {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(111, 207, 96, 0.08) 0%, rgba(111, 207, 96, 0.02) 45%, transparent 70%);
    pointer-events: none;
    will-change: transform, opacity;
    transition: opacity 0.3s ease;
}

/* ─── CRT эффект ─── */
.crt {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

.scanline {
    position: fixed;
    inset: 0;
    z-index: 99;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        transparent 50%,
        rgba(0, 0, 0, 0.02) 50%
    );
    background-size: 100% 4px;
    animation: scan 8s linear infinite;
}

@keyframes scan {
    0%   { background-position: 0 0; }
    100% { background-position: 0 100vh; }
}

/* ─── Шум ─── */
.noise {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* ─── Терминал ─── */
.terminal {
    position: relative;
    z-index: 2;
    margin: 5vh auto;
    width: min(92vw, 760px);
    height: 90vh;
    height: 90dvh;
    background: var(--term-bg);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 60px var(--glow),
        0 0 120px rgba(111, 207, 96, 0.02),
        inset 0 0 80px rgba(0, 0, 0, 0.6);
}

.term__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(212, 255, 192, 0.015);
}
.term__header::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212, 255, 192, 0.06), transparent);
}

.term__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.term__dot--r { background: #ff5f56; }
.term__dot--y { background: #ffbd2e; }
.term__dot--g { background: #27c93f; }

.term__title {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-dim);
}

.term__body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 255, 192, 0.08) transparent;
}
.term__body::-webkit-scrollbar { width: 6px; }
.term__body::-webkit-scrollbar-track { background: transparent; }
.term__body::-webkit-scrollbar-thumb { background: rgba(212, 255, 192, 0.08); border-radius: 3px; }
.term__body::-webkit-scrollbar-thumb:hover { background: rgba(212, 255, 192, 0.15); }

/* ─── Boot ─── */
.boot {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.boot__line {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.4;
}

.boot__line--ok { color: var(--text); }
.boot__line--ok::before { content: '[  OK  ] '; color: var(--prompt); }
.boot__line--info::before { content: '[ INFO ] '; color: var(--accent); }

.boot__ascii {
    color: var(--prompt);
    font-size: 11px;
    line-height: 1.1;
    white-space: pre;
    text-shadow: 0 0 4px rgba(111, 207, 96, 0.15);
    margin-bottom: 12px;
}

/* ─── Output ─── */
#output {
    margin-bottom: 12px;
}

.msg {
    margin-bottom: 6px;
    animation: fadeIn 0.15s ease;
    line-height: 1.5;
}

.msg--prompt {
    color: var(--text-dim);
}
.msg--prompt .prompt {
    color: var(--prompt);
}

.msg--cmd {
    color: var(--text);
    margin-left: 6px;
}

.msg--response {
    color: var(--text);
    margin-left: 0;
    margin-bottom: 10px;
}

.msg--response p {
    margin-bottom: 4px;
}

.msg--response .highlight {
    color: var(--accent);
}

.msg--response a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(255, 179, 71, 0.3);
    transition: text-decoration-color 0.2s;
}

.msg--response a:hover {
    text-decoration-color: var(--accent);
}

.msg--error {
    color: #ff5f56;
}

.msg--ascii {
    font-size: 11px;
    line-height: 1.15;
    color: var(--prompt);
    margin: 8px 0;
    white-space: pre;
}

.msg--separator {
    color: var(--text-dim);
    margin: 8px 0;
}

/* ─── Command chips ─── */
.term__chips {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.term__chips--show {
    display: flex;
}

.chip {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 4px 12px;
    background: rgba(111, 207, 96, 0.06);
    border: 1px solid rgba(111, 207, 96, 0.12);
    border-radius: 999px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.chip:hover {
    background: rgba(111, 207, 96, 0.14);
    border-color: rgba(111, 207, 96, 0.35);
}
.cmd-link {
    color: var(--text);
    cursor: pointer;
    transition: color 0.15s;
}
.cmd-link:hover {
    color: var(--prompt);
}
.cmd-link:active {
    color: #fff;
}
.chip:hover {
    background: rgba(111, 207, 96, 0.14);
    border-color: rgba(111, 207, 96, 0.35);
    box-shadow: 0 0 12px rgba(111, 207, 96, 0.04);
}
.chip:active {
    transform: scale(0.95);
}

.pw-cursor {
    animation: blink 0.8s step-end infinite;
    color: var(--prompt);
}

/* ─── Input ─── */
.input-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.prompt {
    color: var(--prompt);
    white-space: nowrap;
    font-size: 15px;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#cmdInput {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 16px;
    caret-color: var(--prompt);
}

#cmdInput::selection {
    background: rgba(192, 255, 176, 0.3);
}

/* ─── Menu sections ─── */
.menu-section {
    position: relative;
    border: 1px solid var(--border);
    border-left: 2px solid transparent;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    background: var(--surface);
    transition: border-color 0.25s, border-left-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.menu-section:hover {
    border-color: var(--border-hover);
    border-left-color: var(--prompt);
    background: rgba(111, 207, 96, 0.03);
    box-shadow: 0 0 20px rgba(111, 207, 96, 0.02);
}
.menu-section--open {
    border-color: rgba(111, 207, 96, 0.2);
    border-left-color: var(--prompt);
    background: rgba(111, 207, 96, 0.02);
}
.menu-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}
.menu-section__title {
    color: var(--text);
    font-size: 14px;
    letter-spacing: 0.01em;
}
.menu-section__hint {
    color: var(--accent);
    font-size: 11px;
    white-space: nowrap;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
}
.menu-section:hover .menu-section__hint {
    opacity: 1;
    transform: translateX(2px);
}
.menu-section__body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0 16px;
    color: var(--text-dim);
    line-height: 1.7;
    font-size: 13px;
    transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
}
.menu-section--open .menu-section__body {
    max-height: 600px;
    opacity: 1;
    padding: 0 16px 14px;
}
.menu-section__body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--accent-dim);
    transition: text-decoration-color 0.2s;
}
.menu-section__body a:hover {
    text-decoration-color: var(--accent);
}
.menu-section__body strong {
    color: var(--text);
    font-weight: 500;
}
.menu-section__body .label {
    color: var(--prompt);
    display: inline-block;
    min-width: 7em;
}

/* ─── About section with video ─── */
.about-content {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.about-text {
    flex: 1;
    min-width: 0;
}
.about-video {
    position: relative;
    flex-shrink: 0;
    width: 160px;
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 40%, rgba(111, 207, 96, 0.06) 0%, transparent 60%),
        #0a0a0a;
}
.about-video__player {
    display: block;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    object-fit: cover;
    margin: -1px;
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #0a0a0a;
}

@media (max-width: 600px) {
    .about-content {
        flex-direction: column;
        align-items: center;
    }
    .about-video {
        width: 130px;
    }
}

/* ─── Stats panel ─── */
.stats {
    background: rgba(111, 207, 96, 0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}
.stats__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    background: rgba(111, 207, 96, 0.03);
}
.stats__title {
    color: var(--prompt);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.stats__counts {
    color: var(--text-dim);
    margin-right: auto;
}
.stats__close {
    cursor: pointer;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1;
    transition: color 0.15s;
}
.stats__close:hover { color: var(--text); }
.stats__body {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    font-size: 12px;
}
.stats__col {
    flex: 1;
    min-width: 10em;
    padding: 8px 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.stats__col:last-child { border-right: none; }
.stats__col--wide { flex: 1.5; }
.stats__foot {
    border-top: 1px solid var(--border);
    padding: 6px 12px;
    display: flex;
    justify-content: flex-end;
}
.stats__reset {
    background: none;
    border: 1px solid rgba(255, 80, 80, 0.3);
    color: rgba(255, 80, 80, 0.7);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stats__reset:hover {
    background: rgba(255, 80, 80, 0.1);
    border-color: rgba(255, 80, 80, 0.6);
    color: #ff5050;
}
.stats__label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    opacity: 0.7;
    margin-bottom: 4px;
}
.s-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1px 0;
    line-height: 1.6;
}
.s-cmd {
    color: var(--text);
    width: auto;
    min-width: 5em;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.s-bar {
    flex: 1;
    min-width: 0;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-dim);
}
.s-fill {
    display: inline-block;
    height: 5px;
    background: var(--prompt);
    border-radius: 2px;
    opacity: 0.45;
    vertical-align: middle;
}
.s-num {
    color: var(--prompt);
    min-width: 2em;
    text-align: right;
    flex-shrink: 0;
    font-weight: 600;
    padding-left: 4px;
}
.s-row--recent .s-cmd { color: var(--text-dim); width: 4em; min-width: 4em; }
.s-row--recent .s-bar { flex: 0; min-width: auto; color: var(--prompt); margin: 0 4px; }
.s-row--recent .s-num { color: var(--text); font-weight: 400; text-align: left; width: auto; min-width: 0; }
.s-empty {
    color: var(--text-dim);
    font-style: italic;
    opacity: 0.5;
    padding: 4px 0;
    font-size: 11px;
}

@media (max-width: 600px) {
    .stats__body { flex-direction: column; }
    .stats__col { min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
    .stats__col:last-child { border-bottom: none; }
}

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ─── Responsive ─── */
@media (max-width: 600px) {
    html, body { font-size: 14px; }
    .terminal {
        margin: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    .term__body { padding: 14px; }
    .boot__ascii { font-size: 9px; }
    .msg--ascii { font-size: 9px; }
    .menu-section__title { font-size: 13px; }
}

@media (max-height: 480px) and (orientation: landscape) {
    .terminal {
        height: 100dvh;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    .term__body { padding: 8px 14px; }
    .boot__ascii { font-size: 7px; }
    .boot__line { font-size: 11px; }
    .msg--ascii { font-size: 7px; }
    .term__header { padding: 6px 14px; }
    .term__dot { width: 8px; height: 8px; }
    .term__title { font-size: 11px; }
    .menu-section__header { padding: 8px 12px; }
    .menu-section__title { font-size: 12px; }
    .about-content { flex-direction: row; align-items: flex-start; }
    .about-video { width: 100px; }
    .chip { font-size: 10px; padding: 2px 10px; }
    .input-line { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
    .scanline { animation: none; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
    }
}
