@font-face {
    font-family: 'Px437';
    src: url('fonts/Perfect DOS VGA 437 Win.ttf') format('truetype');
}

/* ── Base ─────────────────────────────────────────── */

body {
    margin: 0;
    padding: 0;
    background: #001;
    color: #00ff00;
    font-family: 'Px437', monospace;
    font-size: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    flex-direction: column;
}

/* ── Scene Layout ─────────────────────────────────── */

.scene {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    max-width: 1200px;
    width: 100%;
    padding: 100px 20px 20px;
    box-sizing: border-box;
    flex: 1;
}

/* ── Monitor ──────────────────────────────────────── */

.monitor {
    width: 55%;
    max-width: 700px;
    background: #928e71;
    border: 30px solid #e7e7bc;
    padding: 30px;
    border-radius: 24px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
    position: relative;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin 0.6s ease;
}

.crt {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    border: 5px solid #333;
    border-radius: 8px;
    box-shadow: 0 0 30px #00ff00, inset 0 0 10px #00ff00;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.crt::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 255, 0, 0.1),
        rgba(0, 255, 0, 0.1) 2px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
    mix-blend-mode: normal;
    z-index: 10;
    animation: scanline 0.1s infinite;
}

@keyframes scanline {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

/* ── Monitor Chin ────────────────────────────────── */

.monitor-chin {
    background: #e7e7bc;
    margin: 30px -30px -30px;
    padding: 24px 30px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

/* ── Cart Slot (drive bay in chin) ───────────────── */

.cart-slot {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 20;
}

.cart-slot-opening {
    width: 110px;
    height: 4px;
    background: #0a0a0a;
    border-radius: 1px;
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.9),
        0 1px 0 rgba(255, 255, 255, 0.08);
    border: 1px solid #5a5640;
    position: relative;
    z-index: 25;
}

.cart-slot.receiving .cart-slot-opening {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 12px #00ff00, 0 0 24px #00ff00;
    border-color: #00ff00;
}

/* ── Monitor Badge ───────────────────────────────── */

.monitor-badge {
    display: flex;
    align-items: center;
    gap: 6px;
}

.monitor-logo {
    flex-shrink: 0;
}

.monitor-name {
    font-size: 10px;
    color: #6a6652;
    letter-spacing: 2px;
    font-family: 'Px437', monospace;
}

/* ── Screen / Terminal ────────────────────────────── */

.screen {
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

.terminal {
    padding-bottom: 20px;
    overflow-x: hidden;
    width: 100%;
    scrollbar-width: none;
}

.terminal::-webkit-scrollbar {
    display: none;
}

.input-line {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.input-line span {
    margin-right: 5px;
}

input {
    background: transparent;
    border: none;
    outline: none;
    color: #00ff00;
    font-family: 'Px437', monospace;
    font-size: 25px;
    caret-color: #00ff00;
}

.clickable {
    color: #00ff00;
    cursor: pointer;
    text-decoration: underline;
    animation: clickable-pulse 2s ease-in-out infinite;
}

.clickable:hover {
    color: #ff00ff;
    text-shadow: 0 0 8px #ff00ff;
    animation: none;
}

@keyframes clickable-pulse {
    0%, 100% { text-shadow: 0 0 4px #00ff00; }
    50% { text-shadow: 0 0 14px #00ff00, 0 0 24px rgba(0, 255, 0, 0.4); }
}

/* ── Cartridge Case ───────────────────────────────── */

.shelf {
    width: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateX(40px);
    pointer-events: none;
    transition: width 0.6s ease, opacity 0.6s ease, transform 0.6s ease, margin-left 0.6s ease;
    position: relative;
    flex-shrink: 0;
    margin-left: 0;
}

.shelf.active {
    width: 30%;
    opacity: 1;
    overflow: visible;
    transform: translateX(0);
    pointer-events: all;
    margin-left: 40px;
}

.case-body {
    background: linear-gradient(180deg, #d8d4c0 0%, #c8c4ae 30%, #bbb7a0 100%);
    border-radius: 8px;
    position: relative;
    box-shadow:
        3px 3px 0 #9e9a86,
        -1px -1px 0 #eae7d6,
        0 6px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Molded plastic texture */
.case-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.015) 2px,
            rgba(0, 0, 0, 0.015) 4px
        );
    pointer-events: none;
    z-index: 1;
}

/* Thick molded rim at top */
.case-rim {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 14px 20px;
    background: linear-gradient(180deg, #d8d4c0 0%, #ccc8b2 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
}

.case-led {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #2a2a2a;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.shelf.active .case-led {
    background: #ff2200;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.2),
        0 0 4px #ff2200,
        0 0 10px rgba(255, 34, 0, 0.4);
    animation: led-pulse 2s ease-in-out infinite;
}

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

/* Recessed tray well */
.case-tray {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-end;
    padding: 24px 20px 28px;
    margin: 0 12px 16px;
    gap: 12px;
    background: linear-gradient(180deg, #b8b4a0, #c0bca8);
    border-radius: 4px;
    box-shadow:
        inset 0 2px 6px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 2;
}

/* ── Cartridge Visuals ────────────────────────────── */

.cartridge {
    cursor: pointer;
    transition: transform 0.3s ease;
    flex: 1;
    display: flex;
    justify-content: center;
}

.cartridge:focus {
    outline: 2px solid #00ff00;
    outline-offset: 4px;
    border-radius: 4px;
}

.cart-body {
    width: 100%;
    max-width: 120px;
    height: 160px;
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 50%, #222 100%);
    border-radius: 8px 8px 2px 2px;
    position: relative;
    box-shadow:
        2px 0 0 #444,
        -2px 0 0 #111,
        0 4px 8px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.cart-grip {
    width: 100%;
    height: 20px;
    background: repeating-linear-gradient(
        90deg,
        #3a3a3a,
        #3a3a3a 3px,
        #2e2e2e 3px,
        #2e2e2e 6px
    );
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.cart-label {
    width: 75%;
    height: 70px;
    margin-top: 6px;
    background: #ddd;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.cart-label-art {
    width: 100%;
    height: 100%;
    background-size: 200%;
    background-position: center 30%;
    background-repeat: no-repeat;
}

.cart-title {
    font-family: 'Px437', monospace;
    font-size: 10px;
    color: #aaa;
    text-align: center;
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
}

.cart-pins {
    width: 66%;
    height: 14px;
    margin-top: auto;
    margin-bottom: 2px;
    background: repeating-linear-gradient(
        90deg,
        #b8962e,
        #b8962e 4px,
        #222 4px,
        #222 6px
    );
    border-radius: 0 0 2px 2px;
    flex-shrink: 0;
}

/* Hover — cartridge lifts out of the slot */
.cartridge:hover {
    transform: translateY(-18px);
}

.cartridge:hover .cart-body {
    box-shadow:
        2px 0 0 #444,
        -2px 0 0 #111,
        0 8px 16px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(0, 255, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Dimmed state for non-selected cartridges */
.cartridge.dimmed {
    filter: brightness(0.4);
    pointer-events: none;
}

/* ── Flight Animation ─────────────────────────────── */

.cart-flying {
    position: fixed;
    z-index: 1000;
    will-change: transform;
    pointer-events: none;
}

.cart-inserted {
    position: absolute;
    /* top set dynamically by JS */
    left: 50%;
    transform: translateX(-50%);
    clip-path: inset(0 0 82% 0);
    z-index: 19;
    pointer-events: none;
}

/* ── CRT Flicker ──────────────────────────────────── */

@keyframes crt-flicker {
    0%   { opacity: 1; }
    10%  { opacity: 0.3; }
    20%  { opacity: 1; }
    30%  { opacity: 0.5; }
    40%  { opacity: 1; }
    55%  { opacity: 0.2; }
    65%  { opacity: 1; }
    80%  { opacity: 0.6; }
    100% { opacity: 1; }
}

.crt.flickering .screen {
    animation: crt-flicker 0.5s ease-in-out;
}

/* ── Boot Progress Bar ────────────────────────────── */

.boot-progress-bar {
    width: 80%;
    height: 14px;
    background: #111;
    border: 1px solid #00ff00;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.boot-progress-fill {
    height: 100%;
    width: 0%;
    background: #00ff00;
    transition: width 1.2s linear;
}

/* ── Footer ───────────────────────────────────────── */

footer {
    width: 100%;
    background: #111;
    color: #00ff00;
    text-align: center;
    padding: 20px 0;
}

footer .footer-content a {
    color: #00ff00;
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.3s ease;
}

footer .footer-content a:hover {
    color: #ff00ff;
}

/* ── Touch devices ────────────────────────────────── */

@media (hover: none) {
    .cartridge:hover {
        transform: none;
    }

    .cartridge:hover .cart-body {
        box-shadow:
            2px 0 0 #444,
            -2px 0 0 #111,
            0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }

    .cartridge:active {
        transform: scale(0.95);
    }

    .cartridge:active .cart-body {
        box-shadow:
            2px 0 0 #444,
            -2px 0 0 #111,
            0 2px 4px rgba(0, 0, 0, 0.6),
            0 0 15px rgba(0, 255, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
}

/* ── Responsive (< 1024px) — small desktop / tablet ─ */

@media (max-width: 1024px) {
    .monitor {
        border-width: 24px;
        padding: 24px;
    }

    .monitor-chin {
        margin: 24px -24px -24px;
        padding: 12px 24px 16px;
    }

    .shelf.active {
        width: 35%;
        margin-left: 24px;
    }
}

/* ── Responsive (< 768px) — large phone ─────────── */

@media (max-width: 768px) {
    .scene {
        flex-direction: column;
        padding: 30px 10px 10px;
    }

    .monitor {
        width: 90%;
        border-width: 18px;
        padding: 18px;
        flex-shrink: 1;
    }

    .shelf {
        transform: translateY(30px);
    }

    .shelf.active {
        width: 85%;
        margin-left: 0;
        margin-top: 20px;
        transform: translateY(0);
    }

    .case-rim {
        padding: 12px 16px;
    }

    .case-tray {
        padding: 20px 16px 24px;
        margin: 0 10px 14px;
    }

    .monitor-chin {
        margin: 18px -18px -18px;
        padding: 10px 18px 12px;
        gap: 10px;
    }

    .cart-slot-opening {
        width: 90px;
    }

    .monitor-name {
        font-size: 9px;
        letter-spacing: 1.5px;
    }

    .monitor-logo {
        width: 12px;
        height: 12px;
    }

    .cart-body {
        max-width: 100px;
        height: 135px;
    }

    .cart-label {
        height: 55px;
    }

    footer {
        position: relative;
    }

    input {
        font-size: 18px;
    }

    body {
        font-size: 18px;
    }
}

/* ── Responsive (< 480px) — small phone ──────────── */

@media (max-width: 480px) {
    .monitor {
        width: 95%;
        border-width: 12px;
        padding: 12px;
    }

    .shelf.active {
        width: 90%;
    }

    .case-rim {
        padding: 10px 14px;
    }

    .case-tray {
        padding: 16px 12px 20px;
        margin: 0 8px 12px;
        gap: 8px;
    }

    .monitor-chin {
        margin: 12px -12px -12px;
        padding: 8px 12px 10px;
        gap: 6px;
    }

    .cart-slot-opening {
        width: 70px;
    }

    .monitor-name {
        font-size: 8px;
        letter-spacing: 1px;
    }

    .monitor-logo {
        width: 10px;
        height: 10px;
    }

    .cart-body {
        max-width: 90px;
        height: 120px;
    }

    .cart-label {
        height: 48px;
    }

    .cart-title {
        font-size: 8px;
    }

    .screen {
        padding: 10px;
    }

    body {
        font-size: 15px;
    }

    input {
        font-size: 15px;
    }

    footer {
        padding: 12px 0;
        font-size: 13px;
    }
}
