/* === GAME-DECK.CSS === */
/* =========================================
   GAME DECK PANEL & DOCKING SYSTEM
   ========================================= */

#game-deck-panel {
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    flex-shrink: 0;
    opacity: 0;
    transition:
        width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
        height 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
        opacity 0.2s ease;
    width: 0;
    height: 100%;
    border: none;
}

#game-deck-panel.panel-open {
    opacity: 1;
}

#game-deck-panel.panel-hidden {
    display: none !important;
}

/* =========================================
   WORKSPACE DOCKING POSITIONS
   ========================================= */

/* DOCK: LEFT */
#workspace-flex.pos-left {
    flex-direction: row;
}

#workspace-flex.pos-left #game-deck-panel {
    order: -1;
    width: 360px;
    height: 100%;
    max-height: 100%;
    border-right: 2px solid var(--main-color);
    border-left: none;
    border-top: none;
    border-bottom: none;
}

#workspace-flex.pos-left #panel-resizer {
    order: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

#workspace-flex.pos-left #editor-container {
    order: 1;
    flex: 1 1 auto;
    width: auto;
    height: 100%;
    max-height: 100%;
    min-width: 280px;
}

/* DOCK: RIGHT */
#workspace-flex.pos-right {
    flex-direction: row;
}

#workspace-flex.pos-right #game-deck-panel {
    order: 3;
    width: 360px;
    height: 100%;
    max-height: 100%;
    border-left: 2px solid var(--main-color);
    border-right: none;
    border-top: none;
    border-bottom: none;
}

#workspace-flex.pos-right #panel-resizer {
    order: 2;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

#workspace-flex.pos-right #editor-container {
    order: 1;
    flex: 1 1 auto;
    width: auto;
    height: 100%;
    max-height: 100%;
    min-width: 280px;
}

/* DOCK: TOP */
#workspace-flex.pos-top {
    flex-direction: column;
}

#workspace-flex.pos-top #game-deck-panel {
    order: -1;
    width: 100%;
    height: 320px;
    max-height: 50vh;
    border-bottom: 2px solid var(--main-color);
    border-top: none;
    border-left: none;
    border-right: none;
}

#workspace-flex.pos-top #panel-resizer {
    order: 0;
    width: 100%;
    height: 8px;
    cursor: row-resize;
}

#workspace-flex.pos-top #editor-container {
    order: 1;
    flex: 1 1 auto;
    height: auto;
    min-height: 200px;
}

/* DOCK: BOTTOM */
#workspace-flex.pos-bottom {
    flex-direction: column;
}

#workspace-flex.pos-bottom #game-deck-panel {
    order: 3;
    width: 100%;
    height: 320px;
    max-height: 50vh;
    border-top: 2px solid var(--main-color);
    border-bottom: none;
    border-left: none;
    border-right: none;
}

#workspace-flex.pos-bottom #panel-resizer {
    order: 2;
    width: 100%;
    height: 8px;
    cursor: row-resize;
}

#workspace-flex.pos-bottom #editor-container {
    order: 1;
    flex: 1 1 auto;
    height: auto;
    min-height: 200px;
}

/* Hide resizer when game deck is closed */
#panel-resizer {
    flex: 0 0 auto;
    background: transparent;
    z-index: 50;
    transition: background 0.2s;
}

#panel-resizer:hover,
#panel-resizer.active {
    background: rgba(0, 255, 65, 0.25);
}

#game-deck-panel.panel-hidden ~ #panel-resizer,
#game-deck-panel:not(.panel-open) ~ #panel-resizer {
    display: none !important;
}

/* =========================================
   HEADER NAV DROPDOWN (1-CLICK POSITIONS)
   ========================================= */

.nav-dropdown-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
}

.deck-pos-dropdown-menu {
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    min-width: 190px;
    background: var(--panel-bg);
    border: 1px solid var(--main-color);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 255, 65, 0.15);
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    z-index: 5000;
    animation: dropdownFade 0.15s ease-out;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-dropdown-wrapper:hover .deck-pos-dropdown-menu,
.nav-dropdown-wrapper:focus-within .deck-pos-dropdown-menu,
.deck-pos-dropdown-menu.open {
    display: flex;
}

.deck-dropdown-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: var(--main-color);
    opacity: 0.8;
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--main-color);
    letter-spacing: 0.5px;
}

.deck-pos-btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.deck-pos-btn {
    background: var(--bg-color);
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: 'VT323', monospace;
    font-size: 14px;
    padding: 5px 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-transform: uppercase;
}

