/* ═══════════════════════════════════════════════════════════════
   THE COUNCIL — PREMIUM DESIGN SYSTEM
   Cinematic. Glassmorphism. Micro-animations. Every pixel alive.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ───────────────────────────────────── */
:root {
    --bg-void:       #060610;
    --bg-surface:    #0a0a18;
    --bg-elevated:   #0e0e1e;
    --bg-card:       #111125;
    --bg-glass:      rgba(14, 14, 30, 0.6);
    --border-faint:  rgba(255,255,255,0.04);
    --border-subtle: rgba(255,255,255,0.07);
    --border-active: rgba(255,255,255,0.14);
    --text-primary:  #eeeef2;
    --text-secondary:#a0a0b8;
    --text-muted:    #5c5c78;
    --accent-primary: #E2E8F0;
    --accent-blue:   #60A5FA;
    --accent-green:  #34D399;
    --accent-red:    #EF4444;
    --accent-gold:   #FBBF24;
    --accent-amber:  #F59E0B;
    --accent-coral:  #FB7185;
    --accent-purple: #C084FC;
    --glow-primary:  rgba(226,232,240,0.10);
    --glow-blue:     rgba(96,165,250,0.12);
    --glow-green:    rgba(52,211,153,0.12);
    --glow-coral:    rgba(251,113,133,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ─── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px; line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Ambient Background ─────────────────────────────── */
.ambient-bg {
    position: fixed; inset: 0; z-index: 0;
    transition: opacity 0.8s ease;
}
.ambient-orb {
    position: absolute; border-radius: 50%;
    filter: blur(100px); opacity: 0.08;
    animation: orbFloat 20s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: #475569; top: -200px; left: -200px; }
.orb-2 { width: 500px; height: 500px; background: var(--accent-blue); bottom: -150px; right: -150px; animation-delay: -7s; }
.orb-3 { width: 400px; height: 400px; background: #1E293B; top: 50%; left: 50%; transform: translate(-50%, -50%); animation-delay: -14s; }
.noise-overlay {
    position: absolute; 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.02'/%3E%3C/svg%3E");
    opacity: 0.3; mix-blend-mode: overlay;
}
.ambient-bg.hidden { opacity: 0; pointer-events: none; visibility: hidden; }

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ─── State Machine ──────────────────────────────────── */
#app { position: relative; z-index: 1; height: 100vh; overflow: hidden; }
.state { display: none; height: 100vh; }
.state.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════════
   ANIMATIONS — Silky smooth micro-interactions
   ═══════════════════════════════════════════════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 var(--glow-color, var(--glow-primary)); }
    50% { box-shadow: 0 0 16px 4px var(--glow-color, var(--glow-primary)); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes typingBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
@keyframes speakingPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 0; }
}
@keyframes breathe {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════
   LANDING — Cinematic entry
   ═══════════════════════════════════════════════════════ */
#landing { justify-content: center; align-items: center; }

.landing-content {
    display: flex; flex-direction: column; align-items: center;
    gap: 28px; max-width: 560px; width: 100%; padding: 0 24px;
    animation: fadeInUp 0.8s ease-out;
}
.brand {
    font-family: var(--font-display); font-size: 0.7rem; font-weight: 600;
    letter-spacing: 0.35em; text-transform: uppercase;
    color: var(--text-muted);
}
.landing-title {
    font-family: var(--font-display); font-size: 2.8rem; font-weight: 700;
    line-height: 1.1; text-align: center;
    color: var(--text-primary);
}
.landing-subtitle {
    font-family: var(--font-body); font-size: 0.95rem;
    color: var(--text-secondary); text-align: center; line-height: 1.6;
}

/* Topic Input */
.topic-group {
    display: flex; gap: 10px; width: 100%; position: relative;
}
.topic-input {
    flex: 1; padding: 14px 20px; border-radius: var(--radius-lg);
    background: var(--bg-glass);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary); font-family: var(--font-body); font-size: 0.9rem;
    outline: none; transition: all 0.3s ease;
}
.topic-input::placeholder { color: var(--text-muted); }
.topic-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--glow-primary), 0 8px 32px rgba(0,0,0,0.3);
}

/* Convene Button */
.convene-btn {
    padding: 14px 32px; border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.15); cursor: pointer; position: relative; overflow: hidden;
    background: rgba(255,255,255,0.06);
    color: white; font-family: var(--font-display); font-size: 0.85rem;
    font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
    transition: all 0.3s ease;
}
.convene-btn:hover {
    transform: translateY(-1px);
    background: rgba(255,255,255,0.10);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.25);
}
.convene-btn:active { transform: translateY(0); }
.convene-btn .btn-text { position: relative; z-index: 1; }

/* Capabilities Bar */
.capabilities {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
    font-family: var(--font-mono); font-size: 0.65rem;
    color: var(--text-muted); letter-spacing: 0.05em;
}
.cap-item { transition: color 0.2s; }
.cap-item:hover { color: var(--text-secondary); }
.cap-divider { opacity: 0.3; }

