/* ==========================================================================
   RETRO CRT TERMINAL - Shared styles for kildekode.php and terminal.php
   Provides the TV/CRT monitor aesthetic for embedded xterm.js terminals
   ========================================================================== */

/* ── Terminal Container ── */

.kilde-terminal-container {
    background: #0a0e17;
    position: relative;
    z-index: 1;
    width: fit-content;
    height: fit-content;
}

/* Force xterm canvas to capture all pointer events */
.kilde-terminal-container .xterm {
    position: relative;
    z-index: 10;
}

/* Chromatic aberration — slight RGB split on the terminal text */
.kilde-terminal-container .xterm-screen {
    text-shadow:
        0.3px 0 0 rgba(255, 0, 0, 0.06),
        -0.3px 0 0 rgba(0, 100, 255, 0.06);
}

/* xterm scrollbar */
.kilde-terminal-container .xterm-viewport { overflow-y: auto !important; }
.kilde-terminal-container .xterm-viewport::-webkit-scrollbar { width: 6px; }
.kilde-terminal-container .xterm-viewport::-webkit-scrollbar-track { background: transparent; }
.kilde-terminal-container .xterm-viewport::-webkit-scrollbar-thumb { background: rgba(0, 255, 249, 0.15); border-radius: 3px; }
.kilde-terminal-container .xterm-viewport::-webkit-scrollbar-thumb:hover { background: rgba(0, 255, 249, 0.3); }

/* ==========================================================================
   RETRO CRT MONITOR
   ========================================================================== */

.retro-monitor {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    padding: 12px 16px 6px;
}

.retro-monitor-bezel {
    display: flex;
    flex-direction: column;
    width: fit-content;
    max-width: 100%;
    background: linear-gradient(180deg, #3a3a4a 0%, #2a2a38 8%, #222230 50%, #1e1e2c 92%, #2d2d3d 100%);
    border-radius: 12px 12px 8px 8px;
    padding: 10px 12px 0 12px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.06),
        inset 0 1px 0 rgba(255,255,255,0.1),
        inset 0 -1px 0 rgba(0,0,0,0.4),
        0 8px 32px rgba(0,0,0,0.7),
        0 2px 8px rgba(0,0,0,0.5);
    position: relative;
}

/* Model label embossed in top-right */
.retro-monitor-label {
    position: absolute;
    top: 4px;
    right: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.12);
    text-transform: uppercase;
}

.retro-monitor-freq {
    color: rgba(0, 255, 249, 0.15);
    margin-left: 4px;
}

/* Screen inset - the "glass" area */
.retro-monitor-screen {
    display: flex;
    flex-direction: column;
    width: fit-content;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.8),
        inset 0 0 4px rgba(0,0,0,0.9),
        0 0 8px rgba(0, 255, 249, 0.05),
        0 0 30px rgba(0, 255, 249, 0.02);
    border: 2px solid #111118;
}

/* ── CRT EFFECTS ── */

/* CRT effects sit between terminal background and xterm canvas.
   All have pointer-events:none. The .xterm element has z-index:10
   so it captures all mouse/keyboard input above the effects. */

/* Scanlines + RGB sub-pixel rasterization */
.retro-scanlines {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background:
        /* Horizontal scanlines */
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 2px,
            rgba(0, 0, 0, 0.12) 2px,
            rgba(0, 0, 0, 0.12) 3px
        ),
        /* RGB sub-pixel columns (visible on light text) */
        repeating-linear-gradient(
            90deg,
            rgba(255, 0, 0, 0.02) 0px,
            rgba(0, 0, 0, 0) 1px,
            rgba(0, 255, 0, 0.02) 1px,
            rgba(0, 0, 0, 0) 2px,
            rgba(0, 100, 255, 0.02) 2px,
            rgba(0, 0, 0, 0) 3px
        );
}

/* Rolling CRT refresh bar */
.retro-screen-flicker {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background: linear-gradient(
        0deg,
        transparent 0%,
        rgba(255, 255, 255, 0.012) 10%,
        rgba(255, 255, 255, 0.025) 20%,
        transparent 30%
    );
    background-size: 100% 100%;
    animation: crt-roll 6s linear infinite;
}

@keyframes crt-roll {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* Vignette — CRT edge darkening */
.retro-monitor-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    border-radius: inherit;
    background: radial-gradient(
        ellipse at 50% 50%,
        transparent 55%,
        rgba(0, 0, 0, 0.35) 100%
    );
}

/* Glass reflection */
.retro-monitor-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8%;
    right: 55%;
    height: 35%;
    z-index: 5;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(
        160deg,
        rgba(255, 255, 255, 0.03) 0%,
        transparent 50%
    );
}

/* Phosphor glow on screen — green-cyan tinge on the glass */
.retro-monitor-screen {
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.8),
        inset 0 0 4px rgba(0,0,0,0.9),
        0 0 15px rgba(0, 255, 249, 0.04),
        0 0 50px rgba(0, 255, 249, 0.02),
        0 0 100px rgba(0, 255, 200, 0.01);
    border: 2px solid #111118;
}

