/* ═══════════════════════════════════════════════════
   ЛАБОРАТОРИЯ "ОШИБКА 404" — Cyberpunk x Fallout UI
   Pip-Boy meets underground lab terminal
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

:root {
    --bg-dark: #000a0f;
    --bg-terminal: #0a0f0a;
    --bg-card: #0d1a0d;
    --bg-card-hover: #122012;
    --neon-green: #00ff41;
    --neon-green-dim: #00cc33;
    --neon-blue: #00d4ff;
    --neon-pink: #ff0066;
    --neon-yellow: #ffcc00;
    --neon-red: #ff3333;
    --text-primary: #00ff41;
    --text-secondary: #00aa2a;
    --text-muted: #005518;
    --text-white: #ccffcc;
    --border: #003300;
    --border-bright: #00ff41;
    --scanline: rgba(0, 255, 65, 0.03);
    --radius: 2px;
    /* Fallout amber accents */
    --amber: #ffaa00;
    --amber-dim: #aa7700;
    --rust: #8b4513;
    --radiation: #ccff00;
}

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

body {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

/* ── Scanlines overlay ── */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        var(--scanline) 2px,
        var(--scanline) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* ── CRT flicker ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
    z-index: 9998;
    animation: flicker 0.15s infinite alternate;
}

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

/* ── Screens ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════
   INTRO VIDEO — Full screen
   ═══════════════════════════════════════ */

#screen-intro {
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
}

.intro-video {
    width: 100%;
    height: 100vh;
    object-fit: cover;
}

.skip-btn {
    position: absolute;
    bottom: 40px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    padding: 8px 16px;
    cursor: pointer;
    letter-spacing: 2px;
    z-index: 10;
    animation: fadeIn 1s 2s both;
}

.skip-btn:active {
    background: var(--neon-green);
    color: #000;
}

/* ═══════════════════════════════════════
   BACKGROUND VIDEO — Behind terminal
   ═══════════════════════════════════════ */

.bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.15;
    filter: saturate(0.5) brightness(0.4);
}

.bg-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0,10,0,0.7) 0%, rgba(0,0,0,0.95) 100%);
}

/* ═══════════════════════════════════════
   WELCOME — Terminal Boot Sequence
   ═══════════════════════════════════════ */

#screen-welcome {
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
}

.welcome-bg {
    position: absolute; inset: 0;
    overflow: hidden;
}

/* Matrix rain effect via gradient */
.welcome-bg::after {
    content: '';
    position: absolute; inset: 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(0,255,65,0.02) 50%, transparent 100%);
    animation: matrix-scroll 3s linear infinite;
}

@keyframes matrix-scroll {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

.neon-ring, .ring-2 { display: none; }

.welcome-content {
    position: relative; z-index: 1;
    text-align: left;
    width: 100%; max-width: 400px;
    border: 1px solid var(--border);
    padding: 24px;
    background: rgba(0, 10, 0, 0.9);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.1), inset 0 0 20px rgba(0, 255, 65, 0.02);
}

/* Pip-Boy terminal header */
.welcome-content::before {
    content: '☢ VAULT-TEC TERMINAL v4.04 | LAB_404';
    display: block;
    font-size: 0.65rem;
    color: var(--amber);
    border-bottom: 1px solid var(--amber-dim);
    padding-bottom: 8px;
    margin-bottom: 16px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(255, 170, 0, 0.2);
}

/* Corner decorations — vault-tec style */
.welcome-content::after {
    content: 'RAD LEVEL: LOW ▰▰▰▱▱▱▱';
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.55rem;
    color: var(--neon-green);
    letter-spacing: 1px;
    opacity: 0.5;
}

/* ── Glitch effect ── */
.glitch {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green), 0 0 40px rgba(0, 255, 65, 0.3);
    position: relative;
    animation: glitch-anim 4s infinite;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

.glitch::before {
    color: var(--neon-pink);
    animation: glitch-1 0.3s infinite;
    clip-path: inset(20% 0 60% 0);
}

.glitch::after {
    color: var(--neon-blue);
    animation: glitch-2 0.3s infinite;
    clip-path: inset(60% 0 10% 0);
}

