/* ═══════════════════════════════════════════
   Twin Matrix — Matrix Status Page
   ═══════════════════════════════════════════ */

/* 2×2 Quadrant Grid — seamless */
.matrix-quadrant-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.matrix-quadrant {
  padding: 0;
  background: none;
  border: none;
}
.matrix-q-cells {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
/* External legend strip */
.matrix-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.matrix-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.matrix-legend-dot {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.matrix-legend-item[data-q="physical"] .matrix-legend-dot { background: rgb(120,180,90); box-shadow: 0 0 6px rgb(120,180,90); }
.matrix-legend-item[data-q="digital"]  .matrix-legend-dot { background: rgb(80,160,220); box-shadow: 0 0 6px rgb(80,160,220); }
.matrix-legend-item[data-q="social"]   .matrix-legend-dot { background: rgb(220,180,60); box-shadow: 0 0 6px rgb(220,180,60); }
.matrix-legend-item[data-q="spiritual"].matrix-legend-dot { background: rgb(180,120,200); box-shadow: 0 0 6px rgb(180,120,200); }
.matrix-legend-item[data-q="physical"] { color: rgb(120,180,90); }
.matrix-legend-item[data-q="digital"]  { color: rgb(80,160,220); }
.matrix-legend-item[data-q="social"]   { color: rgb(220,180,60); }
.matrix-legend-item[data-q="spiritual"]{ color: rgb(180,120,200); }
.matrix-cell {
  display: flex; align-items: center; justify-content: center;
  width: clamp(1.3rem, 2.8vw, 2rem);
  height: clamp(1.3rem, 2.8vw, 2rem);
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: clamp(7px, 1.2vw, 10px);
  border: 1px solid rgba(74, 124, 89, 0.2);
  color: rgba(74, 124, 89, 0.35);
  cursor: default;
  position: relative;
  transition: all 0.15s;
}
.matrix-cell:hover { transform: scale(1.15); z-index: 10; }
.matrix-cell.active {
  color: var(--green-forest);
  border-color: var(--green-forest);
}
body.dark .matrix-cell {
  border-color: rgba(168, 184, 122, 0.15);
  color: rgba(168, 184, 122, 0.25);
}
body.dark .matrix-cell.active {
  color: #d4c89a;
  border-color: #d4c89a;
}
.matrix-cell.active.animate-pop {
  animation: matrixPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes matrixPop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Pending state: dashed borders = not yet on-chain */
.pending-state .matrix-cell.active {
  border-style: dashed;
  border-width: 1.5px;
}
.pending-state .matrix-cell.active::after {
  content: '';
  position: absolute;
  top: -4px; right: -4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #e0a800;
}

/* Quadrant colors */
.matrix-cell[data-q="physical"] { --q-color: 74, 124, 89; }
.matrix-cell[data-q="digital"]  { --q-color: 60, 110, 160; }
.matrix-cell[data-q="social"]   { --q-color: 180, 130, 40; }
.matrix-cell[data-q="spiritual"]{ --q-color: 140, 80, 160; }

body.dark .matrix-cell[data-q="physical"] { --q-color: 120, 180, 90; }
body.dark .matrix-cell[data-q="digital"]  { --q-color: 80, 160, 220; }
body.dark .matrix-cell[data-q="social"]   { --q-color: 220, 180, 60; }
body.dark .matrix-cell[data-q="spiritual"]{ --q-color: 180, 120, 200; }

.matrix-cell.active[data-q="physical"] {
  color: rgb(74, 124, 89);
  border-color: rgba(74, 124, 89, 0.6);
  background: rgba(74, 124, 89, 0.1);
}
.matrix-cell.active[data-q="digital"] {
  color: rgb(60, 110, 160);
  border-color: rgba(60, 110, 160, 0.6);
  background: rgba(60, 110, 160, 0.1);
}
.matrix-cell.active[data-q="social"] {
  color: rgb(180, 130, 40);
  border-color: rgba(180, 130, 40, 0.6);
  background: rgba(180, 130, 40, 0.1);
}
.matrix-cell.active[data-q="spiritual"] {
  color: rgb(140, 80, 160);
  border-color: rgba(140, 80, 160, 0.6);
  background: rgba(140, 80, 160, 0.1);
}

body.dark .matrix-cell.active[data-q="physical"] {
  color: rgb(120, 180, 90);
  border-color: rgba(120, 180, 90, 0.6);
  background: rgba(120, 180, 90, 0.1);
}
body.dark .matrix-cell.active[data-q="digital"] {
  color: rgb(80, 160, 220);
  border-color: rgba(80, 160, 220, 0.6);
  background: rgba(80, 160, 220, 0.1);
}
body.dark .matrix-cell.active[data-q="social"] {
  color: rgb(220, 180, 60);
  border-color: rgba(220, 180, 60, 0.6);
  background: rgba(220, 180, 60, 0.1);
}
body.dark .matrix-cell.active[data-q="spiritual"] {
  color: rgb(180, 120, 200);
  border-color: rgba(180, 120, 200, 0.6);
  background: rgba(180, 120, 200, 0.1);
}

/* Cell tooltip */
.matrix-tooltip {
  position: absolute; bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  padding: 2px 8px; border-radius: 4px;
  font-size: 9px; z-index: 20;
  background: var(--green-deep); color: var(--cream);
  pointer-events: none;
}

/* Insight bars */
.insight-row {
  display: flex; flex-direction: column; gap: 0.4rem;
}
.insight-label-row {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
}
.insight-label { color: var(--text-primary); }
.insight-pct { color: var(--text-secondary); }
.insight-bar {
  height: 6px; border-radius: 4px; overflow: visible;
  background: rgba(74, 124, 89, 0.1);
  position: relative;
}
body.dark .insight-bar { background: rgba(255, 255, 255, 0.05); }

/* Apply quad colors to the bar fill */
.insight-bar-fill[data-q="physical"] { --q-color: 74, 124, 89; }
.insight-bar-fill[data-q="digital"]  { --q-color: 60, 110, 160; }
.insight-bar-fill[data-q="social"]   { --q-color: 180, 130, 40; }
.insight-bar-fill[data-q="spiritual"]{ --q-color: 140, 80, 160; }

body.dark .insight-bar-fill[data-q="physical"] { --q-color: 120, 180, 90; }
body.dark .insight-bar-fill[data-q="digital"]  { --q-color: 80, 160, 220; }
body.dark .insight-bar-fill[data-q="social"]   { --q-color: 220, 180, 60; }
body.dark .insight-bar-fill[data-q="spiritual"]{ --q-color: 180, 120, 200; }

.insight-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  
  /* Lightsaber effect: Bright core, saturated large glow */
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 10px 2px rgba(var(--q-color), 1),
              0 0 20px rgba(var(--q-color), 0.6);
}

/* ── Selective Disclosure UI ── */
.sd-panel {
  margin-top: 1.5rem;
}
.sd-note {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border-left: 2px solid var(--green-deep);
  background: rgba(74, 124, 89, 0.04);
  border-radius: 0 4px 4px 0;
}
body.dark .sd-note { background: rgba(255,255,255,0.02); }
.sd-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.3rem;
}
.sd-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: background 0.15s;
}
.sd-item:hover { background: rgba(74, 124, 89, 0.06); }
body.dark .sd-item:hover { background: rgba(255,255,255,0.03); }
.sd-item input[type="checkbox"] {
  accent-color: var(--green-forest);
  width: 14px; height: 14px;
  cursor: pointer;
}
.sd-dim-idx {
  color: var(--text-muted);
  min-width: 2.5rem;
}
.sd-dim-label {
  flex: 1;
  color: var(--text-primary);
}
.sd-dim-val {
  color: var(--text-secondary);
  min-width: 2rem;
  text-align: right;
}
.sd-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}
.sd-count {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Success state */
.chain-success-card {
  text-align: center;
  padding: 1.5rem;
}
.chain-success-card h3 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--green-deep);
  margin-bottom: 0.6rem;
}
.chain-success-card p {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  .matrix-quadrant-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
  .matrix-cell {
    width: 1.6rem; height: 1.6rem;
    font-size: 7px;
  }
  .app-stats-bar { grid-template-columns: repeat(3, 1fr) !important; }
  .app-stats-bar .app-stat-cell:nth-child(n+4) { display: none; }
}

/* ── Humanity flash on the Begin Onboarding CTA ────────────────── */
@keyframes humflashIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Humanity "+" button hover treatment (matches Completion "+" styling) ── */
#btn-humanity-verify:hover {
  background: rgba(82, 168, 120, 0.12);
  border-color: var(--green);
}