/* Chin strip — thin bar under screen */
.retro-monitor-chin {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 5px;
    flex-shrink: 0;
}

/* Power LED */
.retro-monitor-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #39ff14;
    box-shadow: 0 0 4px #39ff14, 0 0 8px rgba(57, 255, 20, 0.4);
    animation: led-pulse 3s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px #39ff14, 0 0 8px rgba(57, 255, 20, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 2px #39ff14, 0 0 4px rgba(57, 255, 20, 0.2); }
}

/* Adjustment knobs */
.retro-monitor-controls {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.retro-knob {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3a3a4a 0%, #252535 50%, #1a1a28 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 1px 2px rgba(0,0,0,0.4);
    position: relative;
}

/* Knob indicator line */
.retro-knob::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    width: 1px;
    height: 3px;
    background: rgba(255,255,255,0.15);
    transform: translateX(-50%);
}

/* Ventilation slots */
.retro-monitor-vents {
    margin-left: 12px;
    display: flex;
    gap: 3px;
}

.retro-monitor-vents span {
    display: block;
    width: 12px;
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 1px;
}

/* Right side of chin — theme dots + fullscreen */
.retro-chin-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme color dots */
.retro-theme-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.theme-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s, box-shadow 0.2s, transform 0.15s;
    outline: none;
}

.theme-dot:hover {
    opacity: 0.7;
    transform: scale(1.4);
}

.theme-dot.active {
    opacity: 1;
    box-shadow: 0 0 4px currentColor;
    transform: scale(1.3);
}

/* Theme dot colors */
.theme-dot[data-theme="cyber"]     { background: #00fff9; color: #00fff9; }
.theme-dot[data-theme="dracula"]   { background: #bd93f9; color: #bd93f9; }
.theme-dot[data-theme="matrix"]    { background: #00ff41; color: #00ff41; }
.theme-dot[data-theme="amber"]     { background: #ffb000; color: #ffb000; }
.theme-dot[data-theme="solarized"] { background: #268bd2; color: #268bd2; }

/* Fullscreen button */
.retro-fullscreen-btn {
    background: none;
    border: none;
    padding: 2px;
    color: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: color 0.2s, background 0.2s;
    outline: none;
}

.retro-fullscreen-btn:hover {
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
}

/* CRT power-on effect */
.retro-monitor-screen {
    animation: crt-on 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes crt-on {
    0% {
        filter: brightness(30) saturate(0);
        transform: scaleY(0.005) scaleX(0.8);
        opacity: 1;
    }
    20% {
        filter: brightness(15) saturate(0);
        transform: scaleY(0.005) scaleX(1);
    }
    45% {
        filter: brightness(3) saturate(0.5);
        transform: scaleY(1.05) scaleX(1);
    }
    65% {
        filter: brightness(1.5) saturate(0.8);
        transform: scaleY(0.98) scaleX(1);
    }
    80% {
        filter: brightness(1.1) saturate(1);
        transform: scaleY(1.01) scaleX(1);
    }
    100% {
        filter: brightness(1) saturate(1);
        transform: scaleY(1) scaleX(1);
    }
}

/* Stand */
.retro-monitor-stand {
    width: 60px;
    height: 14px;
    background: linear-gradient(180deg, #2a2a38, #222230);
    border-radius: 0 0 3px 3px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.05),
        0 2px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

/* Base */
.retro-monitor-base {
    width: 180px;
    height: 5px;
    background: linear-gradient(180deg, #2d2d3d, #252535);
    border-radius: 0 0 10px 10px;
    box-shadow:
        0 2px 6px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.05);
    flex-shrink: 0;
}

/* Plaque under the monitor */
.retro-monitor-plaque {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.15);
}

.retro-plaque-brand {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.retro-plaque-sep {
    color: rgba(255, 255, 255, 0.08);
}

.retro-plaque-tech {
    color: rgba(0, 255, 249, 0.2);
}

.retro-plaque-alt {
    color: rgba(57, 255, 20, 0.2);
}

/* ==========================================================================
   FULLSCREEN MODE — monitor fills viewport with space visible at edges
   ========================================================================== */

.retro-terminal-view:fullscreen {
    background: #050508;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    padding: 10px 2%;
}

.retro-terminal-view:fullscreen .retro-monitor {
    flex: 1;
    align-items: stretch;
    padding: 6px 10px 4px;
    max-height: 100%;
    max-width: 100%;
}

.retro-terminal-view:fullscreen .retro-monitor-bezel {
    flex: 1;
    width: 100%;
    max-width: 100%;
}

.retro-terminal-view:fullscreen .retro-monitor-screen {
    flex: 1;
    width: 100%;
}

.retro-terminal-view:fullscreen .kilde-terminal-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* Hide stand/base — not part of the monitor frame */
.retro-terminal-view:fullscreen .retro-monitor-stand,
.retro-terminal-view:fullscreen .retro-monitor-base,
.retro-terminal-view:fullscreen .retro-monitor-plaque,
.retro-terminal-view:fullscreen .retro-monitor-label {
    display: none;
}
