/*
Theme Name: LCARS23
Author: USS Typhon NCC-74930
Description: 23rd Century Bridge Interface for Prometheus Class.
Version: 1.1
*/

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Michroma&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Fjalla+One&display=swap');

:root {
    --primary: #00aaff;
    --btn-bg: #0757A7;
    --secondary: #4CAF50;
    --bg-accent: transparent;
    --border-glow: 0 0 10px rgba(7, 87, 167, 0.3);
    --alert-bg: #000000;
    --border-width: 3px;
}

/* --- ALERT STATES --- */

body.alert-yellow {
    --primary: #CC9900;
    --btn-bg: #886600;
}

body.alert-red {
    --primary: #ff0000;
    --btn-bg: #660000;
    animation: red-pulse-bg 2s infinite ease-in-out;
}

@keyframes red-pulse-bg {
    0%, 100% { background-color: #000000; }
    50% { background-color: #1a0000; }
}

/* --- GLOBAL LAYOUT --- */

body {
    background-color: #000000 !important;
    color: var(--primary);
    font-family: 'Share Tech Mono', monospace;
    overflow-x: hidden !important;
    overflow-y: auto; 
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    transition: all 0.5s ease;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    body {
        overflow: hidden;
        height: 100vh;
    }
}

/* --- TYPOGRAPHY --- */

.font-federation {
    font-family: 'Michroma', sans-serif !important;
    font-weight: 900 !important;
    -webkit-text-stroke: 1.2px var(--primary);
    letter-spacing: -0.01em;
    filter: none !important;
    text-shadow: none !important;
}

@media (max-width: 640px) {
    .font-federation {
        font-size: 1.25rem !important;
        -webkit-text-stroke: 0.8px var(--primary);
    }
}

.ship-tagline {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px !important;
    letter-spacing: 0.25em !important;
    color: var(--primary);
    opacity: 1 !important;
    text-shadow: none !important;
}

/* --- SCROLLBARS --- */

::-webkit-scrollbar {
    width: 8px !important;
    height: 8px !important;
}

::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3) !important; }
::-webkit-scrollbar-thumb { 
    background: var(--primary) !important; 
    border-radius: 10px !important; 
}

#main-frame {
    /* Firefox support */
    scrollbar-width: thin !important; 
    scrollbar-color: var(--primary) rgba(0, 0, 0, 0.3) !important;
    
    /* Layout */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100%;
    box-sizing: border-box;
    border-radius: 0 18px 0 0 !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important; 
}

/* --- MODULES --- */

.kirk-module {
    border: var(--border-width) solid var(--primary) !important;
    transition: border-color 0.4s ease;
    border-radius: 18px;
    background-color: transparent !important;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .kirk-module { border-radius: 12px; }
}

.kirk-module-secondary {
    border: var(--border-width) solid var(--secondary);
    color: var(--secondary);
    background-color: transparent !important;
}

/* --- BUTTONS & MENU --- */

.beeping-button {
    display: flex !important;
    text-decoration: none !important;
    background-color: var(--btn-bg) !important;
    color: #FFFFFF !important;
    cursor: pointer;
    text-transform: uppercase;
    font-family: 'Fjalla One', sans-serif !important;
    padding: 6px 12px;
    border: none !important;
    border-radius: 8px;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.4s ease;
    min-height: 34px;
    height: 34px;
    font-size: 16px;
    box-sizing: border-box;
}

/* Alert-specific button colours */
/* YELLOW ALERT */
body.alert-yellow .submenu-item,
body.alert-yellow .nested-child {
    background-color: #443300 !important;
    border-color: #ffff00 !important;
}

/* RED ALERT */
body.alert-red .submenu-item,
body.alert-red .nested-child {
    background-color: #550000 !important;
    border-color: #ff0000 !important;
    animation: alert-flash 2s infinite;
}

