/* =========================================================================
   Department of Physics • D.B. Pampa College, Parumala
   Simulation Suite: Chapter 4 - Moving Charges and Magnetism
   Theme & Styling Specification (Simulation 4: Ampère's Law & Solenoid)
   ========================================================================= */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #059669;
    --secondary-hover: #047857;
    --background-color: #f8fafc;
    --panel-background: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --accent-color: #d97706;
    --badge-bg: #e0e7ff;
    --badge-text: #3730a3;
    --canvas-bg: #090d16;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    padding: 1rem;
}

.container {
    max-width: 1380px;
    margin: 0 auto;
}

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

.nav-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e293b;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    background: #f1f5f9;
    transition: background 0.2s, color 0.2s;
}

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

.nav-dept-tag {
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@media (max-width: 600px) {
    .nav-dept-tag {
        display: none;
    }
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 2.1rem;
    color: #0f172a;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

header p {
    color: #64748b;
    font-size: 0.95rem;
}

.series-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.series-card h3 {
    font-size: 1rem;
    color: #1e3a8a;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.series-card p {
    font-size: 0.88rem;
    color: #4b5563;
    line-height: 1.55;
    margin-bottom: 0.5rem;
}

.series-card .series-tagline {
    font-weight: 700;
    color: #111827;
    font-style: italic;
}

/* Rigid Grid Layout Track Guards */
.sim-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 960px) {
    .sim-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.panel {
    background: var(--panel-background);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04);
}

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

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.control-group h3 {
    font-size: 0.92rem;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.35rem;
    margin-bottom: 0.2rem;
}

.mode-toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.mode-btn {
    flex: 1 1 auto;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: nowrap;
}

.mode-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.mode-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.25);
}

.slider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.slider-row label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
    min-width: 140px;
}

.stepper-container {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-grow: 1;
}

.step-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: #f1f5f9;
    color: #334155;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.step-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

input[type="range"] {
    flex-grow: 1;
    height: 6px;
    border-radius: 3px;
    background: #cbd5e1;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.stat-badge {
    background: var(--badge-bg);
    color: var(--badge-text);
    padding: 0.22rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 72px;
    text-align: right;
}

.slider-hint {
    font-size: 0.74rem;
    color: #64748b;
    margin-top: -0.15rem;
}

.hidden-control {
    display: none !important;
}

.btn {
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.button-split-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

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

.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-neutral { background-color: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.btn-neutral:hover { background-color: #e2e8f0; color: #0f172a; }

.concepts-box {
    background-color: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #6366f1;
    overflow-x: auto;
}

.concepts-box h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: #334155;
}

.concepts-box ul {
    list-style-type: none;
}

.concepts-box li {
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
    line-height: 1.45;
    color: #475569;
}

/* Visualizer Panel */
.visualizer-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.stats-bar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 0.4rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    min-height: 48px;
    height: 48px;
    overflow: hidden;
}

.stat-item {
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    overflow: hidden;
}

.stat-item em {
    font-style: italic;
    font-family: 'Times New Roman', Times, serif;
    font-weight: 700;
    font-size: 0.78rem;
}

.stat-item sub {
    font-size: 0.62rem;
    vertical-align: sub;
}

.stat-value {
    color: #0f172a;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: right;
    display: inline-block;
}

.unit {
    font-size: 0.74rem;
    font-weight: 700;
    color: #2563eb;
    margin-left: 1px;
    text-transform: none !important;
}

#status-badge {
    width: 100%;
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 800;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.25s ease;
}

