/* 486-era BIOS aesthetic */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

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

body {
    background-color: #000000;
    color: #FFFFFF;
    font-family: 'VT323', 'Courier New', monospace;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* CRT scanline effect */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.08),
        rgba(0, 0, 0, 0.08) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 1000;
}

#terminal {
    width: 90%;
    max-width: 900px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Main border frame */
.border-frame {
    border: 2px solid #FFFFFF;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #0000AA;
}

#header {
    background-color: #0000AA;
    color: #FFFFFF;
    padding: 16px;
    text-align: center;
    font-size: 24px;
    letter-spacing: 2px;
    border-bottom: 1px solid #FFFFFF;
}

#header .visitor {
    color: #FFFF00;
}

#content {
    flex: 1;
    background-color: #0000AA;
    color: #FFFFFF;
    padding: 16px;
    overflow-y: auto;
    font-size: 20px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#input-area {
    background-color: #0000AA;
    padding: 16px;
    display: flex;
    align-items: center;
    border-top: 1px solid #FFFFFF;
    border-bottom: 1px solid #FFFFFF;
}

#prompt {
    color: #00FFFF;
    margin-right: 8px;
    font-size: 20px;
}

#input {
    flex: 1;
    background-color: #0000AA;
    color: #00FFFF;
    border: none;
    outline: none;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 20px;
    caret-color: #00FFFF;
}

#input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#input::selection {
    background-color: #00FFFF;
    color: #0000AA;
}

#footer {
    background-color: #0000AA;
    color: #FFFFFF;
    padding: 12px 16px;
    text-align: center;
    font-size: 18px;
    letter-spacing: 4px;
}

/* Custom scrollbar */
#content::-webkit-scrollbar {
    width: 10px;
}

#content::-webkit-scrollbar-track {
    background: #0000AA;
}

#content::-webkit-scrollbar-thumb {
    background: #FFFFFF;
    border: 2px solid #0000AA;
}

/* Blinking cursor animation */
@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

/* Studio intro overlay */
#studio-intro {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 102; /* Above CRT power-on */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* Snackbox logo styling */
.studio-logo {
    width: 200px;
    height: auto;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    filter: brightness(1);
}

.studio-logo.visible {
    opacity: 1;
}

/* "presents—" text */
.studio-presents {
    color: #F5F0E6;
    font-family: Georgia, serif;
    font-size: 18px;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.studio-presents.visible {
    opacity: 1;
}

/* Glitch effect */
.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.1) 2px,
        transparent 2px,
        transparent 4px
    );
    opacity: 0;
    animation: glitchFlash 0.3s ease-in-out;
}

@keyframes glitchFlash {
    0% { opacity: 0; transform: translateX(0); }
    25% { opacity: 0.8; transform: translateX(-5px); }
    50% { opacity: 0.5; transform: translateX(5px); }
    75% { opacity: 0.8; transform: translateX(-3px); }
    100% { opacity: 0; transform: translateX(0); }
}

/* Indexed text (Archive takeover) */
.indexed-text {
    color: #00FF00;
    font-family: 'VT323', monospace;
    font-size: 24px;
    text-align: center;
    line-height: 1.6;
    opacity: 0;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.indexed-text.visible {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

.indexed-text.fade-out {
    opacity: 0;
    transition: opacity 1s ease-out;
}

/* Character transformation effects */
.char-span {
    display: inline-block;
    color: #00FF00;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.char-span.scatter {
    animation: scatterUpward 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes scatterUpward {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--scatter-x), var(--scatter-y)) scale(0.3);
        opacity: 0;
    }
}

.char-span.descend {
    animation: descendToPosition 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes descendToPosition {
    0% {
        transform: translate(var(--start-x), var(--start-y)) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
}

/* Transformation canvas overlay */
#transformation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
}

/* CRT power-on effect */
#crt-poweron {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 101;
    pointer-events: none;
}

.crt-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(0, 255, 0, 0.3) 0%, transparent 50%);
    opacity: 0;
}

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

/* Matrix rain canvas overlay */
#matrix-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
}

/* Scrambled fragment (center, green, cycling) */
.fragment-scramble {
    text-align: center;
    color: #00FF00;
    font-size: 22px;
    line-height: 1.8;
    padding: 40px 20px;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
    max-width: 80%;
    margin: 0 auto;
    font-family: 'VT323', monospace;
    letter-spacing: 1px;
}

/* Stable fragment (white, glowing) */
.fragment-stable {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

/* Archived fragment (shrunk, dimmed, at top) */
.fragment-archived {
    font-size: 20px !important;
    opacity: 0.6;
    margin-bottom: 16px;
    padding: 0 24px !important;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
}

/* Fragment drift effect for boot sequence */
.fragment-drift {
    text-align: center;
    color: #FFFFFF;
    font-size: 22px;
    line-height: 1.8;
    padding: 0 20px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
    max-width: 80%;
    margin: 0 auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
}

@keyframes fragmentFadeIn {
    from {
        opacity: 0;
        filter: blur(2px);
    }
    to {
        opacity: 1;
        filter: blur(0px);
    }
}

@keyframes fragmentFadeOut {
    from {
        opacity: 1;
        filter: blur(0px);
    }
    to {
        opacity: 0;
        filter: blur(2px);
    }
}

/* F-Key Overlay System */
.terminal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'VT323', monospace;
    color: #00FF00;
}

.overlay-box {
    border: 2px solid #00FF00;
    padding: 32px;
    max-width: 600px;
    text-align: center;
    line-height: 1.8;
}

.overlay-title {
    font-size: 24px;
    margin-bottom: 24px;
}

.overlay-close-hint {
    margin-top: 24px;
    font-size: 14px;
    opacity: 0.6;
}

.hidden-word {
    color: #00FFAA;
    text-shadow: 0 0 5px rgba(0, 255, 170, 0.4);
}

@keyframes glitchBg {
    0% { background-color: #000000; }
    50% { background-color: #AA0000; }
    100% { background-color: #000000; }
}

/* Word Earning Overlay */
.word-earned-box {
    max-width: 500px;
}

.word-divider {
    font-size: 16px;
    margin: 16px 0;
    opacity: 0.8;
}

.earned-word {
    font-size: 36px;
    font-weight: bold;
    color: #00FFAA;
    text-shadow: 0 0 10px rgba(0, 255, 170, 0.6);
    margin: 24px 0;
    letter-spacing: 4px;
}

.word-message {
    font-size: 16px;
    line-height: 1.8;
    margin: 24px 0;
    opacity: 0.9;
}