/* Base states to ensure variables are used */
.submenu-item, .nested-child {
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.beeping-button:hover, 
.beeping-button:focus,
.submenu-item:hover,
.active-tab,
.nested-child.active-tab {
    background-color: var(--secondary) !important;
    color: #FFFFFF !important;
    filter: none !important;
}

/* --- SUBMENU ACCORDION LOGIC --- */

.submenu-item {
    display: none !important;
    background-color: var(--btn-bg) !important;
    font-family: 'Fjalla One', sans-serif !important;
    width: 85% !important;
    align-self: flex-end !important;
    font-size: 15px !important;
    padding: 2px 12px;
    min-height: 26px;
    border: none !important;
    margin: 0 !important;
    border-radius: 6px;
}

.submenu-item.is-open,
.nested-child.is-open {
    display: flex !important;
}

body.alert-yellow .submenu-item { background-color: #443300; }
body.alert-red .submenu-item { background-color: #550000; }

.submenu-item:hover {
    background-color: #4CAF50 !important;
    color: #000000 !important;
}

.nested-child {
    width: 75% !important;
    font-size: 13px !important;
    background-color: var(--btn-bg) !important;
}

.nested-child.active-tab {
    background-color: #4CAF50 !important;
    color: #000000 !important;
}

.beeping-button span.material-symbols-outlined {
    line-height: 1;
    display: flex;
    align-items: center;
    font-size: 16px;
}

/* --- SIDEBAR & OVERLAY --- */

#sidebar-nav {
    width: 200px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
    padding: 8px !important;
    border-right: var(--border-width) solid var(--primary) !important;
    transition: border-color 0.4s ease;
    border-radius: 18px 0 0 0 !important;
}
#sidebar-nav div.relative span {
    color: var(--primary) !important;
    transition: color 0.4s ease;
}
.rotate-180 { 
    transform: rotate(180deg); 
}

/* Ensure the container shows its children properly when not hidden */
.lcars-accordion-content:not(.hidden) .submenu-item {
    display: flex !important;
}

/* Ensure the container itself hides when told */
.lcars-accordion-content.hidden {
    display: none !important;
}

/* Animation for borders only */
@keyframes border-fade-red {
    0%, 100% { border-color: #ff0000; }
    50% { border-color: #440000; }
}

@media (max-width: 1023px) {
    #sidebar-nav {
        position: fixed;
        top: 0;
        left: 0;
        /* Force the menu to fill the entire viewport */
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        z-index: 1000;
        background-color: #000000 !important;
        
        /* Ensures 100vw includes the padding so buttons don't clip */
        box-sizing: border-box !important;
        
        /* Start hidden off-screen to the left */
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        
        /* Increased padding for better gutter space and touch safety */
        padding: 40px 24px !important;
        border: none !important;

        /* Standard LCARS vertical stack */
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important; 
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* When open, slide it to cover the screen */
    #sidebar-nav.mobile-open { 
        transform: translateX(0); 
    }

    #sidebar-nav span.text-\[13px\], 
    #sidebar-nav .text-lg {
        font-size: 18px !important; /* Larger header text */
        opacity: 1 !important;
    }

    /* Main Menu Buttons: Chunky and legible for PADD-style use */
    #sidebar-nav .beeping-button {
        width: 100% !important;
        min-height: 60px !important; /* Massive hit area for thumbs */
        font-size: 18px !important;  /* High legibility mono text */
        padding: 0 24px !important;
        letter-spacing: 0.05em;
        box-sizing: border-box !important;
    }

    /* Submenu items: Clear but visually nested */
    #sidebar-nav .submenu-item {
        width: calc(100% - 1.5rem) !important;
        min-height: 54px !important;
        font-size: 16px !important;
        padding: 0 20px !important;
        box-sizing: border-box !important;
        margin-top: 4px !important;
        margin-bottom: 4px !important;
    }

    /* Scale up the icons to match the larger text */
    #sidebar-nav .beeping-button span.material-symbols-outlined {
        font-size: 26px !important;
    }

    /* Ensure the close 'X' is easy to hit */
    #sidebar-nav button.absolute {
        font-size: 32px !important;
        padding: 10px !important;
        top: -5px;
    }
}

#menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999;
}

/* --- INTERFACE FX --- */

.scanline {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 3px;
    position: absolute;
    top: 0; left: 0;
    z-index: 100;
    pointer-events: none;
    opacity: 0.2;
}

.condition-box {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.4);
    color: transparent !important;
    overflow: hidden;
}

.condition-green { background-color: #00ff44; box-shadow: 0 0 10px #00ff44; }
.condition-yellow { background-color: #ffff00; box-shadow: 0 0 10px #ffff00; }
.condition-red { background-color: #ff0000; box-shadow: 0 0 15px #ff0000; animation: alert-flash 0.8s infinite; }

@keyframes alert-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* --- FOOTER & TICKER --- */

.bridge-footer-wrapper {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    height: 40px !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.daemon-module {
    width: 200px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    border: 3px solid var(--primary) !important;
    color: var(--primary) !important;
    border-radius: 0 0 0 18px !important;
    transition: all 0.4s ease;
    box-sizing: border-box !important;
}

.daemon-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    text-transform: uppercase;
}

/* --- DEFAULT GREEN OVERRIDE FOR RESET STATE --- */
body:not(.alert-yellow):not(.alert-red) #sidebar-nav,
body:not(.alert-yellow):not(.alert-red) #sidebar-nav div.relative,
body:not(.alert-yellow):not(.alert-red) .subspace-link,
body:not(.alert-yellow):not(.alert-red) .daemon-module {
    --primary: #00ff44 !important;
}

.ticker-module {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 18px 0 !important;
}

.ticker-window {
    width: calc(100% - 20px);
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.data-stream {
    display: inline-block;
    white-space: nowrap;
    animation: stream 45s linear infinite;
}

@keyframes stream {
    from { transform: translateX(100vw); }
    to { transform: translateX(-100%); }
}

@media (max-width: 768px) {
    body { padding: 5px; gap: 5px; }
    #main-frame {
    border-radius: 18px 18px 0 0 !important;
    }
    
    .ship-tagline { font-size: 9px !important; }
    .beeping-button { padding: 8px 12px; min-height: 40px; font-size: 10px; }
    .bridge-footer-wrapper { height: 32px !important; gap: 4px !important; }
    .daemon-module { min-width: 90px; padding: 0 8px; }
}