@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&family=Outfit:wght@600;700;800&display=swap");

:root {
  --color-bg: #050505;
  --color-surface: #120708;
  --color-surface-strong: #1a0a0c;
  --color-primary: #ff3148;
  --color-secondary: #ff7382;
  --color-text: #fff7f7;
  --color-text-muted: #948b8c;
  --color-line: rgba(255, 95, 111, 0.2);
}

body.body-graph-shell {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
}

#app-root {
  --hud-pointer-x: 50%;
  --hud-pointer-y: 18%;
  --node-glow-color: var(--color-primary);
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  grid-template-rows: 68px minmax(0, 1fr) 78px;
  width: 100%;
  height: 100vh;
  color: var(--color-text);
  font-family: "Inter", sans-serif;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(5, 5, 5, 0.52), rgba(5, 5, 5, 0.86)),
    radial-gradient(circle at top right, rgba(255, 49, 72, 0.14), transparent 28%);
}

#app-root::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--hud-pointer-x) var(--hud-pointer-y), rgba(255, 92, 114, 0.14), transparent 24%),
    radial-gradient(circle at 76% 18%, rgba(140, 232, 255, 0.08), transparent 18%);
}

#flow-canvas-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#hud-left,
#hud-right,
#hud-top,
#hud-bottom {
  background:
    radial-gradient(circle at var(--hud-pointer-x, 50%) var(--hud-pointer-y, 0%), rgba(255, 95, 111, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(21, 8, 10, 0.88), rgba(10, 4, 5, 0.8)),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.022) 1px, transparent 1px, transparent 28px);
  border-color: var(--color-line);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

#hud-left,
#hud-right {
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow-y: auto;
  z-index: 10;
}

#hud-left {
  grid-column: 1;
  grid-row: 2;
  border-right: 1px solid var(--color-line);
}

#hud-right {
  grid-column: 3;
  grid-row: 2;
  border-left: 1px solid var(--color-line);
}

#hud-top {
  grid-column: 1 / 4;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-line);
  z-index: 11;
}

#hud-bottom {
  grid-column: 1 / 4;
  grid-row: 3;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-top: 1px solid var(--color-line);
  z-index: 11;
}

.app-title {
  margin: 0;
  color: var(--color-primary);
  font-family: "Outfit", sans-serif;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
}

.app-nav {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: all 0.2s ease;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}

.nav-link:hover {
  color: var(--color-text);
}

.nav-link.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.top-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

.top-stats span {
  color: var(--color-text-muted);
}

.top-stats strong {
  color: var(--color-text);
  font-family: "JetBrains Mono", monospace;
}

.top-stats strong.is-updating {
  animation: stat-flash 0.45s ease;
}

#sigma-container {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  z-index: 2;
  background: #1e1e1e;
}

#sigma-container::before {
  display: none;
}

#sigma-container .node-visualizer-container {
  display: none;
}

#signal-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}

.btn-gl {
  background: linear-gradient(135deg, var(--color-primary), #ff5b6f);
  color: #fff;
  border: 1px solid rgba(255, 135, 148, 0.42);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.btn-gl:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

input,
select {
  width: 100%;
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 95, 111, 0.24);
  border-radius: 8px;
  background: rgba(10, 4, 5, 0.68);
  color: var(--color-text);
}

input:focus,
select:focus {
  outline: 1px solid rgba(255, 113, 129, 0.6);
  border-color: rgba(255, 113, 129, 0.7);
}

.hud-block {
  margin-bottom: 24px;
}

.hud-field label,
#hud-left > .hud-block > label,
.control-group label {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  color: var(--color-text-muted);
}

.node-type-filters {
  display: grid;
  gap: 8px;
}

.node-type-filter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid rgba(255, 95, 111, 0.16);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(21, 8, 10, 0.55);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.node-type-filter-item:hover {
  transform: translateX(3px);
  border-color: rgba(255, 95, 111, 0.3);
  background: rgba(24, 9, 11, 0.76);
}

.node-type-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

#detail-title {
  margin-top: 0;
  margin-bottom: 8px;
  font-family: "Outfit", sans-serif;
  font-size: 1.35rem;
}