@keyframes glitch-1 {
    0%, 90% { transform: translate(0); }
    92% { transform: translate(-3px, 1px); }
    94% { transform: translate(3px, -1px); }
    96% { transform: translate(-1px, 2px); }
    100% { transform: translate(0); }
}

@keyframes glitch-2 {
    0%, 90% { transform: translate(0); }
    91% { transform: translate(2px, -1px); }
    93% { transform: translate(-2px, 1px); }
    95% { transform: translate(1px, -2px); }
    100% { transform: translate(0); }
}

@keyframes glitch-anim {
    0%, 85%, 100% { opacity: 1; }
    86% { opacity: 0.8; transform: skewX(-2deg); }
    87% { opacity: 1; transform: skewX(0); }
    92% { opacity: 0.9; transform: skewX(1deg); }
    93% { opacity: 1; transform: skewX(0); }
}

.tagline {
    font-size: 0.75rem;
    letter-spacing: 6px;
    color: var(--neon-pink);
    margin: 4px 0 20px;
    text-shadow: 0 0 10px var(--neon-pink);
}

/* Boot text */
.boot-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

.boot-text .loaded {
    color: var(--neon-green);
}

.boot-text .warning {
    color: var(--neon-yellow);
}

.boot-text .error {
    color: var(--neon-red);
}

/* ── Forms — Terminal style ── */
.cyber-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-terminal);
    border: 1px solid var(--border);
    border-left: 3px solid var(--neon-green);
    color: var(--text-primary);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    margin-bottom: 10px;
    outline: none;
    transition: all 0.3s;
    -webkit-appearance: none;
    border-radius: 0;
}

.cyber-input::placeholder {
    color: var(--text-muted);
}

.cyber-input:focus {
    border-color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.15);
    background: rgba(0, 255, 65, 0.03);
}

select.cyber-input {
    cursor: pointer;
    color: var(--text-primary);
}

select.cyber-input option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

textarea.cyber-input { resize: none; font-family: inherit; }

/* ── Buttons ── */
.cyber-btn {
    padding: 12px 20px;
    border: 1px solid var(--border);
    background: var(--bg-terminal);
    color: var(--text-primary);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-radius: 0;
    position: relative;
    overflow: hidden;
}

.cyber-btn:active { transform: scale(0.97); }

.cyber-btn.primary {
    background: transparent;
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.15);
}

.cyber-btn.primary::before {
    content: '> ';
}

.cyber-btn.primary:not(:disabled):active {
    background: var(--neon-green);
    color: var(--bg-dark);
    text-shadow: none;
}

.cyber-btn.primary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.cyber-btn.glow {
    animation: btn-pulse 2s ease-in-out infinite;
}

@keyframes btn-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 255, 65, 0.15); }
    50% { box-shadow: 0 0 20px rgba(0, 255, 65, 0.3), 0 0 40px rgba(0, 255, 65, 0.1); }
}

.bill-type {
    display: flex; gap: 6px;
    margin-bottom: 12px;
}

.bill-btn {
    flex: 1;
    padding: 10px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
}

.bill-btn.active {
    border-color: var(--neon-green);
    color: var(--neon-green);
    background: rgba(0, 255, 65, 0.05);
}

.welcome-form .primary { width: 100%; margin-top: 8px; }

/* ═══════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-terminal);
    border-bottom: 2px solid var(--amber-dim);
    position: sticky; top: 0; z-index: 10;
    box-shadow: 0 2px 10px rgba(255, 170, 0, 0.05);
}

/* Pip-Boy status line under top bar */
.top-bar::after {
    content: '▰▰▰▰▰▰▰▰▱▱ HP: OK | AP: 12 | CAPS: --';
    position: absolute;
    bottom: -14px;
    left: 0; right: 0;
    font-size: 0.5rem;
    color: var(--amber-dim);
    text-align: center;
    letter-spacing: 1px;
    opacity: 0.4;
    pointer-events: none;
}

.logo-sm {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
    letter-spacing: 2px;
}

.table-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border: 1px solid var(--neon-pink);
    color: var(--neon-pink);
    letter-spacing: 1px;
}

.cart-btn {
    background: none; border: none; cursor: pointer;
    position: relative;
    font-size: 1.2rem;
    color: var(--neon-green);
}

