:root {
    /* Ground, ink and rules from the shared ecosystem tokens with
       pre-adoption fallbacks. The orange/green/blue/purple accents stay local. */
    --bg-color: var(--mjm-bg, #0f172a);
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-main: var(--mjm-ink, #f8fafc);
    --text-muted: var(--mjm-muted, #94a3b8);
    --mjm-accent: var(--mjm-blue, #3b82f6);
    --accent-orange: #f59e0b;
    --accent-green: #10b981;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background */
.background-animation {
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 60%),
                radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
    z-index: -1;
    animation: pulse 15s infinite alternate;
}
@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.1) translate(-2%, 2%); }
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.paired-link-panel {
    max-width: 900px;
    margin: 1rem auto 0;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.paired-link-panel p {
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.paired-link-panel a {
    flex: 0 0 auto;
    color: #07111f;
    background: var(--accent-orange);
    text-decoration: none;
    font-weight: 800;
    padding: 0.65rem 0.8rem;
    border-radius: 8px;
}

.paired-link-panel a:hover,
.paired-link-panel a:focus {
    background: #fbbf24;
    outline: 3px solid rgba(245, 158, 11, 0.25);
    outline-offset: 2px;
}

header { text-align: center; padding: 2rem; margin: 2rem auto; max-width: 900px; }
header h1 {
    font-weight: 700; font-size: 2.5rem; margin-bottom: 0.5rem;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle { color: var(--accent-orange); font-weight: 600; }

nav { position: sticky; top: 1rem; max-width: 900px; margin: 0 auto 2rem auto; z-index: 100; padding: 0.5rem; }
nav ul { list-style: none; display: flex; justify-content: space-around; flex-wrap: wrap; }
nav a { color: var(--text-muted); text-decoration: none; padding: 0.5rem 1rem; border-radius: 8px; font-weight: 600; transition: all 0.3s; }
nav a:hover, nav a.active { color: var(--text-main); background: rgba(255, 255, 255, 0.1); }

main { max-width: 900px; margin: 0 auto 4rem auto; }

/* Global Toggle Control */
.global-controls {
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    padding: 1rem; margin-bottom: 2rem; background: rgba(59, 130, 246, 0.1); border-color: var(--accent-blue);
}

.toggle-switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--panel-border); transition: .4s; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--accent-green); }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }
.toggle-label { font-weight: 600; font-size: 1.1rem; }

/* Section Management */
.section-container { padding: 2rem; margin-bottom: 2rem; opacity: 0.3; transform: translateY(20px); transition: all 0.5s ease; }
.section-container.active-section { opacity: 1; transform: translateY(0); }

.section-header { margin-bottom: 1.5rem; border-bottom: 2px solid var(--panel-border); padding-bottom: 0.5rem; }
h2 { font-size: 1.8rem; }

/* View Modes (Academic vs Simple) */
.content-wrapper { position: relative; margin-bottom: 1.5rem; min-height: 100px; }
.view-mode { position: absolute; top: 0; left: 0; width: 100%; opacity: 0; visibility: hidden; transition: all 0.4s ease-in-out; transform: translateY(10px); }
.view-mode.active-view { opacity: 1; visibility: visible; transform: translateY(0); position: relative; }

.academic-text p, .simple-text p { margin-bottom: 1rem; }
.simple-text { background: rgba(16, 185, 129, 0.1); padding: 1.5rem; border-left: 4px solid var(--accent-green); border-radius: 8px; }
.simple-text strong { color: var(--accent-green); }

/* Tooltips */
/* Lifted from the shared blue, which reads 4.34 on the panel. Scoped here
   so --accent-blue keeps its value for bars and fills. */
.tooltip {
    border-bottom: 1px dotted #5a97f8;
    cursor: help;
    position: relative;
    color: #5a97f8;
    font-weight: 600;
}
.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%; left: 50%; transform: translateX(-50%);
    background: #1e293b; color: #fff;
    padding: 0.5rem 1rem; border-radius: 6px;
    font-size: 0.85rem; font-weight: 400;
    white-space: normal; width: 250px; text-align: center;
    z-index: 1000; box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    margin-bottom: 8px; pointer-events: none;
}
.tooltip:hover::before {
    content: ""; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    border-width: 6px; border-style: solid; border-color: #1e293b transparent transparent transparent;
    margin-bottom: 2px;
}

/* Interactive Elements */
.interactive-box { background: rgba(15, 23, 42, 0.6); border-radius: 12px; padding: 1.5rem; border: 1px solid var(--panel-border); }
.flex-row { display: flex; gap: 2rem; align-items: center; }

.control-group { margin-bottom: 1.5rem; }
.control-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; }
.control-group span { color: var(--accent-blue); }
.highlight-label { color: var(--accent-orange); }

input[type="range"] { width: 100%; accent-color: var(--accent-blue); cursor: pointer; }
.instruction { color: var(--accent-orange); font-weight: 600; font-size: 0.9rem; margin-bottom: 1rem; }

