/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #08080d;
  --bg-panel: #0f0f16;
  --text: #d8d8e0;
  --text-dim: #6e6e80;
  --text-muted: #4a4a58;
  --accent-argument: #ffe4a8;
  --accent-context: #8b9fd4;
  --edge: #303040;
  --edge-highlight: #6868a0;
  --panel-width: 380px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* === Starfield (universal background) === */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* === Entrance === */
#entrance {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 100;
  cursor: pointer;
  transition: opacity 1s ease;
}

#entrance.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Radial glow behind entrance content */
.entrance-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 228, 168, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.entrance-content {
  text-align: center;
  user-select: none;
  position: relative;
  z-index: 1;
}

.entrance-content h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 1.2rem;
  text-shadow: 0 0 40px rgba(255, 228, 168, 0.12), 0 0 80px rgba(255, 228, 168, 0.05);
}

.entrance-content .author {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-bottom: 2.5rem;
}

.entrance-content .tagline {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 3rem;
}

.enter-cta {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.85; }
}

#entrance:hover .enter-cta {
  animation: none;
  opacity: 1;
  color: var(--text);
  transition: color 0.3s ease, opacity 0.3s ease;
}

/* === Graph Container === */
#graph-container {
  position: fixed;
  inset: 0;
  background: transparent;
  opacity: 0;
  transition: opacity 1s ease;
}

#graph-container.visible {
  opacity: 1;
}

#graph {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

/* === Credit (linked) === */
#credit {
  position: fixed;
  bottom: 16px;
  left: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.3s ease, color 0.2s ease;
  user-select: none;
  z-index: 2;
  text-decoration: none;
}

#credit:hover {
  opacity: 0.7;
  color: var(--text-dim);
}

#graph-container:hover #credit,
#graph-container:hover #maker-credit {
  opacity: 0.25;
}

#graph-container #credit:hover {
  opacity: 0.7;
}

/* === Obsidian Export === */
#obsidian-export {
  position: fixed;
  top: 16px;
  right: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.3s ease, color 0.2s ease;
  text-decoration: none;
  z-index: 2;
}

#obsidian-export:hover {
  opacity: 0.85;
  color: var(--text-dim);
}

#graph-container:hover #obsidian-export {
  opacity: 0.3;
}

#graph-container #obsidian-export:hover {
  opacity: 0.85;
}

/* === Maker Credit === */
#maker-credit {
  position: fixed;
  bottom: 16px;
  right: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.3s ease;
  user-select: none;
  z-index: 2;
}

#maker-credit a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s ease;
  pointer-events: auto;
}

#maker-credit a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* === Node labels (SVG text) === */
.node-label {
  font-family: var(--font);
  font-size: 7.5px;
  fill: var(--text-dim);
  pointer-events: none;
  user-select: none;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.node-label.prominent {
  font-size: 8.5px;
  fill: var(--text);
  stroke-width: 3px;
}

/* === Panel === */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid #1a1a24;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 50;
}

#panel.open {
  transform: translateX(0);
}

#panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

#panel-close:hover {
  color: var(--text);
}

#panel-title {
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  padding-right: 2rem;
  word-break: break-word;
}

#panel-type {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 1.2rem;
}

#panel-type.argument {
  color: var(--accent-argument);
  border: 1px solid rgba(255, 228, 168, 0.25);
}

#panel-type.context {
  color: var(--accent-context);
  border: 1px solid rgba(139, 159, 212, 0.25);
}

#panel-essay-context {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 1.5rem;
}

#panel-connections h3,
#panel-critical-context h3 {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

#panel-connections {
  margin-bottom: 1.5rem;
}

#panel-connections-list {
  list-style: none;
}

#panel-connections-list li {
  margin-bottom: 0.6rem;
  padding-left: 0;
}

.connection-name {
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}

.connection-name.argument {
  color: var(--accent-argument);
}

.connection-name.context {
  color: var(--accent-context);
}

.connection-name:hover {
  text-decoration: underline;
}

.connection-explanation {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 0.15rem;
}

#panel-critical-context {
  border-top: 1px solid #1a1a24;
  padding-top: 1.2rem;
}

#panel-critical-text {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-dim);
  font-style: italic;
}

/* === Scrollbar === */
#panel::-webkit-scrollbar {
  width: 4px;
}

#panel::-webkit-scrollbar-track {
  background: transparent;
}

#panel::-webkit-scrollbar-thumb {
  background: #2a2a38;
  border-radius: 2px;
}

/* === Mobile === */
@media (max-width: 768px) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60vh;
    border-left: none;
    border-top: 1px solid #1a1a24;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }

  #panel.open {
    transform: translateY(0);
  }

  .entrance-content h1 {
    font-size: clamp(1.6rem, 8vw, 2.8rem);
  }

  .entrance-glow {
    width: 300px;
    height: 300px;
  }
}
