/* Trig Hand Rule Simulation - Styles */
* { box-sizing: border-box; }
:root {
    --primary: #f472b6;
    /* Pink as the hand's primary highlight */
    --accent: #22d3ee;
    /* Cyan for cos highlighting */
    --accent-yellow: #fbbf24;
    /* Yellow for sine highlighting */
    --bg: #0f172a;
    --grid: rgba(255, 255, 255, 0.05);
}

body.math-lab-theme {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    background: var(--bg);
    color: white;
    overflow: hidden; touch-action: none;
    display: flex;
    flex-direction: column;
    font-family: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

#phet-stage {
    position: absolute; top: 0; left: 0;
    width: 1280px; height: 720px;
    background: var(--bg);
    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;
}

#sim-app {
    flex: 1;
    display: flex;
    gap: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.hand-panel {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    background: radial-gradient(var(--grid) 1px, transparent 1px);
    background-size: 40px 40px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Side Info Overlay */
.math-overlay {
    position: absolute;
    top: 40px;
    right: 40px;
    pointer-events: none;
    z-index: 10;
}

.formula-label {
    color: var(--primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
    margin-bottom: 15px;
    display: block;
}

.hud-box {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 10px 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border-right: 3px solid var(--primary);
    border-left: none;
    min-width: 150px;
}

#ratio-name {
    font-size: 0.75rem;
    margin-bottom: 5px;
    color: #94a3b8;
    font-weight: 600;
}

#ratio-calc {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono';
    font-size: 1.1rem;
    font-weight: 700;
}

/* Fraction Styling */
.frac {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.numer {
    border-bottom: 2px solid white;
    padding: 0 10px;
}

.denom {
    padding-top: 5px;
}

.eq {
    color: rgba(255, 255, 255, 0.3);
}

.res {
    color: var(--primary);
    text-shadow: 0 0 20px rgba(244, 114, 182, 0.4);
}

/* SVG Hand Section */
.hand-svg-container {
    width: 80%;
    max-width: 600px;
}

.interactive-hand {
    overflow: visible;
}

.hand-base path {
    fill: rgba(244, 114, 182, 0.05);
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3;
}

.finger-zone circle {
    stroke: rgba(255,255,255,0.1); stroke-width: 2; transition: 0.3s; cursor: pointer;
}

.finger-zone:hover circle { stroke: rgba(255,255,255,0.5); fill: rgba(255,255,255,0.05); }

.zone-label {
    fill: #64748b; font-size: 14px; font-weight: 800; font-family: 'Outfit';
    pointer-events: none; transition: 0.3s;
}

/* Glow States */
.finger-zone.active circle {
    stroke: var(--primary); fill: rgba(244, 114, 182, 0.2); filter: drop-shadow(0 0 10px var(--primary));
}

.finger-zone.active .zone-label { fill: white; filter: brightness(1.5); font-size: 18px; }

.finger-zone.counting-sin circle {
    stroke: var(--accent-yellow); fill: rgba(251, 191, 36, 0.1);
}

.finger-zone.counting-cos circle {
    stroke: var(--accent); fill: rgba(34, 211, 238, 0.1);
}

/* Sidebar Explanation */
.calc-sidebar {
    background: #1e293b;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px;
    width: 270px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    z-index: 100;
}

.theorem-card h2 {
    font-size: 1.3rem;
    margin: 0 0 6px;
    background: linear-gradient(135deg, #f472b6, #fb7185);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #94a3b8;
    line-height: 1.4;
    font-size: 0.8rem;
}

.instruction-box {
    margin-top: 10px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.instruction-box p {
    margin: 0 0 10px;
    color: #cbd5e1;
    line-height: 1.5;
    font-size: 0.82rem;
}

.instruction-box strong {
    color: var(--primary);
}

.formula-box {
    background: #0f172a;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.math-font {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

.step-guide {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.step-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid transparent;
}

.step-item.active {
    border-color: rgba(244, 114, 182, 0.15);
    background: rgba(244, 114, 182, 0.05);
}

.step-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #334155;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 0.9rem;
}

.step-item.active .step-num {
    background: var(--primary);
    color: white;
}

.step-text h4 {
    margin: 0 0 5px;
    font-size: 1rem;
    color: #f8fafc;
}

.step-text p {
    margin: 0;
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.4;
}

.insight-box {
    margin-top: auto;
    padding: 14px;
    background: rgba(244, 114, 182, 0.05);
    border: 1px dashed var(--primary);
    border-radius: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--primary);
}

.insight-box i {
    font-size: 1.4rem;
    opacity: 0.8;
}

.insight-box p {
    margin: 0;
    font-size: 0.78rem;
    color: white;
    line-height: 1.4;
    opacity: 0.9;
}

/* Switcher Positioning */
.mode-switcher-container {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.mode-switcher {
    display: flex;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 14px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.mode-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 10px 24px;
    font-size: 0.9rem;
    font-family: 'Outfit';
    font-weight: 700;
    cursor: pointer;
    border-radius: 10px;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 5px 20px rgba(244, 114, 182, 0.4);
}

/* Tutorial Box */
.tutorial-box {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 15px 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    width: 320px;
    opacity: 1;
    transition: 0.5s;
}

.tutorial-box.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

.tutorial-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.tuto-icon { font-size: 1.5rem; }
.tuto-text h4 { margin: 0; color: var(--primary); font-size: 0.9rem; text-transform: uppercase; }
.tuto-text p { margin: 2px 0 0; color: #cbd5e1; font-size: 0.85rem; }

.tuto-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.1);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.1s linear;
}

/* Tutorial Trigger Button */
.tutorial-trigger-box {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
}

.btn-demo {
    background: linear-gradient(135deg, var(--bg) 0%, #1e293b 100%);
    border: 1px solid rgba(244, 114, 182, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.btn-demo:hover {
    border-color: var(--primary);
    background: rgba(244, 114, 182, 0.1);
    transform: translateY(-2px);
}

.tiny-text { font-size: 0.7rem; color: #64748b; margin-top: 8px; }

/* Pulse Animation for Demo */
@keyframes demo-pulse {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.5); }
    100% { transform: scale(1); filter: brightness(1); }
}

.demo-active {
    animation: demo-pulse 1s infinite;
}