/* Guided Text */
.guided-text { background: rgba(255, 255, 255, 0.05); padding: 1rem; border-radius: 8px; font-style: italic; border-left: 3px solid var(--accent-orange); }

/* Charts */
.chart-container { flex: 1; min-width: 300px; height: 250px; }
.insight { margin-top: 1rem; padding: 1rem; background: rgba(59, 130, 246, 0.1); border-left: 4px solid var(--accent-blue); border-radius: 4px; font-size: 0.95rem; }

/* Composite Scoring Grid */
.scoring-demo { display: flex; gap: 2rem; }
.items-grid { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.item-val { background: var(--bg-color); color: var(--text-main); border: 1px solid var(--panel-border); padding: 0.25rem; border-radius: 4px; margin-left: 1rem; }
.results-grid { flex: 1; display: flex; flex-direction: column; gap: 1rem; }
.result-card { background: var(--bg-color); padding: 1rem; border-radius: 8px; text-align: center; border: 1px solid var(--panel-border); transition: all 0.3s; }
.result-card.highlight { border-color: var(--accent-green); box-shadow: 0 0 15px rgba(16, 185, 129, 0.2); }
.score-val { font-size: 2rem; font-weight: 700; margin: 0.5rem 0; }

/* Item-behaviour dials (mean inter-item and item-total r) */
.simulation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.controls-panel { border-right: 1px solid var(--panel-border); padding-right: 2rem; }
.metrics-panel { display: flex; justify-content: space-around; align-items: center; }
.metric-card { text-align: center; }
.dial { position: relative; width: 120px; height: 120px; margin: 1rem auto; }
.circular-chart { display: block; margin: 0 auto; max-width: 80%; max-height: 250px; }
.circle-bg { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 3.8; }
.circle { fill: none; stroke-width: 2.8; stroke-linecap: round; transition: stroke-dasharray 0.5s ease-out; }
.orange .circle { stroke: var(--accent-orange); }
.green .circle { stroke: var(--accent-green); }
.percentage { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 1.5rem; font-weight: 700; }
.insight-panel { grid-column: 1 / -1; }

/* EFA Visualization */
.efa-vis { height: 200px; position: relative; border: 1px dashed var(--panel-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: all 0.5s; }
.efa-vis.locked .factor-nodes { filter: blur(5px); opacity: 0.3; }
.lock-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.8); z-index: 10; transition: opacity 0.5s; opacity: 0; pointer-events: none; }
.efa-vis.locked .lock-overlay { opacity: 1; }
.lock-overlay .icon { font-size: 3rem; margin-bottom: 1rem; }
.factor-nodes { display: flex; gap: 2rem; transition: all 0.5s; }
.factor { padding: 1rem; border-radius: 50%; width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 600; font-size: 0.8rem; background: rgba(255, 255, 255, 0.05); border: 2px solid; transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.noetic { border-color: var(--accent-blue); }
.rhetorical { border-color: var(--accent-orange); }
.existential { border-color: var(--accent-purple); }
.infrastructural { border-color: var(--accent-green); }
.efa-vis.unlocked .factor-nodes { gap: 1rem; }
.efa-vis.unlocked .factor { transform: scale(1.1); box-shadow: 0 0 20px rgba(255, 255, 255, 0.1); }

@media (max-width: 768px) {
    .paired-link-panel { align-items: flex-start; flex-direction: column; margin-left: 1rem; margin-right: 1rem; }
    .flex-row, .simulation-grid, .scoring-demo { flex-direction: column; grid-template-columns: 1fr; }
    .controls-panel { border-right: none; border-bottom: 1px solid var(--panel-border); padding-right: 0; padding-bottom: 2rem; }
}


/* ------------------------------------------------------------------ */
/* July 2026 alignment pass: DOM bars replacing the Chart.js canvases  */
/* ------------------------------------------------------------------ */

.split-bar {
  display: flex; width: 100%; height: 44px; border-radius: 6px; overflow: hidden;
  background: rgba(148, 163, 184, .18);
}
.split-bar span {
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 600; color: #0b1120;
  transition: width .25s ease; white-space: nowrap; overflow: hidden;
}
.split-valid { background: #3b82f6; }
.split-missing { background: #f59e0b; }

.compare-bars { display: grid; gap: 14px; width: 100%; }
.compare-row {
  display: grid; grid-template-columns: minmax(120px, auto) 1fr auto;
  gap: 12px; align-items: center;
}
.compare-label { font-size: .88rem; color: #cbd5e1; }
.compare-track {
  height: 18px; border-radius: 4px; background: rgba(148, 163, 184, .18); overflow: hidden;
}
.compare-fill { display: block; height: 100%; background: #10b981; }
.compare-value { font-variant-numeric: tabular-nums; font-weight: 700; color: #e2e8f0; }