.deck-pos-btn:hover {
    background: var(--main-color);
    color: var(--bg-color);
    box-shadow: 0 0 8px var(--main-color);
}

.deck-pos-btn.active {
    background: var(--main-color);
    color: var(--bg-color);
    font-weight: bold;
    box-shadow: 0 0 10px var(--main-color);
}

/* =========================================
   DECK PANEL HEADER & QUICK-DOCK BAR
   ========================================= */

.deck-header {
    padding: 6px 10px;
    border-bottom: 1px solid var(--main-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
    background: var(--header-bg);
    flex-shrink: 0;
    min-height: 34px;
    box-sizing: border-box;
}

.deck-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-wrap: nowrap;
}

.deck-footer {
    border-top: 1px solid var(--main-color);
    border-bottom: none;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    display: flex;
    background: var(--header-bg);
    flex-shrink: 0;
}

.deck-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    white-space: nowrap;
    letter-spacing: 0.5px;
    line-height: 1;
}

.deck-pos-quick-bar {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0;
}

.deck-pos-quick-btn {
    background: var(--bg-color);
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: 'VT323', monospace;
    font-size: 11px;
    padding: 0 4px;
    line-height: 18px;
    height: 20px;
    min-width: 18px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.deck-pos-quick-btn:hover {
    background: var(--main-color);
    color: var(--bg-color);
    box-shadow: 0 0 5px var(--main-color);
}

.deck-pos-quick-btn.active {
    background: var(--main-color);
    color: var(--bg-color);
    font-weight: bold;
}

#btn-close-deck {
    background: transparent;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    width: 20px;
    height: 20px;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin: 0;
    box-sizing: border-box;
}

#btn-close-deck:hover {
    background: #ff0000 !important;
    border-color: #ff0000 !important;
    color: #fff !important;
}

.deck-epilepsy-btn {
    background: transparent;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    font-family: 'VT323', monospace;
    font-size: 12px;
    height: 20px;
    padding: 0 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.deck-epilepsy-btn:hover {
    background: rgba(0, 255, 65, 0.2);
    border-color: #00FF41;
    color: #00FF41;
}

.deck-epilepsy-btn.active {
    background: #00FF41;
    border-color: #00FF41;
    color: #000;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

@media (max-width: 320px) {
    .deck-header {
        padding: 4px 6px;
        gap: 3px;
    }
    .deck-title {
        font-size: 8.5px;
    }
    .deck-header-actions {
        gap: 2px;
    }
    .deck-pos-quick-btn {
        padding: 0 2px;
        min-width: 16px;
        font-size: 10px;
    }
}

/* Global Photosensitivity / Epilepsy Safe Mode Overrides */
html.epilepsy-safe-mode,
body.epilepsy-safe-mode {
    --flicker-strength: 0 !important;
    --rolling-bar-opacity: 0 !important;
    --jitter-x: 0px !important;
    --jitter-y: 0px !important;
    --aberration-offset: 0px !important;
}

html.epilepsy-safe-mode #crt-flicker-layer,
body.epilepsy-safe-mode #crt-flicker-layer,
html.epilepsy-safe-mode .crt-jitter-active,
body.epilepsy-safe-mode .crt-jitter-active {
    animation: none !important;
    transform: none !important;
    opacity: 0 !important;
}

/* =========================================
   IFRAME & CARTRIDGE CONTROLS
   ========================================= */

.iframe-container {
    flex: 1 1 auto;
    background: #000;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

#game-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

#game-deck-panel button,
#game-select {
    background: var(--bg-color);
    color: var(--main-color);
    border: 1px solid var(--main-color);
    font-family: 'VT323', monospace;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 8px;
}

#game-deck-panel button:hover {
    background: var(--main-color);
    color: var(--bg-color);
}

#btn-stop-game:hover {
    background: #ff0000 !important;
    border-color: #ff0000 !important;
    color: #fff !important;
}

.cart-controls {
    display: flex;
    width: 100%;
    gap: 5px;
}

#game-select {
    flex-grow: 1;
}

.deck-btn-group {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 5px;
}

.deck-btn {
    flex: 1;
    text-align: center;
    padding: 4px 0;
}

.deck-sep {
    color: var(--main-color);
    opacity: 0.5;
    padding: 0 5px;
    display: flex;
    align-items: center;
}

/* Mobile Deck Position Buttons active state */
.deck-pos-m-btn.active,
[data-deck-pos].active {
    background: var(--main-color) !important;
    color: var(--bg-color) !important;
    font-weight: bold;
}