/* =============================================================================
   CABIN — Terminal UI
   A dialogue engine for the multiplicity of self
   ============================================================================= */

:root {
    /* The phosphor glow - warm amber like an old CRT */
    --phosphor: #ffb000;
    --phosphor-dim: #cc8c00;
    --phosphor-bright: #ffd966;
    --phosphor-glow: rgba(255, 176, 0, 0.15);
    
    /* Alternative: Classic green phosphor */
    /* --phosphor: #33ff33;
    --phosphor-dim: #22aa22;
    --phosphor-bright: #66ff66;
    --phosphor-glow: rgba(51, 255, 51, 0.1); */
    
    /* The void */
    --black: #0a0a08;
    --black-less: #121210;
    --black-lighter: #1a1a16;
    
    /* Aspect colors */
    --aspect-1: #ff6b6b;
    --aspect-2: #4ecdc4;
    --aspect-3: #a855f7;
    --cabin: #888;
    
    /* Typography */
    --font-mono: 'IBM Plex Mono', 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    --font-size: 15px;
    --line-height: 1.6;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--black);
    color: var(--phosphor);
    font-family: var(--font-mono);
    font-size: var(--font-size);
    line-height: var(--line-height);
}

/* =============================================================================
   CRT Effect Container
   ============================================================================= */

.crt {
    position: fixed;
    inset: 0;
    overflow: hidden;
    
    /* Subtle vignette */
    background: radial-gradient(
        ellipse at center,
        var(--black) 0%,
        var(--black) 70%,
        #000 100%
    );
}

/* Scanlines overlay */
.scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.15) 1px,
        rgba(0, 0, 0, 0.15) 2px
    );
    
    /* Subtle flicker */
    animation: flicker 0.15s infinite;
}

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

/* =============================================================================
   Terminal Container
   ============================================================================= */

.terminal {
    position: relative;
    height: 100%;
    padding: 40px 60px;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    
    /* Subtle glow effect */
    text-shadow: 0 0 8px var(--phosphor-glow);
}

/* =============================================================================
   Output Area
   ============================================================================= */

.output {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    
    /* Scroll styling */
    scrollbar-width: thin;
    scrollbar-color: var(--phosphor-dim) transparent;
}

.output::-webkit-scrollbar {
    width: 4px;
}

.output::-webkit-scrollbar-track {
    background: transparent;
}

.output::-webkit-scrollbar-thumb {
    background: var(--phosphor-dim);
    border-radius: 2px;
}

/* =============================================================================
   Message Styling
   ============================================================================= */

