/* ═══════════════════════════════════════════════════════════
   korolev.tech — Terminal Theme (Fullscreen CRT)
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg:          #0a0a0a;
    --terminal-bg: #0a0a0a;
    --green:       #00ff41;
    --green-dim:   #00cc33;
    --green-dark:  #004d00;
    --green-glow:  rgba(0, 255, 65, 0.15);
    --cyan:        #00d4ff;
    --yellow:      #ffd700;
    --red:         #ff4444;
    --white:       #c9d1d9;
    --gray:        #484f58;
    --font:        'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--green);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
}

/* ── Matrix Background ──────────────────────────────────── */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.05;
    pointer-events: none;
}

/* ── CRT Scanlines — fullscreen overlay ──────────────────── */
#crt-scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.06) 2px,
        rgba(0, 0, 0, 0.06) 4px
    );
    pointer-events: none;
    z-index: 10;
}

/* ── Terminal — fullscreen ────────────────────────────────── */
#terminal {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    animation: crt-flicker 4s infinite;
}

/* ── CRT Flicker — subtle brightness jitter ──────────────── */
@keyframes crt-flicker {
    0%    { opacity: 1; }
    3%    { opacity: 0.97; }
    6%    { opacity: 1; }
    42%   { opacity: 1; }
    44%   { opacity: 0.98; }
    45%   { opacity: 1; }
    76%   { opacity: 1; }
    77%   { opacity: 0.96; }
    78%   { opacity: 1; }
    100%  { opacity: 1; }
}

/* ── Boot [OK] label ──────────────────────────────────────── */
.boot-ok {
    color: var(--green);
    font-weight: 700;
}

.bio-block {
    padding: 12px 0;
}


/* ── Terminal Body ──────────────────────────────────────── */
#terminal-body {
    background: transparent;
    flex: 1;
    overflow: hidden;
    padding: 0 24px 20px;
    display: flex;
    flex-direction: column;
    -webkit-user-select: text;
    user-select: text;
}

/* Output scrolls independently — input stays at bottom */
#output {
    overflow-y: auto;
    padding-top: 20px;
}

#output::-webkit-scrollbar {
    width: 4px;
}

#output::-webkit-scrollbar-track {
    background: transparent;
}

#output::-webkit-scrollbar-thumb {
    background: var(--green-dark);
    border-radius: 2px;
}

/* ── Output Area ────────────────────────────────────────── */
#output {
    flex: 1;
    white-space: pre-wrap;
    word-wrap: break-word;
    -webkit-user-select: text;
    user-select: text;
    cursor: text;
    position: relative;
    z-index: 1;
    padding-bottom: 8px;
}

#output .line {
    margin-bottom: 2px;
}

.prompt-text { color: var(--cyan); }
.command-text { color: var(--white); }
.output-text { color: var(--green); }
.output-error { color: var(--red); }
.output-info { color: var(--gray); }
.output-highlight { color: var(--yellow); }
.output-cyan { color: var(--cyan); }
.output-bold { font-weight: 700; color: var(--green); }

.output-link {
    color: var(--cyan);
    text-decoration: underline;
    cursor: pointer;
}

.output-link:hover {
    color: var(--yellow);
}

/* ── ASCII art / banner ─────────────────────────────────── */
.banner-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.banner-wrap::-webkit-scrollbar {
    height: 4px;
}

.banner-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.banner-wrap::-webkit-scrollbar-thumb {
    background: var(--green-dark);
    border-radius: 2px;
}

.ascii-art {
    color: var(--green);
    line-height: 1.2;
    font-size: 11px;
    white-space: pre;
    display: inline-block;
    min-width: max-content;
}

@media (max-width: 600px) {
    .banner-wrap {
        padding-bottom: 2px;
    }

    .ascii-art {
        font-size: 8px;
        line-height: 1.1;
    }
}

/* ── Input Line ─────────────────────────────────────────── */
#input-line {
    display: flex;
    align-items: center;
    margin-top: 4px;
    flex-shrink: 0;
    cursor: text;
    position: relative;
}

