/**
 * Text Adventure Terminal Interface Styles
 * Classic green-on-black terminal appearance
 */

#text-adventure-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
}

#text-adventure-window {
    width: 80%;
    height: 70%;
    max-width: 900px;
    max-height: 600px;
    min-width: 600px;
    min-height: 400px;
    background: #000;
    border: 2px solid #00ff00;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}

#ta-header {
    background: #003300;
    color: #00ff00;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #00ff00;
    font-weight: bold;
    user-select: none;
}

#ta-title {
    font-size: 14px;
}

#ta-close {
    background: none;
    border: none;
    color: #00ff00;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s;
}

#ta-close:hover {
    background: #00ff00;
    color: #000;
}

#ta-output {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    color: #00ff00;
    background: #000;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-align: left;
}

#ta-output::-webkit-scrollbar {
    width: 12px;
}

#ta-output::-webkit-scrollbar-track {
    background: #001100;
    border-radius: 6px;
}

#ta-output::-webkit-scrollbar-thumb {
    background: #003300;
    border-radius: 6px;
}

#ta-output::-webkit-scrollbar-thumb:hover {
    background: #00ff00;
}

#ta-output .command {
    color: #ffff00;
    font-weight: bold;
}

#ta-output .title {
    color: #00ffff;
    font-weight: bold;
    font-size: 16px;
}

#ta-output .error {
    color: #ff6600;
}

#ta-output .success {
    color: #00ff00;
    font-weight: bold;
}

#ta-input-container {
    display: flex;
    align-items: center;
    background: #000;
    border-top: 1px solid #00ff00;
    padding: 8px 12px;
}

#ta-prompt {
    color: #00ff00;
    font-weight: bold;
    margin-right: 8px;
    user-select: none;
}

#ta-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #00ff00;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    caret-color: #00ff00;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Prevent zoom on focus on iOS */
    font-size: 16px;
    transform-origin: left;
    transform: scale(0.875);
}

#ta-input::placeholder {
    color: #006600;
    opacity: 0.7;
}

/* Terminal cursor effect */
#ta-input:focus {
    box-shadow: none;
}


/* Responsive design */

/* Large screens (desktops) */
@media (min-width: 1200px) {
    #text-adventure-window {
        width: 70%;
        height: 65%;
        max-width: 1000px;
        max-height: 700px;
    }
}

/* Medium screens (tablets landscape) */
@media (max-width: 1199px) and (min-width: 992px) {
    #text-adventure-window {
        width: 85%;
        height: 75%;
        max-width: 900px;
        max-height: 600px;
    }
}

/* Small tablets and landscape phones */
@media (max-width: 991px) and (min-width: 768px) {
    #text-adventure-window {
        width: 90%;
        height: 80%;
        min-width: 500px;
        max-width: 700px;
        min-height: 400px;
        max-height: 500px;
    }

    #ta-output {
        font-size: 13px;
        padding: 10px;
    }

    #ta-input {
        font-size: 13px;
    }
}

/* Mobile devices (portrait tablets and large phones) */
@media (max-width: 767px) and (min-width: 481px) {
    #text-adventure-window {
        width: 95%;
        height: 85%;
        min-width: 320px;
        max-width: none;
        min-height: 400px;
        max-height: none;
        border-radius: 4px;
    }

    #ta-header {
        padding: 6px 10px;
        font-size: 13px;
    }

    #ta-output {
        font-size: 12px;
        padding: 8px;
        line-height: 1.3;
    }

    #ta-input-container {
        padding: 6px 10px;
    }

    #ta-input {
        font-size: 12px;
    }

    #ta-close {
        width: 20px;
        height: 20px;
        font-size: 16px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    #text-adventure-overlay {
        padding: 5px;
    }

    #text-adventure-window {
        width: 100%;
        height: 95%;
        min-width: 280px;
        max-width: none;
        min-height: 300px;
        max-height: none;
        border-radius: 0;
        border: 1px solid #00ff00;
    }

    #ta-header {
        padding: 8px;
        font-size: 12px;
    }

    #ta-title {
        font-size: 12px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        max-width: calc(100% - 30px);
    }

    #ta-output {
        font-size: 11px;
        padding: 6px;
        line-height: 1.2;
    }

    #ta-input-container {
        padding: 6px 8px;
    }

    #ta-input {
        font-size: 11px;
    }

    #ta-prompt {
        margin-right: 4px;
    }

    #ta-close {
        width: 18px;
        height: 18px;
        font-size: 14px;
    }
}

/* Landscape orientation adjustments for mobile */
@media (max-width: 767px) and (orientation: landscape) {
    #text-adventure-window {
        height: 90%;
        max-height: 90vh;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #text-adventure-window {
        border-width: 1px;
    }
}

/* Mobile-specific enhancements */
@media (max-width: 767px) {
    /* Prevent body scroll when terminal is open */
    body.text-adventure-active {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    /* Better touch targets */
    #ta-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Adjust for virtual keyboard */
    #text-adventure-overlay {
        padding: 0;
    }

    /* Input adjustments for mobile */
    #ta-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
        transform: none;
        -webkit-user-select: text;
        user-select: text;
    }

    /* Scrollbar adjustments for mobile */
    #ta-output::-webkit-scrollbar {
        width: 8px;
    }

    #ta-output::-webkit-scrollbar-thumb {
        background: #004400;
    }

    /* Prevent text selection on mobile except in input */
    #text-adventure-window * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    #ta-input, #ta-output {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 767px) {
        #text-adventure-window {
            /* Account for iOS Safari UI chrome */
            height: calc(95% - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        }

        #ta-input {
            /* Prevent zoom on focus */
            font-size: 16px;
            transform: scale(1);
        }
    }
}

/* Animation for window appearance */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#text-adventure-window {
    animation: slideIn 0.3s ease-out;
}

/* Scan line effect for authentic terminal feel */
#ta-output::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        transparent 0%,
        rgba(0, 255, 0, 0.03) 50%,
        transparent 100%
    );
    background-size: 100% 4px;
    animation: scan 0.1s linear infinite;
    pointer-events: none;
}

@keyframes scan {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}