/* RBH-1 Visualization — Dark Space Theme */

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

:root {
  --bg-deep: #050510;
  --bg-panel: #0a0a1a;
  --bg-surface: #0f0f24;
  --bg-elevated: #141430;

  --border-dim: #1a1a3a;
  --border-mid: #252550;
  --border-bright: #3a3a6a;

  --cyan: #00ccff;
  --cyan-dim: #00669988;
  --cyan-glow: #00ccff44;
  --orange: #ff8844;
  --orange-dim: #ff884466;
  --violet: #8844ff;
  --violet-dim: #8844ff44;
  --red: #ff4466;
  --green: #44ff88;

  --text-primary: #e0e0f0;
  --text-secondary: #8888aa;
  --text-dim: #666688;
  --text-accent: var(--cyan);

  --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --header-height: 48px;
  --toolbar-height: 44px;
  --panel-gap: 1px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Grid */
#app {
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--toolbar-height);
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "header  header"
    "scene   panel"
    "toolbar toolbar";
  width: 100%;
  height: 100%;
  gap: var(--panel-gap);
}

/* Header */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-dim);
  z-index: 10;
}

#header h1 {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

#header h1 span.accent {
  color: var(--cyan);
  font-weight: 600;
}

#header .velocity-readout {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

#header .velocity-readout .value {
  color: var(--cyan);
  font-weight: 500;
}

.paper-link {
  display: inline-block;
  margin-left: 12px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  border-radius: 3px;
  text-decoration: none;
  transition: all 0.2s;
  vertical-align: middle;
}

.paper-link:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: white;
}

.paper-link-footer {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.paper-link-footer:hover {
  color: var(--cyan);
}

/* Scene (3D) */
#scene-container {
  grid-area: scene;
  position: relative;
  background: var(--bg-deep);
  overflow: hidden;
}

#scene-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Right panel */
#right-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-dim);
  overflow: hidden;
}

/* Toolbar */
#toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-dim);
  font-size: 12px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* Utility */
.mono {
  font-family: var(--font-mono);
}

.text-cyan { color: var(--cyan); }
.text-orange { color: var(--orange); }
.text-violet { color: var(--violet); }
.text-dim { color: var(--text-dim); }
.text-secondary { color: var(--text-secondary); }

/* Easy/Complex mode visibility */
body.mode-easy .complex-only { display: none !important; }
body.mode-complex .easy-only { display: none !important; }
body.mode-easy #dashboard { display: none !important; }
body.mode-easy #frame-label { display: none !important; }
body.mode-complex #easy-dashboard { display: none !important; }

/* Intro splash */
#intro-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at center, #0a0a2a 0%, #020208 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s;
}
#intro-splash.hidden { opacity: 0; pointer-events: none; }

.splash-content {
  text-align: center;
  max-width: 600px;
  padding: 40px;
}

.splash-title {
  font-size: 64px;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.splash-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.splash-tagline {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 460px;
  margin: 0 auto 28px;
}

.splash-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.splash-facts {
  text-align: left;
  margin-bottom: 36px;
}

.splash-fact {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-dim);
  font-size: 15px;
}

.splash-fact .fact-num {
  color: var(--cyan);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 17px;
}

.splash-fact .fact-text {
  color: var(--text-secondary);
  margin-left: 8px;
}

.splash-btn {
  display: inline-block;
  padding: 12px 48px;
  font-size: 16px;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--bg-deep);
  background: var(--cyan);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.splash-btn:hover {
  background: white;
  transform: scale(1.05);
}

.splash-credit {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Splash entrance animations */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 204, 255, 0.3); }
  50% { box-shadow: 0 0 40px rgba(0, 204, 255, 0.6), 0 0 80px rgba(0, 204, 255, 0.15); }
}

@keyframes twinkle {
  0% { opacity: 0.3; }
  100% { opacity: 0.8; }
}

.splash-title,
.splash-subtitle,
.splash-tagline,
.splash-fact,
.splash-buttons,
.splash-credit {
  opacity: 0;
  animation: fadeSlideUp 0.6s ease-out forwards;
}

