/* ============================================
   MRCAF — Meta-Recursive Cognition Framework
   Main Stylesheet
   ============================================ */

:root {
  --bg:       #080c12;
  --surface:  #0d1520;
  --card:     #111a28;
  --border:   #1e2e45;
  --glow:     #00d4ff;
  --gold:     #f5c842;
  --coral:    #ff6b5b;
  --green:    #3effa0;
  --purple:   #b06dff;
  --text:     #c8d8ec;
  --muted:    #5a7a9a;
  --white:    #eef4ff;
  --phi:      0.618034;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Space Mono', monospace;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  cursor: crosshair;
}

/* ── NOISE OVERLAY ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 1000; opacity: 0.35;
}

/* ── ANIMATED GRID BG ── */
.grid-bg {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: gridDrift 40s linear infinite;
}
@keyframes gridDrift {
  0%   { background-position: 0 0; }
  100% { background-position: 48px 48px; }
}

/* ── LAYOUT ── */
.wrapper { position: relative; z-index: 10; max-width: 1280px; margin: 0 auto; padding: 0 32px; }

/* ── HERO ── */
header {
  position: relative;
  padding: 80px 0 48px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.hero-glow {
  position: absolute; top: -120px; left: 50%; transform: translateX(-50%);
  width: 800px; height: 400px;
  background: radial-gradient(ellipse, rgba(0,212,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.kicker {
  font-family: 'Space Mono', monospace;
  font-size: 10px; letter-spacing: 4px;
  color: var(--glow); text-transform: uppercase;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}
.kicker::before, .kicker::after {
  content: ''; flex: 1; max-width: 60px;
  height: 1px; background: var(--glow); opacity: 0.4;
}
h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(28px, 4vw, 52px);
  font-weight: 800;
  color: var(--white);
  line-height: 1.05;
  letter-spacing: -1px;
  margin-bottom: 8px;
}
h1 span { color: var(--gold); }
.subtitle {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 18px; color: var(--muted);
  margin-bottom: 32px;
}
.phi-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(245,200,66,0.08);
  border: 1px solid rgba(245,200,66,0.3);
  border-radius: 4px; padding: 6px 14px;
  font-size: 11px; color: var(--gold); letter-spacing: 2px;
}

/* ── NAV TABS ── */
nav.tabs {
  display: flex; gap: 4px;
  padding: 24px 0 0;
  flex-wrap: wrap;
}
.tab-btn {
  font-family: 'Space Mono', monospace;
  font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 3px;
  text-decoration: none;
  display: inline-block;
}
.tab-btn:hover { border-color: var(--glow); color: var(--glow); }
.tab-btn.active {
  background: rgba(0,212,255,0.08);
  border-color: var(--glow);
  color: var(--glow);
}

/* ── SECTIONS ── */
section { display: none; padding: 48px 0; }
section.active { display: block; }

/* ── SECTION HEADERS ── */
.section-header {
  display: flex; align-items: flex-start; gap: 20px;
  margin-bottom: 36px;
}
.section-num {
  font-family: 'Syne', sans-serif; font-size: 72px; font-weight: 800;
  line-height: 1; color: rgba(0,212,255,0.08);
  flex-shrink: 0; margin-top: -8px;
}
.section-title { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 700; color: var(--white); }
.section-desc { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.7; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  transition: border-color 0.3s;
}
.card:hover { border-color: rgba(0,212,255,0.25); }

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

/* ── ANALOGY CARDS ── */
.analogy-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.3s;
}
.analogy-card:hover { transform: translateY(-2px); border-color: var(--glow); }
.analogy-header {
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.analogy-icon { font-size: 24px; }
.analogy-domain {
  font-size: 9px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--muted);
}
.analogy-name {
  font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; color: var(--white);
}
.analogy-body { padding: 16px 20px; }
.sim-concept {
  font-size: 10px; letter-spacing: 2px; color: var(--glow);
  text-transform: uppercase; margin-bottom: 6px;
}
.sim-value {
  font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; color: var(--white);
  margin-bottom: 10px;
}
.analogy-arrow {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--muted);
  margin: 12px 0;
}
.analogy-arrow::before, .analogy-arrow::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.human-concept { font-size: 13px; color: var(--text); line-height: 1.6; }
.tag {
  display: inline-block;
  font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 3px; margin-top: 10px;
}
.tag-gold { background: rgba(245,200,66,0.1); color: var(--gold); border: 1px solid rgba(245,200,66,0.2); }
.tag-green { background: rgba(62,255,160,0.1); color: var(--green); border: 1px solid rgba(62,255,160,0.2); }
.tag-coral { background: rgba(255,107,91,0.1); color: var(--coral); border: 1px solid rgba(255,107,91,0.2); }
.tag-purple { background: rgba(176,109,255,0.1); color: var(--purple); border: 1px solid rgba(176,109,255,0.2); }
.tag-cyan  { background: rgba(0,212,255,0.1); color: var(--glow); border: 1px solid rgba(0,212,255,0.2); }

