/* ============================================
   TERMINAL ECHO - STYLES
   ============================================ */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #FFB000; /* green: 33FF00*/ /* amber: #FFB000;*/
    --color-bg-dark: #0f0b00; /*green 0a180a*/ /*amber: #0f0b00*/
    --color-bg-darker: #222;
    --color-bg-light: #ffcf661c; /*rgba(0, 255, 0, 0.1);*/
    --color-border: var(--color-primary);
    --color-text: var(--color-primary);
    --color-text-inverse: #000;
    --color-disabled: #030;
    
    --font-primary: 'VT323', monospace;
    --font-size-base: 30px;
    --text-shadow: 0 0 10px #ffb000; /* amber glow: #ffe3a6;*/
    --scan-line-color: rgba(255, 176, 0, 0); /* scanning line gradient start */
    --scan-line-color-mid: rgba(255, 176, 0, 0.08); /* scanning line gradient middle */
    --scan-line-color-end: rgba(255, 176, 0, 0.15); /* scanning line gradient end */
    
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    
    --transition-fast: 0.1s;
}

body {
    background: var(--color-bg-darker);
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    text-shadow: var(--text-shadow);
    color: var(--color-text);
    /*overflow:  scroll;*/
    /* cursor: none; */
    user-select: none;
    letter-spacing: 1px;
}

/* === TERMINAL CONTAINER === */
.terminal-container {
    display: flex;
    justify-content: center;
    align-items: top;
    /*min-height: 100vh;*/
    height: 100vh;
    padding: var(--spacing-lg);
}

.terminal-frame {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    padding: var(--spacing-md);
    border: 5px solid #000;
    border-radius: 15px;
    background: var(--color-bg-dark);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 15px var(--color-primary);
    position: relative;
    overflow: hidden;
}

/* CRT Effects: pixel grain */
.terminal-frame::before {
    content: '';
    position: absolute;
    top:  0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), 
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 10;
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;

    animation: flicker 0.8s infinite;
}

/* CRT Effects: scanning line */
.terminal-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(
        to bottom,
        var(--scan-line-color) 0%,
        var(--scan-line-color-mid) 50%,
        var(--scan-line-color-end) 100%
    );
    pointer-events: none;
    z-index: 11;
    animation: scan 8s linear infinite;
}

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

@keyframes scan {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

.terminal-border {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: var(--spacing-lg);
    border: 2px solid var(--color-primary);
}

/* === LAYOUT SECTIONS === */
.terminal-header {
    height: 60px;
    flex-shrink: 0;
    padding: var(--spacing-md) 2px;
    border-bottom: 2px solid var(--color-border);
}

.terminal-header.hidden {
    display: none;
}

.terminal-body {
    flex: 1;
    padding:  var(--spacing-md) 0;
    overflow-y:  scroll;
    cursor: default;
}

.terminal-footer {
    height: 150px;
    flex-shrink: 0;
    flex-direction: column-reverse;
    margin-bottom: 0; /* Remove the default bottom margin */
    border-top: 2px solid var(--color-border);
    padding: var(--spacing-md);
    overflow-y:  scroll;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) var(--color-bg-darker);
}

/* === STATUS BAR === */
.terminal-status {
    font-size: var(--font-size-base);
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    user-select: none;
}

.status-left,
.status-right {
    display: flex;
    gap: var(--spacing-lg);
}

/* HP Low Warning */
.hp-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.hp-display.hp-low {
    color: #ff3333;
    text-shadow: 0 0 10px #ff3333;
}

.hp-pulse-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ff3333;
    box-shadow: 0 0 8px #ff3333;
    animation: hpPulse 1s ease-in-out infinite;
}

@keyframes hpPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Location Unlock Indicator */
.location-pulse-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
    animation: locationPulse 1s ease-in-out infinite;
    vertical-align: middle;
    margin-left: 4px;
}

@keyframes locationPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* === SCREEN BASE === */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    user-select: none;
    cursor: default;
}

.screen.active {
    display: flex;
}

.screen-title {
    font-size:  var(--font-size-base);
    font-weight: bold;
    margin-bottom: var(--spacing-lg);
    text-align: center;
    padding: var(--spacing-md);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    letter-spacing: 2px;
}

.screen-description {
    background: var(--color-bg-light);
    border: 1px solid var(--color-border);
    margin-bottom: var(--spacing-lg);
    line-height: 1.4;
    padding: var(--spacing-md);
    text-align: center;
}

/* === MENU COMPONENT === */
.menu-list {
    list-style: none;
    margin: var(--spacing-lg) 0;
}

.menu-item {
    padding: var(--spacing-sm);
    /* margin: 5px 0; */
    transition: all var(--transition-fast);
    cursor: pointer !important;
    font-size: var(--font-size-base);
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    touch-action: manipulation;
}

.menu-item:hover {
    cursor: pointer !important;
    background: var(--color-bg-light);
}

.menu-item.focused {
    cursor: pointer !important;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    /*font-weight: bold;*/
}

.menu-item.focused::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid var(--color-text-inverse);
}

.menu-item.disabled {
    opacity: 0.4;
    /* cursor: not-allowed; */
}

.menu-item.disabled:hover {
    background: none;
}

.menu-item-label {
    flex: 1;
    padding-left: var(--spacing-lg);
    cursor: pointer !important;
}

.menu-item-hotkey {
    margin-left: var(--spacing-sm);;
    opacity: 0.7;
}

