/* ════════════════════════════════════════════════════════════
   COSMOS V2 — Unified TES Cosmology Map
   Nirn (center 3D globe) → Aedra (variable orbits) → Daedra (outer)
   ════════════════════════════════════════════════════════════ */

.cosmos-v2 {
  position: relative;
  padding: 60px 0 40px;
  background: #0a0610;
  border-top: 1px solid rgba(160,140,200,0.08);
  border-bottom: 1px solid rgba(160,140,200,0.08);
  overflow: hidden;
}

.cosmos-v2__head {
  max-width: 1280px;
  margin: 0 auto 20px;
  padding: 0 56px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.cosmos-v2__title {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-weight: 300;
  font-size: clamp(32px, 4vw, 54px);
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text, #e8e4dc);
}
.cosmos-v2__title em { font-style: italic; color: var(--accent-bright, #c8b8e0); }
.cosmos-v2__hint {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute, rgba(232,228,220,0.4));
}
.cosmos-v2__hint::before { content: '\25C7 '; color: var(--accent, rgba(160,140,200,0.6)); }

/* ── Viewport ─────────────────────────────────────────────── */
.cosmos-v2__viewport {
  position: relative;
  margin: 0 auto;
  max-width: 1400px;
  height: clamp(700px, 90vh, 1100px);
  overflow: hidden;
  border: 1px solid rgba(160,140,200,0.06);
  background: #0a0610;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.cosmos-v2__viewport.is-panning { cursor: grabbing; }

/* ── Canvas (8000x8000 logical) ───────────────────────────── */
.cosmos-v2__canvas {
  position: absolute;
  width: 8000px;
  height: 8000px;
  top: 0;
  left: 0;
  z-index: 1;                 /* above the WebGL backdrop sibling */
  transform-origin: 0 0;
  transition: transform 0.3s cubic-bezier(.16,.84,.44,1);
  will-change: transform;
  background:
    radial-gradient(ellipse 40% 35% at 55% 45%, rgba(60,30,80,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 30% 50% at 30% 60%, rgba(30,50,80,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 70% 30%, rgba(40,20,60,0.04) 0%, transparent 65%),
    radial-gradient(circle at 50% 50%, rgba(20,10,30,0.8) 0%, #0a0610 70%);
}
.cosmos-v2__canvas.is-panning { transition: none; }

/* ── WebGL backdrop (Three.js layer) ──────────────────────── */
/* Sibling of .cosmos-v2__canvas inside .cosmos-v2__viewport so it
   stays viewport-sized (NOT 8000x8000). The engine's syncTransform
   mirrors the SVG canvas pan/zoom in the orthographic camera. */
.cosmos-v2__webgl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;       /* clicks fall through to SVG nodes */
  z-index: 0;                 /* behind the SVG canvas */
  display: block;
  opacity: 0;                 /* fades in once the engine has initialized */
  transition: opacity 1.2s ease-out;
}
.cosmos-v2__webgl.is-ready {
  opacity: 1;
}
/* When WebGL is active, dim the SVG fallback starfield (now nested in canvas) */
.cosmos-v2__webgl.is-ready ~ .cosmos-v2__canvas .cosmos-v2__starfield {
  opacity: 0.25;
  transition: opacity 1.2s ease-out;
}
/* When 3D Nirn is active, hide the layered DOM Nirn (keep label visible) */
.cosmos-v2__webgl.is-ready ~ .cosmos-v2__canvas .cosmos-v2__nirn .cosmos-v2__nirn-sphere {
  opacity: 0;
  transition: opacity 1.2s ease-out;
  pointer-events: none;
}

/* ── Fullscreen / immersive mode ──────────────────────────── */
.cosmos-v2:fullscreen,
.cosmos-v2.cosmos-v2--immersive {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #04060c;
  z-index: 9000;
  margin: 0;
  padding: 0;
  border-radius: 0;
}
.cosmos-v2:fullscreen .cosmos-v2__viewport,
.cosmos-v2--immersive .cosmos-v2__viewport {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  border: none;
}
.cosmos-v2:fullscreen .cosmos-v2__head,
.cosmos-v2--immersive .cosmos-v2__head {
  position: absolute;
  top: 14px;
  left: 24px;
  right: 24px;
  z-index: 100;
  background: linear-gradient(180deg, rgba(4,6,12,0.65), transparent);
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
}
.cosmos-v2:fullscreen .cosmos-v2__controls,
.cosmos-v2--immersive .cosmos-v2__controls {
  bottom: 24px;
  right: 24px;
}
.cosmos-v2:fullscreen .cosmos-v2__preview,
.cosmos-v2--immersive .cosmos-v2__preview {
  position: absolute;
  bottom: 24px;
  left: 24px;
  max-width: 380px;
  z-index: 90;
}

/* ── Starfield SVG layer ──────────────────────────────────── */
.cosmos-v2__starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.7;
}

/* ── Connection lines SVG ─────────────────────────────────── */
.cosmos-v2__lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.cosmos-v2__line {
  stroke-width: 1.5;
  opacity: 0.08;
  fill: none;
  transition: opacity 0.4s, stroke-width 0.4s;
  stroke-dasharray: 8 4;
}
.cosmos-v2__line.is-active {
  opacity: 0.6;
  stroke-width: 2.5;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 3px currentColor);
}

/* ═══════════════════════════════════════════════════════════
   CONSTELLATION LINES — Daedric rivalries & alliances
   Faint at rest, illuminate when a connected node is active
   ═══════════════════════════════════════════════════════════ */
.cosmos-v2__constellations {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.cosmos-v2__constellation {
  fill: none;
  opacity: 0.05;
  transition: opacity 0.5s ease, stroke-width 0.5s ease;
}

/* Rivalry: jagged red, like a fault line - dormant power */
.cosmos-v2__constellation--rivalry {
  stroke: #c84830;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2 6;
}
.cosmos-v2__constellation--rivalry.is-active {
  opacity: 0.55;
  stroke-width: 2.2;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 4px #c84830);
  animation: cosmos-v2-rivalry-pulse 2.4s ease-in-out infinite;
}

/* Alliance: smooth gold, an arcane bond */
.cosmos-v2__constellation--alliance {
  stroke: #c8a050;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 1 5;
}
.cosmos-v2__constellation--alliance.is-active {
  opacity: 0.5;
  stroke-width: 2;
  stroke-dasharray: 4 6;
  filter: drop-shadow(0 0 4px #c8a050);
  animation: cosmos-v2-alliance-flow 6s linear infinite;
}

@keyframes cosmos-v2-rivalry-pulse {
  0%, 100% { stroke-width: 2.2; opacity: 0.55; }
  50% { stroke-width: 3; opacity: 0.7; }
}
@keyframes cosmos-v2-alliance-flow {
  to { stroke-dashoffset: -100; }
}

/* ═══════════════════════════════════════════════════════════
   3D NIRN GLOBE (center)
   Multi-layer CSS sphere with perspective
   ═══════════════════════════════════════════════════════════ */
.cosmos-v2__nirn {
  position: absolute;
  width: 500px;
  height: 500px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  perspective: 1200px;
}
.cosmos-v2__nirn-sphere {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform-style: preserve-3d;
  box-shadow:
    0 0 80px rgba(80,120,180,0.08),
    0 0 160px rgba(80,120,180,0.04);
}
.cosmos-v2__nirn-layer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

/* Ocean base - dark deep water */
.cosmos-v2__nirn-ocean {
  background: radial-gradient(
    circle at 40% 38%,
    #0e1820 0%,
    #0a1420 30%,
    #060c14 60%,
    #040810 100%
  );
}

/* Continental SVG - rotates slowly */
.cosmos-v2__nirn-continents {
  animation: cosmos-v2-rotate 60s linear infinite;
  overflow: hidden;
  border-radius: 50%;
}
.cosmos-v2__nirn-continents svg {
  width: 100%;
  height: 100%;
}

/* Cloud wisps - counter-rotates */
.cosmos-v2__nirn-clouds {
  background:
    radial-gradient(ellipse 25% 8% at 30% 25%, rgba(180,200,220,0.06) 0%, transparent 100%),
    radial-gradient(ellipse 20% 6% at 65% 55%, rgba(180,200,220,0.04) 0%, transparent 100%),
    radial-gradient(ellipse 30% 5% at 45% 75%, rgba(180,200,220,0.05) 0%, transparent 100%),
    radial-gradient(ellipse 15% 10% at 70% 30%, rgba(180,200,220,0.03) 0%, transparent 100%);
  animation: cosmos-v2-rotate-reverse 90s linear infinite;
  opacity: 0.7;
}

/* Lighting overlay - creates 3D sphere illusion (static) */
.cosmos-v2__nirn-lighting {
  background:
    radial-gradient(circle at 35% 35%, transparent 0%, transparent 40%, rgba(0,0,0,0.3) 65%, rgba(0,0,0,0.7) 85%, rgba(0,0,0,0.9) 100%),
    linear-gradient(135deg, rgba(140,180,220,0.08) 0%, transparent 40%);
  pointer-events: none;
}

/* Atmosphere rim glow */
.cosmos-v2__nirn-atmosphere {
  inset: -5px;
  border: 4px solid transparent;
  background: radial-gradient(circle at 50% 50%, transparent 46%, rgba(100,160,220,0.12) 48%, rgba(100,160,220,0.06) 50%, transparent 52%) border-box;
  box-shadow:
    0 0 30px rgba(100,160,220,0.1),
    0 0 60px rgba(100,160,220,0.05),
    inset 0 0 30px rgba(100,160,220,0.04);
  pointer-events: none;
}

.cosmos-v2__nirn-label {
  position: absolute;
  bottom: -36px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(140,180,220,0.5);
}

@keyframes cosmos-v2-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes cosmos-v2-rotate-reverse {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* ── Orbital paths ────────────────────────────────────────── */
.cosmos-v2__orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1px dashed rgba(160,140,200,0.06);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cosmos-v2__orbit--aedra {
  border-color: rgba(212,168,80,0.05);
}
.cosmos-v2__orbit--daedra {
  border-color: rgba(160,60,80,0.04);
}

/* ═══════════════════════════════════════════════════════════
   ORBITAL ANIMATION — Aedra spinner mechanism
   Three nested transforms: spinner rotates around canvas center,
   arm extends to orbit radius, node counter-rotates so labels
   stay upright. Hover scale applies to inner body separately.
   ═══════════════════════════════════════════════════════════ */
.cosmos-v2__orbit-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  animation: cosmos-v2-orbit var(--orbit-period, 200s) linear infinite;
  animation-delay: calc(var(--orbit-start, 0deg) / 360 * var(--orbit-period, 200s) * -1);
  pointer-events: none;
  z-index: 2;
}
.cosmos-v2__orbit-arm {
  position: absolute;
  top: 0;
  left: var(--orbit-radius, 1000px);
  width: 0;
  height: 0;
  pointer-events: auto;
}

/* Aedra node within an orbit arm: counter-rotates so labels stay upright.
   Override the static .cosmos-v2__node transform translate(-50%,-50%). */
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra {
  position: absolute;
  top: 0;
  left: 0;
  transform: none;
  animation: cosmos-v2-counter-rotate var(--orbit-period, 200s) linear infinite;
  animation-delay: calc(var(--orbit-start, 0deg) / 360 * var(--orbit-period, 200s));
}

@keyframes cosmos-v2-orbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes cosmos-v2-counter-rotate {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(-360deg); }
}

/* Pause both animations when user hovers/focuses/activates a planet */
.cosmos-v2__orbit-spinner:hover,
.cosmos-v2__orbit-spinner:focus-within,
.cosmos-v2__orbit-spinner:has(.cosmos-v2__node.is-active) {
  animation-play-state: paused;
}
.cosmos-v2__orbit-spinner:hover .cosmos-v2__node--aedra,
.cosmos-v2__orbit-spinner:focus-within .cosmos-v2__node--aedra,
.cosmos-v2__orbit-spinner:has(.cosmos-v2__node.is-active) .cosmos-v2__node--aedra {
  animation-play-state: paused;
}

/* Hover scale on the body specifically (not the button) so it doesn't
   fight the counter-rotation transform on the button itself. */
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra:hover .cosmos-v2__node-body,
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra:focus-visible .cosmos-v2__node-body,
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra.is-active .cosmos-v2__node-body {
  transform: scale(1.2);
  transition: transform 0.3s, box-shadow 0.3s;
}
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra .cosmos-v2__node-body {
  transition: transform 0.3s, box-shadow 0.3s;
}
/* Disable the original button-level scale for orbiting nodes */
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra:hover,
.cosmos-v2__orbit-arm > .cosmos-v2__node--aedra:focus-visible {
  transform: none;
}

/* ── Node base ────────────────────────────────────────────── */
.cosmos-v2__node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: filter 0.3s, transform 0.3s;
  z-index: 2;
}
.cosmos-v2__node:hover,
.cosmos-v2__node:focus-visible {
  z-index: 10;
  filter: brightness(1.4);
  transform: translate(-50%, -50%) scale(1.2);
}
.cosmos-v2__node:focus-visible {
  outline: 2px solid rgba(160,140,200,0.6);
  outline-offset: 4px;
  border-radius: 4px;
}
.cosmos-v2__node.is-active {
  z-index: 10;
  filter: brightness(1.5);
  transform: translate(-50%, -50%) scale(1.2);
}

/* ── Aedra planet nodes ───────────────────────────────────── */
.cosmos-v2__node--aedra .cosmos-v2__node-body {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 32%, var(--node-color) 0%, color-mix(in srgb, var(--node-color) 30%, #000) 70%, rgba(0,0,0,0.8) 100%);
  box-shadow:
    0 0 14px var(--node-color),
    0 0 28px color-mix(in srgb, var(--node-color) 40%, transparent),
    inset -4px -4px 8px rgba(0,0,0,0.4);
  transition: box-shadow 0.3s;
}
.cosmos-v2__node--aedra:hover .cosmos-v2__node-body,
.cosmos-v2__node--aedra:focus-visible .cosmos-v2__node-body,
.cosmos-v2__node--aedra.is-active .cosmos-v2__node-body {
  box-shadow:
    0 0 24px var(--node-color),
    0 0 48px color-mix(in srgb, var(--node-color) 60%, transparent),
    inset -4px -4px 8px rgba(0,0,0,0.4);
}

/* ── Daedra star nodes ────────────────────────────────────── */
.cosmos-v2__node--daedra .cosmos-v2__node-body {
  position: relative;
  width: 36px;
  height: 36px;
}
.cosmos-v2__node--daedra .cosmos-v2__node-core {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--node-color);
  box-shadow: 0 0 12px var(--node-color), 0 0 24px color-mix(in srgb, var(--node-color) 50%, transparent);
}
.cosmos-v2__node--daedra .cosmos-v2__node-spike {
  position: absolute;
  top: 50%;
  left: 50%;
  background: linear-gradient(to bottom, transparent 0%, var(--node-color) 50%, transparent 100%);
  transform-origin: center;
  opacity: 0.7;
}
.cosmos-v2__node--daedra .cosmos-v2__node-spike--v {
  width: 2px;
  height: 100%;
  transform: translate(-50%, -50%);
}
.cosmos-v2__node--daedra .cosmos-v2__node-spike--h {
  width: 100%;
  height: 2px;
  transform: translate(-50%, -50%);
}
.cosmos-v2__node--daedra .cosmos-v2__node-spike--d1 {
  width: 2px;
  height: 70%;
  transform: translate(-50%, -50%) rotate(45deg);
}
.cosmos-v2__node--daedra .cosmos-v2__node-spike--d2 {
  width: 2px;
  height: 70%;
  transform: translate(-50%, -50%) rotate(-45deg);
}
.cosmos-v2__node--daedra .cosmos-v2__node-halo {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid var(--node-color);
  opacity: 0.3;
  animation: cosmos-v2-pulse 3s ease-in-out infinite;
}
.cosmos-v2__node--daedra.is-active .cosmos-v2__node-halo,
.cosmos-v2__node--daedra:hover .cosmos-v2__node-halo {
  opacity: 0.6;
}

@keyframes cosmos-v2-pulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.15); opacity: 0.15; }
}

