/* =============================================================================
   THE ELEMENTS 3D — Coni WASM Quantum Periodic Table & Tom Lehrer Synchronizer
   Inspired by the Google DeepMind Gemini 4 Argon Reel + Coni Homoiconic Twist
   ============================================================================= */

:root {
  --bg-deep: #030911;
  --bg-Glow: #0a3548;
  --panel-bg: rgba(7, 20, 32, 0.72);
  --border-subtle: rgba(125, 211, 252, 0.16);
  --text-main: #f1f5f9;
  --text-dim: #7da2b8;
  --text-muted: #4b6a7e;
  --accent-cyan: #00d4ff;
  --accent-coral: #ff6b4a;
  --accent-coni: #00ffcc;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 26%, #0c3b52 0%, #051824 46%, #02070c 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* -----------------------------------------------------------------------------
   1. Top Header, Scrubber & Synchronized Lyrics
   ----------------------------------------------------------------------------- */

.top-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.title-cluster {
  text-align: center;
}

.main-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.sub-title {
  font-size: 0.74rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

.player-controls-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-pill-btn {
  background: linear-gradient(135deg, #ff7854 0%, #f05232 100%);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 107, 74, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.play-pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(255, 107, 74, 0.72);
}

.play-pill-btn.playing {
  background: linear-gradient(135deg, #ff5938 0%, #d9381e 100%);
}

.scrubber-track {
  flex: 1;
  height: 18px;
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
}

.scrubber-line {
  width: 100%;
  height: 3px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.scrubber-fill {
  height: 100%;
  width: 7.68%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-coni));
  box-shadow: 0 0 10px var(--accent-cyan);
}

.scrubber-thumb {
  position: absolute;
  left: 7.68%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 16px;
  background: var(--accent-cyan);
  border-radius: 3px;
  box-shadow: 0 0 12px var(--accent-cyan), 0 0 4px #ffffff;
  pointer-events: none;
}

.time-readout {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.top-action-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-pill-btn {
  background: rgba(15, 35, 52, 0.78);
  color: var(--text-dim);
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 6px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.mini-pill-btn:hover {
  color: #ffffff;
  border-color: var(--accent-cyan);
}

.mini-pill-btn.active {
  background: rgba(0, 255, 204, 0.16);
  color: var(--accent-coni);
  border-color: var(--accent-coni);
  box-shadow: 0 0 12px rgba(0, 255, 204, 0.32);
}

.lyrics-banner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #a5c4d4;
  min-height: 20px;
  text-align: center;
}

.lyric-active-tag {
  color: var(--accent-coni);
  font-weight: 700;
  font-size: 0.74rem;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(0, 255, 204, 0.12);
  border: 1px solid rgba(0, 255, 204, 0.3);
}

/* -----------------------------------------------------------------------------
   2. Centerpiece: Element Header & 3D Quantum Atom Viewport
   ----------------------------------------------------------------------------- */

.atom-stage {
  position: relative;
  width: 100%;
  height: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.hero-element-overlay {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  margin-top: 2px;
}

.hero-z-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
}

.hero-z-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
}

.hero-symbol {
  font-size: 3.1rem;
  font-weight: 800;
  line-height: 1.0;
  color: var(--accent-cyan);
  text-shadow: 0 0 28px rgba(0, 212, 255, 0.65), 0 0 8px rgba(0, 212, 255, 0.9);
  margin: 2px 0;
}

.hero-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #f8fafc;
}

.hero-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 2px;
  cursor: pointer;
}

.hero-sub-row:hover {
  color: #ffffff;
}

#atom-canvas-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
}

#atom-canvas-container:active {
  cursor: grabbing;
}

.stage-floating-controls {
  position: absolute;
  bottom: 8px;
  right: 10px;
  z-index: 5;
  display: flex;
  gap: 5px;
}

.stage-hint {
  position: absolute;
  bottom: 10px;
  left: 12px;
  z-index: 5;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Coni Twist Homoiconic S-Expression Live Ticker */
.coni-sexpr-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(4, 18, 28, 0.85);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  transition: all 0.2s ease;
}

.coni-sexpr-bar.highlight-twist {
  border-color: var(--accent-coni);
  box-shadow: 0 0 16px rgba(0, 255, 204, 0.2);
  background: rgba(2, 28, 30, 0.9);
}

.coni-sexpr-tag {
  color: var(--accent-coni);
  font-weight: 700;
  white-space: nowrap;
}

.coni-sexpr-code {
  color: #bae6fd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* -----------------------------------------------------------------------------
   3. Middle Two-Column Scientific Telemetry HUD
   ----------------------------------------------------------------------------- */

.telemetry-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 6px 2px;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.telemetry-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(125, 211, 252, 0.14);
  padding-bottom: 4px;
}

.essentials-table {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ess-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.ess-label {
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.ess-val {
  color: #f8fafc;
  font-weight: 700;
  text-align: right;
}

.element-lore {
  margin-top: 4px;
  font-size: 0.74rem;
  line-height: 1.45;
  color: #94b4c7;
}

.uses-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.use-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.75rem;
  color: #dbeafe;
}

.use-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  min-width: 18px;
}

.spectrum-section {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.spectrum-box {
  position: relative;
  width: 100%;
  height: 34px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 3px;
  overflow: hidden;
  background: #040b12;
  cursor: pointer;
}

.spectrum-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.spectrum-scale {
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--text-muted);
}

.spectrum-wavelengths {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #93c5fd;
  letter-spacing: 0.03em;
}

/* -----------------------------------------------------------------------------
   4. Bottom Full 120-Element Interactive Periodic Table
   ----------------------------------------------------------------------------- */

.periodic-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--text-dim);
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.cat-pill:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.periodic-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  grid-auto-rows: 30px;
  gap: 3px;
  width: 100%;
}

.pt-cell {
  position: relative;
  background: rgba(15, 30, 44, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 3px;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 1px;
  transition: all 0.14s ease;
}

.pt-cell:hover {
  border-color: var(--el-color, #00d4ff);
  background: rgba(30, 58, 82, 0.9);
  transform: translateY(-1px) scale(1.05);
  z-index: 6;
}

.pt-z {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  color: #64748b;
  line-height: 1;
}

.pt-sym {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
}

/* Elements already sung in Tom Lehrer's song */
.pt-cell.sung-element {
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(16, 44, 64, 0.85);
  color: #f1f5f9;
}

/* Currently selected / active element (Matches Argon highlight in Reel!) */
.pt-cell.active-element {
  background: rgba(0, 212, 255, 0.24);
  border: 1.5px solid var(--el-color, #00d4ff);
  box-shadow: 0 0 14px var(--el-color, #00d4ff), inset 0 0 8px rgba(255, 255, 255, 0.35);
  color: #ffffff;
  transform: scale(1.08);
  z-index: 8;
}

.pt-cell.active-element .pt-z {
  color: #e0f2fe;
}

.pt-cell.cat-coni-synth {
  border-color: rgba(0, 255, 204, 0.45);
  background: rgba(0, 60, 55, 0.55);
}

.pt-cell.dimmed-cat {
  opacity: 0.22;
}

@media (max-width: 768px) {
  .telemetry-columns {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .atom-stage {
    height: 270px;
  }
  .periodic-grid {
    grid-auto-rows: 24px;
    gap: 2px;
  }
  .pt-sym {
    font-size: 0.58rem;
  }
  .pt-z {
    font-size: 0.4rem;
  }
}
