/* ============================================================
   COMPONENT STYLES — swarm · buddy · review
   ============================================================ */

/* ---------- SWARM ---------- */
.swarm { position: relative; }
.swarm-stage {
  display: grid;
  grid-template-columns: 0.85fr 2.2fr 0.85fr;
  gap: 0; align-items: center;
  position: relative; z-index: 2;
  min-height: 360px;
}
.swarm-col { display: flex; flex-direction: column; gap: 14px; }
.swarm-goal-col { align-items: flex-start; }
.swarm-merge-col { align-items: flex-end; }
.swarm-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--faint);
}
.swarm-node {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.4s, box-shadow 0.4s, transform 0.4s;
}
.swarm-node.goal { border-color: rgba(232,176,75,0.4); }
.swarm-node.goal.active { box-shadow: 0 0 0 1px rgba(232,176,75,0.5), var(--glow-violet); }
.swarm-node.main.active { box-shadow: 0 0 0 1px rgba(67,224,138,0.5), 0 0 50px rgba(67,224,138,0.25); border-color: rgba(67,224,138,0.5); }
.swarm-commits { font-size: 12px; color: var(--muted); }
.swarm-commits b { color: var(--green); font-family: var(--mono); }

.swarm-lanes { display: flex; flex-direction: column; gap: 10px; }
.swarm-lane {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 14px;
  opacity: 0.25; transform: translateX(-10px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), border-color 0.4s;
}
.swarm-lane.spawned { opacity: 1; transform: none; }
.swarm-lane.judged { border-color: var(--line-strong); }
.swarm-lane.merging { box-shadow: 0 0 30px rgba(61,127,184,0.18); border-color: rgba(61,127,184,0.4); }
.lane-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.lane-id { font-size: 11px; color: var(--brass-lt); background: rgba(232,176,75,0.1); padding: 2px 7px; border-radius: 5px; }
.lane-name { font-size: 13.5px; color: var(--ink); flex: 1; }
.lane-model { font-size: 11px; color: var(--faint); }
.lane-cands { display: flex; gap: 8px; }
.cand { flex: 1; }
.cand-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.07); overflow: hidden; position: relative; }
.cand-bar i {
  position: absolute; inset: 0; width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--violet-lt));
  border-radius: 3px;
}
.swarm-lane.running .cand-bar i { animation: fill 1.4s var(--ease) forwards; }
.swarm-lane.running .cand:nth-child(2) .cand-bar i { animation-delay: 0.15s; }
.swarm-lane.running .cand:nth-child(3) .cand-bar i { animation-delay: 0.3s; }
@keyframes fill { to { width: 100%; } }
.cand.win .cand-bar { box-shadow: 0 0 12px rgba(67,224,138,0.6); }
.cand.win .cand-bar i { background: linear-gradient(90deg, var(--green), #8af0b4); width: 100% !important; animation: none; }
.cand.lose .cand-bar i { background: rgba(255,255,255,0.12); width: 100% !important; animation: none; }
.cand.lose { opacity: 0.4; }

.swarm-wires { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; overflow: visible; }
.wire { fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 5 5; opacity: 0; transition: opacity 0.6s; }
.swarm-wires.show-in .wire-in { opacity: 0.7; animation: dash 1s linear infinite; }
.swarm-wires.show-out .wire-out { opacity: 0.7; stroke: rgba(67,224,138,0.5); animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -20; } }

.swarm-log {
  margin-top: 26px; border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(0,0,0,0.3); overflow: hidden;
}
.swarm-log-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.swarm-phase { margin-left: auto; color: var(--teal-lt); }
.swarm-log-body { padding: 10px 16px; height: 132px; overflow: hidden; display: flex; flex-direction: column; gap: 6px; justify-content: flex-end; }
.log-line { display: flex; gap: 12px; font-size: 12.5px; opacity: 0; transform: translateY(6px); transition: opacity 0.4s, transform 0.4s; }
.log-line.in { opacity: 1; transform: none; }
.log-name { font-size: 12px; flex: none; width: 168px; }
.log-msg { color: var(--ink-2); font-family: var(--mono); font-size: 12px; }
.tone-violet { color: var(--violet-lt); } .tone-teal { color: var(--teal-lt); }
.tone-green { color: var(--green); } .tone-brass { color: var(--brass-lt); } .tone-muted { color: var(--faint); }

@media (max-width: 860px) {
  .swarm-stage { grid-template-columns: 1fr; gap: 22px; }
  .swarm-goal-col, .swarm-merge-col { align-items: stretch; }
  .swarm-wires { display: none; }
}

/* ---------- BUDDY ---------- */
.buddy { display: grid; grid-template-columns: 320px 1fr; gap: 40px; align-items: center; }
.buddy-viz { position: relative; height: 320px; display: flex; align-items: center; justify-content: center; }
.buddy-halo {
  position: absolute; width: 260px; height: 260px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 60px rgba(61,127,184,0.1);
  animation: spin 24s linear infinite;
}
.buddy-halo::before {
  content: ''; position: absolute; top: -4px; left: 50%; width: 8px; height: 8px;
  border-radius: 50%; background: var(--brass); box-shadow: 0 0 12px var(--brass); transform: translateX(-50%);
}
@keyframes spin { to { transform: rotate(360deg); } }

.buddy-orb {
  position: relative; width: 168px; height: 168px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #1e2532, #10131a 70%);
  border: 1px solid rgba(61,127,184,0.35);
  box-shadow: 0 0 60px rgba(61,127,184,0.3), inset 0 -20px 40px rgba(0,0,0,0.5), inset 0 8px 20px rgba(61,127,184,0.15);
  animation: bob 5s ease-in-out infinite;
  transition: box-shadow 0.6s, border-color 0.6s;
}
@keyframes bob { 50% { transform: translateY(-12px); } }
.buddy-scan {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden; opacity: 0.5;
  background: linear-gradient(transparent 46%, rgba(61,127,184,0.18) 50%, transparent 54%);
  background-size: 100% 8px; animation: scanmove 4s linear infinite;
}
@keyframes scanmove { to { background-position: 0 40px; } }
.buddy-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 22px; }
.eye {
  width: 17px; height: 30px; border-radius: 10px;
  background: var(--teal-lt); box-shadow: 0 0 16px var(--teal-lt);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-radius 0.3s var(--ease); position: relative; top: -6px;
}
.mouth {
  position: absolute; bottom: 46px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 4px; border-radius: 4px; background: var(--teal-lt);
  box-shadow: 0 0 10px var(--teal-lt); transition: box-shadow 0.3s var(--ease), border 0.3s var(--ease);
}
/* states — orb glow keyed off orb class; eyes/mouth keyed off DIRECT element classes */
.buddy-orb.s-thinking { border-color: rgba(61,127,184,0.5); box-shadow: 0 0 70px rgba(61,127,184,0.45), inset 0 -20px 40px rgba(0,0,0,0.5); }
.eye.mood-thinking { background: var(--violet-lt); box-shadow: 0 0 16px var(--violet-lt); height: 22px; top: -14px; animation: look 2s ease-in-out infinite; }
.mouth.mood-thinking { width: 14px; }
@keyframes look { 0%,100% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

.buddy-orb.s-concerned { border-color: rgba(255,93,108,0.55); box-shadow: 0 0 70px rgba(255,93,108,0.4), inset 0 -20px 40px rgba(0,0,0,0.5); }
.eye.mood-concerned { background: var(--red); box-shadow: 0 0 16px var(--red); height: 26px; }
.eye-l.mood-concerned { transform: rotate(18deg); }
.eye-r.mood-concerned { transform: rotate(-18deg); }
.mouth.mood-concerned { width: 22px; height: 12px; border-radius: 0 0 14px 14px; border: 2px solid var(--red); background: transparent; box-shadow: 0 0 10px rgba(255,93,108,0.4); bottom: 42px; }

.buddy-orb.s-happy { border-color: rgba(67,224,138,0.55); box-shadow: 0 0 70px rgba(67,224,138,0.4), inset 0 -20px 40px rgba(0,0,0,0.5); }
.eye.mood-happy { background: var(--green); box-shadow: 0 0 16px var(--green); height: 13px; border-radius: 12px 12px 3px 3px; top: -10px; }
.mouth.mood-happy { width: 30px; height: 14px; border-radius: 0 0 18px 18px; background: var(--green); box-shadow: 0 0 14px rgba(67,224,138,0.5); bottom: 40px; }

.buddy-orb.s-talking { border-color: rgba(95,240,220,0.5); }
.eye.mood-talking { background: var(--teal-lt); height: 24px; }
.mouth.mood-talking { animation: talk 0.4s ease-in-out infinite; }
@keyframes talk { 0%,100% { height: 5px; width: 24px; } 50% { height: 14px; width: 18px; border-radius: 8px; } }

.buddy-moon {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: var(--brass-lt); box-shadow: 0 0 14px var(--brass);
  top: 50%; left: 50%; margin: -6px;
  animation: moon 8s linear infinite;
}
@keyframes moon { from { transform: rotate(0) translateX(108px); } to { transform: rotate(360deg) translateX(108px); } }

.buddy-wave { position: absolute; bottom: 8px; display: flex; gap: 3px; align-items: flex-end; height: 26px; opacity: 0; transition: opacity 0.4s; }
.buddy-orb.s-talking ~ .buddy-wave, .buddy:has(.s-talking) .buddy-wave { opacity: 1; }
.buddy-wave i { width: 3px; height: 6px; border-radius: 2px; background: var(--teal); animation: wv 0.9s ease-in-out infinite; }
.buddy-wave i:nth-child(odd) { animation-delay: 0.2s; }
.buddy-wave i:nth-child(3n) { animation-delay: 0.4s; }
.buddy-wave i:nth-child(3n+1) { animation-delay: 0.1s; }
@keyframes wv { 50% { height: 22px; } }

.buddy-side { display: flex; flex-direction: column; gap: 14px; }
.buddy-name { display: flex; align-items: center; gap: 12px; }
.buddy-tag { font-size: 13px; color: var(--teal-lt); }
.buddy-state-pill {
  font-family: var(--mono); font-size: 11px; padding: 3px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); color: var(--muted); text-transform: lowercase;
}
.buddy-state-pill.tone-thinking { color: var(--violet-lt); border-color: rgba(61,127,184,0.4); }
.buddy-state-pill.tone-concerned { color: var(--red); border-color: rgba(255,93,108,0.4); }
.buddy-state-pill.tone-happy { color: var(--green); border-color: rgba(67,224,138,0.4); }
.buddy-state-pill.tone-talking { color: var(--teal-lt); border-color: rgba(45,212,191,0.4); }

