/* UCL RAG — IGNITE Edition v2 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sans: 'Space Grotesk', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

html { scroll-behavior: auto; }
body { background: #000; color: #fff; font-family: var(--sans); overflow-x: hidden; }

#c {
  position: fixed; inset: 0;
  width: 100%; height: 100%; z-index: 0; pointer-events: none;
}
#scroll-space { height: 600vh; pointer-events: none; }

/* ── Panels ── */
.panel {
  position: fixed; z-index: 10;
  pointer-events: none; opacity: 0;
}

/* Panel 0 — top left */
#p0 { top: 50%; left: 8vw; transform: translateY(-50%); }
.p-num {
  font-family: var(--mono);
  font-size: clamp(6rem, 18vw, 20rem); font-weight: 600; line-height: 1;
  color: rgba(255,255,255,0.05); letter-spacing: -.04em;
  user-select: none; pointer-events: none;
  position: absolute; top: -0.15em; left: -0.08em;
}
.p-h1 {
  font-size: clamp(3.5rem, 8vw, 9rem);
  font-weight: 700; line-height: .88; letter-spacing: -.04em; position: relative;
}
.p-sub {
  font-family: var(--mono); font-size: .65rem; letter-spacing: .25em;
  text-transform: uppercase; color: rgba(255,255,255,.3); margin-top: 2rem;
}

/* Panel 1 — bottom right */
#p1 { bottom: 10vh; right: 8vw; text-align: right; }
.p-tag {
  font-family: var(--mono); font-size: .65rem; letter-spacing: .2em;
  text-transform: uppercase; color: rgba(255,255,255,.28); margin-bottom: 1.5rem;
}
.p-h2 {
  font-size: clamp(3rem, 7vw, 8rem);
  font-weight: 700; line-height: .86; letter-spacing: -.04em;
}
.p-h2 em { font-style: normal; color: rgba(255,255,255,.35); }

/* Panel 2 — left with stat */
#p2 { top: 50%; left: 8vw; transform: translateY(-50%); }
.p-h2--right { text-align: left; }
.p-stat {
  font-family: var(--mono); font-size: .7rem; line-height: 1.9;
  color: rgba(255,255,255,.22); margin-top: 3rem; letter-spacing: .04em;
}
.p-stat span { font-size: .6rem; color: rgba(255,255,255,.15); }

/* Panel 3 — center */
#p3 { top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.p-word {
  font-size: clamp(5rem, 16vw, 18rem);
  font-weight: 700; line-height: .85; letter-spacing: -.06em;
}
.p-word--sub {
  font-size: clamp(1.5rem, 4vw, 5rem); font-weight: 300;
  letter-spacing: .02em; color: rgba(255,255,255,.38); margin-top: 1rem;
}
.p-graph-sub {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .18em;
  text-transform: uppercase; color: rgba(255,255,255,.18); margin-top: 2rem;
}

/* Panel 4 — Chat only */
.panel--chat {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(960px, 92vw);
  pointer-events: auto;
}

/* ── Chat interface ── */
.chat-wrap {
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  background: rgba(0,0,0,.82);
  backdrop-filter: blur(24px);
}
.chat-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ct-l { display: flex; align-items: center; gap: .6rem; }
.ct-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #fff;
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse { 0%,100%{opacity:.4} 50%{opacity:1} }
.ct-title { font-size: .9rem; font-weight: 500; color: rgba(255,255,255,.8); }
.ct-status { font-family: var(--mono); font-size: .68rem; color: rgba(255,255,255,.25); }

.chat-log {
  min-height: 420px; max-height: 560px; overflow-y: auto;
  padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem;
}
.chat-log::-webkit-scrollbar { width: 2px; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }

.msg { display: flex; flex-direction: column; gap: .3rem; max-width: 88%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot, .msg.error { align-self: flex-start; }
.role { font-family: var(--mono); font-size: .58rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.22); }
.msg-text { padding: .85rem 1.1rem; border-radius: 4px; font-size: .92rem; line-height: 1.7; }
.msg.user  .msg-text { background: #fff; color: #000; }
.msg.bot   .msg-text { background: rgba(255,255,255,.08); color: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.15); }
.msg.error .msg-text { background: rgba(255,80,50,.08); color: rgba(255,120,90,.9); border: 1px solid rgba(255,80,50,.18); }

.evidence-block { margin-top: .6rem; }
.ev-label { font-family: var(--mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.22); margin-bottom: .35rem; }
.vector-label { color: rgba(255,255,255,.4); }
.graph-label  { color: rgba(255,255,255,.35); }
.ev-count { color: rgba(255,255,255,.25); }
.ev-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .7rem; }
.ev-table td, .ev-table th { padding: .28rem .45rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.55); }
.src-idx { opacity: .28; } .src-name { color: rgba(255,255,255,.9); } .src-score { white-space: nowrap; }
.src-excerpt { opacity: .45; font-size: .65rem; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-bar-wrap { display: inline-block; vertical-align: middle; width: 48px; height: 2px; background: rgba(255,255,255,.1); border-radius: 1px; overflow: hidden; margin-right: .3rem; }
.score-bar-fill { display: block; height: 100%; background: #fff; border-radius: 1px; }
.score-num { vertical-align: middle; }
.cite-badge { display: inline-block; font-family: var(--mono); font-size: .6rem; padding: .08rem .3rem; border-radius: 3px; background: rgba(255,255,255,.07); color: rgba(255,255,255,.35); margin-left: .18rem; }
.cite-unknown { color: rgba(255,255,255,.18); }
.md-table { border-collapse: collapse; margin: .6rem 0; width: 100%; }
.md-table td, .md-table th { border: 1px solid rgba(255,255,255,.1); padding: .3rem .55rem; font-size: .78rem; color: rgba(255,255,255,.55); }
.md-table th { color: #fff; background: rgba(255,255,255,.04); }

.chat-form { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.08); }
.chat-form textarea {
  width: 100%; background: transparent; border: none; outline: none; resize: none;
  font-family: var(--sans); font-size: .95rem; color: #fff; line-height: 1.65; min-height: 68px;
}
.chat-form textarea::placeholder { color: rgba(255,255,255,.2); }
.cf-footer { display: flex; align-items: center; justify-content: space-between; margin-top: .6rem; }
.cf-hint { font-family: var(--mono); font-size: .65rem; color: rgba(255,255,255,.2); }
.cf-footer button {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .1em;
  background: #fff; color: #000; border: none;
  padding: .65rem 1.5rem; border-radius: 2px; cursor: pointer;
  transition: background .2s;
}
.cf-footer button:hover { background: rgba(255,255,255,.75); }

/* ── Progress bar ── */
#progress-bar {
  position: fixed; left: 0; bottom: 0; height: 1px; width: 0%;
  background: rgba(255,255,255,.5); z-index: 999; transition: width .1s linear;
}
/* ── Section label ── */
#section-label {
  position: fixed; right: 3vw; top: 50%; transform: translateY(-50%);
  z-index: 999; font-family: var(--mono); font-size: .58rem;
  letter-spacing: .15em; text-transform: uppercase;
  color: rgba(255,255,255,.2); writing-mode: vertical-rl;
}

@media (max-width: 640px) {
  #p1 { bottom: 5vh; right: 5vw; }
  #p0, #p2 { left: 5vw; }
  .p-num { font-size: 7rem; }
  .panel--chat { width: 94vw; top: 5vh; transform: translateX(-50%); max-height: 90vh; overflow-y: auto; }
  .chat-log { min-height: 240px; max-height: 44vh; }
}