#input-line .prompt {
    color: var(--cyan);
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
}

#command-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    font-family: var(--font);
    font-size: 16px;
    caret-color: transparent;
    z-index: 3;
    -webkit-text-fill-color: transparent;
    direction: ltr;
}

#input-mirror {
    color: var(--white);
    white-space: pre;
    overflow: hidden;
}

.cursor-blink {
    color: var(--green);
    animation: blink 1s step-end infinite;
    user-select: none;
}

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

/* ── Skills bar ─────────────────────────────────────────── */
.skill-filled { color: var(--green); }
.skill-empty  { color: var(--green-dark); }

/* ── Attack Countdown Overlay ───────────────────────────── */
#attack-countdown {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
    font-family: var(--font);
}

#countdown-box {
    text-align: center;
    border: 1px solid #ff2200;
    padding: 30px 60px;
    background: #080808;
    box-shadow: 0 0 50px rgba(255, 34, 0, 0.4),
                inset 0 0 40px rgba(255, 34, 0, 0.05);
}

#countdown-warning {
    color: #ff4444;
    font-size: 13px;
    letter-spacing: 3px;
    margin-bottom: 24px;
    animation: atk-blink 0.8s step-end infinite;
}

#countdown-num {
    color: #ff0000;
    font-size: 80px;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 16px;
    text-shadow: 0 0 40px rgba(255, 0, 0, 0.9);
}

#countdown-sub {
    color: #444;
    font-size: 10px;
    letter-spacing: 2px;
}

/* ── Attack Popup ────────────────────────────────────────── */
#attack-popup {
    position: fixed;
    z-index: 10000;
    width: 420px;
    max-width: calc(100vw - 20px);
    background: #060606;
    border: 1px solid #cc1100;
    box-shadow: 0 0 30px rgba(255, 34, 0, 0.35),
                0 0 80px rgba(255, 34, 0, 0.1);
    font-family: var(--font);
    font-size: 11px;
    color: var(--green);
    user-select: none;
}

#attack-titlebar {
    background: linear-gradient(to right, #3d0000 0%, #820000 100%);
    color: #ff5555;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: move;
    border-bottom: 1px solid #cc1100;
    min-height: 26px;
}

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

.atk-blink {
    color: #ff0000;
    font-size: 10px;
    animation: atk-blink 0.6s step-end infinite;
    flex-shrink: 0;
}

#attack-title-text {
    flex: 1;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#attack-lock-icon {
    flex-shrink: 0;
    font-size: 13px;
    cursor: not-allowed;
}

#attack-content {
    padding: 10px 14px 14px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

#attack-content::-webkit-scrollbar { width: 3px; }
#attack-content::-webkit-scrollbar-track { background: transparent; }
#attack-content::-webkit-scrollbar-thumb { background: #550000; border-radius: 2px; }

.attack-line {
    font-size: 11px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-all;
}

