/* ============================================================================
   UMBROSUS — Stilus (Styles)
   ============================================================================ */

/* -- Font Faces ------------------------------------------------------------- */

@font-face {
    font-family: 'VT323';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/acta/litterae/vt323.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+0100-024F, U+0259, U+1E00-1EFF, U+2000-206F,
                   U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
                   U+FEFF, U+FFFD, U+2020, U+20A0-20CF, U+2113;
}

/* -- Reset ------------------------------------------------------------------ */

*, *::before, *::after {
    box-sizing: border-box;
}

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

/* -- Theme Variables -------------------------------------------------------- */

:root,
[data-theme="amber"] {
    --t-fg:        #c4a674;
    --t-bg:        #232323;
    --t-glow:      rgba(196, 166, 116, 0.4);
    --t-cursor:    #c4a674;
    --t-link:      #82caff;
    --t-error:     #cc5555;
    --t-dim:       #665e4a;
    --t-bold:      #e0cc9a;
    --t-highlight: #d4b684;
    --t-selection: #c4a674;
    --t-selbg:     rgba(196, 166, 116, 0.25);
    --t-logo-filter: sepia(1) saturate(2) brightness(0.8) hue-rotate(5deg);
}

[data-theme="green"] {
    --t-fg:        #33ff33;
    --t-bg:        #0a0a0a;
    --t-glow:      rgba(51, 255, 51, 0.35);
    --t-cursor:    #33ff33;
    --t-link:      #66ffcc;
    --t-error:     #ff4444;
    --t-dim:       #227722;
    --t-bold:      #66ff66;
    --t-highlight: #44dd44;
    --t-selection: #33ff33;
    --t-selbg:     rgba(51, 255, 51, 0.2);
    --t-logo-filter: sepia(1) saturate(10) brightness(0.6) hue-rotate(75deg);
}

[data-theme="white"] {
    --t-fg:        #d0d0d0;
    --t-bg:        #1a1a1a;
    --t-glow:      rgba(255, 255, 255, 0.2);
    --t-cursor:    #ffffff;
    --t-link:      #82caff;
    --t-error:     #ff5555;
    --t-dim:       #666666;
    --t-bold:      #ffffff;
    --t-highlight: #cccccc;
    --t-selection: #ffffff;
    --t-selbg:     rgba(255, 255, 255, 0.2);
    --t-logo-filter: grayscale(1) brightness(0.8);
}

/* -- Body ------------------------------------------------------------------- */

