/*  The Magic of Pi — Styles  */
@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; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; font-family: 'Outfit', sans-serif; background: #0a0e1a; color: #e2e8f0; overflow: hidden; touch-action: none; }

#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;
}

/* ── OVERLAY ────────────────────────────────────────── */
.pi-overlay {
    position: absolute; inset: 0; z-index: 1000;
    background: rgba(5,10,21,0.9);
    backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center; padding: 16px;
    animation: fadeIn .4s ease;
}
.pi-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.pi-modal {
    background: linear-gradient(145deg, #111827, #1e1b4b);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    max-width: 650px; width: 100%; max-height: 90vh;
    position: relative;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8);
    animation: popIn .5s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes popIn { from { transform: scale(.9) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

.pi-modal-scroll { overflow-y: auto; padding: 36px 32px; max-height: 90vh; }
.pi-modal-scroll::-webkit-scrollbar { width: 4px; }
.pi-modal-scroll::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.4); border-radius: 4px; }

.pi-close {
    position: absolute; top: 16px; right: 16px;
    background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3);
    color: #f87171; width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all .2s; z-index: 10;
}
.pi-close:hover { background: rgba(239,68,68,.3); transform: rotate(90deg); }

.pi-hero { font-family: 'Space Grotesk', serif; font-size: 5rem; text-align: center; color: #8b5cf6; text-shadow: 0 0 30px rgba(139,92,246,0.6); animation: floatY 3s ease-in-out infinite; line-height: 1; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.pi-modal h2 {
    text-align: center; font-size: 1.8rem; font-weight: 800; margin: 12px 0 4px;
    background: linear-gradient(135deg, #c4b5fd, #a78bfa);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.pi-subtitle { text-align: center; color: #8b5cf6; margin-bottom: 24px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; font-size: 0.85rem; }

.th-sec { background: rgba(30,41,59,.5); border-radius: 14px; padding: 18px; margin-bottom: 16px; border: 1px solid rgba(139, 92, 246, 0.15); }
.th-sec h3 { font-size: 1.05rem; color: #ddd6fe; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.th-sec p  { font-size: .9rem; color: #94a3b8; line-height: 1.6; margin-bottom: 8px; }

.fmla-box-center {
    background: rgba(15,23,42,0.8); border: 1px solid rgba(139,92,246,0.3);
    border-radius: 10px; padding: 16px; text-align: center; font-size: 1.2rem;
    color: #c4b5fd; margin-top: 12px;
}
.fmla-list { list-style: none; margin-top: 10px; }
.fmla-list li { margin-bottom: 8px; font-size: 0.95rem; color: #c4b5fd; background: rgba(15,23,42,0.5); padding: 8px 12px; border-radius: 8px; border-left: 3px solid #8b5cf6; }
.fmla-list b { color: #ddd6fe; display: inline-block; width: 120px; }

.th-tip { border-left: 3px solid #f59e0b !important; }
.th-tip h3 { color: #fcd34d !important; }
.th-tip ul { padding-left: 20px; color: #94a3b8; font-size: 0.85rem; line-height: 1.7; }
.th-tip li { margin-bottom: 6px; }

.pi-start-btn {
    display: flex; width: 100%; margin-top: 24px; padding: 16px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; border: none;
    border-radius: 12px; font-family: 'Outfit', sans-serif; font-size: 1.1rem; font-weight: 700;
    cursor: pointer; transition: all .3s; box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
    align-items: center; justify-content: center; gap: 10px;
}
.pi-start-btn:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(139, 92, 246, 0.6); }

/* ── APP LAYOUT ─────────────────────────────────────── */
#pi-app { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* NAV */
#pi-nav {
    position: relative !important; top: auto !important;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 22px; height: 62px;
    background: rgba(10,14,26,.98) !important; border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    flex-shrink: 0; z-index: 50; width: 100% !important; backdrop-filter: none;
}
.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; font-size: 1.1rem; font-weight: 700; }
.brand-thin { font-weight: 300; }
.nav-sep { color: rgba(148,163,184,.35); }
.nav-chapter { font-size: .78rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.nav-current  { font-size: .82rem; color: #a78bfa; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.nav-actions  { display: flex; gap: 10px; align-items: center; }
.nav-btn {
    display: flex; align-items: center; gap: 6px; padding: 7px 15px;
    border-radius: 8px; font-family: 'Outfit', sans-serif; font-size: .82rem; font-weight: 600;
    cursor: pointer; border: none; transition: all .2s; text-decoration: none;
}
.pi-theory-btn { background: linear-gradient(135deg,#8b5cf6,#6366f1); color: #fff; box-shadow: 0 4px 15px rgba(139,92,246,.3); }
.pi-theory-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139,92,246,.5); }
.pi-exit-btn { background: rgba(30,41,59,.8); color: #94a3b8; border: 1px solid rgba(148,163,184,.2); }
.pi-exit-btn:hover { background: rgba(51,65,85,.8); color: #e2e8f0; }

/* MAIN LAYOUT */
.pi-layout { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* SIM AREA */
.sim-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #050a15; min-width: 0; min-height: 0; }

/* MODE TABS */
.mode-tabs { display: flex; gap: 6px; padding: 8px 14px 0; flex-shrink: 0; background: #050a15; border-bottom: 1px solid rgba(139, 92, 246, 0.2); }
.mode-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 20px; border-radius: 8px 8px 0 0;
    font-family: 'Outfit', sans-serif; font-size: .85rem; font-weight: 600;
    cursor: pointer; border: 1px solid rgba(139, 92, 246, 0.1); border-bottom: none;
    background: rgba(15,23,42,.6); color: #64748b; transition: all .2s;
}
.mode-tab:hover  { background: rgba(30,41,59,.8); color: #94a3b8; }
.mode-tab.active { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; border-color: rgba(139, 92, 246, 0.4); border-bottom: 2px solid #8b5cf6; padding-bottom: 8px; }

/* CANVAS WRAP */
.canvas-wrap { flex: 1; position: relative; overflow: hidden; min-height: 0; }
#mainCanvas { width: 100%; height: 100%; display: block; }

/* HUD BAR (floating over canvas) */
.hud-bar {
    position: absolute; top: 14px; left: 14px; right: 14px;
    display: flex; justify-content: center; gap: 12px; pointer-events: none;
}
.hud-bar.hidden { display: none; }
.hud-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(15,23,42,.85); border: 1px solid rgba(139, 92, 246, 0.2); border-radius: 12px;
    padding: 8px 24px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.hud-lbl { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: #64748b; letter-spacing: 1px; margin-bottom: 2px; }
.hud-val { font-size: 1.4rem; font-weight: 800; font-family: 'Space Grotesk', monospace; }
.hud-color-d { color: #fcd34d; }  /* Yellow for diameter */
.hud-color-c { color: #ec4899; }  /* Pink for circumference */
.hud-color-s { color: #38bdf8; }  /* Cyan for slices */
.hud-color-pi{ color: #8b5cf6; text-shadow: 0 0 10px rgba(139,92,246,0.5); }

/* ACTION BAR */
.action-bar {
    flex-shrink: 0; padding: 14px 20px; background: rgba(10,14,26,.95); 
    border-top: 1px solid rgba(139, 92, 246, 0.2); display: flex; align-items: center; justify-content: center;
}
.action-left { display: flex; align-items: center; gap: 16px; width: 100%; max-width: 600px; }
.action-left.hidden { display: none; }
.act-label { font-size: .85rem; color: #cbd5e1; font-weight: 600; white-space: nowrap; }

/* SLIDER */
.neon-slider {
    flex: 1; height: 6px; background: rgba(139, 92, 246, 0.2); border-radius: 4px; outline: none; -webkit-appearance: none; appearance: none; cursor: pointer;
}
.neon-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 22px; height: 22px; background: #8b5cf6; border-radius: 50%; cursor: pointer; border: 3px solid #1e1b4b; box-shadow: 0 0 15px rgba(139, 92, 246, 0.8);
}
.icon-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(139, 92, 246, 0.15); border: 1px solid rgba(139, 92, 246, 0.4);
    color: #c4b5fd; font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(139, 92, 246, 0.3); transform: scale(1.05); color: #fff; box-shadow: 0 0 15px rgba(139,92,246,0.4); }

/* SIDEBAR */
.pi-sidebar { width: 310px; background: #0d1526; border-left: 1px solid rgba(139, 92, 246, 0.15); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 14px; flex-shrink: 0; }
.pi-sidebar::-webkit-scrollbar { width: 4px; }
.pi-sidebar::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 4px; }

.pi-card { background: rgba(15,23,42,.8); border: 1px solid rgba(139, 92, 246, 0.15); border-radius: 14px; padding: 16px; flex-shrink: 0; }
.pi-card.hidden { display: none; }

.pi-card-hdr { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid rgba(139, 92, 246, 0.1); }
.pi-card-hdr i { color: #8b5cf6; }

/* PICKERS (Diam / Slices) */
.ctrl-row { margin-bottom: 10px; }
.ctrl-row label { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: #cbd5e1; margin-bottom: 8px; }
.val-pill { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; padding: 3px 10px; border-radius: 8px; font-family: 'Space Grotesk', monospace; font-size: .8rem; font-weight: 700; border: 1px solid rgba(139,92,246,0.3); }

.diam-picker, .slice-picker { display: flex; gap: 8px; }
.diam-btn, .slice-btn {
    flex: 1; padding: 8px 0; border-radius: 8px; font-family: 'Space Grotesk', monospace; font-size: 1rem; font-weight: 700;
    cursor: pointer; border: 1px solid rgba(139, 92, 246, 0.2); background: rgba(30,41,59,.6); color: #94a3b8; transition: all .2s;
}
.diam-btn.active, .slice-btn.active {
    background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; border-color: transparent; box-shadow: 0 4px 15px rgba(139,92,246,0.4);
}

/* INSIGHT BOX */
.pi-insight { display: flex; gap: 10px; background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.15); border-radius: 10px; padding: 10px; margin-top: 14px; }
.ins-icon { font-size: 1.2rem; }
.ins-text { font-size: .75rem; color: #fcd34d; line-height: 1.5; }

/* PI STREAM */
.stream-card { background: linear-gradient(180deg, rgba(15,23,42,0.8), rgba(6,182,212,0.05)) !important; border-color: rgba(6,182,212,0.2) !important; }
.stream-card .pi-card-hdr i { color: #06b6d4; }
.pi-digits-container { font-family: 'Space Grotesk', monospace; font-weight: 700; background: #0b1120; padding: 14px; border-radius: 10px; border: 1px solid rgba(6,182,212,0.3); overflow: hidden; word-wrap: break-word; line-height: 1.4; }
.pi-digit-main { font-size: 1.4rem; color: #fff; text-shadow: 0 0 10px rgba(6,182,212,0.5); }
.pi-decimals { font-size: .85rem; color: #67e8f9; letter-spacing: 1px; }
.stream-note { font-size: .7rem; color: #94a3b8; margin-top: 8px; font-style: italic; }

/* MATH PROOF LIVE */
.math-card { background: rgba(139, 92, 246, 0.05) !important; }
.live-eq { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.eq-term { display: flex; flex-direction: column; align-items: center; background: rgba(30,41,59,0.7); padding: 8px 12px; border-radius: 8px; font-weight: 700; font-size: .8rem; color: #cbd5e1; border: 1px solid rgba(255,255,255,0.05); }
.eq-op { font-size: 1.2rem; font-weight: 700; color: #64748b; }
.term-c span { color: #ec4899; font-size: 1.2rem; font-family: 'Space Grotesk'; }
.term-pi span { color: #8b5cf6; font-size: 1.2rem; font-family: 'Space Grotesk'; }
.term-d span { color: #fcd34d; font-size: 1.2rem; font-family: 'Space Grotesk'; }

.eq-rect { background: linear-gradient(135deg, rgba(236,72,153,0.1), rgba(139,92,246,0.1)); border: 1px solid rgba(236,72,153,0.3); border-radius: 10px; padding: 10px; text-align: center; }
.eq-subtext { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: #cbd5e1; background: rgba(15,23,42,0.6); padding: 12px; border-radius: 10px; }
.final-proof { margin-top: 8px; font-size: 1.05rem; color: #a5b4fc; font-weight: 700; text-align: center; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); }


