/* ============================================
   completengine.net -- Terminal Dev Console
   ============================================ */

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

:root {
    --terminal: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --green: #3fb950;
    --blue: #58a6ff;
    --orange: #d29922;
    --red: #f85149;
    --text: #c9d1d9;
    --muted: #8b949e;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    font-weight: 400;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: #58a6ff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

strong {
    font-weight: 600;
    color: #e6edf3;
}

/* --- Sidebar Overlay --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background-color: #161b22;
    border-right: 1px solid #30363d;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: #3fb950;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #30363d;
}

.sidebar-title {
    color: #c9d1d9;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.file-tree {
    list-style: none;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
}

.file-tree li {
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tree-branch {
    color: #8b949e;
    user-select: none;
}

.file-tree .toc-link {
    color: #58a6ff;
    display: block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    flex: 1;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.file-tree .toc-link:hover {
    background-color: rgba(88, 166, 255, 0.1);
    text-decoration: none;
}

.file-tree .toc-link.active {
    background-color: rgba(63, 185, 80, 0.12);
    color: #3fb950;
}

.sidebar-hint {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.75rem;
    color: #8b949e;
    padding-top: 0.75rem;
    border-top: 1px solid #30363d;
    text-align: center;
}

/* --- Keyboard Hint --- */
.kbd-hint {
    position: fixed;
    top: 1rem;
    right: 1rem;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.75rem;
    color: #8b949e;
    z-index: 50;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.kbd-hint:hover {
    opacity: 1;
}

.key-hint {
    display: inline-block;
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 3px;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    color: #c9d1d9;
    font-family: 'Source Code Pro', monospace;
}

/* --- Terminal Container --- */
.terminal-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Console Window (Hero) --- */
.hero-section {
    padding-top: 4rem;
    padding-bottom: 2rem;
}

.console-window {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.console-titlebar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.6rem 1rem;
    background-color: #0d1117;
    border-bottom: 1px solid #30363d;
}

.console-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.console-dot.red {
    background-color: #f85149;
}

.console-dot.yellow {
    background-color: #d29922;
}

.console-dot.green {
    background-color: #3fb950;
}

.console-titlebar-text {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.75rem;
    color: #8b949e;
    margin-left: 0.5rem;
}

.console-body {
    padding: 1.5rem;
    font-family: 'Source Code Pro', monospace;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    line-height: 1.6;
    min-height: 320px;
}

.typewriter-line {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.prompt-char {
    color: #3fb950;
    font-weight: 600;
    margin-right: 0.5rem;
    font-family: 'Source Code Pro', monospace;
}

.typed-text {
    color: #c9d1d9;
}

/* --- Blinking Cursor --- */
.cursor {
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background-color: #3fb950;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

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

/* --- Help Output --- */
.help-output {
    margin-top: 1rem;
}

.output-line {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #c9d1d9;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.output-line.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Hidden Utility --- */
.hidden {
    display: none;
}

/* --- ASCII Dividers --- */
.ascii-divider {
    border: none;
    overflow: visible;
    text-align: center;
    margin: 2.5rem 0;
    height: 1.2em;
    position: relative;
}

.ascii-divider::before {
    content: '────────────────────────────────────────';
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    color: #8b949e;
    letter-spacing: 0;
}

.ascii-divider.eq::before {
    content: '════════════════════════════════════════';
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Source Code Pro', monospace;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 600;
    color: #c9d1d9;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.command-text {
    color: #c9d1d9;
}

.cursor-indicator {
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background-color: #3fb950;
    vertical-align: text-bottom;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cursor-indicator.active {
    opacity: 1;
    animation: blink 1s step-end infinite;
}

/* --- Console Sections --- */
.console-section {
    margin-bottom: 1rem;
}

.section-content {
    padding-left: 1.5rem;
}

.section-content p {
    margin-bottom: 1rem;
}

/* --- Pull Quote --- */
.pull-quote {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: #c9d1d9;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-left: 3px solid #3fb950;
    background-color: #161b22;
    border-radius: 0 4px 4px 0;
    line-height: 1.6;
}

.quote-mark {
    color: #3fb950;
    font-size: 1.4rem;
    font-weight: 600;
    font-family: 'Source Serif 4', serif;
}

/* --- Code Blocks --- */
.code-block {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-left: 3px solid #3fb950;
    border-radius: 4px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #30363d;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.75rem;
}

.copy-btn {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.7rem;
    color: #8b949e;
    background: transparent;
    border: 1px solid #30363d;
    border-radius: 3px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.copy-btn:hover {
    color: #c9d1d9;
    border-color: #c9d1d9;
}

.copy-btn.copied {
    color: #3fb950;
    border-color: #3fb950;
    background-color: rgba(63, 185, 80, 0.08);
}

.code-body {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    padding: 1rem;
    overflow-x: auto;
    color: #c9d1d9;
    white-space: pre;
}

.line-num {
    color: #8b949e;
    user-select: none;
    display: inline-block;
    width: 2ch;
    text-align: right;
    margin-right: 1rem;
}

/* --- Thread Entries --- */
.thread-entry {
    padding: 1rem 0;
    border-bottom: 1px dashed #30363d;
}

.thread-entry:last-child {
    border-bottom: none;
}

.thread-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
}

/* --- Contribution List --- */
.contrib-list {
    margin: 1.5rem 0;
}

.contrib-item {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9rem;
}

.contrib-tag {
    font-weight: 700;
    min-width: 64px;
    letter-spacing: 0.05em;
}

.contrib-rule {
    font-family: 'Source Code Pro', monospace;
}

.contrib-desc {
    font-family: 'Source Sans 3', sans-serif;
    color: #c9d1d9;
    flex: 1;
}

/* --- Changelog Entries --- */
.changelog-entry {
    padding: 1rem 0;
    border-bottom: 1px dashed #30363d;
}

.changelog-entry:last-child {
    border-bottom: none;
}

.changelog-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.version-tag {
    display: inline-block;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: #3fb950;
    background-color: rgba(63, 185, 80, 0.12);
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    border: 1px solid rgba(63, 185, 80, 0.25);
}

.changelog-date {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.8rem;
}

.changelog-entry p {
    margin-top: 0.25rem;
}

/* --- Footer --- */
.footer-section {
    text-align: center;
    padding: 2rem 0 4rem 0;
}

.footer-content {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem;
}

.footer-content p {
    margin-bottom: 0.5rem;
}

.footer-ascii {
    margin-top: 1rem;
    letter-spacing: 0;
    color: #8b949e;
    overflow: hidden;
    white-space: nowrap;
}

/* --- Color Utility Classes --- */
.text-green {
    color: #3fb950;
}

.text-blue {
    color: #58a6ff;
}

.text-orange {
    color: #d29922;
}

.text-red {
    color: #f85149;
}

.text-muted {
    color: #8b949e;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .terminal-container {
        padding: 1rem;
    }

    .sidebar {
        width: 240px;
    }

    .kbd-hint {
        display: none;
    }

    .section-content {
        padding-left: 0.75rem;
    }

    .contrib-item {
        flex-wrap: wrap;
    }

    .contrib-rule {
        display: none;
    }
}

@media (max-width: 480px) {
    .console-body {
        padding: 1rem;
        min-height: 240px;
    }

    .section-heading {
        font-size: 1.25rem;
    }

    .ascii-divider::before {
        content: '──────────────────────';
    }

    .ascii-divider.eq::before {
        content: '══════════════════════';
    }

    .footer-ascii {
        font-size: 0.7rem;
    }
}
