/* Cosmos Chommie — theme tokens
   bg: #05060f | panel: #0b0e1f | text: #e8e6f0 | muted: #8b8aa3
   nebula violet: #7c5cff | starlight gold: #f2b134
   supports: #4fd1c5 | contradicts: #ff5d73 | supersedes: #f2b134
*/

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500&family=IBM+Plex+Mono:wght@400;500&display=swap');

.cc-cosmos-wrap {
	--cc-bg: #05060f;
	--cc-panel: #0b0e1f;
	--cc-text: #e8e6f0;
	--cc-muted: #8b8aa3;
	--cc-violet: #7c5cff;
	--cc-gold: #f2b134;
	--cc-support: #4fd1c5;
	--cc-contradict: #ff5d73;
	--cc-supersede: #f2b134;

	position: relative;
	background: radial-gradient(ellipse at 30% 0%, #14163a 0%, var(--cc-bg) 60%);
	color: var(--cc-text);
	border-radius: 12px;
	overflow: hidden;
	padding: 2rem;
	font-family: 'Inter', sans-serif;
	min-height: 640px;
}

.cc-starfield {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 0;
	pointer-events: none;
}

.cc-map-header {
	position: relative;
	z-index: 1;
	margin-bottom: 1.25rem;
}

.cc-map-title {
	font-family: 'Space Grotesk', sans-serif;
	font-weight: 700;
	font-size: clamp(1.5rem, 3vw, 2.25rem);
	margin: 0 0 0.35rem 0;
	letter-spacing: -0.01em;
	background: linear-gradient(90deg, var(--cc-text), var(--cc-violet));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}

.cc-map-sub {
	color: var(--cc-muted);
	margin: 0 0 1rem 0;
	font-size: 0.95rem;
}

.cc-legend {
	display: flex;
	gap: 1.25rem;
	flex-wrap: wrap;
	font-family: 'IBM Plex Mono', monospace;
	font-size: 0.78rem;
	color: var(--cc-muted);
}

.cc-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }

.cc-dot {
	display: inline-block;
	width: 9px; height: 9px;
	border-radius: 50%;
}
.cc-dot--mainstream { background: var(--cc-violet); box-shadow: 0 0 8px var(--cc-violet); }
.cc-dot--alternative { background: var(--cc-support); box-shadow: 0 0 8px var(--cc-support); }
.cc-dot--historical { background: var(--cc-muted); }
.cc-dot--speculative { background: var(--cc-gold); box-shadow: 0 0 8px var(--cc-gold); }

.cc-map-canvas {
	position: relative;
	z-index: 1;
	width: 100%;
	height: 560px;
	border: 1px solid rgba(124, 92, 255, 0.15);
	border-radius: 10px;
	background: rgba(11, 14, 31, 0.4);
}

.cc-map-canvas svg {
	touch-action: none; /* let d3.zoom own touch drag/pinch instead of the browser's native page-scroll gesture */
}

.cc-map-canvas:focus-visible {
	outline: 2px solid rgba(124, 92, 255, 0.6);
	outline-offset: 2px;
}

.cc-node circle {
	cursor: pointer;
	stroke: rgba(255,255,255,0.15);
	stroke-width: 1px;
	transition: r 0.15s ease, filter 0.15s ease;
}
.cc-node:hover circle { filter: brightness(1.4); }

.cc-node text {
	fill: var(--cc-text);
	font-family: 'Inter', sans-serif;
	font-size: 11px;
	pointer-events: none;
}

.cc-link { stroke-opacity: 0.55; fill: none; }
.cc-link--supports { stroke: var(--cc-support); stroke-width: 1.4px; }
.cc-link--contradicts { stroke: var(--cc-contradict); stroke-width: 1.4px; stroke-dasharray: 4 3; }
.cc-link--supersedes { stroke: var(--cc-supersede); stroke-width: 1.4px; stroke-dasharray: 1 4; }
.cc-link--related { stroke: var(--cc-muted); stroke-width: 1px; stroke-opacity: 0.3; }

/* On-screen pan/zoom controls — a discoverable alternative to drag-to-pan
   and scroll/pinch-to-zoom, for exploring a graph larger than the canvas. */