/* ═══ Nirn surface location nodes (enhanced with runes) ═══ */
.cosmos-v2__node--nirn-loc .cosmos-v2__node-body {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--node-color) 0%, rgba(0,0,0,0.6) 100%);
  box-shadow:
    0 0 10px var(--node-color),
    0 0 20px color-mix(in srgb, var(--node-color) 30%, transparent);
  border: 1px solid color-mix(in srgb, var(--node-color) 60%, transparent);
}
.cosmos-v2__node--nirn-loc .cosmos-v2__node-rune {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  color: var(--node-color);
  text-shadow: 0 0 6px var(--node-color);
}
.cosmos-v2__node--nirn-loc:hover .cosmos-v2__node-body,
.cosmos-v2__node--nirn-loc:focus-visible .cosmos-v2__node-body,
.cosmos-v2__node--nirn-loc.is-active .cosmos-v2__node-body {
  box-shadow:
    0 0 16px var(--node-color),
    0 0 32px color-mix(in srgb, var(--node-color) 50%, transparent);
}

/* ── Node label ───────────────────────────────────────────── */
.cosmos-v2__node-label {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(232,228,220,0.6);
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  transition: color 0.3s;
}
.cosmos-v2__node:hover .cosmos-v2__node-label,
.cosmos-v2__node:focus-visible .cosmos-v2__node-label,
.cosmos-v2__node.is-active .cosmos-v2__node-label {
  color: rgba(232,228,220,1);
}