.buddy-bubble {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-strong); border-radius: var(--r); border-top-left-radius: 0;
  padding: 18px 20px; font-size: 18px; line-height: 1.5; color: var(--ink);
  min-height: 64px; position: relative; font-family: var(--display); letter-spacing: -0.01em;
}
.buddy-bubble.typing::after { content: '▍'; color: var(--teal); animation: blink 1s infinite; }
.buddy-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.buddy-controls button {
  font-family: var(--mono); font-size: 12px; padding: 7px 13px; border-radius: var(--r-sm);
  background: rgba(255,255,255,0.03); border: 1px solid var(--line-strong); color: var(--ink-2);
  cursor: pointer; transition: all 0.2s;
}
.buddy-controls button:hover { border-color: var(--violet); color: var(--ink); background: rgba(61,127,184,0.1); transform: translateY(-1px); }
.buddy-meta { font-size: 11.5px; color: var(--faint); }

@media (max-width: 760px) {
  .buddy { grid-template-columns: 1fr; gap: 24px; }
  .buddy-viz { height: 260px; }
}

/* ---------- REVIEW ---------- */
.review-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: stretch; }
.review-stage {
  position: relative; aspect-ratio: 16/10; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line-strong); cursor: ew-resize; background: #0a0a12;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.review-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.review-overlay { will-change: clip-path; }
