/* Styles for Chapter 8 Simulation 2: Plane Electromagnetic Waves, Energy & Polarization */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f1f5f9;
    --panel-bg: #ffffff;
    --text-color: #0f172a;
    --border-color: #cbd5e1;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    padding: 1.5rem;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

/* Top Navigation Bar */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.nav-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e293b;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.nav-home-btn:hover {
    background: #e2e8f0;
    color: var(--primary-color);
}

.nav-dept-tag {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 600;
}

/* Header & Typography */
header {
    background: #ffffff;
    padding: 1.5rem 1.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.45rem;
    line-height: 1.25;
}

header p {
    font-size: 0.95rem;
    color: #475569;
    max-width: 1100px;
    line-height: 1.6;
}

/* Series Card */
.series-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--primary-color);
    border-radius: 10px;
    padding: 1.15rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.series-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

.series-tagline {
    font-size: 0.88rem;
    font-style: italic;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.45rem;
}

.series-card p:last-child {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.55;
}

/* Predict-Observe-Explain (POE) Challenge Card */
.poe-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: #1e40af;
}

.poe-badge {
    background: #2563eb;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.poe-text {
    line-height: 1.5;
}

/* Main Simulation Layout (Option A Mobile Architecture per AGENTS.md) */
.sim-layout {
    display: grid;
    grid-template-columns: 430px 1fr;
    gap: 1.25rem;
    align-items: start;
    width: 100%;
}

