/* --- CSS Theme Variables --- */
:root {
    --bg-gradient: linear-gradient(135deg, #F5E15E 0%, #EE7177 50%, #081041 100%);
    
    /* High-Fidelity Glassmorphism with bottom-lightening gradients */
    --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.65) 100%);
    --card-border: rgba(255, 255, 255, 0.6);
    --card-shadow: rgba(31, 38, 135, 0.08);
    
    --text-color: #1c1c1e;
    --text-secondary: #4a4a4a; /* Main text panel description properties */
    --border-color: rgba(255, 255, 255, 0.3);
    --status-bg: #1c1c1e;
    --status-text: #ffffff;
    
    /* Bottom Navigation Specific Theme Variables */
    --nav-bg: rgba(255, 255, 255, 0.4);
    --nav-text: #2c2c2e;        /* Independent non-active menu color label */
    --nav-text-active: #007aff; /* Independent active menu color label */
    
    /* Light mode dropdown panels */
    --panel-bg: #1c1c1e;
    --panel-card-bg: #2c2c2e;
    --panel-border: transparent;
    --slider-track: #e5e5ea;
}

.nav-item, .metric-tag, .center-logo-container {
    -webkit-tap-highlight-color: transparent; /* Removes the ugly gray flash box on mobile tap */
    user-select: none;                         /* Prevents cursor highlights on rapid button clicks */
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #004D79 0%, #00163A 50%, #471337 100%);
    
    /* Dark Glassmorphism that fades to a lighter, backlit shade at the bottom */
    --card-bg: linear-gradient(180deg, rgba(18, 16, 24, 0.65) 0%, rgba(45, 42, 58, 0.45) 100%);
    --card-border: rgba(255, 255, 255, 0.15);
    --card-shadow: rgba(0, 0, 0, 0.4);
    
    --text-color: #f5f5f7;
    --text-secondary: #d1d1d6;
    --border-color: rgba(255, 255, 255, 0.08);
    --status-bg: #09080f;
    --status-text: #e5e5ea;
    
    /* Bottom Navigation Specific Theme Variables (Dark Mode) */
    --nav-bg: rgba(20, 18, 26, 0.45);
    --nav-text: #a1a1a6;
    --nav-text-active: #0a84ff;
    
    /* High-Contrast Obsidian Dropdown Panels for Dark Mode */
    --panel-bg: #050409; 
    --panel-card-bg: #13111c;
    --panel-border: rgba(10, 132, 255, 0.25);
    --slider-track: #2c2c2e;
}

/* Reset default margins and paddings */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* style.css positioning adjustments */
.svg-background-layer {
    position: absolute;
    top: 75px;
    left: 0;
    
    /* Forces the container bounding box to stretch across the full viewport dimensions */
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Safeguard for mobile browser dynamic menu bars */

    z-index: 50; /* Placed exactly above body gradients, below content cards */
    pointer-events: none; /* Keeps swipe/scroll gestures interactive for the text elements */
    overflow: hidden; /* Trims off any overlapping vectors safely */
}

/* Selector targeting either your <img> or an inline <svg> inside that container */
.svg-background-layer img,
.svg-background-layer svg {
    width: 100%;
    height: 100%;
    
    /* CRITICAL STRETCH PROPERTY: */
    object-fit: cover; 
    
    /* Softens the asset layer lines so they don't block layout visibility */
    opacity: 0.15; 
}

/* Sync main viewport container depth so it floats cleanly above vectors */
.main-content, .status-bar, .nav-bar {
    position: relative;
    z-index: 100;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient); /* Keeps your vibrant color gradient base */
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    position: relative; /* CRITICAL: Serves as the anchor frame for the background layer */


    /* CRITICAL MOBILE WIDTH SAFETY CONSTRAINTS: */
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevents the entire viewport from swaying left/right */

    /* REPLACEMENT RULES FOR HEIGHT CONSTRICTION: */
    height: 100vh;        /* Fallback for older legacy browsers */
    height: 100dvh;       /* Dynamic Viewport Height - auto-calculates current real-time mobile window constraints */
    
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    position: relative;
}

