/* ==========================================================================
   KNOWLEDGE ENGINE - STYLES (PHASE-WEB-005)
   ========================================================================== */

/* The main container covering the Home screen */
.knowledge-engine-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-in-out;
  color: var(--text-primary, #ffffff);
  font-family: 'DM Sans', sans-serif;
  scroll-behavior: smooth;
}

.knowledge-engine-view.active {
  opacity: 1;
  pointer-events: auto;
}

/* Hide background scroll when modal is active */
body.knowledge-active {
  overflow: hidden;
}

/* ── STANDALONE SSG MODE ─────────────────────────────────────────────
   When the KE page is a standalone SSG article (not inside the App
   modal), override the modal-specific styles so the page scrolls
   normally and the content is fully visible.
   ────────────────────────────────────────────────────────────────── */
body.ke-standalone.knowledge-active {
  overflow: auto;         /* allow normal page scroll */
  overflow-x: hidden;
}

body.ke-standalone .knowledge-engine-view {
  position: relative;     /* not fixed – let page flow normally */
  top: auto;
  left: auto;
  width: 100%;
  height: auto;
  min-height: 100vh;
  z-index: auto;
  opacity: 1;             /* always visible */
  pointer-events: auto;
  overflow-y: visible;
  overflow-x: hidden;
  background: var(--bg, #080b14);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: none;
}

/* Wrapper for the content */
.ke-content-wrapper {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navigation / Header */
.ke-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.ke-back-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ke-back-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.ke-app-btn {
  background: linear-gradient(135deg, var(--accent, #a78bfa), var(--accent-light, #d8b4e2));
  color: #000;
  padding: 10px 24px;
  border-radius: 30px;
  text-decoration: none;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(167, 139, 250, 0.3);
  transition: all 0.3s ease;
}

.ke-app-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(167, 139, 250, 0.5);
}

/* Metadata Section */
.ke-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.ke-tag {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ke-tag.domain {
  background: rgba(167, 139, 250, 0.15);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.3);
}

.ke-tag.risk-high {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.ke-tag.risk-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.3);
}

/* Title */
.ke-title {
  font-family: 'Syne', sans-serif;
  font-size: 3rem;
  line-height: 1.1;
  margin-bottom: 30px;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Health Disclaimer */
.ke-disclaimer {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid #ef4444;
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 40px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.ke-disclaimer strong {
  color: #fca5a5;
  display: block;
  margin-bottom: 4px;
}

/* Content Area (Markdown) */
.ke-body {
  font-size: 1.15rem;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 60px;
}

.ke-body h2 {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  margin: 40px 0 20px;
  color: #fff;
}

.ke-body h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  margin: 30px 0 15px;
  color: #e2e8f0;
}

.ke-body p {
  margin-bottom: 24px;
}

.ke-body a {
  color: #c4b5fd;
  text-decoration: none;
  border-bottom: 1px dashed rgba(167, 139, 250, 0.5);
  transition: all 0.2s ease;
}

.ke-body a:hover {
  color: #fff;
  border-bottom-style: solid;
}

.ke-body ul, .ke-body ol {
  margin-bottom: 24px;
  padding-left: 24px;
}

.ke-body li {
  margin-bottom: 10px;
}

.ke-body strong {
  color: #fff;
  font-weight: 700;
}

.ke-body blockquote {
  border-left: 4px solid #a78bfa;
  margin: 0 0 24px 0;
  padding: 10px 20px;
  background: rgba(167, 139, 250, 0.05);
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

/* Related Entities Section */
.ke-relations {
  margin-top: auto;
  padding-top: 40px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ke-relations-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: #fff;
}

.ke-relations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.ke-relation-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  color: #fff;
  text-decoration: none;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.ke-relation-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(167, 139, 250, 0.3);
  transform: translateY(-2px);
}

.ke-relation-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #a78bfa;
  margin-bottom: 8px;
  font-weight: 700;
}

.ke-relation-name {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 768px) {
  .ke-title {
    font-size: 2.2rem;
  }
  .ke-content-wrapper {
    padding: 40px 20px;
  }
  .ke-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .ke-app-btn {
    width: 100%;
    text-align: center;
  }
}