.detail-title-link {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.detail-title-link:hover {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  filter: drop-shadow(0 0 8px rgba(255, 49, 72, 0.4));
}

.detail-subtitle {
  color: var(--color-text-muted);
  line-height: 1.7;
}

#detail-pane {
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

#detail-pane.is-active {
  transform: translateY(-2px);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.26);
}

.detail-divider {
  border: 0;
  border-top: 1px solid var(--color-line);
  margin: 18px 0;
}

.detail-section {
  margin-top: 12px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(255, 247, 247, 0.9);
}

.detail-community {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--color-line);
}

.detail-community-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  letter-spacing: 0.12em;
}

.detail-community-value {
  margin-top: 6px;
  font-weight: 700;
  color: var(--color-secondary);
}

.neighbor-chip {
  display: inline-block;
  background: rgba(255, 49, 72, 0.08);
  color: var(--color-secondary);
  border: 1px solid rgba(255, 49, 72, 0.2);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  margin: 0 4px 6px 0;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-align: left;
}

.neighbor-chip:hover {
  background: rgba(255, 49, 72, 0.18);
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255, 49, 72, 0.15);
}

.detail-neighbors-list {
  display: flex;
  flex-wrap: wrap;
  margin-top: 10px;
}

.bottom-controls {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.control-group {
  flex: 1;
}

.control-group input {
  margin: 0;
}

.year-value {
  width: 70px;
  text-align: center;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  color: var(--color-secondary);
}

@media (max-width: 1180px) {
  #app-root {
    grid-template-columns: 270px minmax(0, 1fr);
    grid-template-rows: 68px minmax(0, 1fr) 250px 78px;
  }

  #hud-right {
    grid-column: 1 / 3;
    grid-row: 3;
    border-left: 0;
    border-top: 1px solid var(--color-line);
  }

  #sigma-container {
    grid-column: 2;
    grid-row: 2;
  }
}

@media (max-width: 860px) {
  #app-root {
    grid-template-columns: 1fr;
    grid-template-rows: 68px minmax(0, 1fr) auto auto auto;
  }

  #hud-left,
  #hud-right,
  #sigma-container,
  #hud-bottom {
    grid-column: 1;
  }

  #hud-left {
    grid-row: 3;
    border-right: 0;
    border-top: 1px solid var(--color-line);
  }

  #hud-right {
    grid-row: 4;
  }

  #hud-bottom {
    grid-row: 5;
    padding: 12px 16px;
    height: auto;
  }

  .top-stats {
    gap: 10px;
    font-size: 0.82rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .bottom-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
}

/* --- Premium QoL Additions --- */

/* Custom Scrollbar */
#hud-left::-webkit-scrollbar,
#hud-right::-webkit-scrollbar {
  width: 4px;
}

#hud-left::-webkit-scrollbar-track,
#hud-right::-webkit-scrollbar-track {
  background: transparent;
}

#hud-left::-webkit-scrollbar-thumb,
#hud-right::-webkit-scrollbar-thumb {
  background: var(--color-line);
  border-radius: 10px;
}

#hud-left::-webkit-scrollbar-thumb:hover,
#hud-right::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Detail Pane Enhancements */
.detail-section {
  position: relative;
  padding-left: 14px;
  border-left: 1px solid var(--color-line);
}

.detail-community-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-community-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-primary);
}

/* Button Pulse for Rebuild */
@keyframes rebuild-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 49, 72, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255, 49, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 49, 72, 0); }
}

.btn-premium.is-loading {
  animation: rebuild-pulse 1.5s infinite;
  pointer-events: none;
  opacity: 0.8;
}

/* Search Focus Highlight */
#graph-search:focus {
  box-shadow: 0 0 15px rgba(255, 49, 72, 0.2);
}