/* ── Locked state ─────────────────────────────────────────── */
.cosmos-v2__node.is-locked {
  opacity: 0.22;
  cursor: default;
  pointer-events: auto;
  transition: opacity 0.3s;
}
.cosmos-v2__node.is-locked .cosmos-v2__node-body {
  filter: grayscale(0.8);
}
.cosmos-v2__node.is-locked .cosmos-v2__node-halo {
  animation: none;
}
.cosmos-v2__node.is-locked:hover,
.cosmos-v2__node.is-locked:focus-visible,
.cosmos-v2__node.is-locked.is-tooltip-visible {
  opacity: 0.55;
  filter: brightness(1.1);
  transform: translate(-50%, -50%) scale(1.05);
}

/* ═══════════════════════════════════════════════════════════
   LOCKED TOOLTIP — appears on hover/long-press for sealed Princes
   Marginalia-style: small sealed parchment beside the star
   ═══════════════════════════════════════════════════════════ */
.cosmos-v2__locked-tooltip {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translate(-50%, 6px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  max-width: 240px;
  padding: 10px 14px;
  background: rgba(8,4,12,0.96);
  border: 1px solid var(--node-color);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(.16,.84,.44,1), visibility 0s linear 0.25s;
  z-index: 200;
  box-shadow:
    0 4px 16px rgba(0,0,0,0.6),
    0 0 20px color-mix(in srgb, var(--node-color) 25%, transparent);
  filter: brightness(2);
}
.cosmos-v2__locked-tooltip::before {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: rgba(8,4,12,0.96);
  border-right: 1px solid var(--node-color);
  border-bottom: 1px solid var(--node-color);
}
.cosmos-v2__node.is-locked:hover .cosmos-v2__locked-tooltip,
.cosmos-v2__node.is-locked:focus-visible .cosmos-v2__locked-tooltip,
.cosmos-v2__node.is-locked.is-tooltip-visible .cosmos-v2__locked-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(.16,.84,.44,1), visibility 0s;
}
.cosmos-v2__locked-tooltip-name {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--node-color);
  line-height: 1.1;
  letter-spacing: 0.02em;
}
.cosmos-v2__locked-tooltip-deck {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(232,228,220,0.65);
  line-height: 1.35;
}
.cosmos-v2__locked-tooltip-soon {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(232,228,220,0.12);
  font-family: var(--font-mono, monospace);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--node-color) 70%, white);
  opacity: 0.85;
}
.cosmos-v2__locked-tooltip-soon::before {
  content: '\25C7\00a0';
  opacity: 0.6;
}

