/* ========================================
   Gravitation Lab - CSS
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: 'Outfit', sans-serif;
    background: #0a0e1a;
    color: #e2e8f0;
    height: 100%;
    overflow: hidden;
}

#grav-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#phet-stage {
    position: absolute; top: 0; left: 0;
    width: 1280px; height: 720px;
    background: #0a0e1a;
    display: flex; flex-direction: column;
    overflow: hidden; transform-origin: 0 0;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

/* ─── NAVIGATION ─── */
#grav-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 64px;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid rgba(99, 179, 237, 0.15);
    flex-shrink: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Space Grotesk', sans-serif;
}

.brand-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon { font-size: 1.4rem; }

.brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f1f5f9;
}

.brand-thin { font-weight: 300; }

.nav-sep {
    color: rgba(148, 163, 184, 0.4);
    font-size: 1.2rem;
}

.nav-chapter {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-current {
    font-size: 0.85rem;
    color: #60a5fa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-actions { display: flex; align-items: center; gap: 12px; }

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.theory-btn-nav {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.theory-btn-nav:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.exit-btn {
    background: rgba(30, 41, 59, 0.8);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}
.exit-btn:hover {
    background: rgba(51, 65, 85, 0.8);
    color: #e2e8f0;
}

/* ─── MAIN LAYOUT ─── */
.lab-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* ─── CANVAS AREA ─── */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #050a15;
    position: relative;
    overflow: hidden;
}

/* ─── INFO BAR ─── */
.info-bar {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(99, 179, 237, 0.1);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.info-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(99, 179, 237, 0.15);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.8rem;
}

.chip-icon { font-size: 0.9rem; }
.chip-label { color: #64748b; font-weight: 500; }
.chip-value { color: #7dd3fc; font-weight: 700; font-family: 'Space Grotesk', monospace; }

/* ─── CANVAS WRAPPER ─── */
.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#gravCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.drop-hint {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(99, 102, 241, 0.15);
    border: 1px dashed rgba(99, 102, 241, 0.5);
    color: #a5b4fc;
    padding: 10px 22px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: none;
    animation: pulseHint 2s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes pulseHint {
    0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.03); }
}

.drop-hint.hidden { display: none; }

/* ─── IMPACT BADGE ─── */
.impact-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #f59e0b;
    border-radius: 20px;
    padding: 20px 32px;
    text-align: center;
    z-index: 50;
    animation: badgeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
}

.impact-badge.hidden { display: none; }

@keyframes badgeIn {
    from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.impact-icon { font-size: 2.5rem; }

.impact-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #f59e0b;
    letter-spacing: 2px;
    margin: 4px 0;
}

.impact-stats {
    color: #94a3b8;
    font-size: 0.85rem;
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.6;
}

/* ─── CANVAS ACTIONS ─── */
.canvas-actions {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(99, 179, 237, 0.1);
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.drop-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.drop-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}
.drop-btn:disabled {
    background: #374151;
    color: #6b7280;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.reset-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.reset-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

.trace-btn {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.trace-btn.active {
    background: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}
.trace-btn:hover { transform: translateY(-2px); }

.compare-btn {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
    margin-left: auto;
}
.compare-btn:hover {
    background: rgba(245, 158, 11, 0.3);
    transform: translateY(-2px);
}

/* ─── CONTROL PANEL ─── */
.control-panel {
    width: 300px;
    background: #0d1526;
    border-left: 1px solid rgba(99, 179, 237, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    padding: 12px;
    gap: 10px;
    flex-shrink: 0;
}

.control-panel::-webkit-scrollbar { width: 5px; }
.control-panel::-webkit-scrollbar-track { background: transparent; }
.control-panel::-webkit-scrollbar-thumb { background: rgba(99, 179, 237, 0.2); border-radius: 5px; }

.panel-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(99, 179, 237, 0.12);
    border-radius: 14px;
    padding: 14px;
    flex-shrink: 0;
}

.card-header {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.08);
    padding-bottom: 8px;
}

.card-header i { color: #60a5fa; }

/* ─── PLANET GRID ─── */
.planet-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.planet-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
    color: #94a3b8;
}

.planet-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #e2e8f0;
    transform: translateY(-2px);
}

.planet-btn.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: #6366f1;
    color: #c7d2fe;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.planet-emoji { font-size: 1.4rem; }

.planet-name {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.planet-g {
    font-size: 0.6rem;
    color: #4ade80;
    font-family: 'Space Grotesk', monospace;
    font-weight: 500;
}

/* ─── CONTROL ROWS ─── */
.control-row {
    margin-bottom: 12px;
}

.control-row label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.val-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.8rem;
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    background: rgba(99, 179, 237, 0.15);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #0d1526;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

/* ─── OBJECT PICKER ─── */
.object-picker-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 7px;
    font-weight: 500;
}

.object-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.obj-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 2px solid rgba(99, 179, 237, 0.15);
    background: rgba(30, 41, 59, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.obj-btn:hover {
    border-color: rgba(99, 102, 241, 0.5);
    transform: scale(1.1);
}

.obj-btn.active {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.25);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.air-note {
    font-size: 0.72rem;
    color: #f59e0b;
    margin: 8px 0 0 0;
    line-height: 1.4;
}

/* ─── TOGGLE SWITCH ─── */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(99, 179, 237, 0.06);
    cursor: pointer;
    font-size: 0.85rem;
    color: #94a3b8;
    gap: 10px;
}

.toggle-row:last-child { border-bottom: none; }

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 22px;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid rgba(99, 179, 237, 0.2);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: #64748b;
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.6);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #6366f1;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
}