/* Mobile & Tablet Refinements */
@media (max-width: 1180px) {
  #hud-left {
    padding: 12px;
  }
  .node-type-filters {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

@media (max-width: 860px) {
  #hud-top {
    flex-direction: column;
    height: auto;
    padding: 12px;
    gap: 12px;
  }
  .app-nav {
    gap: 12px;
    justify-content: center;
    width: 100%;
  }
  .top-stats {
    width: 100%;
    justify-content: center;
    font-size: 0.7rem;
  }
}

/* Dossier Typography */
#detail-content {
  font-size: 0.88rem;
  line-height: 1.6;
  color: rgba(255, 247, 247, 0.8);
}

#detail-content strong {
  color: var(--color-primary);
}

.detail-section {
  margin-bottom: 20px;
}


/* --- Neural Node Visualizer --- */
.node-visualizer-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  width: 800px;
  height: 800px;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 2000px;
  background: radial-gradient(circle at center, rgba(255, 49, 72, 0.02), transparent 75%);
  border-radius: 50%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: all 1.2s cubic-bezier(0.19, 1, 0.22, 1);
}

.node-visualizer-container.node-selected-active {
  opacity: 0.25; /* Subtle background presence */
  transform: translate(-50%, -50%) scale(1);
}

.neural-sphere {
  position: relative;
  width: 320px;
  height: 320px;
  transform-style: preserve-3d;
  animation: sphere-float 12s ease-in-out infinite;
}

.sphere-core {
  position: absolute;
  inset: 80px;
  background: var(--node-glow-color, var(--color-primary));
  border-radius: 50%;
  box-shadow: 
    0 0 60px var(--node-glow-color, var(--color-primary)),
    0 0 120px var(--node-glow-color, var(--color-primary)),
    0 0 240px var(--node-glow-color, var(--color-primary));
  filter: blur(8px);
  z-index: 2;
}

.sphere-orbit {
  position: absolute;
  inset: -60px;
  border: 1px solid var(--node-glow-color, var(--color-primary));
  border-radius: 50%;
  opacity: 0.2;
  transform-style: preserve-3d;
}

.sphere-orbit--1 {
  animation: orbit-rotate-x 8s linear infinite;
}

.sphere-orbit--2 {
  animation: orbit-rotate-y 12s linear infinite;
  border-width: 2px;
  opacity: 0.2;
}

.sphere-orbit--3 {
  animation: orbit-rotate-z 10s linear infinite;
  border-style: dashed;
}

@keyframes sphere-float {
  0%, 100% { transform: translateY(0) rotateX(0) rotateY(0); }
  50% { transform: translateY(-10px) rotateX(10deg) rotateY(10deg); }
}

@keyframes orbit-rotate-x {
  from { transform: rotateX(0); }
  to { transform: rotateX(360deg); }
}

@keyframes orbit-rotate-y {
  from { transform: rotateY(0); }
  to { transform: rotateY(360deg); }
}

@keyframes orbit-rotate-z {
  from { transform: rotateX(45deg) rotateZ(0); }
  to { transform: rotateX(45deg) rotateZ(360deg); }
}

@keyframes stat-flash {
  0% {
    text-shadow: 0 0 0 rgba(255, 49, 72, 0);
    filter: brightness(1);
  }
  50% {
    text-shadow: 0 0 14px rgba(255, 49, 72, 0.42);
    filter: brightness(1.2);
  }
  100% {
    text-shadow: 0 0 0 rgba(255, 49, 72, 0);
    filter: brightness(1);
  }
}

@keyframes hud-grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-36px, -24px, 0); }
}

@media (prefers-reduced-motion: reduce) {
  #sigma-container::before,
  .btn-premium.is-loading,
  .node-visualizer-container,
  .neural-sphere,
  .sphere-orbit {
    animation: none !important;
    transition: none !important;
  }
}

/* Enhancing existing detail section for the new visual flow */
.detail-divider {
  margin: 10px 0;
}
