/* ============================================
   SOCRATIC — World Idea Browser
   Dark-Mode Observatory Aesthetic
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --bg-deep: #060a1e;
  --bg-primary: #0a0e27;
  --bg-card: rgba(15, 20, 50, 0.85);
  --bg-glass: rgba(15, 20, 50, 0.6);
  --border-subtle: rgba(100, 120, 200, 0.15);
  --border-glow: rgba(100, 180, 255, 0.3);
  --text-primary: #e8ecf4;
  --text-secondary: #8892b0;
  --text-muted: #5a6380;
  --accent-amber: #f0a500;
  --accent-teal: #00d4aa;
  --accent-blue: #4a9eff;
  --accent-green: #00d4aa;
  --accent-gold: #ffd740;
  --accent-purple: #b388ff;
  --badge-verified: #00d4aa;
  --badge-unverified: #ffa726;
  --badge-redflag: #ff5252;
  --panel-width: 380px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── Header ─────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 100;
  background: linear-gradient(180deg, rgba(6, 10, 30, 0.95) 0%, rgba(6, 10, 30, 0) 100%);
  backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.header-brand h1 {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.header-brand .tagline {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.header-search {
  position: relative;
  width: 280px;
}

.header-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: var(--transition);
}

.header-search input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 20px rgba(0, 212, 170, 0.1);
}

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

.header-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.header-stats {
  display: flex;
  gap: 24px;
  align-items: center;
}

.stat-item {
  text-align: center;
}

.stat-item .stat-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-teal);
}

.stat-item .stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Globe Container ────────────────────── */
.globe-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#globe-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Left Panel (Filters) ───────────────── */
.left-panel {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--panel-width);
  height: calc(100vh - var(--header-height));
  z-index: 50;
  padding: 24px 20px;
  overflow-y: auto;
  background: linear-gradient(90deg, rgba(6, 10, 30, 0.9) 0%, rgba(6, 10, 30, 0) 100%);
  pointer-events: none;
}

.left-panel > * {
  pointer-events: auto;
}

.panel-section {
  margin-bottom: 28px;
}

.panel-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Affinity Filters ───────────────────── */
.filter-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 6px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(8px);
}

.filter-btn:hover {
  border-color: var(--border-glow);
  background: rgba(20, 30, 70, 0.7);
}

.filter-btn.active {
  border-color: var(--filter-color, var(--accent-teal));
  background: rgba(20, 30, 70, 0.8);
  color: var(--text-primary);
  box-shadow: 0 0 20px rgba(var(--filter-rgb, 0,212,170), 0.15);
}

.filter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-btn .filter-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-btn[data-affinity="Restraint"] { --filter-color: var(--accent-blue); --filter-rgb: 74,158,255; }
.filter-btn[data-affinity="Restraint"] .filter-dot { background: var(--accent-blue); }

.filter-btn[data-affinity="Human Security"] { --filter-color: var(--accent-green); --filter-rgb: 0,212,170; }
.filter-btn[data-affinity="Human Security"] .filter-dot { background: var(--accent-green); }

.filter-btn[data-affinity="Strategic Autonomy"] { --filter-color: var(--accent-gold); --filter-rgb: 255,215,64; }
.filter-btn[data-affinity="Strategic Autonomy"] .filter-dot { background: var(--accent-gold); }

.filter-btn[data-affinity="Democratic Resilience"] { --filter-color: var(--accent-purple); --filter-rgb: 179,136,255; }
.filter-btn[data-affinity="Democratic Resilience"] .filter-dot { background: var(--accent-purple); }

/* ── Topic List ─────────────────────────── */
.topic-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
}

.topic-item:hover {
  background: rgba(20, 30, 70, 0.6);
  color: var(--text-primary);
}

.topic-item.active {
  background: rgba(20, 30, 70, 0.8);
  color: var(--text-primary);
}

.topic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topic-count {
  margin-left: auto;
  font-size: 10px;
  background: rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

/* ── Hot Topics Overlay ─────────────────── */
.hot-topics-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(8px);
  margin-bottom: 12px;
  width: 100%;
}

