/* ============================
   DOAC Knowledge Engine
   ============================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #080808;
  --surface:      #111111;
  --border:       #1e1e1e;
  --border-mid:   #2a2a2a;
  --text:         #efefef;
  --text-dim:     #888888;
  --text-muted:   #444444;
  --accent:       #e8392b;
  --accent-glow:  rgba(232, 57, 43, 0.12);
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --nav-h:        56px;
  --max-w:        760px;
  --r:            10px;
  --r-sm:         6px;
  --r-pill:       100px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- NAV ---- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 100;
  transition: background 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}

body.has-results .nav {
  background: rgba(8, 8, 8, 0.92);
  backdrop-filter: blur(16px);
  border-color: var(--border);
}

.nav-brand {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-brand:hover { color: var(--text); }

.nav-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text-dim); }

/* ---- HERO ---- */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nav-h) 1.5rem 8rem;
}

body.has-results .hero {
  display: none;
}

.hero-inner {
  width: 100%;
  max-width: var(--max-w);
}

.hero-eyebrow {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 3.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.hero-tagline {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* ---- SEARCH BOX ---- */

.search-box {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem 1rem 1rem 1.25rem;
  margin-bottom: 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--border-mid);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.query-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  resize: none;
  min-height: 28px;
  max-height: 160px;
  overflow-y: auto;
}

.query-input::placeholder { color: var(--text-muted); }

.search-submit {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.search-submit:hover  { background: #ff4a3b; }
.search-submit:active { transform: scale(0.91); }

/* ---- PILLS ---- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 2rem;
}

.pill {
  padding: 0.3rem 0.8rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.76rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.pill:hover {
  border-color: var(--border-mid);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.example-questions {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 2rem;
}

.example-q {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0.3rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: color 0.15s;
}

.example-q::before {
  content: "→";
  color: var(--text-muted);
  font-size: 0.78rem;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}

.example-q:hover {
  color: var(--text);
}

.example-q:hover::before {
  color: var(--accent);
  transform: translateX(3px);
}

.hero-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.proto-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
}

/* ---- RESULTS SECTION ---- */

.results-wrap {
  display: none;
  padding-top: calc(var(--nav-h) + 1.5rem);
  min-height: 100vh;
  padding-bottom: 5rem;
}

body.has-results .results-wrap {
  display: block;
}

.results-query-bar {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.back-btn:hover { border-color: var(--border-mid); color: var(--text-dim); }

.results-query-text {
  font-size: 0.92rem;
  color: var(--text-dim);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pills-compact { margin-bottom: 0; }

/* ---- SYNTHESIS CARD ---- */

.synthesis-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 1.5rem;
  animation: fadeUp 0.35s ease both;
}

.synthesis-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.synthesis-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

.synthesis-body {
  font-size: 0.9rem;
  line-height: 1.8;
  color: #d0d0d0;
  margin-bottom: 1.25rem;
  min-height: 1.8rem;
}

.synthesis-body p { margin-bottom: 0.9rem; }
.synthesis-body p:last-child { margin-bottom: 0; }

.synthesis-guests {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.synthesis-guest {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
}

/* ---- MOMENT CARDS ---- */

.results {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.moment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  transition: border-color 0.2s;
  animation: fadeUp 0.35s ease both;
}

.moment-card:hover { border-color: var(--border-mid); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.moment-card:nth-child(1) { animation-delay:   0ms; }
.moment-card:nth-child(2) { animation-delay:  60ms; }
.moment-card:nth-child(3) { animation-delay: 120ms; }
.moment-card:nth-child(4) { animation-delay: 180ms; }
.moment-card:nth-child(5) { animation-delay: 240ms; }
.moment-card:nth-child(6) { animation-delay: 300ms; }
.moment-card:nth-child(7) { animation-delay: 360ms; }
.moment-card:nth-child(8) { animation-delay: 420ms; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.guest-name {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.episode-title {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.topic-badge {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.6rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.excerpt {
  font-size: 0.88rem;
  line-height: 1.75;
  color: #bfbfbf;
  margin-bottom: 1.25rem;
  border-left: 2px solid var(--border-mid);
  padding-left: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
}

.watch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.95rem;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-body);
  text-decoration: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  cursor: pointer;
}

.watch-btn .ts {
  font-weight: 600;
  color: var(--text);
  transition: color 0.18s;
}

.watch-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.watch-btn:hover .ts { color: #fff; }

/* ---- LOADING ---- */

.loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 1.5rem;
  max-width: var(--max-w);
  margin: 0 auto;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.1s infinite ease-in-out;
}

.loading-dot:nth-child(2) { animation-delay: 0.18s; }
.loading-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.75); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ---- EMPTY / ERROR STATE ---- */

.state-message {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4rem 1.5rem;
  text-align: center;
}

.state-message h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.state-message p {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- FOOTER ---- */

.results-footer {
  max-width: var(--max-w);
  margin: 3rem auto 0;
  padding: 1.5rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.73rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-disclaimer {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ---- MOBILE ---- */

@media (max-width: 600px) {
  .nav { padding: 0 1rem; }
  .hero-title { font-size: 2rem; }
  .search-box { padding: 0.875rem 0.875rem 0.875rem 1rem; }
  .query-input { font-size: 0.95rem; }
  .results-query-bar { gap: 0.6rem; }
  .results-query-text { font-size: 0.82rem; }
  .card-header { flex-direction: column; gap: 0.5rem; }
  .moment-card { padding: 1.25rem; }
}
