/* ============================================================
   simulai.dev - Terminal Emulator Styles
   Palette: Dark Terminal (Dracula/Nord lineage)
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep: #0D1117;
    --surface: #161B22;
    --border-dim: #21262D;
    --text-primary: #C9D1D9;
    --text-dimmed: #484F58;
    --accent-green: #39D353;
    --accent-blue: #58A6FF;
    --accent-orange: #D29922;
    --accent-red: #F85149;
    --accent-purple: #BC8CFF;
    --line-height: 1.5rem;
    --font-primary: 'JetBrains Mono', monospace;
    --font-accent: 'Fira Code', monospace;
    --font-comment: 'Source Code Pro', monospace;
    --font-size: clamp(0.875rem, 1vw, 1rem);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    font-size: var(--font-size);
    font-weight: 400;
    line-height: var(--line-height);
    letter-spacing: 0;
    color: var(--text-primary);
    background: var(--bg-deep);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Scanline Overlay --- */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.03) 1px,
        rgba(0, 0, 0, 0.03) 2px
    );
}

/* --- Matrix Rain Canvas --- */
#matrix-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.08;
}

/* --- Terminal Window --- */
#terminal-window {
    position: relative;
    z-index: 10;
    max-width: 80ch;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-deep);
    opacity: 0;
    animation: terminalFadeIn 300ms ease-out forwards;
}

@keyframes terminalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 80ch) {
    #terminal-window {
        max-width: 100%;
        padding: 0 12px;
    }
}

/* --- Title Bar --- */
#title-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-dim);
}

#window-controls {
    display: flex;
    gap: 8px;
}

.control {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.control.close {
    background: var(--accent-red);
}

.control.minimize {
    background: var(--accent-orange);
}

.control.maximize {
    background: var(--accent-green);
}

#title-text {
    font-family: var(--font-primary);
    font-size: 0.85em;
    color: var(--text-dimmed);
}

/* --- Terminal Body --- */
#terminal-body {
    display: flex;
    position: relative;
    padding-bottom: calc(var(--line-height) * 4);
}

/* --- Line Numbers Gutter --- */
#line-numbers {
    position: fixed;
    left: 0;
    top: 0;
    width: 3.5ch;
    height: 100vh;
    padding-top: 40px;
    font-family: var(--font-comment);
    font-weight: 300;
    font-size: 0.85em;
    color: var(--text-dimmed);
    text-align: right;
    padding-right: 0.5ch;
    user-select: none;
    z-index: 50;
    overflow: hidden;
    background: var(--bg-deep);
    border-right: 1px solid var(--border-dim);
}

@media (max-width: 80ch) {
    #line-numbers {
        display: none;
    }
}

.line-num {
    display: block;
    height: var(--line-height);
    line-height: var(--line-height);
}

/* --- Terminal Content --- */
#terminal-content {
    flex: 1;
    padding: calc(var(--line-height) * 2) 16px;
    padding-left: 4.5ch;
}

@media (max-width: 80ch) {
    #terminal-content {
        padding-left: 16px;
    }
}

/* --- Sections --- */
.terminal-section {
    margin-bottom: calc(var(--line-height) * 2);
}

.section-rule {
    color: var(--border-dim);
    margin-bottom: var(--line-height);
    overflow: hidden;
    white-space: nowrap;
}

.section-header {
    font-weight: 700;
    margin-bottom: var(--line-height);
}

.section-content {
    margin-bottom: var(--line-height);
}

/* Content sections - hidden initially for scroll animation */
.content-section {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.content-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Command Line --- */
.command-line {
    margin-bottom: var(--line-height);
    white-space: nowrap;
}

.prompt {
    color: var(--accent-green);
    font-weight: 700;
    margin-right: 1ch;
}

.command {
    color: var(--text-primary);
}

/* --- Cursor --- */
.cursor {
    display: inline-block;
    width: 1ch;
    height: 1.2em;
    background: var(--accent-green);
    vertical-align: text-bottom;
    margin-left: 1px;
}

.cursor.blink {
    animation: cursorBlink 1060ms step-end infinite;
}

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

/* --- Man Page Navigation --- */
.man-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: calc(var(--line-height) * 2);
    font-weight: 700;
}

.man-title {
    color: var(--text-primary);
}

.man-center {
    color: var(--text-dimmed);
}

.man-section {
    margin-bottom: var(--line-height);
}

.man-heading {
    color: var(--text-primary);
    font-weight: 700;
    text-transform: uppercase;
}

.man-body {
    color: var(--text-primary);
}

.indented {
    padding-left: 5ch;
}

.flag-link {
    color: var(--accent-blue);
    cursor: pointer;
    transition: color 150ms;
}

