/* ═══════════════════════════════════════════════════════════════════
   CRT DOS MENU — Main Stylesheet
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
    --bg: #000080;
    --text: #00FF00;
    --highlight: #FFFF00;
    --menu-bg: #000000;
    --menu-border: #00FF00;
    --menubar-bg: #008080;
    --menubar-text: #FFFFFF;
    --selected-bg: #00AA00;
    --selected-text: #000000;
    --key-color: #FF5555;
    --clock-color: #00FF00;
    --clock-bg: #003300;
    --glow-intensity: 8px;
    --scanline-opacity: 0.15;
    --curvature: 3px;
    --flicker-intensity: 0.03;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'VT323', monospace;
}

/* ─── CRT Monitor Frame ─────────────────────────────────────────── */
.crt-monitor {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
}

.crt-bezel {
    position: relative;
    width: 92%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
    border-radius: 20px;
    background: #2a2a2a;
    padding: 20px;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.5),
        0 0 20px rgba(0,0,0,0.8),
        0 5px 15px rgba(0,0,0,0.6);
}

.crt-screen-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.crt-screen {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── CRT Curvature Effect ───────────────────────────────────────── */
.crt-curvature .crt-screen-wrapper {
    /* Simulated slight barrel distortion */
    border-radius: 18px / 16px;
}
.crt-curvature .crt-screen-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    box-shadow:
        inset 0 0 60px rgba(0,0,0,0.4),
        inset 0 0 120px rgba(0,0,0,0.2);
    z-index: 100;
    pointer-events: none;
}

/* ─── Scanlines ──────────────────────────────────────────────────── */
.crt-scanlines .crt-screen::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(0, 0, 0, var(--scanline-opacity)) 1px,
        rgba(0, 0, 0, var(--scanline-opacity)) 2px
    );
    z-index: 90;
    pointer-events: none;
    animation: scanline-scroll 10s linear infinite;
}

@keyframes scanline-scroll {
    0% { background-position: 0 0; }
    100% { background-position: 0 100px; }
}

/* ─── Screen Reflection / Glare ──────────────────────────────────── */
.crt-reflection .crt-screen-wrapper::after {
    content: '';
    position: absolute;
    top: -10%;
    left: -20%;
    width: 80%;
    height: 60%;
    background: radial-gradient(
        ellipse at center,
        rgba(255,255,255,0.06) 0%,
        transparent 70%
    );
    transform: rotate(-15deg);
    z-index: 95;
    pointer-events: none;
}

/* ─── Flicker ────────────────────────────────────────────────────── */
.crt-flicker .crt-screen {
    animation: flicker 0.15s infinite alternate;
}

@keyframes flicker {
    0% { opacity: 1; }
    100% { opacity: calc(1 - var(--flicker-intensity)); }
}

/* ─── Text Glow ──────────────────────────────────────────────────── */
.crt-glow .crt-screen {
    text-shadow: 0 0 var(--glow-intensity) currentColor;
}

/* ─── Chromatic Aberration ───────────────────────────────────────── */
.crt-chromatic .menu-item-name,
.crt-chromatic .menu-title {
    text-shadow:
        -1px 0 rgba(255,0,0,0.3),
        1px 0 rgba(0,255,255,0.3);
}

/* ─── Noise ──────────────────────────────────────────────────────── */
.crt-noise .crt-screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    z-index: 80;
    pointer-events: none;
    animation: noise-shift 0.5s steps(5) infinite;
}

@keyframes noise-shift {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-1px, 1px); }
    40% { transform: translate(1px, -1px); }
    60% { transform: translate(-1px, -1px); }
    80% { transform: translate(1px, 1px); }
    100% { transform: translate(0, 0); }
}

/* ─── Menu Bar (DOS style top bar) ───────────────────────────────── */
.menu-bar {
    display: flex;
    align-items: center;
    background: var(--menubar-bg);
    color: var(--menubar-text);
    font-size: 18px;
    padding: 2px 0;
    min-height: 32px;
    position: relative;
    z-index: 50;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.menu-bar-left {
    display: flex;
    align-items: center;
    gap: 0;
}

.menu-bar-item {
    padding: 4px 14px;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    user-select: none;
}

.menu-bar-item:hover,
.menu-bar-item.active {
    background: var(--selected-bg);
    color: var(--selected-text);
}

.menu-bar-item .hotkey {
    color: var(--highlight);
    text-decoration: underline;
}

.menu-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 10px;
}

/* ─── Dropdown Menu ──────────────────────────────────────────────── */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--menu-bg);
    border: 2px solid var(--menu-border);
    min-width: 220px;
    z-index: 200;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    padding: 4px 16px;
    cursor: pointer;
    color: var(--text);
    white-space: nowrap;
    font-size: 17px;
}