.message {
    margin-bottom: 1.5em;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

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

.message-speaker {
    font-weight: 600;
    margin-bottom: 0.25em;
    letter-spacing: 0.05em;
}

.message-content {
    padding-left: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Speaker colors */
.message.user .message-speaker {
    color: var(--phosphor-bright);
}

.message.user .message-speaker::before {
    content: "» ";
    opacity: 0.6;
}

.message.cabin .message-speaker {
    color: var(--cabin);
}

.message.cabin .message-content {
    color: var(--cabin);
}

.message.aspect-0 .message-speaker { color: var(--aspect-1); }
.message.aspect-1 .message-speaker { color: var(--aspect-2); }
.message.aspect-2 .message-speaker { color: var(--aspect-3); }

/* =============================================================================
   Banner & Special Elements
   ============================================================================= */

.banner {
    color: var(--phosphor-dim);
    margin-bottom: 2em;
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

.banner-title {
    font-size: 1.4em;
    font-weight: 600;
    letter-spacing: 0.3em;
    margin-bottom: 0.5em;
}

.banner-subtitle {
    opacity: 0.7;
    font-style: italic;
}

.divider {
    color: var(--phosphor-dim);
    opacity: 0.4;
    margin: 1.5em 0;
    letter-spacing: 0.5em;
}

.aspects-list {
    margin: 1em 0;
}

.aspects-list .aspect-item {
    padding-left: 1em;
    margin-bottom: 0.3em;
}

.aspects-list .aspect-item::before {
    content: "• ";
    opacity: 0.6;
}

.commands-help {
    margin: 1em 0;
    opacity: 0.6;
    font-size: 0.9em;
}

.commands-help div {
    padding-left: 1em;
}

/* =============================================================================
   Input Line
   ============================================================================= */

.input-line {
    display: flex;
    align-items: center;
    padding: 1em 0;
    border-top: 1px solid var(--black-lighter);
}

.prompt {
    color: var(--phosphor-bright);
    font-weight: 600;
    margin-right: 0.75em;
    flex-shrink: 0;
}

#input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--phosphor);
    font-family: inherit;
    font-size: inherit;
    caret-color: var(--phosphor);
}

#input::placeholder {
    color: var(--phosphor-dim);
    opacity: 0.3;
}

/* Custom blinking cursor (hidden, using native) */
.cursor {
    display: none;
}

/* =============================================================================
   Typewriter Effect
   ============================================================================= */

.typing {
    overflow: hidden;
}

.typing .char {
    opacity: 0;
    animation: typeChar 0.01s forwards;
}

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

/* =============================================================================
   Loading Indicator
   ============================================================================= */

.loading {
    color: var(--phosphor-dim);
    opacity: 0.6;
}

.loading::after {
    content: "...";
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* =============================================================================
   Discovery Mode
   ============================================================================= */

.discovery-question {
    color: var(--cabin);
    margin-bottom: 1em;
}

.discovery-progress {
    color: var(--phosphor-dim);
    opacity: 0.5;
    font-size: 0.85em;
    margin-bottom: 0.5em;
}

.discovery-hint {
    color: var(--phosphor-dim);
    opacity: 0.4;
    font-size: 0.8em;
    font-style: italic;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

/* =============================================================================
   Scenario Mode
   ============================================================================= */

.scenario-narration {
    color: var(--cabin);
    margin-bottom: 1.5em;
    padding: 1em 0;
    border-left: 2px solid var(--black-lighter);
    padding-left: 1.5em;
}

.scenario-choices {
    margin: 1em 0;
}

.scenario-choice {
    padding: 0.3em 0;
    padding-left: 1em;
    color: var(--phosphor);
    opacity: 0.8;
}

.scenario-choice:hover {
    opacity: 1;
}

.scenario-choice .choice-key {
    color: var(--phosphor-bright);
    font-weight: 600;
}

/* =============================================================================
   Aspect Details Panel
   ============================================================================= */

.aspect-detail {
    margin-bottom: 2em;
    padding-bottom: 1em;
    border-bottom: 1px solid var(--black-lighter);
}

.aspect-detail:last-child {
    border-bottom: none;
}

.aspect-detail-name {
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 0.5em;
}

.aspect-detail-desc {
    opacity: 0.8;
    margin-bottom: 0.5em;
}

.aspect-detail-meta {
    font-size: 0.85em;
    opacity: 0.6;
}

/* =============================================================================
   Proposals Display
   ============================================================================= */

.proposal {
    margin: 1.5em 0;
    padding: 1em 0;
    border-bottom: 1px solid var(--black-lighter);
}

.proposal-name {
    font-weight: 600;
    letter-spacing: 0.15em;
    margin-bottom: 0.75em;
}

.proposal-desc {
    margin-bottom: 0.75em;
    opacity: 0.9;
}

.proposal-voice {
    font-style: italic;
    opacity: 0.7;
    padding-left: 1em;
    border-left: 2px solid var(--phosphor-dim);
}

/* =============================================================================
   Error State
   ============================================================================= */

.error {
    color: #ff6b6b;
    opacity: 0.9;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .terminal {
        padding: 20px 25px;
    }
    
    :root {
        --font-size: 14px;
    }
}

@media (max-width: 480px) {
    .terminal {
        padding: 15px 15px;
    }
    
    :root {
        --font-size: 13px;
    }
}

/* =============================================================================
   Selection
   ============================================================================= */

::selection {
    background: var(--phosphor);
    color: var(--black);
}

/* =============================================================================
   Focus States
   ============================================================================= */

#input:focus {
    outline: none;
}

/* Ensure the terminal feels alive */
.terminal::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--phosphor-glow),
        transparent
    );
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { top: 0; opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { top: 100%; opacity: 0; }
}

