/* The Severed Sun - IBM CRT Terminal Interface */

:root {
    /* EGA 16-color palette */
    --ega-black: #000000;
    --ega-blue: #0000AA;
    --ega-green: #00AA00;
    --ega-cyan: #00AAAA;
    --ega-red: #AA0000;
    --ega-magenta: #AA00AA;
    --ega-brown: #AA5500;
    --ega-light-gray: #AAAAAA;
    --ega-dark-gray: #555555;
    --ega-light-blue: #5555FF;
    --ega-light-green: #55FF55;
    --ega-light-cyan: #55FFFF;
    --ega-light-red: #FF5555;
    --ega-light-magenta: #FF55FF;
    --ega-yellow: #FFFF55;
    --ega-white: #FFFFFF;
}

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

body {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 14px;
    background: #1a1a1a;
    color: var(--ega-light-green);
    overflow: hidden;
    height: 100vh;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CRT Container */
.crt-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Bezel Container */
.bezel-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-height: calc(100vw * 9 / 16);
    max-width: calc(100vh * 16 / 9);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Screen Area (positioned within the transparent area of the IBM PNG) */
.screen-area {
    position: absolute;
    left: 25.17%;
    top: 12%;
    width: 49.83%;
    height: 63%;
    background: var(--ega-black);
    overflow: hidden;
    z-index: 5;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    font-size: calc(0.75vw + 0.3vh);
}

/* Screen lens distortion effect */
.screen-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 60%,
        rgba(0, 0, 0, 0.15) 80%,
        rgba(0, 0, 0, 0.4) 95%,
        rgba(0, 0, 0, 0.6) 100%
    );
    pointer-events: none;
    z-index: 200;
    border-radius: 8px;
}

/* Bezel Image Overlay */
.bezel-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    filter: drop-shadow(0 0 30px rgba(0, 100, 200, 0.3));
    pointer-events: none;
    z-index: 10;
}

/* Power LED */
.power-led {
    position: absolute;
    left: 80.08%;
    top: 39.26%;
    width: 0.42%;
    height: 0.74%;
    background: #00ff00;
    border-radius: 50%;
    box-shadow: 0 0 8px #00ff00, 0 0 16px #00ff00;
    z-index: 20;
    transition: all 0.3s ease;
}

.power-led.off {
    background: #003300;
    box-shadow: 0 0 3px #003300;
}

/* Power Switch */
.power-switch {
    position: absolute;
    left: 79.17%;
    top: 44.44%;
    width: 2.25%;
    height: 4.44%;
    background: linear-gradient(145deg, #c0c0c0 0%, #a0a0a0 50%, #808080 100%);
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    border: 1px outset #a0a0a0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 1px 1px 2px rgba(255,255,255,0.5),
        inset -1px -1px 2px rgba(0,0,0,0.3),
        1px 1px 2px rgba(0,0,0,0.3);
}

.power-switch::before {
    content: "⏻";
    font-size: 14px;
    color: #000;
}

.power-switch:hover {
    background: linear-gradient(145deg, #d0d0d0 0%, #b0b0b0 50%, #909090 100%);
}

.power-switch:active {
    border: 1px inset #a0a0a0;
    box-shadow:
        inset -1px -1px 2px rgba(255,255,255,0.5),
        inset 1px 1px 2px rgba(0,0,0,0.3);
}

/* Contrast Button */
.contrast-button {
    position: absolute;
    left: 79.17%;
    top: 54.07%;
    width: 2.25%;
    height: 4.59%;
    background: linear-gradient(145deg, #c0c0c0 0%, #a0a0a0 50%, #808080 100%);
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    border: 1px outset #a0a0a0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 1px 1px 2px rgba(255,255,255,0.5),
        inset -1px -1px 2px rgba(0,0,0,0.3),
        1px 1px 2px rgba(0,0,0,0.3);
}

.contrast-button::before {
    content: "◐";
    font-size: 12px;
    color: #000;
}

.contrast-button:hover {
    background: linear-gradient(145deg, #d0d0d0 0%, #b0b0b0 50%, #909090 100%);
}

.contrast-button:active {
    border: 1px inset #a0a0a0;
    box-shadow:
        inset -1px -1px 2px rgba(255,255,255,0.5),
        inset 1px 1px 2px rgba(0,0,0,0.3);
}

/* Brightness Button */
.brightness-button {
    position: absolute;
    left: 79.17%;
    top: 63.70%;
    width: 2.25%;
    height: 4.74%;
    background: linear-gradient(145deg, #c0c0c0 0%, #a0a0a0 50%, #808080 100%);
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    border: 1px outset #a0a0a0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 1px 1px 2px rgba(255,255,255,0.5),
        inset -1px -1px 2px rgba(0,0,0,0.3),
        1px 1px 2px rgba(0,0,0,0.3);
}

.brightness-button::before {
    content: "☀";
    font-size: 12px;
    color: #000;
}

.brightness-button:hover {
    background: linear-gradient(145deg, #d0d0d0 0%, #b0b0b0 50%, #909090 100%);
}

.brightness-button:active {
    border: 1px inset #a0a0a0;
    box-shadow:
        inset -1px -1px 2px rgba(255,255,255,0.5),
        inset 1px 1px 2px rgba(0,0,0,0.3);
}

/* Boot Animation Content */
.boot-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ega-black);
    z-index: 50;
    overflow: hidden;
    padding: 1.5vh 1.5vw;
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: inherit;
    color: var(--ega-light-green);
    display: none;
}

.boot-content.active {
    display: block !important;
}

.bios-text {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: inherit;
    line-height: 1.3;
    color: #f0f0f0;
    text-shadow: 0 0 5px rgba(240, 240, 240, 0.5);
}

.text-scan {
    animation: textScan 0.05s ease-in;
}

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

.memory-counter {
    color: var(--ega-light-cyan);
}

/* Terminal - Fills screen area */
#terminal {
    width: 100%;
    height: 100%;
    background: var(--ega-black);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 50;
}

.terminal-header {
    background: var(--ega-blue);
    color: var(--ega-white);
    padding: 0.6vh 1.2vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--ega-cyan);
    font-weight: bold;
    font-size: 0.9em;
    flex-shrink: 0;
}

.terminal-status {
    color: var(--ega-yellow);
}

#terminal-output {
    flex: 1;
    padding: 1.2vh 1.2vw;
    overflow: hidden;
    font-family: 'IBM Plex Mono', monospace;
    position: relative;
}

.terminal-line {
    margin-bottom: 4px;
    color: var(--ega-light-green);
    word-wrap: break-word;
}

.terminal-line.error {
    color: var(--ega-light-red);
}

.terminal-line.info {
    color: var(--ega-light-cyan);
}

.terminal-line.warning {
    color: var(--ega-yellow);
}

.terminal-line.story {
    color: var(--ega-light-gray);
}

.terminal-line.title {
    color: var(--ega-light-cyan);
    font-weight: bold;
    margin-top: 10px;
}

.terminal-line.ascii-art {
    color: var(--ega-cyan);
    font-family: monospace;
    line-height: 1.2;
}

.terminal-input-line {
    padding: 0.8vh 1.2vw;
    display: flex;
    align-items: center;
    background: var(--ega-black);
    flex-shrink: 0;
}

.prompt {
    color: var(--ega-yellow);
    margin-right: 0.5vw;
    white-space: nowrap;
}

#terminal-input {
    background: transparent;
    border: none;
    color: var(--ega-white);
    font-family: 'IBM Plex Mono', monospace;
    font-size: inherit;
    flex: 1;
    outline: none;
}

