/* ==============================================
   completengine.net - Terminal Computation Engine
   ============================================== */

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

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

body {
    background-color: #0a0a0a;
    color: #f0f0f0;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.6vw, 1.05rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* --- INTRO SCREEN (100vh black with blinking cursor) --- */
.intro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.6s ease;
}

.intro.fade-out {
    opacity: 0;
    pointer-events: none;
}

.intro.hidden {
    display: none;
}

.intro-cursor {
    width: 2px;
    height: 20px;
    background-color: #00e5ff;
    animation: cursorBlink 1.06s step-end infinite;
}

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

/* --- TERMINAL CONTAINER --- */
.terminal {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    border: 1px solid #333333;
    padding: 48px;
    position: relative;
    opacity: 0;
    transition: opacity 0.8s ease;
    min-height: 100vh;
}

.terminal.visible {
    opacity: 1;
}

/* Terminal title bar */
.terminal-titlebar {
    width: 100%;
    height: 3px;
    background-color: #ffffff;
    margin-bottom: 12px;
}

/* Window control dots */
.terminal-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 48px;
}

.control-dot {
    width: 8px;
    height: 8px;
    display: block;
}

.control-dot:nth-child(1) {
    background-color: #555555;
}

.control-dot:nth-child(2) {
    background-color: #777777;
}

.control-dot:nth-child(3) {
    background-color: #999999;
}

/* --- TERMINAL BODY (gutter + content) --- */
.terminal-body {
    display: flex;
    position: relative;
}

/* Line number gutter */
.line-gutter {
    position: absolute;
    left: -40px;
    top: 0;
    width: 30px;
    text-align: right;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: #333333;
    line-height: 1.85;
    user-select: none;
}

.line-gutter .line-number {
    display: block;
    height: 1.85em;
}

/* Terminal content area */
.terminal-content {
    flex: 1;
    min-width: 0;
}

/* --- BLOCKS & SPACING --- */
.block {
    margin-bottom: 64px;
}

/* --- SEPARATOR --- */
.separator {
    margin-bottom: 64px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.separator-text {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.875rem, 1.6vw, 1.05rem);
    color: #555555;
    white-space: nowrap;
}

.block-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background-color: #00e5ff;
    animation: cursorBlink 1.06s step-end infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

/* --- HERO / TYPEWRITER --- */
.hero-block {
    padding-top: 20px;
}

.typewriter-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.6rem, 4vw, 3.2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f0f0f0;
    line-height: 1.3;
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
}

.typewriter-text {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    animation: typeTitle 1.17s steps(18, end) 1.8s forwards;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: #00e5ff;
    animation: cursorBlink 1.06s step-end infinite;
    margin-left: 2px;
    vertical-align: baseline;
    flex-shrink: 0;
}

@keyframes typeTitle {
    from { width: 0; }
    to { width: 100%; }
}

.typewriter-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.6vw, 1.05rem);
    color: #777777;
    line-height: 1.85;
    display: inline-flex;
    align-items: center;
}

.subtitle-text {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    animation: typeSubtitle 1.95s steps(30, end) 3.37s forwards;
}

.subtitle-cursor {
    opacity: 0;
    animation: cursorBlink 1.06s step-end infinite, subtitleCursorAppear 0s 3.37s forwards;
}

@keyframes subtitleCursorAppear {
    to { opacity: 1; }
}

@keyframes typeSubtitle {
    from { width: 0; }
    to { width: 100%; }
}

/* --- SECTION HEADINGS --- */
.section-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.6rem, 4vw, 3.2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f0f0f0;
    margin-bottom: 32px;
    position: relative;
    display: inline-block;
}

.section-heading::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #00e5ff;
    transition: width 0.6s ease;
}

.section-heading.in-view::after {
    width: 100%;
}

/* --- BODY TEXT --- */
.body-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.6vw, 1.05rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: #f0f0f0;
    margin-bottom: 24px;
}

.body-text:last-child {
    margin-bottom: 0;
}

/* Code inline */
.code-inline {
    background-color: #1a1a1a;
    padding: 2px 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
}

/* Accent text */
.accent-text {
    color: #00e5ff;
}

/* --- SYSTEM OUTPUT --- */
.system-output {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.875rem, 1.6vw, 1.05rem);
    color: #777777;
    margin-bottom: 24px;
    line-height: 1.85;
}

/* --- INITIALIZATION GRID (6x6) --- */
.grid-block .system-output {
    margin-bottom: 24px;
}

.init-grid {
    display: grid;
    grid-template-columns: repeat(6, 12px);
    grid-template-rows: repeat(6, 12px);
    gap: 4px;
    margin-bottom: 24px;
}

.grid-cell {
    width: 12px;
    height: 12px;
    background-color: #1a1a1a;
    transition: background-color 0.3s ease;
}

.grid-cell.lit {
    background-color: #f0f0f0;
}

.grid-status {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.grid-status.visible {
    opacity: 1;
}

/* --- PROGRESS BAR --- */
.progress-container {
    width: 100%;
    height: 3px;
    background-color: #1a1a1a;
    margin-bottom: 16px;
    position: relative;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #00e5ff;
    transition: width 0.1s linear;
}

.progress-counter {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.875rem, 1.6vw, 1.05rem);
    color: #777777;
    line-height: 1.85;
}

/* --- OUTPUT MATRIX (4x8 grid for "OK") --- */
.output-matrix {
    display: grid;
    grid-template-columns: repeat(8, 20px);
    grid-template-rows: repeat(4, 8px);
    gap: 4px;
    margin-bottom: 24px;
}

.matrix-cell {
    width: 20px;
    height: 8px;
    background-color: #1a1a1a;
    transition: background-color 0.2s ease;
}

.matrix-cell.lit {
    background-color: #f0f0f0;
}

.matrix-status {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.matrix-status.visible {
    opacity: 1;
}

/* --- FINAL BLOCK --- */
.final-block .system-output {
    margin-bottom: 16px;
}

.final-cursor {
    width: 2px;
    height: 20px;
    background-color: #00e5ff;
    animation: cursorBlink 1.06s step-end infinite;
    margin-top: 32px;
}

.final-cursor.solid {
    animation: none;
    opacity: 1;
}

/* --- LINKS (if any) --- */
a {
    color: #00e5ff;
    text-decoration: none;
    position: relative;
    background-image: linear-gradient(#00e5ff, #00e5ff);
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition: color 0.2s ease, background-size 0.3s ease;
}

a:hover {
    color: #ffffff;
    background-size: 100% 1px;
}

/* --- RESPONSIVE --- */

/* Tablet: 720px - 1024px */
@media (min-width: 720px) and (max-width: 1024px) {
    .terminal {
        max-width: 600px;
    }
}

/* Mobile: below 720px */
@media (max-width: 719px) {
    .terminal {
        max-width: none;
        width: calc(100vw - 32px);
        padding: 24px 16px;
        margin: 0 16px;
    }

    .line-gutter {
        display: none;
    }

    .terminal-controls {
        margin-bottom: 32px;
    }

    .block {
        margin-bottom: 48px;
    }

    .separator {
        margin-bottom: 48px;
    }

    .typewriter-title {
        font-size: clamp(1.2rem, 5vw, 2rem);
    }

    .section-heading {
        font-size: clamp(1.2rem, 5vw, 2rem);
    }
}

/* Ensure full height for scrolling */
body {
    padding-bottom: 30vh;
}