.review-stage.no-webgl::before {
  content: 'WebGL unavailable'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-family: var(--mono); font-size: 13px;
  background: radial-gradient(circle, #1a1730, #0a0a12);
}
.review-tag {
  position: absolute; bottom: 14px; font-size: 11px; padding: 5px 11px; border-radius: var(--r-sm);
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); border: 1px solid var(--line-strong);
  transition: opacity 0.3s; pointer-events: none;
}
.review-tag-before { left: 14px; color: var(--ink-2); }
.review-tag-after { right: 14px; color: var(--green); border-color: rgba(67,224,138,0.4); }
.review-handle {
  position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.8);
  transform: translateX(-50%); pointer-events: none; box-shadow: 0 0 16px rgba(255,255,255,0.5);
}
.review-handle span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 38px; height: 38px; border-radius: 50%; background: rgba(10,10,20,0.9);
  border: 1.5px solid #fff; display: flex; align-items: center; justify-content: center;
}
.review-handle span::before { content: '⟺'; color: #fff; font-size: 15px; }

.review-panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px;
  display: flex; flex-direction: column; gap: 18px;
}
.review-verdict { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.verdict-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 14px var(--red); transition: all 0.4s; }
.verdict-text { font-size: 18px; letter-spacing: 0.1em; color: var(--red); transition: color 0.4s; }
.review-verdict.ok .verdict-dot { background: var(--green); box-shadow: 0 0 14px var(--green); }
.review-verdict.ok .verdict-text { color: var(--green); }
.review-aspects { display: flex; flex-direction: column; gap: 11px; }
.aspect { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.aspect-k { flex: 1; color: var(--ink-2); }
.aspect-w { font-size: 11.5px; color: var(--faint); }
.aspect-mark { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; transition: all 0.3s; }
.aspect-mark.pass { background: rgba(67,224,138,0.14); color: var(--green); }
.aspect-mark.fail { background: rgba(255,93,108,0.14); color: var(--red); }
.review-metric { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.metric-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.metric-row b { font-size: 22px; color: var(--ink); }
.metric-track { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.07); overflow: hidden; }
.metric-track i { display: block; height: 100%; width: 41%; border-radius: 4px; transition: width 0.3s, background 0.3s; }
.metric-foot { font-size: 11px; color: var(--faint); margin-top: 10px; }

@media (max-width: 820px) { .review-grid { grid-template-columns: 1fr; } }