.cart-count {
    position: absolute; top: -6px; right: -8px;
    background: var(--neon-pink);
    color: #fff; font-size: 0.65rem; font-weight: 700;
    width: 16px; height: 16px;
    display: flex; justify-content: center; align-items: center;
}

.back-btn {
    background: none; border: none;
    color: var(--neon-green); font-size: 1.2rem;
    cursor: pointer;
    font-family: 'Share Tech Mono', monospace;
}

/* ═══════════════════════════════════════
   CATEGORY TILES — Big buttons grid
   ═══════════════════════════════════════ */

.cat-tiles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 12px 100px;
}

.cat-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--amber-dim);
    padding: 18px 14px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
    animation: fadeIn 0.3s ease-out both;
}

.cat-tile:active {
    border-left-color: var(--neon-green);
    background: rgba(0, 255, 65, 0.05);
}

.cat-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 100%;
    background: linear-gradient(90deg, rgba(0,255,65,0.08), transparent);
    transition: width 0.3s;
}

.cat-tile:active::before {
    width: 100%;
}

/* Random glitch on some tiles */
.cat-tile:nth-child(4n+1) {
    animation: fadeIn 0.3s ease-out both, item-glitch-subtle 10s 2s infinite;
}

.cat-tile-icon {
    font-size: 1.4rem;
    margin-bottom: 6px;
}

.cat-tile-name {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: var(--neon-green);
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.3;
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.2);
}

.cat-tile-count {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Old horizontal chips — hidden now but kept for future */
.categories { display: none; }

/* ═══════════════════════════════════════
   MENU GRID — Terminal list style
   ═══════════════════════════════════════ */

.menu-grid {
    padding: 8px 16px 100px;
    display: flex; flex-direction: column;
    gap: 8px;
}

/* Pip-Boy style category header */
.cat-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 8px 16px 4px;
    border-bottom: 1px dashed var(--amber-dim);
    margin-bottom: 4px;
    text-shadow: 0 0 5px rgba(255, 170, 0, 0.3);
}

.cat-header::before {
    content: '[ ';
    color: var(--amber-dim);
}

.cat-header::after {
    content: ' ]';
    color: var(--amber-dim);
}

/* Radiation meter decoration */
.rad-meter {
    display: flex;
    gap: 2px;
    padding: 4px 16px 8px;
}

.rad-bar {
    height: 3px;
    flex: 1;
    background: var(--border);
    transition: background 0.3s;
}

.rad-bar.active {
    background: var(--neon-green);
    box-shadow: 0 0 4px var(--neon-green);
}

.rad-bar.warning {
    background: var(--amber);
    box-shadow: 0 0 4px var(--amber);
}

.rad-bar.danger {
    background: var(--neon-red);
    box-shadow: 0 0 4px var(--neon-red);
}

.menu-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-muted);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.menu-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 100%;
    background: linear-gradient(90deg, rgba(0,255,65,0.05), transparent);
    transition: width 0.3s;
}

.menu-card:active::before {
    width: 100%;
}

.menu-card:active {
    border-left-color: var(--neon-green);
}

/* Glitch on scroll — random cards get effect */
.menu-card:nth-child(3n)::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 95%, rgba(255,0,102,0.1) 100%);
    animation: card-glitch 8s infinite;
    pointer-events: none;
}

@keyframes card-glitch {
    0%, 95%, 100% { opacity: 0; transform: translateX(0); }
    96% { opacity: 1; transform: translateX(-2px); }
    97% { opacity: 0.5; transform: translateX(3px); }
    98% { opacity: 1; transform: translateX(-1px); }
    99% { opacity: 0; transform: translateX(0); }
}

.item-info { flex: 1; margin-right: 12px; }

.item-name {
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text-white);
    font-size: 0.9rem;
}

.item-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.item-price {
    color: var(--neon-green);
    font-weight: 700;
    font-size: 0.95rem;
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.3);
}

.add-btn {
    width: 36px; height: 36px;
    border: 1px solid var(--neon-green);
    background: transparent;
    color: var(--neon-green);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex; justify-content: center; align-items: center;
    font-family: 'Share Tech Mono', monospace;
}