/* --- Isolated Background SVG Layer --- */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Keeps the graphic resting safely behind status, navigation, and content layers */
    
    /* 1. Specify your SVG file path here */
    background-image: url('img/pixelFade.svg');
     
    /* 2. Configure alignment and scaling rules */
    background-repeat: no-repeat;
    background-position: center center; /* Centers the vector on screen */
    background-size: 100% auto;        /* Forces the SVG to scale perfectly to the width of the view */
    
    /* 3. Handle your precise opacity requirement */
    opacity: 0.5;                      /* Fixed exactly at 50% opacity */
    
    pointer-events: none;              /* Ensures users can click "through" this layer onto buttons */
}


/* --- High-Density Telemetry Status Bar --- */
.status-bar {
    background-color: var(--status-bg);
    color: var(--status-text);
    height: 75px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 16px;
    font-size: 1.5rem;
    font-weight: 600;
    z-index: 200;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    transition: background-color 0.3s ease, color 0.3s ease;

    /* REFINEMENT: Force sizing models to subtract padding from overall width calculation */
    width: 100%;
    box-sizing: border-box;
}

.status-bar .left-deck {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-bar .right-deck {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

.metric-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 12px;
    min-height: 50px;
    min-width: 50px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease, transform 0.1s ease;
}
.metric-tag:hover {
    background-color: rgba(255, 255, 255, 0.2);
}
.metric-tag:active {
    transform: scale(0.96);
}

/* Locked Monospaced Numerical Subcontainer for the Speed Metric Tag */
.speed-text-lock {
    font-variant-numeric: tabular-nums;
    display: inline-block;
    min-width: 60px;
    text-align: right;
}

/* Centered Image/Logo Trigger Container Styling */
.status-bar .center-logo-container {
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s ease;
    height: 50px;
}
.status-bar .center-logo-container:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.status-logo {
    height: 100%;       
    max-height: 50px;
    width: auto;        
    object-fit: contain;
    display: block;
}

.status-bar .caret-icon {
    font-size: 0.65rem; 
    color: #ffffff;
    opacity: 0.6;
    margin-left: 2px;
}

/* Embedded Inner Dropdown Option Style */
.panel-row-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: #0a84ff;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.2s ease;
}
.panel-row-btn:hover {
    background: #007aff;
}

/* --- Custom Interactive Slider Layout Elements --- */
.slider-container {
    background: var(--panel-card-bg);
    padding: 20px 25px;
    border-radius: 16px;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.slider-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-value-badge {
    background: #0a84ff;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 65px;
    text-align: center;
    box-shadow: 0 0 10px rgba(10, 132, 255, 0.4);
    font-variant-numeric: tabular-nums;
}

.horizontal-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--slider-track);
    outline: none;
    cursor: pointer;
}

.horizontal-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #0a84ff;
    box-shadow: 0 0 12px rgba(10, 132, 255, 0.6);
    transition: transform 0.1s ease, background-color 0.2s ease;
}
.horizontal-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: #0a84ff;
}

.horizontal-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #0a84ff;
    box-shadow: 0 0 12px rgba(10, 132, 255, 0.6);
    transition: transform 0.1s ease, background-color 0.2s ease;
    cursor: pointer;
}
.horizontal-range::-moz-range-thumb:hover {
    transform: scale(1.15);
    background: #0a84ff;
}

/* Status colors */
.txt-nominal { color: #30d158; }
.txt-active { color: #0a84ff; } 
.txt-alarm { color: #ff453a; }  

/* --- Individual High-Contrast Animated Dropdown Panels --- */
.dropdown-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--panel-bg);
    color: #ffffff;
    padding: 20px;
    padding-top: 95px; 
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    border-bottom: 2px solid var(--panel-border);
    border-left: 1px solid var(--panel-border);
    border-right: 1px solid var(--panel-border);
    box-shadow: 0 16px 40px rgba(0,0,0,0.6); 
    z-index: 150;
    
    opacity: 0;
    pointer-events: none;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.3s ease-out, 
                background-color 0.3s ease, 
                border-color 0.3s ease;
}

.dropdown-panel.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0%);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.panel-card {
    background: var(--panel-card-bg);
    padding: 15px;
    border-radius: 14px;
    text-align: center;
    transition: background-color 0.3s ease;
}

.panel-card i {
    font-size: 1.4rem;
    margin-bottom: 6px;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.75); 
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* --- Middle Scrollable Section --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 25px 20px;
    background: transparent;
    z-index: 100;
    
    /* CRITICAL MOBILE INTERACTION RULES: */
    -webkit-overflow-scrolling: touch; /* Forces buttery-smooth 60fps native momentum scrolling on iOS */
    overscroll-behavior-y: contain;   /* Blocks the scroll chain from bouncing the parent body shell */
}