.flag-link:hover {
    color: var(--accent-green);
    text-decoration: underline;
}

/* --- Output Lines --- */
.output-line {
    line-height: var(--line-height);
}

.blank-line {
    height: var(--line-height);
}

/* --- Text Colors --- */
.accent-green { color: var(--accent-green); }
.accent-blue { color: var(--accent-blue); }
.accent-orange { color: var(--accent-orange); }
.accent-red { color: var(--accent-red); }
.accent-purple { color: var(--accent-purple); }
.text-primary { color: var(--text-primary); }
.text-dimmed {
    color: var(--text-dimmed);
    font-family: var(--font-comment);
    font-weight: 300;
    font-size: 0.85em;
}

/* --- ASCII Art --- */
.ascii-art {
    font-family: var(--font-accent);
    font-weight: 400;
    color: var(--accent-green);
    line-height: var(--line-height);
    white-space: pre;
    overflow-x: auto;
}

/* --- Code Blocks --- */
.code-block {
    background: var(--surface);
    border: 1px solid var(--border-dim);
    padding: var(--line-height) 2ch;
    margin: var(--line-height) 0;
    position: relative;
    transition: background 200ms ease;
}

.code-block:hover {
    background: #1c2129;
}

.code-block::after {
    content: '$ cp';
    position: absolute;
    top: 8px;
    right: 12px;
    color: var(--text-dimmed);
    font-size: 0.75em;
    opacity: 0;
    transition: opacity 200ms ease;
    cursor: pointer;
}

.code-block:hover::after {
    opacity: 1;
}

.code-line {
    line-height: var(--line-height);
    white-space: pre-wrap;
}

/* --- Diff Block --- */
.diff-block {
    margin: var(--line-height) 0;
    padding: var(--line-height) 2ch;
    background: var(--surface);
    border: 1px solid var(--border-dim);
}

/* --- Help Block --- */
.help-block {
    margin: var(--line-height) 0;
}

/* --- Progress Bar --- */
.progress-bar {
    font-family: var(--font-accent);
}

.filled {
    color: var(--accent-green);
}

.unfilled {
    color: var(--text-dimmed);
}

/* --- Git Log --- */
.git-log {
    margin: var(--line-height) 0;
}

/* --- Tree Output --- */
.tree-output {
    margin: var(--line-height) 0;
}

/* --- Terminal Links --- */
.terminal-link {
    color: var(--accent-green);
    cursor: pointer;
    transition: color 150ms;
}

.terminal-link:hover {
    color: var(--accent-blue);
}

/* --- Footer --- */
.footer-text {
    text-align: left;
}

/* --- Neofetch Output --- */
.neofetch-output {
    font-family: var(--font-primary);
    font-weight: 400;
    line-height: var(--line-height);
    white-space: pre-wrap;
}

/* --- Boot Sequence Hidden State --- */
#boot-sequence .output,
#ascii-logo .ascii-art {
    overflow: hidden;
}

/* --- Command Palette --- */
#command-palette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
}

#command-palette.hidden {
    display: none;
}

#palette-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.85);
}

#palette-container {
    position: relative;
    width: 100%;
    max-width: 50ch;
    background: var(--surface);
    border: 1px solid var(--border-dim);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#palette-input-wrapper {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-dim);
}

.palette-prompt {
    color: var(--accent-green);
    font-weight: 700;
    margin-right: 1ch;
}

#palette-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: var(--font-size);
    line-height: var(--line-height);
}

#palette-input::placeholder {
    color: var(--text-dimmed);
}

#palette-results {
    padding: 8px 0;
}

.palette-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 100ms;
}

.palette-item:hover,
.palette-item.active {
    background: var(--border-dim);
}

.palette-item .text-dimmed {
    margin-left: 2ch;
}

/* --- Typewriter Animation Helper --- */
.typewriter-hidden {
    visibility: hidden;
}

.typewriter-char {
    visibility: visible;
}

/* --- Line Reveal Animation --- */
.line-hidden {
    opacity: 0;
    transform: translateY(4px);
}

.line-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 200ms ease, transform 200ms ease;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .man-header {
        flex-direction: column;
        gap: 0;
    }

    .man-center {
        display: none;
    }

    .indented {
        padding-left: 2ch;
    }

    .code-block {
        padding: var(--line-height) 1ch;
    }

    .diff-block {
        padding: var(--line-height) 1ch;
    }
}

/* --- Section Transition Command --- */
.section-transition {
    margin-bottom: var(--line-height);
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--border-dim);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dimmed);
}

/* --- Selection --- */
::selection {
    background: var(--accent-blue);
    color: var(--bg-deep);
}
