/*
 * styles.css
 * Styling for the Thomson Crossed Fields simulation 
 * Includes Historical and Exam mode themes.
 */

:root {
    /* Default Exam Mode Variables (Clean, High Contrast, Modern) */
    --bg-color: #f4f4f9;
    --text-color: #222;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --panel-border: rgba(0, 0, 0, 0.1);
    --accent-color: #004e5e;
    /* Matching Mr. Vilchez brand */
    --accent-hover: #0a6c80;
    --highlight-color: #d4af37;
    --font-main: 'Inter', system-ui, sans-serif;
    --font-mono: 'Courier New', monospace;
    --slider-track: #ccc;
    --slider-thumb: var(--accent-color);
    --crt-glow: 0px 0px 15px rgba(0, 255, 100, 0.2);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.historical-mode {
    /* Historical Mode Variables (1890s lab feel) */
    --bg-color: #1a1614;
    --text-color: #dfcdba;
    --panel-bg: rgba(45, 35, 25, 0.85);
    --panel-border: #5c4d3c;
    --accent-color: #b87a3d;
    --accent-hover: #d28c46;
    --highlight-color: #e6b981;
    --font-main: 'Georgia', serif;
    --slider-track: #3d3024;
    --slider-thumb: #b87a3d;
    --crt-glow: 0px 0px 30px rgba(184, 122, 61, 0.4);
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    /* Canvas fills screen */
}

/* 3D Canvas Layer */
#simulation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* UI Overlay Layer */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through to 3D canvas... */
    display: flex;
    justify-content: space-between;
    padding: 20px;
}

/* Re-enable pointer events for actual panels */
.panel {
    pointer-events: auto;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#controls-panel {
    width: 320px;
}

#data-panel {
    width: 380px;
    display: none;
    /* Hidden until data collection begins or toggled */
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--panel-border);
    padding-bottom: 10px;
    margin-bottom: 5px;
}

.panel-header h2 {
    font-size: 1.2rem;
    color: var(--highlight-color);
}

/* Controls Grid */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 600;
}

.control-val {
    font-family: var(--font-mono);
    color: var(--accent-color);
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--slider-thumb);
    cursor: pointer;
    margin-top: -6px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--slider-track);
    border-radius: 2px;
}

/* Action Buttons */
.btn {
    background: var(--accent-color);
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Live Readout Displays */
.readout-box {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

body.historical-mode .readout-box {
    background: rgba(0, 0, 0, 0.3);
    /* darker inside the dark panel */
}

/* Data Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: right;
}

th,
td {
    padding: 6px 4px;
    border-bottom: 1px solid var(--panel-border);
}

th {
    text-align: right;
    color: var(--accent-color);
    font-weight: bold;
}

/* Toggle Switches */
.switch-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Chart Canvas Space */
#chart-container {
    width: 100%;
    height: 200px;
    margin-top: 15px;
}

/* Top bar controls */
#top-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    display: flex;
    gap: 15px;
    z-index: 10;
}

/* Responsive */
@media (max-width: 800px) {
    #ui-container {
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 10px;
        overflow-y: auto;
        pointer-events: auto;
    }

    #simulation-canvas {
        height: 50vh;
        /* split screen on mobile */
        position: relative;
    }

    .panel {
        width: 100% !important;
        margin-bottom: 10px;
        max-height: none;
    }

    #top-bar {
        position: relative;
        top: 0;
        left: 0;
        transform: none;
        justify-content: center;
        margin: 10px 0;
    }
}