.cc-nav-controls {
	position: absolute;
	bottom: 1.1rem;
	left: 1.1rem;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35rem;
	background: rgba(11, 14, 31, 0.78);
	border: 1px solid rgba(124, 92, 255, 0.35);
	border-radius: 14px;
	padding: 0.6rem;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}
.cc-nav-mid-row,
.cc-nav-zoom-row {
	display: flex;
	align-items: center;
	gap: 0.35rem;
}
.cc-nav-zoom-row {
	margin-top: 0.2rem;
	padding-top: 0.45rem;
	border-top: 1px solid rgba(124, 92, 255, 0.22);
	width: 100%;
	justify-content: center;
}
.cc-nav-btn {
	width: 36px;
	height: 36px;
	min-width: 36px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	border: 1px solid rgba(124, 92, 255, 0.4);
	background: rgba(124, 92, 255, 0.14);
	color: var(--cc-text);
	font-size: 0.95rem;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
}
.cc-nav-btn:hover { background: rgba(124, 92, 255, 0.32); }
.cc-nav-btn:active { transform: scale(0.9); }
.cc-nav-home { color: var(--cc-gold); font-size: 1.05rem; }

@media (max-width: 640px) {
	.cc-nav-controls { bottom: 0.75rem; left: 0.75rem; padding: 0.45rem; }
	.cc-nav-btn { width: 32px; height: 32px; min-width: 32px; font-size: 0.85rem; }
}
@media (prefers-reduced-motion: reduce) {
	.cc-nav-btn { transition: none; }
}

.cc-detail-panel {
	position: absolute;
	top: 0; right: -420px;
	width: 380px;
	height: 100%;
	background: var(--cc-panel);
	border-left: 1px solid rgba(124, 92, 255, 0.25);
	padding: 1.75rem;
	overflow-y: auto;
	transition: right 0.3s ease;
	z-index: 3;
}
.cc-detail-panel.cc-open { right: 0; }

.cc-detail-close {
	position: absolute; top: 1rem; right: 1rem;
	background: none; border: none; color: var(--cc-muted);
	font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.cc-detail-close:hover { color: var(--cc-text); }

.cc-detail-content h3 {
	font-family: 'Space Grotesk', sans-serif;
	font-size: 1.35rem;
	margin: 0 0 0.25rem 0;
	color: var(--cc-text);
}

.cc-detail-meta {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 0.78rem;
	color: var(--cc-muted);
	margin-bottom: 1rem;
}

.cc-detail-section { margin-bottom: 1.1rem; }
.cc-detail-section h4 {
	font-family: 'Inter', sans-serif;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--cc-gold);
	margin: 0 0 0.4rem 0;
}
.cc-detail-section p { font-size: 0.9rem; line-height: 1.5; margin: 0; color: var(--cc-text); }

.cc-detail-links { list-style: none; padding: 0; margin: 0; }
.cc-detail-links li { margin-bottom: 0.5rem; }
.cc-detail-links a {
	color: var(--cc-violet);
	text-decoration: none;
	font-size: 0.88rem;
	border-bottom: 1px solid rgba(124, 92, 255, 0.35);
}
.cc-detail-links a:hover { color: var(--cc-gold); border-color: var(--cc-gold); }

@media (max-width: 640px) {
	.cc-detail-panel { width: 100%; right: -100%; }
	.cc-map-canvas { height: 420px; }
}

@media (prefers-reduced-motion: reduce) {
	.cc-node circle, .cc-detail-panel { transition: none; }
}

/* Library grid (simple fallback list view) */
.cc-library-wrap {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 1rem;
}
.cc-library-card {
	background: #0b0e1f;
	border: 1px solid rgba(124, 92, 255, 0.2);
	border-radius: 10px;
	padding: 1.25rem;
	color: #e8e6f0;
}
.cc-library-card h3 { font-family: 'Space Grotesk', sans-serif; margin: 0 0 0.5rem 0; font-size: 1.05rem; }
.cc-library-card a { color: #e8e6f0; text-decoration: none; }
.cc-library-card p { color: #8b8aa3; font-size: 0.88rem; margin: 0; }