.hot-topics-toggle.active {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
  box-shadow: 0 0 20px rgba(240, 165, 0, 0.15);
}

.hot-topics-toggle .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-amber);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

/* ── Right Panel (Detail) ───────────────── */
.right-panel {
  position: fixed;
  top: var(--header-height);
  right: -420px;
  width: 400px;
  height: calc(100vh - var(--header-height));
  z-index: 50;
  padding: 24px 20px;
  overflow-y: auto;
  background: linear-gradient(270deg, rgba(6, 10, 30, 0.95) 0%, rgba(6, 10, 30, 0.7) 100%);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-subtle);
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.right-panel.open {
  right: 0;
}

.right-panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.right-panel-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.region-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  margin-bottom: 4px;
}

.region-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── Expert Card ────────────────────────── */
.expert-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.expert-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.expert-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.expert-name {
  font-size: 15px;
  font-weight: 600;
}

.expert-affiliation {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.expert-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.affinity-tag {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.affinity-tag.restraint { background: rgba(74, 158, 255, 0.15); color: var(--accent-blue); }
.affinity-tag.human-security { background: rgba(0, 212, 170, 0.15); color: var(--accent-green); }
.affinity-tag.strategic-autonomy { background: rgba(255, 215, 64, 0.15); color: var(--accent-gold); }
.affinity-tag.democratic-resilience { background: rgba(179, 136, 255, 0.15); color: var(--accent-purple); }

.provenance-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.provenance-badge.verified {
  background: rgba(0, 212, 170, 0.12);
  color: var(--badge-verified);
}

.provenance-badge.unverified {
  background: rgba(255, 167, 38, 0.12);
  color: var(--badge-unverified);
}

.provenance-badge.redflag {
  background: rgba(255, 82, 82, 0.12);
  color: var(--badge-redflag);
}

.expert-content {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.content-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.content-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-topic-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* ── Content Reader Overlay ─────────────── */
.content-reader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  background: rgba(4, 6, 18, 0.95);
  backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.content-reader.open {
  opacity: 1;
  visibility: visible;
}

.content-reader-inner {
  width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 48px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  position: relative;
}

.content-reader-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.content-reader-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.reader-author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.reader-author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--bg-deep);
}

.reader-author-info h3 {
  font-size: 16px;
  font-weight: 600;
}

.reader-author-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.reader-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  line-height: 1.3;
  margin-bottom: 16px;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  font-size: 12px;
  color: var(--text-muted);
}

.reader-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.reader-body p {
  margin-bottom: 16px;
}

.reader-related {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.reader-related h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.related-author {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.related-author:hover {
  background: rgba(255,255,255,0.04);
}

.related-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--bg-deep);
}

.related-info {
  flex: 1;
}

.related-name {
  font-size: 13px;
  font-weight: 500;
}

.related-topic {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Search Results ─────────────────────── */
.search-results {
  position: fixed;
  top: var(--header-height);
  left: 50%;
  transform: translateX(-50%);
  width: 420px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  z-index: 150;
  display: none;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.search-results.visible {
  display: block;
}

.search-result-item {
  padding: 12px 18px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-subtle);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(255,255,255,0.04);
}

.search-result-name {
  font-size: 14px;
  font-weight: 500;
}

.search-result-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Tooltip ────────────────────────────── */
.globe-tooltip {
  position: fixed;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 90;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.globe-tooltip.visible {
  opacity: 1;
}

/* ── Loading Screen ─────────────────────── */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-title {
  font-family: 'Playfair Display', serif;
  font-size: 42px;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.loading-tagline {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 40px;
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-teal), var(--accent-blue));
  border-radius: 2px;
  animation: loading-fill 2s ease-out forwards;
}

@keyframes loading-fill {
  0% { width: 0%; }
  100% { width: 100%; }
}

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Animations ─────────────────────────── */
@keyframes marker-pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* ── Responsive ─────────────────────────── */
@media (max-width: 768px) {
  .left-panel { width: 280px; }
  .right-panel { width: 320px; right: -340px; }
  .header-search { width: 180px; }
  .header-stats { display: none; }
  .content-reader-inner { width: 95%; padding: 24px; }
}