/* History Link */
.history-link-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-lg);
    background: transparent; border: 1px solid var(--border-subtle);
    color: var(--text-muted); font-family: var(--font-body);
    font-size: 0.8rem; cursor: pointer; transition: all 0.3s ease;
    text-decoration: none;
}
.history-link-btn:hover {
    border-color: var(--accent-primary); color: var(--accent-primary);
    background: rgba(226,232,240,0.04);
}

/* ═══════════════════════════════════════════════════════
   DEBATE VIEW — The Command Center
   ═══════════════════════════════════════════════════════ */

/* Top Bar */
.debate-header {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 24px; min-height: 52px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-faint);
    flex-shrink: 0;
}
.debate-logo {
    font-family: var(--font-display); font-size: 0.65rem;
    font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}
.debate-topic {
    font-family: var(--font-body); font-size: 0.82rem;
    color: var(--text-secondary); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.debate-status {
    margin-left: auto; display: flex; align-items: center; gap: 8px;
    font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono);
}
.status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent-green);
    animation: breathe 2s ease-in-out infinite;
}

/* Main Content Area */
.debate-body {
    display: flex; flex: 1; overflow: hidden;
}

/* ─── Editorial Panel (Left — Live Transcript) ──────── */
.editorial-panel {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; min-width: 0;
}
.editorial-scroll {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 20px 24px 100px;
    scroll-behavior: smooth;
}
.editorial-scroll::-webkit-scrollbar { width: 3px; }
.editorial-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08); border-radius: 3px;
}

/* ─── Phase Banner ────────────────────────────────────── */
.phase-banner {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; margin-bottom: 16px;
    animation: fadeInUp 0.5s ease-out;
}
.phase-dots {
    display: flex; gap: 4px;
}
.phase-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent-primary);
    animation: breathe 1.5s ease-in-out infinite;
}
.phase-dot:nth-child(2) { animation-delay: 0.3s; }
.phase-dot:nth-child(3) { animation-delay: 0.6s; }
.phase-text {
    font-family: var(--font-body); font-size: 0.82rem;
    color: var(--text-muted); font-style: italic;
}

/* ─── Agent Section (Speaker Card) ───────────────────── */
.agent-section {
    margin-bottom: 24px;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-glass);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--agent-color, var(--accent-primary));
    animation: fadeInUp 0.4s ease-out;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.agent-section.speaking {
    box-shadow: 0 0 24px -4px color-mix(in srgb, var(--agent-color, var(--accent-primary)) 20%, transparent);
}

/* Agent Header */
.agent-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px;
}
.agent-avatar {
    position: relative;
    width: 36px; height: 36px; border-radius: 50%;
    background: color-mix(in srgb, var(--agent-color, var(--accent-primary)) 15%, transparent);
    border: 1.5px solid color-mix(in srgb, var(--agent-color, var(--accent-primary)) 40%, transparent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
}
.agent-avatar .speaking-ring {
    position: absolute; inset: -3px; border-radius: 50%;
    border: 2px solid var(--agent-color, var(--accent-primary));
    animation: speakingPulse 1.5s ease-in-out infinite;
    display: none;
}
.agent-section.speaking .speaking-ring { display: block; }

.agent-info { flex: 1; min-width: 0; }
.agent-name {
    font-family: var(--font-display); font-size: 0.88rem;
    font-weight: 600; color: var(--text-primary);
    line-height: 1.2;
}
.agent-role {
    font-family: var(--font-body); font-size: 0.72rem;
    color: var(--text-muted);
}
.agent-research-badge {
    font-family: var(--font-mono); font-size: 0.6rem;
    color: var(--accent-blue); padding: 2px 8px;
    border-radius: 4px; background: rgba(96,165,250,0.08);
    animation: breathe 2s ease-in-out infinite;
}

/* Agent Text Content */
.agent-text {
    font-family: var(--font-body); font-size: 0.88rem;
    color: var(--text-secondary); line-height: 1.8;
    word-break: break-word;
}
.typing-cursor {
    display: inline-block; width: 2px; height: 1em;
    background: var(--agent-color, var(--accent-primary));
    margin-left: 2px; vertical-align: text-bottom;
    animation: typingBlink 0.8s step-end infinite;
}

/* Tool Loading */
.tool-indicator {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; margin: 8px 0;
    border-radius: var(--radius-sm);
    background: rgba(96,165,250,0.06);
    border: 1px solid rgba(96,165,250,0.12);
    font-family: var(--font-mono); font-size: 0.68rem;
    color: var(--accent-blue);
    animation: fadeIn 0.3s ease;
}
.tool-indicator .tool-spinner {
    width: 10px; height: 10px; border: 1.5px solid transparent;
    border-top-color: var(--accent-blue); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* User Section */
.user-section {
    margin-bottom: 24px; padding: 16px 20px;
    border-radius: var(--radius-lg);
    background: rgba(226,232,240,0.03);
    border: 1px solid rgba(226,232,240,0.08);
    border-left: 3px solid var(--accent-primary);
    animation: fadeInUp 0.3s ease-out;
}
.user-section .agent-name { color: var(--accent-primary); }

/* ─── Intelligence Panel (Right Sidebar) ─────────────── */
.intel-panel {
    width: 300px; flex-shrink: 0;
    border-left: 1px solid var(--border-faint);
    display: flex; flex-direction: column;
    background: var(--bg-surface);
    overflow: hidden;
}
.intel-header {
    padding: 14px 16px;
    font-family: var(--font-mono); font-size: 0.6rem;
    letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-faint);
    display: flex; align-items: center; gap: 8px;
}
.intel-header .status-dot {
    width: 5px; height: 5px;
}
.intel-feed {
    flex: 1; overflow-y: auto; padding: 12px;
    display: flex; flex-direction: column; gap: 10px;
}
.intel-feed::-webkit-scrollbar { width: 2px; }
.intel-feed::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); }