/* ── METRIC BARS ── */
.metric-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.metric-label { font-size: 11px; color: var(--muted); width: 160px; flex-shrink: 0; }
.bar-track {
  flex: 1; height: 6px;
  background: var(--border); border-radius: 3px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.metric-val { font-size: 11px; color: var(--white); width: 60px; text-align: right; flex-shrink: 0; }

/* ── RECURSION LEVELS ── */
.level-list { display: flex; flex-direction: column; gap: 0; }
.level-item {
  display: grid; grid-template-columns: 80px 1fr;
  gap: 0;
  border-left: 2px solid var(--border);
  padding: 0 0 0 24px;
  margin-left: 40px;
  position: relative;
  transition: border-color 0.3s;
}
.level-item:hover { border-color: var(--glow); }
.level-item::before {
  content: attr(data-level);
  position: absolute; left: -41px; top: 16px;
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 700;
  color: var(--glow);
  background: var(--bg);
  padding: 2px 6px;
  border: 1px solid var(--glow);
  border-radius: 3px;
}
.level-content {
  grid-column: 2;
  padding: 20px 0 28px;
}
.level-title {
  font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700;
  color: var(--white); margin-bottom: 6px;
}
.level-sim { font-size: 12px; color: var(--glow); margin-bottom: 4px; }
.level-human { font-size: 13px; color: var(--text); line-height: 1.7; margin-bottom: 10px; }
.level-metric {
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--gold);
  background: rgba(245,200,66,0.06);
  border: 1px solid rgba(245,200,66,0.15);
  padding: 4px 10px; border-radius: 3px;
  display: inline-block;
}

/* ── FORMULA BLOCKS ── */
.formula-block {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  padding: 16px 20px;
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  color: var(--gold);
  overflow-x: auto;
}
.formula-block .comment { color: var(--muted); font-size: 11px; }

/* ── DATA TABLE ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px; color: var(--text);
  border-bottom: 1px solid rgba(30,46,69,0.5);
}
.data-table tr:hover td { background: rgba(0,212,255,0.03); }
.data-table .num { color: var(--glow); font-family: 'Space Mono', monospace; }
.data-table .good { color: var(--green); }
.data-table .warn { color: var(--gold); }
.data-table .crit { color: var(--coral); }

/* ── CANVAS CHART ── */
.chart-wrap { position: relative; width: 100%; }
canvas { width: 100% !important; display: block; }

/* ── CORRELATION MAP ── */
.corr-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}
.corr-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--white); font-weight: 700;
  border-radius: 3px;
  transition: transform 0.2s;
  cursor: default;
}
.corr-cell:hover { transform: scale(1.15); z-index: 10; }
.corr-label {
  font-size: 9px; color: var(--muted); letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
}

/* ── PHASE DIAGRAM ── */
#phaseDiagram { background: var(--surface); border-radius: 8px; }

/* ── INSIGHT BLOCKS ── */
.insight {
  display: flex; gap: 16px;
  padding: 20px;
  border-left: 3px solid var(--border);
  margin-bottom: 16px;
  background: var(--card);
  border-radius: 0 8px 8px 0;
  transition: border-color 0.3s;
}
.insight:hover { border-left-color: var(--glow); }
.insight-num {
  font-family: 'Syne', sans-serif; font-size: 32px; font-weight: 800;
  color: rgba(0,212,255,0.12); flex-shrink: 0; line-height: 1;
}
.insight-title { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--white); margin-bottom: 6px; }
.insight-text { font-size: 12px; color: var(--text); line-height: 1.7; }
.insight-human { font-size: 11px; color: var(--gold); margin-top: 8px; font-style: italic; }

/* ── STAT BOXES ── */
.stat-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px; text-align: center;
}
.stat-box .stat-val {
  font-family: 'Syne', sans-serif; font-size: 36px; font-weight: 800;
  color: var(--white); line-height: 1;
}
.stat-box .stat-unit { font-size: 13px; color: var(--gold); margin-top: 2px; }
.stat-box .stat-label { font-size: 10px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-top: 8px; }

/* ── MRS INDICATOR ── */
.mrs-gauge {
  display: flex; flex-direction: column; align-items: center; padding: 32px;
}
.gauge-svg { width: 200px; height: 120px; }

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 64px;
  display: flex; justify-content: space-between; align-items: center;
}
footer .ftext { font-size: 11px; color: var(--muted); }
.phi-symbol {
  font-family: 'Instrument Serif', serif;
  font-size: 40px; color: rgba(245,200,66,0.2);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .wrapper { padding: 0 16px; }
  h1 { font-size: 28px; }
}

/* ── ANIMATIONS ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.animate-in { animation: fadeIn 0.5s ease both; }
.pulse { animation: pulse 2.5s ease infinite; }

.dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin-right: 6px;
  animation: pulse 2s ease infinite;
}