/* --- Vertical Dynamic Lighter-Bottom Glassmorphism Cards --- */
.content-card {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 15px 20px 20px 20px;
    margin-bottom: 20px;
    border-radius: 15px;
    border: 1px solid var(--card-border); 
    backdrop-filter: blur(24px) saturate(140%); 
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    box-shadow: 0 8px 32px var(--card-shadow), inset 0 1px 1px rgba(255, 255, 255, 0.3); 
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* --- Full Glowing Button Styling --- */
.glow-btn-container {
    text-align: center;
    margin: 25px 0;
}

.glow-button {
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    background-color: #1c1c1e;
    color: #a1a1a6;
    border: 2px solid transparent;
    cursor: pointer;
    outline: none;
    transition: all 0.4s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.glow-button i { margin-right: 8px; transition: color 0.4s ease; }

.glow-button.glow-green {
    background-color: #0c2b14; border-color: #30d158; color: #ffffff;
    animation: pulse-green 2s infinite alternate;
}
.glow-button.glow-green i { color: #30d158; }

.glow-button.glow-red {
    background-color: #381210; border-color: #ff453a; color: #ffffff;
    animation: pulse-red 2s infinite alternate;
}
.glow-button.glow-red i { color: #ff453a; }

@keyframes pulse-green {
    0% { box-shadow: 0 0 10px rgba(48, 209, 88, 0.4), inset 0 0 15px rgba(48, 209, 88, 0.3); }
    100% { box-shadow: 0 0 25px rgba(48, 209, 88, 0.85), inset 0 0 25px rgba(48, 209, 88, 0.6); }
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 10px rgba(255, 69, 58, 0.4), inset 0 0 15px rgba(255, 69, 58, 0.3); }
    100% { box-shadow: 0 0 25px rgba(255, 69, 58, 0.85), inset 0 0 25px rgba(255, 69, 58, 0.6); }
}

/* --- Glass Navigation Bar --- */
.nav-bar {
    background: var(--nav-bg);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    height: 70px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 30px var(--card-shadow);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--nav-text); /* Linked to independent variable */
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    flex: 1;
}

.nav-item span {
    font-size: 0.75rem;       /* 👈 Adjust this to change text size independently (e.g., 0.8rem or 12px) */
    font-weight: 600;         /* Controls text thickness (500 = Medium, 600 = Semi-Bold, 700 = Bold) */
    letter-spacing: 0.3px;    /* Adds slight tracking space between characters for crisp readability */
    margin-top: 2px;          /* Fine-tunes the exact air gap beneath the icon */
    text-transform: none;     /* Can be changed to 'uppercase' if you want ALL CAPS labels */
}

.nav-item:active { transform: scale(0.95); }

.nav-item.active { 
    color: var(--nav-text-active); /* Linked to independent variable */
}

/* --- Content Page Transition Classes --- */
.fade-in-target {
    opacity: 0;
    /* Uses a clean, hardware-accelerated easing curve */
    animation: quickFadeUp 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes quickFadeUp {
    from {
        opacity: 0;
        transform: translateY(5px); /* Subtly glides up for a premium look */
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Mobile Responsive Rules --- */
@media screen and (max-width: 414px) {
    /* Reduce status bar height slightly to save screen real estate */
    .status-bar {
        height: 65px;
        padding: 0 8px;
    }
    
    /* Make metric tags smaller and tightly grouped */
    .metric-tag {
        padding: 4px 8px;
        min-height: 42px;
        min-width: 42px;
        font-size: 1.1rem; /* Adjusts standard status text dimensions */
    }

    /* Shrink the center logo constraint to preserve space */
    .status-logo {
        max-height: 38px;
    }

    /* Clean up the 6-column bottom navigation bar */
    .nav-bar {
        height: 65px;
        padding-bottom: env(safe-area-inset-bottom); /* Fix for iPhone notch/home bar */
    }

    .nav-item {
        font-size: 0.6rem; /* Snug text sizing stops wrapping strings */
    }

    .nav-item i {
        font-size: 1.15rem; /* Scales icon glyph volume down gracefully */
        margin-bottom: 2px;
    }

    /* Open up padding inside main content cards to maximize reading space */
    .main-content {
        padding: 15px 12px;
    }
    
    .content-card {
        padding: 16px;
        border-radius: 16px; /* Slightly tighter curves look better on phones */
    }
}