.splash-title { animation-delay: 0.1s; }
.splash-subtitle { animation-delay: 0.3s; }
.splash-tagline { animation-delay: 0.5s; }
.splash-fact:nth-child(1) { animation-delay: 0.8s; }
.splash-fact:nth-child(2) { animation-delay: 1.0s; }
.splash-fact:nth-child(3) { animation-delay: 1.2s; }
.splash-fact:nth-child(4) { animation-delay: 1.4s; }
.splash-buttons { animation-delay: 1.8s; }
.splash-credit { animation-delay: 2.0s; }

.splash-btn {
  box-shadow: 0 0 20px rgba(0, 204, 255, 0.3);
  animation: pulseGlow 2s ease-in-out 2.4s infinite;
}

#intro-splash::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 25% 55%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 40% 12%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 55% 68%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 70% 35%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 85% 75%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 15% 80%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 60% 25%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 35% 90%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 90% 10%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 5% 45%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 78% 58%, rgba(255,255,255,0.2), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
  pointer-events: none;
}

/* Easy mode annotations */
.easy-annotation {
  background: rgba(5, 5, 16, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  z-index: 4;
  pointer-events: none;
}

/* Fun facts bar */
#fun-facts {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(5, 5, 16, 0.8);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--orange);
  z-index: 5;
  max-width: 260px;
}

#fun-facts .fun-fact {
  transition: opacity 0.4s ease-in-out;
}

#fun-facts .fun-fact.fading {
  opacity: 0;
}

/* Mode toggle in header */
.mode-toggle {
  vertical-align: middle;
}

/* Focus styles for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 8px var(--cyan-glow);
}

input[type="range"]:focus-visible {
  outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--cyan-glow);
}

/* Responsive */
@media (max-width: 1024px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 40vh 1fr var(--toolbar-height);
    grid-template-areas:
      "header"
      "scene"
      "panel"
      "toolbar";
  }

  #right-panel {
    border-left: none;
    border-top: 1px solid var(--border-dim);
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  #header h1 { font-size: 14px; }
  #header .velocity-readout { font-size: 11px; }
  :root {
    --header-height: 40px;
    --toolbar-height: 38px;
  }
  #header h1 #title-text { display: none; }
  .tab-btn { font-size: 10px; padding: 8px 6px; }
  .easy-annotation { font-size: 12px; padding: 8px 10px; }
  .tab-nav { padding: 6px 10px; }
  .tab-nav-btn { padding: 5px 10px; font-size: 11px; }

  /* Fix: make tab content scrollable so schematic doesn't overlap tab-nav */
  .tab-content.active { overflow-y: auto; }

  /* Fix: fixed height for plot area so canvases render legibly instead of
     being crushed to 0px by competing flex siblings */
  .plot-area { flex: none; height: 200px; }

  /* Constrain slider panel to leave room for tab-nav */
  .slider-panel { max-height: 160px; }

  /* Key Facts overlay: shrink on mobile */
  #easy-dashboard {
    bottom: 8px;
    left: 8px;
    padding: 8px 10px;
    min-width: 160px;
    max-width: 200px;
  }
  .easy-dash-value { font-size: 11px; }
  .easy-dash-comp { display: none; }
  .easy-dash-icon { font-size: 12px; }
  .easy-dash-row { margin-bottom: 3px; padding-bottom: 3px; gap: 6px; }
  .easy-dash-title { margin-bottom: 4px; }

  /* Fun facts: shrink */
  #fun-facts { max-width: 180px; font-size: 10px; padding: 6px 10px; }
}

@media (max-width: 480px) {
  #header { padding: 0 10px; }
  #header h1 { font-size: 13px; }
  .tab-btn { font-size: 9px; padding: 6px 4px; letter-spacing: 0; }
  .slider-panel { padding: 8px 10px; max-height: 120px; }
  .splash-title { font-size: 48px; }
  .splash-content { padding: 20px; }
  .splash-fact { font-size: 13px; }

  /* Smaller plot area on phones */
  .plot-area { height: 160px; }

  /* Hide Key Facts on small phones — too much canvas coverage */
  #easy-dashboard { display: none !important; }
  #fun-facts { display: none !important; }

  /* Reduce scene further on small phones */
  #app {
    grid-template-rows: var(--header-height) 35vh 1fr var(--toolbar-height);
  }
}