/* ─── LIVE FORMULA ─── */
.live-formula {
    background: rgba(5, 10, 21, 0.6);
    border: 1px solid rgba(99, 179, 237, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
}

.formula-row {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.6;
}

.formula-row.highlight {
    color: #7dd3fc;
    font-weight: 600;
}

.formula-row.highlight strong {
    color: #f59e0b;
}

/* ─── DATA LOG ─── */
.data-log {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.data-log::-webkit-scrollbar { width: 3px; }
.data-log::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 5px; }

.log-entry {
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.72rem;
    border-left: 3px solid #6366f1;
    line-height: 1.5;
}

.log-entry .log-planet { color: #a5b4fc; font-weight: 600; }
.log-entry .log-data { color: #94a3b8; }

.log-empty {
    color: #475569;
    font-size: 0.78rem;
    text-align: center;
    padding: 20px 0;
    font-style: italic;
}

.mini-btn {
    margin-left: auto;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: none;
    border-radius: 6px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 0.72rem;
    transition: all 0.2s;
}
.mini-btn:hover { background: rgba(239, 68, 68, 0.3); }

/* ─── THEORY OVERLAY ─── */
.theory-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 21, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: overlayIn 0.3s ease;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.theory-overlay.hidden { display: none; }

.theory-modal {
    background: linear-gradient(135deg, #0d1526, #0f1f3d);
    border: 1px solid rgba(99, 179, 237, 0.2);
    border-radius: 24px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 32px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.6);
    animation: modalIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalIn {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.theory-modal::-webkit-scrollbar { width: 5px; }
.theory-modal::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.4); border-radius: 5px; }

.theory-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theory-close:hover { background: rgba(239, 68, 68, 0.3); transform: rotate(90deg); }

.theory-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 10px;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.theory-content h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
}

.theory-section {
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(99, 179, 237, 0.1);
}

.theory-section h3 {
    font-size: 1rem;
    color: #7dd3fc;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.theory-section p {
    color: #94a3b8;
    font-size: 0.88rem;
    line-height: 1.7;
    margin: 8px 0;
}

.theory-section ul {
    color: #94a3b8;
    font-size: 0.88rem;
    line-height: 2;
    padding-left: 20px;
    margin: 8px 0;
}

.theory-section ul li strong {
    color: #c7d2fe;
}

.formula-box {
    background: rgba(5, 10, 21, 0.7);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    padding: 12px 20px;
    text-align: center;
    margin: 10px 0;
}

.formula-box .formula {
    font-family: 'Space Grotesk', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #f59e0b;
}

.formula-box.small .formula,
.formula-box.small span {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: #f59e0b;
}

.tip {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem !important;
}

.planets-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.planets-table th {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
}

.planets-table td {
    color: #94a3b8;
    padding: 5px 10px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.06);
}

.planets-table tr:nth-child(even) td {
    background: rgba(30, 41, 59, 0.3);
}

.start-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.6);
}

/* Media Queries Removed for PhET Scaling */