@media (max-width: 960px) {
    .sim-layout {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }
    .visualizer-panel {
        order: 1;
        width: 100%;
    }
    .controls-panel {
        order: 2;
        width: 100%;
        max-height: none;
        overflow-y: visible;
        padding-right: 1.5rem;
        padding-bottom: 1.5rem;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
}

/* Control Panel & Containers */
.panel {
    background: var(--panel-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1.15rem;
}

.control-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.control-group h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Mode Switcher Buttons */
.mode-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
}

.mode-btn {
    width: 100%;
    min-height: 42px;
    padding: 0.65rem 0.85rem;
    font-size: 0.86rem;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    touch-action: manipulation;
}

.mode-btn:hover {
    background: #f8fafc;
    color: var(--primary-color);
    border-color: #94a3b8;
}

.mode-btn.active {
    background: #1e293b;
    color: #ffffff;
    border-color: #0f172a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-goal-desc {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.45;
    background: #f8fafc;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

/* Invariant & Energy Ratio Banner */
.invariant-banner {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.invariant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.invariant-title {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.invariant-badge {
    background: #10b981;
    color: #042f2e;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
}

.invariant-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.55rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.inv-col {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.inv-label {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 600;
}

.inv-val {
    font-family: 'Consolas', monospace;
    font-size: 0.86rem;
    font-weight: 700;
}

.inv-col.ratio .inv-val { color: #f59e0b; }
.inv-col.energy .inv-val { color: #38bdf8; }

/* 2-Line Slider Rows (Mobile-First AGENTS.md Standard) */
.slider-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.slider-label-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-label-bar label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.stat-badge {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e293b;
    min-width: 65px;
    text-align: right;
}

.stepper-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.stepper-container .step-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: all 0.15s ease;
    user-select: none;
}

.stepper-container .step-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.stepper-container input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 8px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Polarization & Surface Selectors */
.toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.45rem;
}

.toggle-btn {
    padding: 0.6rem 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.toggle-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.toggle-btn.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

/* Action Buttons & Presets Grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.presets-grid {
    grid-template-columns: 1fr;
}

.action-btn {
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    text-align: center;
    min-height: 42px;
}

.action-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.action-btn.primary {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.action-btn.primary:hover {
    background: var(--primary-hover);
}

/* Concept Insight Card */
.concept-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    padding: 0.95rem;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #334155;
}

.concept-card h4 {
    color: #1e293b;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Visualizer Panel */
.visualizer-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 3D Canvas Viewport */
.canvas-container {
    position: relative;
    width: 100%;
    height: 450px;
    min-height: 380px;
    border-radius: 10px;
    overflow: hidden;
    background: #060911;
    border: 1px solid #1e293b;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.7);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

@media (max-width: 768px) {
    .canvas-container {
        height: 370px;
        min-height: 340px;
        max-height: 52vh;
    }
}

#sim-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Persistent Arrow Normalization Watermark Badge */
.scale-watermark-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    pointer-events: none;
    z-index: 10;
}

/* In-Canvas Telemetry HUD */
.voltmeter-hud {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 0.4rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    z-index: 10;
    pointer-events: none;
    font-size: 0.72rem;
    font-family: 'Consolas', monospace;
    color: #e2e8f0;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.hud-label { color: #94a3b8; font-weight: 600; }
.hud-val { font-weight: 700; }
.hud-val.gold { color: #f59e0b; }
.hud-val.purple { color: #c084fc; }
.hud-val.cyan { color: #38bdf8; }
.hud-val.green { color: #10b981; }
.hud-divider { color: rgba(255, 255, 255, 0.2); }

/* Viewport Legend Card (Docked cleanly at bottom) */
.viewport-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    display: flex;
    gap: 0.85rem;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #e2e8f0;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

@media (max-width: 680px) {
    .voltmeter-hud {
        top: 6px;
        left: 6px;
        right: 6px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.35rem 0.5rem;
        padding: 0.4rem 0.6rem;
    }

    .voltmeter-hud .hud-divider {
        display: none;
    }

    .hud-label {
        font-size: 0.62rem;
    }

    .hud-val {
        font-size: 0.74rem;
    }

    .viewport-legend {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 5px 8px;
        gap: 6px 12px;
        justify-content: center;
        background: rgba(8, 12, 20, 0.94);
    }
}

.gesture-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.85);
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .gesture-hint {
        bottom: 34px;
        right: 8px;
        font-size: 0.65rem;
        padding: 0.2rem 0.45rem;
    }
}

/* Real-Time Telemetry Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
    width: 100%;
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

.stat-cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.5rem 0.45rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

.stat-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    text-transform: uppercase;
}

.stat-number {
    font-family: 'Consolas', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
    word-break: break-all;
}

.stat-number.gold { color: #f59e0b; }
.stat-number.purple { color: #c084fc; }
.stat-number.cyan { color: #38bdf8; }
.stat-number.green { color: #10b981; }
.stat-number.rose { color: #fb7185; }

/* Dual 2D Graph Engine (Lissajous Polarization Plane & Scope) */
.dual-canvas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
}

@media (max-width: 768px) {
    .dual-canvas-grid {
        grid-template-columns: 1fr;
    }
}

.graph-container {
    background: #0b0f19;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.graph-title {
    font-size: 0.74rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.graph-legend {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.graph-canvas {
    width: 100%;
    height: 115px;
    display: block;
    background: #04060a;
    border-radius: 4px;
}

/* Admission Callout Box */
.admission-card { 
    background: linear-gradient(135deg, #1e3a8a, #0f172a); 
    color: #ffffff; 
    border-radius: 12px; 
    padding: 1.5rem; 
    margin-top: 1.25rem; 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); 
    display: flex; 
    flex-direction: column; 
    gap: 1.25rem; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
} 

.admission-card.attention-flash { 
    animation: bannerGlowPulse 4s infinite ease-in-out; 
} 

@keyframes bannerGlowPulse { 
    0% { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: rgba(255, 255, 255, 0.1); } 
    50% { box-shadow: 0 0 20px 4px rgba(251, 191, 36, 0.35); border-color: rgba(251, 191, 36, 0.5); } 
    100% { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: rgba(255, 255, 255, 0.1); } 
} 

@media (prefers-reduced-motion: reduce) {
    .admission-card.attention-flash {
        animation: none;
    }
}

.promo-copy { 
    display: flex; 
    flex-direction: column; 
    gap: 0.25rem; 
} 

.promo-copy .promo-kicker { 
    color: #60a5fa; 
    font-weight: 600; 
    text-transform: uppercase; 
    font-size: 0.8rem; 
    letter-spacing: 0.05em; 
    margin-bottom: 0.2rem; 
} 

.promo-copy .promo-lead { 
    color: #ffffff; 
    font-weight: 600; 
    font-size: 1.05rem; 
    margin-bottom: 0.25rem; 
} 

.promo-copy .promo-headline { 
    color: #fcd34d; 
    font-weight: 800; 
    font-size: 1.45rem; 
    line-height: 1.25; 
} 

.program-grid { 
    display: flex; 
    gap: 1.5rem; 
    flex: 1; 
    justify-content: center; 
} 

@media (max-width: 680px) {
    .program-grid {
        flex-direction: column;
        gap: 0.75rem;
    }
}

.program-card { 
    background: rgba(255, 255, 255, 0.08); 
    padding: 0.75rem 1rem; 
    border-radius: 8px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    font-size: 0.85rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.2rem; 
} 

.program-card strong { color: #fcd34d; font-size: 0.95rem; } 
.program-card span { color: #e2e8f0; } 
.program-card small { color: #94a3b8; font-style: italic; } 

.promo-actions { 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
    width: 100%;
} 

@media (min-width: 681px) {
    .promo-actions {
        min-width: 160px;
        width: auto;
    }
} 

.promo-button { 
    padding: 0.65rem 1.2rem; 
    border-radius: 6px; 
    font-weight: 700; 
    text-decoration: none; 
    transition: all 0.2s ease; 
    text-align: center; 
    font-size: 0.9rem; 
    min-height: 44px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    touch-action: manipulation; 
} 

.main-cta { background-color: #fbbf24; color: #0f172a; } 
.main-cta:hover { background-color: #f59e0b; transform: translateY(-1px); } 

.sub-cta { background-color: transparent; color: #e2e8f0; border: 1px solid rgba(255, 255, 255, 0.3); } 
.sub-cta:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; border-color: #fff; } 

/* Feedback & Suggestions Card */
.feedback-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

@media (max-width: 800px) {
    .feedback-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .feedback-btn {
        width: 100%;
        text-align: center;
    }
}

.feedback-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.feedback-icon {
    color: var(--primary-color);
    flex-shrink: 0;
}

.feedback-text h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.2rem;
}

.feedback-text p {
    font-size: 0.88rem;
    color: #64748b;
    line-height: 1.45;
}

.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.15rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--primary-color);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 44px;
    touch-action: manipulation;
}

.feedback-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: var(--primary-hover);
}

.series-footer { 
    text-align: center; 
    padding: 1.5rem 0 0; 
    border-top: 1px solid #e5e7eb; 
    margin-top: 1.5rem; 
} 

.series-footer p { 
    font-size: 0.82rem; 
    color: #64748b; 
    font-weight: 500; 
}