/* ── Preview card ─────────────────────────────────────────── */
.cosmos-v2__preview {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}
.cosmos-v2__preview-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(10,6,16,0.92);
  border: 1px solid rgba(160,140,200,0.12);
  border-radius: 8px;
  padding: 14px 20px;
  min-width: 360px;
  max-width: 500px;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  transition: border-color 0.3s;
}
.cosmos-v2__preview-img {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(160,140,200,0.06);
}
.cosmos-v2__preview-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cosmos-v2__preview-kicker {
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-mute, rgba(232,228,220,0.4));
  margin-bottom: 2px;
}
.cosmos-v2__preview-title {
  font-family: var(--font-display, serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--text, #e8e4dc);
  margin: 0 0 4px;
}
.cosmos-v2__preview-title em { font-style: italic; color: var(--accent-bright, #c8b8e0); }
.cosmos-v2__preview-deck {
  font-size: 12px;
  color: var(--text-mute, rgba(232,228,220,0.5));
  margin: 0 0 6px;
  line-height: 1.4;
}
.cosmos-v2__preview-cta {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent, rgba(160,140,200,0.8));
  text-decoration: none;
  pointer-events: auto;
}
.cosmos-v2__preview-cta:hover { color: var(--accent-bright, #c8b8e0); }

/* ── Zoom controls ────────────────────────────────────────── */
.cosmos-v2__controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 50;
}
.cosmos-v2__controls button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(160,140,200,0.15);
  border-radius: 4px;
  background: rgba(10,6,16,0.8);
  color: var(--text-mute, rgba(232,228,220,0.5));
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.cosmos-v2__controls button:hover {
  background: rgba(160,140,200,0.12);
  color: var(--text, #e8e4dc);
}
.cosmos-v2__zoom-level {
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  text-align: center;
  color: var(--text-mute, rgba(232,228,220,0.4));
  padding: 2px 0;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cosmos-v2__nirn-continents { animation: none; }
  .cosmos-v2__nirn-clouds { animation: none; }
  .cosmos-v2__canvas { transition: none; }
  .cosmos-v2__node { transition: none; }
  .cosmos-v2__node--daedra .cosmos-v2__node-halo { animation: none; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .cosmos-v2__head { padding: 0 20px; }
  .cosmos-v2__viewport { height: 70vh; min-height: 500px; }
  .cosmos-v2__preview-card { min-width: 280px; padding: 10px 14px; }
  .cosmos-v2__preview-img { width: 48px; height: 48px; }
}

/* ════════════════════════════════════════════════════════════
   ARTICLE NODES (chronicle-articles.js renderer)
   Anchored small SVG glyphs that scale across thousands of
   entries via cluster collapse and tier-based visibility.
   ════════════════════════════════════════════════════════════ */
.cosmos-v2__articles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.cosmos-v2__articles.is-search-mode .cosmos-v2__article:not(.is-search-match) {
  opacity: 0.05;
  filter: saturate(0);
}

.cosmos-v2__article {
  --cosmos-glyph-size: 14px;
  position: absolute;
  width: var(--cosmos-glyph-size);
  height: var(--cosmos-glyph-size);
  margin-left: calc(var(--cosmos-glyph-size) / -2);
  margin-top:  calc(var(--cosmos-glyph-size) / -2);
  padding: 0;
  background: none;
  border: none;
  color: var(--node-color, #c8b8e0);
  cursor: pointer;
  pointer-events: auto;
  transform-origin: 50% 50%;
  transition: transform 0.25s cubic-bezier(.16,.84,.44,1),
              opacity 0.4s ease,
              filter 0.4s ease;
  opacity: 0.85;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.7));
  z-index: 5;
}
.cosmos-v2__article:hover,
.cosmos-v2__article:focus-visible {
  opacity: 1;
  transform: scale(1.6);
  outline: none;
  z-index: 20;
  filter: drop-shadow(0 0 6px currentColor);
}
.cosmos-v2__article:focus-visible {
  outline: 1px dashed currentColor;
  outline-offset: 4px;
}

.cosmos-v2__article-glyph {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cosmos-v2__article-glyph svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cosmos-v2__article-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, 4px);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--text, #e8e4dc);
  background: rgba(8,4,16,0.85);
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid rgba(160,140,200,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}
.cosmos-v2__article:hover .cosmos-v2__article-label,
.cosmos-v2__article:focus-visible .cosmos-v2__article-label {
  opacity: 1;
}

/* ── Type accent colors ───────────────────────────────────── */
.cosmos-v2__article--lore          { --node-color: #c8b8e0; }
.cosmos-v2__article--place         { --node-color: #6a9eb4; }
.cosmos-v2__article--lesser_daedra { --node-color: #c07a6a; }
.cosmos-v2__article--people        { --node-color: #d4a850; }
.cosmos-v2__article--artifact      { --node-color: #e0a060; }
.cosmos-v2__article--creature      { --node-color: #8a9a6a; }

/* ── Drift animation (subtle wobble for orbital articles) ─── */
@keyframes cosmosArticleDrift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(0.4px, -0.6px); }
  50%  { transform: translate(-0.3px, 0.4px); }
  75%  { transform: translate(0.5px, 0.3px); }
  100% { transform: translate(0, 0); }
}
.cosmos-v2__article--drift {
  animation: cosmosArticleDrift 7s ease-in-out infinite;
}
.cosmos-v2__article--drift:hover {
  animation: none;
}

/* ── Stack badge (cluster collapse) ───────────────────────── */
.cosmos-v2__article--stack {
  --cosmos-glyph-size: 22px;
  background: radial-gradient(circle at 35% 30%,
              rgba(40,28,60,0.95) 0%,
              rgba(16,8,28,0.95) 70%);
  border: 1px solid currentColor;
  border-radius: 50%;
  padding: 3px;
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.4),
    0 0 8px currentColor;
  opacity: 0.95;
}
.cosmos-v2__article--stack:hover {
  transform: scale(1.4);
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.4),
    0 0 14px currentColor;
}
.cosmos-v2__article-stack-count {
  position: absolute;
  bottom: -5px;
  right: -5px;
  background: rgba(8,4,16,0.95);
  border: 1px solid currentColor;
  border-radius: 8px;
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 4px;
  min-width: 14px;
  text-align: center;
  color: var(--text, #e8e4dc);
  pointer-events: none;
}

.cosmos-v2__article-stack-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -6px);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--text, #e8e4dc);
  background: rgba(8,4,16,0.92);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
}
.cosmos-v2__article--stack:hover .cosmos-v2__article-stack-tooltip,
.cosmos-v2__article--stack:focus-visible .cosmos-v2__article-stack-tooltip {
  opacity: 1;
  transform: translate(-50%, -10px);
}

/* ── From-stack expansion (fan-out animation) ─────────────── */
@keyframes cosmosArticleFanIn {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 0.85; }
}
.cosmos-v2__article--from-stack {
  animation: cosmosArticleFanIn 0.35s cubic-bezier(.16,.84,.44,1) backwards;
}

/* ── Search match highlight ───────────────────────────────── */
.cosmos-v2__article.is-search-match {
  z-index: 25;
  animation: cosmosArticleSearchPulse 1.4s ease-in-out 3;
}
@keyframes cosmosArticleSearchPulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 2px currentColor); }
  50%      { transform: scale(1.25); filter: drop-shadow(0 0 8px currentColor); }
}

/* ── Mobile: 44px tap target via padding wrapper ──────────── */
@media (hover: none) and (pointer: coarse) {
  .cosmos-v2__article {
    padding: 14px;
    margin-left: calc(var(--cosmos-glyph-size) / -2 - 14px);
    margin-top:  calc(var(--cosmos-glyph-size) / -2 - 14px);
  }
  .cosmos-v2__article-label {
    font-size: 10px;
    padding: 3px 8px;
  }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cosmos-v2__article,
  .cosmos-v2__article--drift,
  .cosmos-v2__article--from-stack,
  .cosmos-v2__article.is-search-match {
    animation: none;
    transition: opacity 0.2s ease;
  }
}

/* ════════════════════════════════════════════════════════════
   FILTER BAR + SEARCH (Tier 2 + Tier 3 controls)
   ════════════════════════════════════════════════════════════ */
.cosmos-v2__filterbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(8,4,16,0.92), rgba(8,4,16,0.72));
  border: 1px solid rgba(160,140,200,0.18);
  border-radius: 10px;
  backdrop-filter: blur(8px) saturate(1.2);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  z-index: 50;
  box-shadow: 0 4px 22px rgba(0,0,0,0.4);
  max-width: calc(100% - 32px);
  flex-wrap: wrap;
  justify-content: center;
}