.dropdown-item:hover,
.dropdown-item.selected {
    background: var(--selected-bg);
    color: var(--selected-text);
}

.dropdown-divider {
    border-top: 1px solid var(--menu-border);
    margin: 2px 0;
}

/* ─── Digital Clock ──────────────────────────────────────────────── */
.digital-clock {
    font-family: 'VT323', monospace;
    font-size: 18px;
    color: var(--clock-color);
    background: var(--clock-bg);
    padding: 2px 10px;
    border: 1px solid var(--clock-color);
    letter-spacing: 2px;
}

/* ─── Main Content Area ──────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 10;
}

/* ─── Title Area ─────────────────────────────────────────────────── */
.menu-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 22px;
    color: var(--highlight);
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: 3px;
}

.menu-subtitle {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 24px;
    text-align: center;
    opacity: 0.7;
}

/* ─── Menu Box ───────────────────────────────────────────────────── */
.menu-box {
    border: 3px double var(--menu-border);
    background: rgba(0, 0, 0, 0.6);
    padding: 12px 30px;
    min-width: 450px;
    max-width: 600px;
    position: relative;
}

.menu-box-title {
    position: absolute;
    top: -12px;
    left: 16px;
    background: var(--bg);
    padding: 0 8px;
    color: var(--menu-border);
    font-size: 16px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 22px;
    color: var(--text);
    transition: none;
    user-select: none;
}

.menu-item:hover,
.menu-item.selected {
    background: var(--selected-bg);
    color: var(--selected-text);
}

.menu-item.selected .menu-item-key {
    color: var(--selected-text);
}

.menu-item-key {
    color: var(--key-color);
    font-weight: bold;
    min-width: 30px;
    margin-right: 16px;
    font-size: 22px;
}

.menu-item-name {
    flex: 1;
}

.menu-item-admin {
    font-size: 14px;
    color: var(--key-color);
    opacity: 0.6;
    margin-left: 10px;
}

/* ─── Bottom Status Bar ──────────────────────────────────────────── */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--menubar-bg);
    color: var(--menubar-text);
    font-size: 16px;
    padding: 4px 10px;
    min-height: 28px;
    border-top: 2px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
    gap: 20px;
    z-index: 50;
}

.status-bar span {
    opacity: 0.9;
}

.status-bar .key {
    color: var(--highlight);
    font-weight: bold;
}

/* ─── Login Modal ────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 300;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: var(--menu-bg);
    border: 3px double var(--menu-border);
    padding: 20px 30px;
    min-width: 360px;
    color: var(--text);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}

.modal-title {
    font-size: 20px;
    color: var(--highlight);
    margin-bottom: 16px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
}

.modal-input {
    width: 100%;
    background: #001a00;
    border: 1px solid var(--menu-border);
    color: var(--text);
    font-family: 'VT323', monospace;
    font-size: 20px;
    padding: 8px 12px;
    outline: none;
    margin-bottom: 14px;
}

.modal-input:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 8px var(--text);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    background: var(--menubar-bg);
    color: var(--menubar-text);
    border: 1px solid var(--menu-border);
    font-family: 'VT323', monospace;
    font-size: 18px;
    padding: 6px 24px;
    cursor: pointer;
}

.modal-btn:hover {
    background: var(--selected-bg);
    color: var(--selected-text);
}

.modal-error {
    color: var(--key-color);
    font-size: 16px;
    text-align: center;
    margin-bottom: 10px;
    min-height: 20px;
}

/* ─── Startup animation ─────────────────────────────────────────── */
.startup-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 500;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 30px;
    font-size: 18px;
    color: var(--text);
    overflow: hidden;
}

.startup-overlay.hidden {
    display: none;
}

.startup-line {
    opacity: 0;
    white-space: pre;
}

.startup-line.visible {
    opacity: 1;
}

.startup-cursor {
    display: inline-block;
    width: 10px;
    height: 18px;
    background: var(--text);
    animation: blink-cursor 0.6s step-end infinite;
    vertical-align: middle;
}

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

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .crt-bezel {
        width: 98%;
        height: 95%;
        padding: 8px;
        border-radius: 10px;
    }
    .menu-box {
        min-width: 90%;
        padding: 10px 14px;
    }
    .menu-title {
        font-size: 14px;
    }
    .menu-item {
        font-size: 18px;
    }
    .menu-bar {
        font-size: 14px;
    }
}

/* ─── Power LED ──────────────────────────────────────────────────── */
.power-led {
    position: absolute;
    bottom: 8px;
    right: 30px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff00;
    box-shadow: 0 0 6px #00ff00, 0 0 12px #00ff00;
    animation: led-pulse 3s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