/* Intel Cards */
.intel-card {
    padding: 14px 16px; border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-faint);
    border-left: 3px solid var(--card-color, var(--accent-blue));
    animation: slideInRight 0.4s ease-out;
    transition: all 0.3s ease;
}
.intel-card:hover {
    background: var(--bg-card);
    border-color: var(--border-subtle);
}
.intel-card.search { --card-color: var(--accent-blue); }
.intel-card.data { --card-color: var(--accent-green); }
.intel-card.source { --card-color: var(--accent-amber); }
.intel-card.crossref { --card-color: var(--accent-coral); }
.intel-card.analysis { --card-color: var(--accent-purple); }

.intel-card-type {
    font-family: var(--font-mono); font-size: 0.58rem;
    letter-spacing: 0.15em; text-transform: uppercase;
    color: var(--card-color, var(--accent-blue));
    margin-bottom: 6px; font-weight: 600;
}
.intel-card-title {
    font-family: var(--font-display); font-size: 0.78rem;
    font-weight: 500; color: var(--text-primary);
    margin-bottom: 4px; line-height: 1.4;
}
.intel-card-body {
    font-family: var(--font-body); font-size: 0.72rem;
    color: var(--text-muted); line-height: 1.5;
}

/* Skeleton State */
.intel-card.skeleton .intel-card-title,
.intel-card.skeleton .intel-card-body {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(255,255,255,0.03) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 4px; color: transparent;
    -webkit-background-clip: initial;
}
.intel-card.skeleton .intel-card-title { height: 14px; width: 70%; margin-bottom: 8px; }
.intel-card.skeleton .intel-card-body { height: 10px; width: 90%; }

/* ─── Input Bar (Bottom) ─────────────────────────────── */
.input-bar {
    padding: 12px 24px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-faint);
    flex-shrink: 0;
}
.input-row {
    display: flex; gap: 10px; max-width: 100%;
    background: var(--bg-glass);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 4px 4px 4px 16px;
    transition: all 0.3s ease;
}
.input-row:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--glow-primary);
}
.inject-input {
    flex: 1; border: none; background: none; outline: none;
    color: var(--text-primary); font-family: var(--font-body);
    font-size: 0.85rem;
}
.inject-input::placeholder { color: var(--text-muted); }
.send-btn {
    width: 38px; height: 38px; border-radius: var(--radius-md);
    border: none; cursor: pointer;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-primary); display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; flex-shrink: 0;
}
.send-btn:hover {
    transform: scale(1.05);
    background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2);
}
.send-btn svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════════════
   ENDED STATE — Session Complete
   ═══════════════════════════════════════════════════════ */
#ended { justify-content: center; align-items: center; }
.ended-content {
    text-align: center; max-width: 480px; padding: 24px;
    animation: fadeInUp 0.6s ease-out;
}
.ended-title {
    font-family: var(--font-display); font-size: 1.6rem; font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}
.ended-summary {
    font-size: 0.88rem; color: var(--text-secondary);
    line-height: 1.7; margin-bottom: 24px;
}
.ended-stats {
    display: flex; gap: 20px; justify-content: center; margin-bottom: 24px;
}
.stat-card {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px 24px; border-radius: var(--radius-lg);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
}
.stat-value {
    font-family: var(--font-display); font-size: 1.4rem; font-weight: 700;
    color: var(--text-primary);
}
.stat-label {
    font-size: 0.6rem; color: var(--text-muted);
    font-family: var(--font-mono); text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ═══════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .intel-panel { display: none; }
    .editorial-scroll { padding: 16px; }
    .landing-title { font-size: 2rem; }
    .topic-group { flex-direction: column; }
    .debate-header { padding: 10px 16px; }
}