.attack-system { color: #ff6666; font-weight: bold; }
.attack-sep    { color: #2a0000; }
.attack-scan   { color: #ffaa00; }
.attack-data   { color: #00ff41; }
.attack-ip     { color: #00d4ff; font-weight: bold; }
.attack-alert  {
    color: #ff2200;
    font-weight: bold;
    animation: atk-blink 0.5s step-end infinite;
}

/* ── Windows-style Error Popup ─────────────────────────── */
#error-popup {
    position: fixed;
    z-index: 9999;
    width: 370px;
    max-width: calc(100vw - 20px);
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    box-shadow: 4px 4px 0 #000000, inset 0 0 0 1px #dfdfdf;
    font-family: 'Tahoma', 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    color: #000000;
    user-select: none;
    cursor: default;
}

/* Shake on appear */
@keyframes popup-shake {
    0%  { transform: translate(0, 0) rotate(0deg); }
    15% { transform: translate(-6px, 2px) rotate(-1deg); }
    30% { transform: translate(6px, -2px) rotate(1deg); }
    45% { transform: translate(-4px, 1px) rotate(-0.5deg); }
    60% { transform: translate(4px, -1px) rotate(0.5deg); }
    75% { transform: translate(-2px, 1px); }
    90% { transform: translate(2px, 0); }
    100% { transform: translate(0, 0); }
}

@keyframes popup-hide {
    to { opacity: 0; transform: scale(0.85); }
}

.popup-shake {
    animation: popup-shake 0.45s ease-out;
}

.popup-jumping {
    transition: left 0.22s cubic-bezier(.25,.46,.45,.94),
                top  0.22s cubic-bezier(.25,.46,.45,.94) !important;
}

.popup-hide {
    animation: popup-hide 0.2s ease-in forwards;
}

.popup-dragging {
    cursor: grabbing !important;
    transition: none !important;
}

/* Title bar */
#error-titlebar {
    background: linear-gradient(to right, #000080 0%, #1084d0 100%);
    color: #ffffff;
    padding: 3px 4px 3px 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: move;
    min-height: 22px;
}

.error-title-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    image-rendering: pixelated;
}

#error-title {
    flex: 1;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Tahoma', 'MS Sans Serif', Arial, sans-serif;
}

#error-close {
    background: #c0c0c0;
    border: 1px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    width: 16px;
    height: 14px;
    font-size: 9px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #000000;
    flex-shrink: 0;
    font-family: 'Tahoma', Arial, sans-serif;
    line-height: 1;
    outline: none;
}

#error-close:active {
    border-color: #808080 #ffffff #ffffff #808080;
}

/* Body */
#error-body {
    padding: 12px 14px 8px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

#error-icon-wrap {
    font-size: 32px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
    color: #ff0000;
    text-shadow: none;
    filter: drop-shadow(1px 1px 0 #800000);
}

#error-text {
    flex: 1;
}

#error-heading {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 7px;
    color: #000080;
}

#error-text p {
    margin-bottom: 5px;
    line-height: 1.5;
    color: #000000;
    font-size: 11px;
}

/* Photo block */
#error-photo-wrap {
    margin: 0 14px 10px;
    border: 1px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    background: #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

#error-photo {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: brightness(0.9) contrast(1.1);
}

#error-photo-label {
    width: 100%;
    padding: 3px 6px;
    background: #000080;
    color: #00ff41;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
}

/* Buttons */
#error-buttons {
    padding: 4px 14px 8px;
    display: flex;
    justify-content: center;
    gap: 8px;
    border-top: 1px solid #808080;
    margin-top: 4px;
}

.error-btn {
    background: #c0c0c0;
    border: 1px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    padding: 3px 0;
    width: 72px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'Tahoma', 'MS Sans Serif', Arial, sans-serif;
    color: #000000;
    outline: none;
}

.error-btn:focus {
    outline: 1px dotted #000000;
    outline-offset: -3px;
}

.error-btn:active {
    border-color: #808080 #ffffff #ffffff #808080;
    padding-top: 4px;
    padding-left: 1px;
}

#error-hint {
    text-align: center;
    padding: 0 0 8px;
    color: #666666;
    font-size: 9px;
}

#error-hint kbd {
    background: #e0e0e0;
    border: 1px solid #808080;
    border-radius: 2px;
    padding: 0 3px;
    font-size: 9px;
    font-family: inherit;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    html, body {
        font-size: 12px;
        -webkit-text-size-adjust: 100%;
        overflow: auto;
        height: auto;
        min-height: 100%;
    }

    #terminal {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    #terminal-body {
        padding: 8px 10px 0;
        -webkit-overflow-scrolling: touch;
        overflow: visible;
        height: auto;
    }

    #output {
        overflow: visible;
        flex: none;
        padding-bottom: 120px;
    }

    #input-line {
        position: sticky;
        bottom: 0;
        background: var(--bg);
        padding: 10px 0 12px;
        z-index: 5;
        box-shadow: 0 -16px 24px 8px rgba(10, 10, 10, 0.98);
    }

    #command-input {
        font-size: 16px;
    }

    .bio-block {
        padding: 6px 0;
    }
}
