/* ================================================================
   ANALYSIS OVERLAY — Full-screen progressive analysis experience
================================================================ */

/* Full-screen overlay */
#analysis-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--white);
  display: flex; flex-direction: column;
  font-family: var(--font-sans);
  transition: opacity 0.3s ease;
}
#analysis-overlay.hidden { display: none; }

/* Header bar */
.analysis-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.analysis-title {
  font-family: var(--font-serif);
  font-size: 1.1rem; font-weight: 600; color: var(--ink);
}
.analysis-meta {
  font-size: 0.78rem; color: var(--muted); margin-left: 0.75rem;
}
.analysis-header-left { display: flex; align-items: center; gap: 0.5rem; }
.analysis-actions { display: flex; gap: 0.5rem; }

/* Body — two columns */
.analysis-body {
  display: grid; grid-template-columns: 1fr 20rem;
  flex: 1; min-height: 0; overflow: hidden;
}

/* Left panel — checklist + feed */
.analysis-left {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1rem;
  min-height: 0;
}
#analysis-hero { flex-shrink: 0; }
#analysis-checklist { flex: 1; overflow-y: auto; min-height: 0; }

/* Checklist */
.analysis-checklist-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0; font-size: 0.82rem; color: var(--mid);
  border-bottom: 1px solid var(--border-light, #f0f0f0);
}
.analysis-checklist-item:last-child { border-bottom: none; }
.acl-icon {
  width: 1.3rem; height: 1.3rem; flex-shrink: 0;
  border-radius: 50%; border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; transition: all 0.3s ease;
}
.acl-icon.pending { background: transparent; }
.acl-icon.active {
  border-color: var(--gold); background: var(--gold);
  animation: acl-pulse 1.2s ease-in-out infinite;
}
.acl-icon.done { border-color: #27AE60; background: #27AE60; color: white; }
.acl-icon.failed { border-color: #C0392B; background: #C0392B; color: white; }
.acl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acl-name.active { color: var(--ink); font-weight: 500; }
.acl-name.done { color: var(--muted); }
.acl-result { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }
.acl-result.has-findings { color: var(--gold); }
.acl-findings {
  font-size: 0.75rem; color: var(--mid); padding: 0.25rem 0 0.25rem 2rem;
  line-height: 1.5; animation: afeed-in 0.3s ease;
}
.acl-findings.risk { color: #991B1B; }
.acl-findings.action { color: var(--gold); }

@keyframes acl-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(201, 168, 76, 0); }
}

/* Feed messages */
.analysis-feed-msg {
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  font-size: 0.8rem; line-height: 1.5;
  animation: afeed-in 0.3s ease;
}
.afeed-hero {
  background: linear-gradient(135deg, #1A1A18 0%, #2A2A28 100%);
  color: var(--white); padding: 1rem 1.25rem;
  border-radius: var(--r-lg); margin-bottom: 0.5rem;
}
.afeed-hero .afeed-label { color: var(--gold); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 0.3rem; }
.afeed-finding { background: var(--surface); color: var(--ink); }
.afeed-action { background: #FDF8E8; color: var(--ink); border-left: 3px solid var(--gold); }
.afeed-risk { background: #FEF2F2; color: #991B1B; border-left: 3px solid #C0392B; }
.afeed-done { background: #F0FDF4; color: #166534; border-left: 3px solid #27AE60; }
@keyframes afeed-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }

/* Right panel — game */
.analysis-right {
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 1.5rem;
  background: #1A1A18;
}
#snake-canvas {
  border-radius: var(--r-md);
  background: #111;
  display: block;
}
#snake-score {
  color: var(--gold); font-size: 0.75rem; font-weight: 600;
  margin-top: 0.6rem; text-align: center;
}
#snake-instructions {
  color: #666; font-size: 0.68rem; margin-top: 0.3rem; text-align: center;
}

/* Summary card at completion */
.analysis-summary-card {
  background: linear-gradient(135deg, #1A1A18 0%, #2A2A28 100%);
  border: 1px solid var(--gold); border-radius: var(--r-lg);
  padding: 1.5rem; text-align: center; margin-top: 1rem;
  color: var(--white);
}
.analysis-summary-card h3 {
  font-family: var(--font-serif); font-size: 1.1rem;
  color: var(--gold); margin-bottom: 0.5rem;
}
.analysis-summary-stats {
  display: flex; gap: 1rem; justify-content: center;
  flex-wrap: wrap; margin: 0.75rem 0;
}
.analysis-stat {
  font-size: 0.78rem; color: var(--mid);
}
.analysis-stat strong { color: var(--gold); font-size: 1.1rem; display: block; }

/* Minimised pill */
#analysis-pill {
  position: fixed; bottom: 4.5rem; right: 1.5rem; z-index: 1001;
  background: var(--ink); color: var(--white);
  padding: 0.5rem 1rem; border-radius: 2rem;
  font-size: 0.78rem; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 0.6rem;
  transition: transform 0.2s ease;
}
#analysis-pill:hover { transform: scale(1.03); }
#analysis-pill.hidden { display: none; }
.analysis-pill-progress {
  width: 4rem; height: 4px; background: #333; border-radius: 2px; overflow: hidden;
}
.analysis-pill-bar {
  height: 100%; background: var(--gold); border-radius: 2px;
  transition: width 0.3s ease;
}

/* Shimmer on background when overlay is open */
#app.analysis-active {
  pointer-events: none; opacity: 0.3;
  filter: blur(2px); transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .analysis-body { grid-template-columns: 1fr; }
  .analysis-right { display: none; }
  #analysis-pill { bottom: 1rem; right: 1rem; }
}