/* ASCII Art Elements */
pre {
    margin: 0;
    font-family: 'IBM Plex Mono', monospace;
    line-height: 1.2;
}

.ascii-box {
    border: 1px solid var(--ega-cyan);
    padding: 5px;
    margin: 10px 0;
}

/* Puzzle ASCII Art */
.puzzle-ascii {
    color: var(--ega-light-cyan);
    margin: 10px 0;
    user-select: none;
}

.puzzle-interactive {
    cursor: pointer;
}

.puzzle-interactive:hover {
    color: var(--ega-white);
}

/* Memory Fragment Display */
.memory-fragment {
    color: var(--ega-light-magenta);
    margin: 5px 0;
}

.memory-fragment::before {
    content: '[MEM] ';
    color: var(--ega-magenta);
}

/* Continue Prompt */
.continue-prompt {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--ega-blue);
    color: var(--ega-yellow);
    padding: 0.8vh 1.2vw;
    text-align: center;
    font-weight: bold;
    z-index: 1000;
    animation: blink 1s infinite;
    font-size: inherit;
}

.terminal-output-paused {
    overflow: hidden !important;
}

/* CRT Effects */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 100;
    opacity: 0.1;
}

.flicker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    pointer-events: none;
    z-index: 100;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.95; }
    50% { opacity: 1; }
    100% { opacity: 0.97; }
}

.curvature-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(0, 0, 0, 0.1) 90%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
    z-index: 100;
}

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

.cursor-blink::after {
    content: '█';
    animation: blink 1s infinite;
}

/* Atmospheric Animations */
@keyframes vignette-move {
    0%, 100% {
        background-position: 50% 50%;
    }
    25% {
        background-position: 48% 48%;
    }
    50% {
        background-position: 52% 52%;
    }
    75% {
        background-position: 50% 48%;
    }
}

@keyframes chromatic-drift {
    0%, 100% {
        filter: none;
    }
    25% {
        filter: hue-rotate(2deg);
    }
    50% {
        filter: hue-rotate(-2deg);
    }
    75% {
        filter: hue-rotate(1deg);
    }
}

@keyframes gradient-pulse {
    0%, 100% {
        opacity: 0.03;
        transform: scale(1);
    }
    50% {
        opacity: 0.06;
        transform: scale(1.02);
    }
}

/* Atmospheric background layer */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(45deg, var(--ega-cyan) 0%, transparent 50%, var(--ega-blue) 100%),
        radial-gradient(circle, var(--ega-light-cyan) 0%, transparent 20%);
    background-size: 80px 80px, 100% 100%;
    background-blend-mode: screen;
    opacity: 0.05;
    animation: gradient-pulse 25s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

/* Bezel vignette effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%,
        transparent 30%,
        rgba(0, 0, 80, 0.6) 85%,
        rgba(0, 0, 0, 0.9) 100%
    );
    mix-blend-mode: multiply;
    animation: vignette-move 16s ease-in-out infinite, chromatic-drift 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}
