/* ============================================================================
   Project:     SpaceInvaders
   File:        app.css
   Description: Global styles for the Space Invaders Blazor WebAssembly
                application, including arcade cabinet panel, touch controls,
                and responsive/mobile layouts
   Author:      James Booth
   Created:     2024
   License:     MIT License - See LICENSE file in the project root
   Copyright:   (c) 2024-2026 James Booth
   Notice:      Space Invaders is (c) 1978 Taito Corporation.
                This emulator is for educational purposes only.
   ============================================================================ */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #000;
    font-family: 'Courier New', monospace;
    color: #fff;
    overflow-x: hidden;
    overflow-y: auto;
}

#app {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    flex-direction: column;
}

.loading {
    text-align: center;
    color: #0f0;
}

.loading .invader-icon {
    margin-bottom: 1.5rem;
}

.loading h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.startup-error {
    color: #ff6b6b;
}

.sound-warning {
    color: #ffd700;
}

.game-container {
    --game-width: 604.8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    outline: none;
}

.copyright-label {
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    color: #888;
    margin: 0;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('../Cabinet.webp');
    background-size: 100% 100%;
    background-position: center;
}

/* Vertical CRT scanlines: 1px dark stripe every 3px. */
.canvas-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        to right,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 2;
}

.pause-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    letter-spacing: 8px;
    text-shadow: 0 0 20px #fff, 0 0 40px rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
    z-index: 3;
}

#gameCanvas {
    display: block;
    border: 2px solid #333;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: var(--game-width);
    height: 691.2px;
    mix-blend-mode: screen;
}

.credit-hint,
.controls-hint {
    font-size: 0.85rem;
    color: #888;
    text-align: center;
    letter-spacing: 1px;
    line-height: 1.6;
}

.credit-hint {
    margin-top: 6px;
    margin-bottom: 0;
}

.controls-hint {
    margin-top: -12px;
}

.credit-key {
    color: #ffd700;
    text-shadow: 0 0 5px #ffd700;
}

.arrow-text {
    font-size: 1.6rem;
}

#blazor-error-ui {
    background: #800;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
    margin-left: 10px;
}

/* ============================================
   ON-SCREEN TOUCH CONTROLS
   ============================================ */

#touch-controls-top,
#touch-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: var(--game-width);
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#touch-controls-top {
    margin-bottom: 6px;
}

#touch-controls {
    margin-top: 10px;
}

.touch-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.touch-row-direction {
    justify-content: center;
    gap: 80px;
}

/* --- Direction buttons --- */

.direction-controls {
    flex: none;
    width: 45%;
    display: flex;
    gap: 16px;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    height: 56px;
}

.touch-btn.touch-dir {
    height: 100%;
    font-size: 1.3rem;
}
.touch-btn.touch-fire {
    flex: none;
    width: 20%;
    font-size: 1.2rem;
    color: #ff4444;
    border-color: rgba(255, 68, 68, 0.4);
    background: rgba(255, 68, 68, 0.15);
}

/* --- Buttons --- */

.touch-btn {
    flex: 1;
    height: 56px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    background: rgba(0, 255, 0, 0.15);
    color: #0f0;
    border: 2px solid rgba(0, 255, 0, 0.4);
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.05s;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(0, 255, 0, 0.45);
    border-color: #0f0;
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.5);
}

.touch-btn.touch-fire:active,
.touch-btn.touch-fire.active {
    background: rgba(255, 68, 68, 0.45);
    border-color: #ff4444;
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.5);
}

.touch-btn.touch-action {
    font-size: 0.9rem;
    height: 44px;
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 215, 0, 0.1);
}

.touch-btn.touch-action:active,
.touch-btn.touch-action.active {
    background: rgba(255, 215, 0, 0.35);
    border-color: #ffd700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* ============================================
   RESPONSIVE / MOBILE STYLES
   ============================================ */

@media (max-width: 700px) {
    #app {
        min-height: 100dvh; /* Dynamic viewport height for mobile */
        padding: 2vw;
        box-sizing: border-box;
    }
    
    .game-container {
        --game-width: min(86.4vw, 604.8px);
        width: 100%;
        max-width: 96vw;
    }
    
    #gameCanvas {
        height: calc(86.4vw * 1.143);
        max-height: 691.2px;
    }

    .touch-btn.touch-dir {
        height: 50px;
    }

    .touch-btn {
        height: 50px;
        font-size: 1rem;
    }

    .touch-btn.touch-action {
        height: 40px;
        font-size: 0.8rem;
    }
    
    .credit-hint,
    .controls-hint {
        display: none;
    }
    
    .loading .invader-icon {
        width: 35vw;
        max-width: 180px;
        height: auto;
    }
    
    .loading h1 {
        font-size: 5vw;
    }
    
    .loading p {
        font-size: 3vw;
    }
    
    .copyright-label {
        font-size: 0.51rem; /* 40% smaller than default 0.85rem */
    }
}