.status-normal {
    background-color: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.status-optimal {
    background-color: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde047;
}

.status-charging {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.status-paused {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.status-alert {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

/* 3D Viewport & Toolbar */
.zoom-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    height: 30px;
}

.zoom-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.zoom-btn-group {
    display: flex;
    gap: 0.3rem;
}

.zoom-btn {
    padding: 0.22rem 0.6rem;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.zoom-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.zoom-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.canvas-container {
    width: 100%;
    aspect-ratio: 16 / 11;
    background: var(--canvas-bg);
    border: 1px solid #1e293b;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#simCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Secondary 2D Graph Overlay Container */
.graph-card {
    width: 100%;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

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

.graph-legend-group {
    display: flex;
    gap: 0.8rem;
    font-size: 0.7rem;
    color: #cbd5e1;
}

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

.legend-line-sample {
    width: 14px;
    height: 3px;
    border-radius: 1px;
}

#graph-canvas {
    width: 100%;
    height: 120px;
    display: block;
}

.gesture-hint {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.82);
    color: #94a3b8;
    font-size: 0.72rem;
    padding: 4px 9px;
    border-radius: 5px;
    border: 1px solid #334155;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 10;
}

.viewport-legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 5px 9px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.68rem;
    color: #cbd5e1;
    z-index: 10;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

/* Institutional Admission Callout Card (Matched to Lorentz Force Standard) */
.admission-card { 
    background: linear-gradient(135deg, #1e3a8a, #0f172a); 
    color: #ffffff; 
    padding: 1.5rem; 
    border-radius: 12px; 
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    justify-content: space-between; 
    gap: 1.5rem; 
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); 
    position: relative; 
    border: 2px solid transparent; 
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) { 
    .admission-card { 
        flex-direction: column; 
        text-align: center; 
        gap: 1.5rem; 
    } 
    .program-grid { 
        flex-direction: column !important; 
    } 
    .promo-actions { 
        width: 100%; 
    } 
}

.attention-flash { 
    animation: bannerGlowPulse 3s infinite ease-in-out; 
}

@keyframes bannerGlowPulse { 
    0% { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: transparent; } 
    50% { box-shadow: 0 0 22px 5px rgba(251, 191, 36, 0.45); border-color: rgba(251, 191, 36, 0.7); } 
    100% { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: transparent; } 
}

.promo-copy .promo-kicker { 
    color: #60a5fa; 
    font-weight: 700; 
    text-transform: uppercase; 
    font-size: 0.8rem; 
    letter-spacing: 0.06em; 
    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.2rem; 
    flex: 1; 
    justify-content: center; 
}

.program-card { 
    background: rgba(255, 255, 255, 0.08); 
    padding: 0.75rem 1rem; 
    border-radius: 8px; 
    border: 1px solid rgba(255, 255, 255, 0.12); 
    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: #cbd5e1; font-style: italic; }

.promo-actions { 
    display: flex; 
    flex-direction: column; 
    gap: 0.6rem; 
    min-width: 170px; 
}

.promo-button { 
    padding: 0.65rem 1.2rem; 
    border-radius: 6px; 
    font-weight: 800; 
    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; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.promo-button.main-cta { 
    background-color: #fbbf24; 
    color: #0f172a; 
} 

.promo-button.main-cta:hover { 
    background-color: #f59e0b; 
    transform: translateY(-2px); 
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.4);
}

.promo-button.sub-cta { 
    background-color: transparent; 
    color: #e2e8f0; 
    border: 1px solid rgba(255, 255, 255, 0.35); 
} 

.promo-button.sub-cta:hover { 
    background-color: rgba(255, 255, 255, 0.12); 
    color: #ffffff; 
    border-color: #ffffff; 
    transform: translateY(-1px);
}

/* Feedback Channel 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;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

@media (max-width: 768px) {
    .feedback-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

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

.feedback-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feedback-text h4 {
    font-size: 0.95rem;
    color: #0f172a;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

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

.feedback-btn {
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 700;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    white-space: nowrap;
    transition: all 0.2s;
}

.feedback-btn:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.series-footer {
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Phones: label + value on one line, stepper and slider on their own full-width line.
   A single row cannot hold label, −, slider, + and the value badge at 360–400 px. */
@media (max-width: 680px) {
    .slider-row {
        flex-wrap: wrap;
        gap: 0.35rem 0.5rem;
        margin-bottom: 0.85rem;
    }
    .slider-row label {
        flex: 1;
        width: auto;
        min-width: 0;
        max-width: none;
    }
    .slider-row .stat-badge {
        flex: 0 0 auto;
        margin-left: auto;
        order: 2;
    }
    .slider-row .stepper-container {
        flex: 0 0 100%;
        width: 100%;
        order: 3;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .stepper-container .step-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 1.25rem;
        border-radius: 8px;
        touch-action: manipulation;
    }
    .stepper-container input[type="range"] {
        flex: 1;
        min-width: 0;
    }
}

/* Single-column layout: the apparatus comes first and the controls unroll beneath it,
   so the simulation is on screen as soon as the page opens (and nothing scrolls inside the panel). */
@media (max-width: 960px) {
    .sim-layout .visualizer-panel { order: 1; }
    .sim-layout .controls-panel { order: 2; max-height: none; overflow-y: visible; }
}

/* Readouts, status lines and labels wrap instead of being cut off. */
.stat-item,
#status-badge {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
#status-badge {
    height: auto;
    max-height: none;
    line-height: 1.3;
    text-align: center;
}
.stats-bar {
    height: auto;
    overflow: visible;
    row-gap: 0.45rem;
}
.stat-item {
    flex-wrap: wrap;
    column-gap: 0.25rem;
    row-gap: 0;
    line-height: 1.3;
    text-align: center;
}
@media (max-width: 600px) {
    .stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
