/* assets/css/terminal.css */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #000;
    color: #0f0;
    font-family: "Fira Code", "Consolas", "Menlo", "DejaVu Sans Mono", monospace;
}

body {
    display: flex;
    flex-direction: column;
}

#terminal {
    box-sizing: border-box;
    padding: 10px;
    height: 100vh;
    overflow-y: auto;
    white-space: pre-wrap;
    tab-size: 4;
    position: relative;
}

#terminal > * {
    position: relative;
    z-index: 1;
}

.terminal-line {
    line-height: 1.4;
    position: relative;
}

.terminal-prompt {
    display: inline;
}

.terminal-input {
    display: inline;
    outline: none;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    min-width: 1px;
}

.cursor {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    background: #0f0;
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

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

.terminal-banner {
    color: #0f0;
}

.terminal-error {
    color: #f55;
}

.terminal-dim {
    color: #0a0;
}

.less-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #0f0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    font-family: inherit;
    z-index: 2;
}

.less-header {
    font-weight: bold;
}

.less-content {
    flex: 1;
    margin: 0;
    overflow: hidden;
    white-space: pre-wrap;
    font-family: inherit;
}

.less-status {
    border-top: 1px solid #0f0;
    padding-top: 4px;
    font-size: 0.9em;
}

.terminal-measure {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    white-space: pre;
}

.terminal-ansi-wrapper {
    white-space: normal;
}

.terminal-ansi {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
}

.terminal-bbs {
    white-space: pre;
    font-family: inherit;
    max-width: 72ch;
    color: #9f9;
}

.plugin-session-line {
    color: #9ff;
}

.plugin-session-line .terminal-prompt {
    color: #7ff;
}

.terminal-figlet {
    white-space: pre;
    font-weight: bold;
}

.terminal-markdown {
    display: block;
    white-space: normal;
    line-height: 1.5;
}

.terminal-markdown .md-heading {
    font-weight: bold;
    color: #7f7;
    margin: 6px 0 2px;
}

.terminal-markdown .md-h1 { font-size: 1.4em; }
.terminal-markdown .md-h2 { font-size: 1.25em; }
.terminal-markdown .md-h3 { font-size: 1.1em; }

.terminal-markdown .md-paragraph {
    margin: 4px 0;
}

.terminal-markdown .md-list {
    margin: 4px 0 4px 20px;
    padding: 0;
    list-style: disc;
}

.terminal-markdown .md-list li {
    margin-bottom: 2px;
}

.terminal-markdown .md-blockquote {
    border-left: 2px solid #0f0;
    padding-left: 10px;
    margin: 6px 0;
    color: #9f9;
}

.terminal-markdown .md-code {
    background: rgba(0, 64, 0, 0.3);
    padding: 6px;
    margin: 6px 0;
    white-space: pre-wrap;
    border-left: 2px solid #0f0;
}

.terminal-markdown code {
    background: rgba(0, 64, 0, 0.4);
    padding: 0 2px;
}

.terminal-markdown a {
    color: #7ff;
    text-decoration: underline;
}

.terminal-markdown a:hover {
    color: #aff;
}

.terminal-markdown .md-image {
    margin: 8px 0;
}

.terminal-markdown .md-image pre {
    margin: 0;
}

.mobile-keyboard-button {
    position: fixed;
    right: 12px;
    bottom: 12px;
    padding: 8px 12px;
    background: rgba(0, 30, 0, 0.85);
    color: #0f0;
    border: 1px solid #0f0;
    font-family: inherit;
    font-size: 0.95em;
    border-radius: 4px;
    z-index: 5;
}

.terminal-hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    left: -9999px;
    top: auto;
}


body.theme-crt {
    background: #050805;
    color: #caffca;
}

body.theme-crt .mobile-keyboard-button {
    background: rgba(0, 30, 0, 0.9);
    border-color: #7f7;
    color: #afffaf;
}

body.theme-crt #terminal {
    background: radial-gradient(circle at center, rgba(12, 30, 12, 0.85) 0%, rgba(2, 8, 2, 0.95) 70%) #020;
    color: #d3ffd3;
    border: 2px solid rgba(0, 255, 170, 0.4);
    box-shadow: 0 0 35px rgba(0, 255, 150, 0.3);
    text-shadow: 0 0 3px rgba(0, 255, 150, 0.35);
}

body.theme-crt #terminal::before,
body.theme-crt #terminal::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

body.theme-crt #terminal::before {
    background: radial-gradient(circle at center, rgba(0, 255, 128, 0.08), rgba(0, 0, 0, 0.85));
}

body.theme-crt #terminal::after {
    background-image:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0) 0px, rgba(0, 0, 0, 0) 2px, rgba(0, 255, 128, 0.04) 2px, rgba(0, 0, 0, 0.1) 3px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.15));
    opacity: 0.45;
    mix-blend-mode: screen;
}

body.theme-crt #terminal .terminal-line {
    text-shadow: 0 0 4px rgba(0, 255, 160, 0.6);
}

body.theme-crt #terminal .less-overlay {
    border-color: #7f7;
    background: rgba(0, 0, 0, 0.92);
}

@media (max-width: 600px) {
    #terminal {
        font-size: 14px;
    }
}