.add-btn:active {
    background: var(--neon-green);
    color: var(--bg-dark);
}

/* ═══════════════════════════════════════
   WAITER FAB
   ═══════════════════════════════════════ */

.waiter-fab {
    position: fixed;
    bottom: 16px; left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--neon-pink);
    color: var(--neon-pink);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 5;
    transition: all 0.3s;
    text-shadow: 0 0 5px var(--neon-pink);
    box-shadow: 0 0 15px rgba(255, 0, 102, 0.2);
    animation: fab-pulse 3s ease-in-out infinite;
}

@keyframes fab-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 0, 102, 0.2); }
    50% { box-shadow: 0 0 25px rgba(255, 0, 102, 0.4); }
}

.waiter-fab:active {
    background: var(--neon-pink);
    color: #fff;
    text-shadow: none;
}

/* ═══════════════════════════════════════
   CART
   ═══════════════════════════════════════ */

.cart-list {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 600; font-size: 0.85rem; color: var(--text-white); }
.cart-item-price { color: var(--text-secondary); font-size: 0.75rem; margin-top: 2px; }

.qty-controls {
    display: flex; align-items: center; gap: 10px;
}

.qty-btn {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--neon-green);
    font-size: 1rem;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    font-family: 'Share Tech Mono', monospace;
}

.qty-btn:active { border-color: var(--neon-green); background: rgba(0,255,65,0.1); }
.qty-value { font-weight: 700; min-width: 20px; text-align: center; color: var(--text-white); }

.cart-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-terminal);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 10px 0;
}

.cart-total span:last-child {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.cart-footer .primary { width: 100%; }

.cart-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════
   DONE SCREEN
   ═══════════════════════════════════════ */

#screen-done {
    justify-content: center;
    align-items: center;
}

.done-content {
    text-align: center;
    padding: 20px;
    border: 1px solid var(--border);
    background: var(--bg-terminal);
    margin: 20px;
    max-width: 380px;
}

.done-content::before {
    content: '☢ TASK COMPLETE — XP GAINED';
    display: block;
    font-size: 0.7rem;
    color: var(--amber);
    border-bottom: 1px solid var(--amber-dim);
    padding-bottom: 8px;
    margin-bottom: 16px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(255, 170, 0, 0.2);
}

.done-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    animation: done-pulse 1s ease-in-out;
}

@keyframes done-pulse {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.done-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--neon-green);
    text-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    letter-spacing: 2px;
}

.done-hint {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.8rem;
}

.done-content .primary { padding: 12px 30px; }

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.cursor::after {
    content: '_';
    animation: blink 1s step-end infinite;
    color: var(--neon-green);
}

/* Pixel dissolve on transition */
@keyframes pixelate {
    0% { filter: none; opacity: 1; }
    30% { filter: contrast(2) brightness(1.5); opacity: 0.8; }
    60% { filter: contrast(3) brightness(2); opacity: 0.4; }
    100% { filter: none; opacity: 0; }
}

.dissolving {
    animation: pixelate 0.4s forwards;
}

@keyframes materialize {
    0% { filter: contrast(3) brightness(2); opacity: 0; transform: translateY(5px); }
    50% { filter: contrast(1.5) brightness(1.2); opacity: 0.7; }
    100% { filter: none; opacity: 1; transform: translateY(0); }
}

.materializing {
    animation: materialize 0.4s ease-out;
}

/* Random glitch on items */
.menu-card:nth-child(5n+2) {
    animation: fadeIn 0.3s ease-out, item-glitch-subtle 12s 3s infinite;
}

@keyframes item-glitch-subtle {
    0%, 98%, 100% { transform: translate(0); filter: none; }
    98.5% { transform: translate(-2px, 0); filter: hue-rotate(90deg); }
    99% { transform: translate(2px, 1px); filter: hue-rotate(-90deg); }
    99.5% { transform: translate(-1px, -1px); filter: hue-rotate(45deg); }
}

/* ═══════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════ */

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--text-muted); }
::-webkit-scrollbar-thumb:hover { background: var(--neon-green); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 360px) {
    .glitch { font-size: 1.1rem; }
    .tagline { font-size: 0.65rem; letter-spacing: 4px; }
}