.menu-item-value {
    margin-left: var(--spacing-lg);;
    font-weight: bold;
}

/* === MENU ITEM TYPES === */

/* Separator - compact delimiter */
.menu-item.type-separator {
    padding: 0 0 0 calc(var(--spacing-md)*2);
    margin: 0px;
    min-height: auto;
    height: auto;
    cursor: default;
    font-size: 10px;
}

.menu-item.type-separator:hover {
    background: none;
}

.menu-item.type-separator.focused {
    background: none;
    color: var(--color-text);
}

.menu-item.type-separator.focused::before {
    display: none;
}

.menu-separator-content {
    opacity: 0.5;
    font-size: calc(var(--font-size-base) * 0.85);
    letter-spacing: 2px;
}

/* Attribute Adjuster */
.menu-item.type-attribute {
    justify-content: space-between;
}

.attribute-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.attribute-button {
    color: var(--color-primary);
    border: 0px solid;
    background: none;
    font-size: var(--font-size-base);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-primary);
}

.menu-item.focused .attribute-button {
    color: var(--color-text-inverse);
    border-color: var(--color-text-inverse);
}

/*.attribute-button:hover {
    background: var(--color-disabled);
}
*/

.attribute-value {
    font-size: var(--font-size-base);
    min-width: 50px;
    text-align: center;
}

/* Input Field */
.menu-item.type-input .input-field {
    width: 100%;
    max-width: 600px;
    /*padding: var(--spacing-sm);*/
    background: var(--color-bg-dark);
    border: 2px solid var(--color-border);
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
}

.menu-item.type-input .input-field:focus {
    outline: none;
    background: var(--color-bg-dark);
    box-shadow: 0 0 10px var(--color-primary);
}


/* === TRADING === */
/* === !!! CURRENTLY NOT IN USE === */
.two-columns-layout {
    display: flex;
    justify-content: space-between;
    gap: 2ch;
    width: 100%;
    /*border-top: 1px solid var(--primary-color);
    border-bottom: 1px solid var(--primary-color);*/
    padding: 1em 0;
}

.column {
    width: 50%;
    border: 1px solid var(--primary-color);
}

/* On smaller screens */
@media (max-width: 600px) {
    .two-columns-layout {
        flex-direction: column;
    }
    .column {
        width: 100%;
    }
}


/* === EVENT LOG === */
.event-log {
    height: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    font-size: var(--font-size-base);
    line-height: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) var(--color-bg-darker);
    text-indent: -1. 5em;
    padding-left: 1. 5em;
}

.event-log::-webkit-scrollbar {
    width: 6px;
}

/* 
.event-log::-webkit-scrollbar-track {
    background: var(--color-disabled);
}

.event-log::-webkit-scrollbar-thumb {
    background: var(--color-disabled); 
}

.event-log-entry {
    margin-bottom: 2px;
}

.event-log-entry:first-child {
    margin-top: 0;
}

.event-log-entry.type-system {
    color: var(--color-primary);
}

.event-log-entry.type-dialogue {
    color: var(--color-primary);
}

.event-log-entry.type-error {
    color: var(--color-primary);
}

/* === UTILITY CLASSES === */
.hidden {
    display: none ! important;
}

.text-center {
    text-align: center;
}

.text-success {
    color: var(--color-primary);
}

.text-warning {
    color: #ff3;
}

.text-error {
    color: #f33;
}

/* --- POPUP STYLES --- */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 0;
}

.popup-content {
    background-color: var(--color-bg-dark);
    border: 2px solid var(--color-primary);
    padding: var(--spacing-md);
    max-width: 80%;
    text-align: center;
    box-shadow: inset 0 0 10px var(--color-primary);
}

/*.popup-title {
    color: #f00; 
    font-size: 2em;
    margin-top: 0;
}

.popup-message {
    color: #ccc;
    margin-bottom: 1.5em;
}

.popup-content .menu-item {
    padding: 0.5em;
}*/


/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .terminal-frame {
        max-width: 100%;
    }
}

/* Small height screens (e.g., Chromebooks) */
@media (max-height: 600px) {
    :root {
        --font-size-base: 26px;
        --spacing-sm: 5px;
        --spacing-md: 10px;
        --spacing-lg: 10px;
    }

    .terminal-header {
        height: 40px;
        /* padding: var(--spacing-sm) 2px; */
    }

    .terminal-footer {
        height: 80px;
        /* padding: var(--spacing-sm); */
    }
}

@media (max-width: 768px) {
    :root {
        --font-size-base: 22px;
        --spacing-sm: 5px;
        --spacing-md: 10px;
        --spacing-lg: 10px;

        /* cursor: pointer; */
        /* user-select: all; */
    }

    .terminal-frame {
        max-height: calc(100vh - 80px); /*space for safari non-hiding address menu*/
    }
    .terminal-frame::before {
        background-size: 100% 3px, 5px 100%;
    }
    .terminal-header {
        height: 40px;
    }
    .terminal-status{
        font-size: 20px;
    }
    .terminal-footer {
        height: 90px;
    }
/*    .screen-title {
        margin-bottom: 10px;
    }
    .screen-description {
        margin-bottom: 10px;
    }



    .status-left,
    .status-right {
        flex-direction:  column;
        gap: 10px;
    }
*/
}


/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity:  0; }
    to { opacity: 1; }
}

.screen.active {
    animation: fadeIn 0.3s ease-in;
}