.cosmos-v2__chips {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.cosmos-v2__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(20,12,32,0.5);
  border: 1px solid rgba(160,140,200,0.15);
  border-radius: 16px;
  padding: 5px 11px;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute, rgba(232,228,220,0.6));
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.cosmos-v2__chip:hover {
  border-color: var(--node-color, #c8b8e0);
  color: var(--text, #e8e4dc);
}
.cosmos-v2__chip[aria-pressed="true"] {
  background: var(--node-color, #c8b8e0);
  border-color: var(--node-color, #c8b8e0);
  color: rgba(8,4,16,0.95);
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(160,140,200,0.35);
}
.cosmos-v2__chip-glyph {
  font-size: 13px;
  line-height: 1;
}

.cosmos-v2__chip--lore          { --node-color: #c8b8e0; }
.cosmos-v2__chip--place         { --node-color: #6a9eb4; }
.cosmos-v2__chip--lesser_daedra { --node-color: #c07a6a; }
.cosmos-v2__chip--people        { --node-color: #d4a850; }
.cosmos-v2__chip--artifact      { --node-color: #e0a060; }
.cosmos-v2__chip--creature      { --node-color: #8a9a6a; }

.cosmos-v2__chip-clear {
  background: transparent;
  border: 1px solid rgba(160,140,200,0.15);
  color: var(--text-mute, rgba(232,228,220,0.5));
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.cosmos-v2__chips.has-active .cosmos-v2__chip-clear {
  opacity: 1;
  pointer-events: auto;
}
.cosmos-v2__chip-clear:hover {
  color: #e07a6a;
  border-color: #e07a6a;
}

.cosmos-v2__search {
  position: relative;
  display: flex;
  align-items: center;
}
.cosmos-v2__search-input {
  width: 220px;
  padding: 6px 10px;
  background: rgba(20,12,32,0.5);
  border: 1px solid rgba(160,140,200,0.15);
  border-radius: 6px;
  color: var(--text, #e8e4dc);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color 0.2s ease, width 0.25s ease;
}
.cosmos-v2__search-input::placeholder {
  color: var(--text-mute, rgba(232,228,220,0.35));
}
.cosmos-v2__search-input:focus {
  border-color: rgba(200,184,224,0.5);
  width: 280px;
}
.cosmos-v2__search-hint {
  position: absolute;
  right: -118px;
  white-space: nowrap;
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-mute, rgba(232,228,220,0.4));
  pointer-events: none;
}

/* ── Back-to-cosmos button (Tier 1+) ─────────────────────── */
.cosmos-v2__back-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: rgba(8,4,16,0.85);
  border: 1px solid rgba(160,140,200,0.25);
  border-radius: 8px;
  color: var(--text, #e8e4dc);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 50;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.cosmos-v2__back-btn:hover {
  background: rgba(20,12,32,0.95);
  border-color: rgba(200,184,224,0.45);
  transform: translateY(-1px);
}
.cosmos-v2__back-btn[hidden] { display: none; }

/* ── Tier dimming (non-focused realms drop opacity) ──────── */
.cosmos-v2__node.is-realm-dimmed {
  opacity: 0.3;
  filter: saturate(0.5);
  transition: opacity 0.5s ease, filter 0.5s ease;
}
.cosmos-v2__node.is-realm-focused {
  z-index: 10;
}
.cosmos-v2__node.is-realm-focused .cosmos-v2__node-halo {
  filter: drop-shadow(0 0 18px currentColor);
}

/* ── Search-mode dimming ──────────────────────────────────── */
.cosmos-v2.is-search-mode .cosmos-v2__node:not(.is-search-match) {
  opacity: 0.05;
  filter: saturate(0);
}
.cosmos-v2__node.is-search-match .cosmos-v2__node-halo {
  animation: cosmosSearchPulse 1.6s ease-in-out 3;
}
@keyframes cosmosSearchPulse {
  0%, 100% { filter: drop-shadow(0 0 4px currentColor); transform: scale(1); }
  50%      { filter: drop-shadow(0 0 16px currentColor); transform: scale(1.18); }
}

/* ── Mobile: stack filter bar above viewport ─────────────── */
@media (max-width: 768px) {
  .cosmos-v2__filterbar {
    top: 8px;
    padding: 6px 8px;
    gap: 8px;
  }
  .cosmos-v2__chip {
    padding: 4px 8px;
    font-size: 9px;
  }
  .cosmos-v2__chip-label {
    display: none;
  }
  .cosmos-v2__chip-glyph {
    font-size: 14px;
  }
  .cosmos-v2__search-input {
    width: 140px;
  }
  .cosmos-v2__search-input:focus {
    width: 180px;
  }
  .cosmos-v2__search-hint {
    display: none;
  }
  .cosmos-v2__back-btn {
    top: 8px;
    left: 8px;
    padding: 5px 10px;
    font-size: 10px;
  }
}