body {
    font-family: 'VT323', monospace;
    font-size: 22px;
    line-height: 1.4;
    color: var(--t-fg);
    background: var(--t-bg);
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('/acta/imago/backe.png') no-repeat center center;
    background-size: 20%;
    filter: var(--t-logo-filter);
    mix-blend-mode: exclusion;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

/* -- Selection -------------------------------------------------------------- */

::selection {
    color: var(--t-selection);
    background: var(--t-selbg);
}

::-moz-selection {
    color: var(--t-selection);
    background: var(--t-selbg);
}

/* -- Terminal Container ----------------------------------------------------- */

.terminal {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    padding: 12px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* -- Output Area ------------------------------------------------------------ */

.terminal-output {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.terminal-output .line {
    min-height: 1.4em;
}

/* -- Scrollbar -------------------------------------------------------------- */

.terminal-output::-webkit-scrollbar {
    width: 6px;
}

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

.terminal-output::-webkit-scrollbar-thumb {
    background: var(--t-dim);
    border-radius: 3px;
}

.terminal-output::-webkit-scrollbar-thumb:hover {
    background: var(--t-fg);
}

.terminal-output {
    scrollbar-width: thin;
    scrollbar-color: var(--t-dim) transparent;
}

/* -- Input Line ------------------------------------------------------------- */

.terminal-input {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    min-height: 1.4em;
    line-height: 1.4;
    flex-wrap: wrap;
}

.terminal-input .prompt {
    white-space: pre;
    color: var(--t-fg);
    flex-shrink: 0;
}

.terminal-input .input-text,
.terminal-input .input-after {
    white-space: pre-wrap;
    word-break: break-all;
}

/* -- Cursor ----------------------------------------------------------------- */

.cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.2em;
    background: var(--t-cursor);
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

.cursor.no-blink {
    animation: none;
}

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

/* -- Text Styles ------------------------------------------------------------ */

.t-bold {
    color: var(--t-bold);
    font-weight: bold;
}

.t-highlight {
    color: var(--t-highlight);
}

.t-dim {
    color: var(--t-dim);
}

.t-error {
    color: var(--t-error);
}

.t-link {
    color: var(--t-link);
    text-decoration: none;
    cursor: pointer;
}

.t-link:hover {
    text-decoration: underline;
    color: var(--t-highlight);
}

/* -- Hidden Clipboard ------------------------------------------------------- */

.clipboard {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0.01;
}

/* -- Emulator (v86) Styles -------------------------------------------------- */

.emulator-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9995;
    display: flex;
    flex-direction: column;
}

.emulator-screen {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.emulator-screen.pointer-locked {
    cursor: none;
}

.v86-container {
    width: 100%;
    height: 100%;
}

.v86-container canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.emulator-controls {
    height: 48px;
    background: #111;
    border-top: 1px solid var(--t-dim);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 16px;
    gap: 12px;
}

.emu-btn {
    background: var(--t-bg);
    color: var(--t-error);
    border: 1px solid var(--t-error);
    font-family: 'VT323', monospace;
    font-size: 18px;
    padding: 4px 12px;
    cursor: pointer;
    text-transform: uppercase;
}

.emu-btn:hover {
    background: var(--t-error);
    color: #000;
}

.emu-mouse-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.82);
    color: #ccc;
    font-family: 'VT323', monospace;
    font-size: 16px;
    padding: 8px 20px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    transition: opacity 0.25s ease;
}

.emu-mouse-hint.hidden {
    opacity: 0;
}

.emu-mouse-hint kbd {
    display: inline-block;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    padding: 1px 6px;
    font-family: 'VT323', monospace;
    font-size: 15px;
    color: #fff;
    margin: 0 2px;
}

/* -- Quake II Overlay ------------------------------------------------------- */

.quake-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9995;
    overflow: hidden;
}

.quake-status-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    color: #888;
    font-family: Arial, sans-serif;
    font-size: 14px;
    text-align: center;
}

.quake-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #1a1a1a;
    border-top-color: #555;
    border-radius: 50%;
    animation: quake-spin 0.8s linear infinite;
}

@keyframes quake-spin {
    to { transform: rotate(360deg); }
}

.quake-status-text {
    margin-top: 16px;
    color: #888;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.quake-progress {
    width: 240px;
    margin-top: 12px;
}

.quake-canvas {
    display: none;
    background: #000;
    border: 0;
    outline: none;
}

.quake-output {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% - 16px);
    height: calc(100% - 48px - 16px);
    margin: 8px;
    padding: 8px;
    font-family: monospace;
    font-size: 13px;
    color: #888;
    background: #000;
    border: 1px solid #222;
    resize: none;
    outline: none;
}

.quake-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #111;
    border-top: 1px solid var(--t-dim);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 16px;
    gap: 12px;
    z-index: 3;
}

/* -- CRT Effect ------------------------------------------------------------- */

.crt {
    position: relative;
}

.crt::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 9999;
}

.crt::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    z-index: 9998;
}

/* -- Responsive ------------------------------------------------------------- */

@media (max-width: 600px) {
    body {
        font-size: 16px;
    }

    body::after {
        background-size: 50%;
    }

    .terminal {
        padding: 8px;
    }
}

@media (max-width: 400px) {
    body {
        font-size: 14px;
    }

    body::after {
        background-size: 60%;
    }
}

/* -- Typing Animation ------------------------------------------------------- */

.typing-cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.2em;
    background: var(--t-cursor);
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

/* -- Matrix Rain (Easter Egg) ----------------------------------------------- */

.matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9990;
    pointer-events: none;
}

/* -- Flash Effect (Konami) -------------------------------------------------- */

.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--t-fg);
    z-index: 10000;
    pointer-events: none;
    animation: flash-fade 2s ease-out forwards;
}

@keyframes flash-fade {
    0%   { opacity: 0.8; }
    100% { opacity: 0; }
}

.terminal.inverted {
    filter: invert(1);
}