/* Turing Soup - Minimal Dark Theme */

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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 0;
}

#soup-canvas {
  width: 512px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

.overlay {
  position: fixed;
  top: 20px;
  z-index: 10;
  pointer-events: none;
  opacity: 0.4;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.overlay.top-left {
  left: 20px;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 14px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.overlay.top-left .title,
.overlay.top-left .gen {
  pointer-events: auto;
  cursor: help;
}

.overlay.top-left .control-row {
  pointer-events: auto;
}

#page-indicator {
  cursor: help;
}

.overlay.top-right {
  right: 20px;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.7);
  padding: 12px 16px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  flex-direction: column;
  gap: 10px;
}

body:hover .overlay {
  opacity: 0.8;
}

.title {
  font-size: 13px;
  color: #666;
  font-weight: 400;
  letter-spacing: 0.5px;
  pointer-events: auto;
  cursor: default;
}

.gen {
  font-size: 13px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.control-row {
  font-size: 11px;
  color: #555;
  font-variant-numeric: tabular-nums;
}

.control-key {
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  color: #666;
}

.control-key:hover {
  color: #fff;
}

.github-link {
  color: #555;
  text-decoration: none;
}

.github-link:hover {
  color: #fff;
}


.control-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.control-label span {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="range"] {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #666;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #888;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #666;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* Graphs Container */
.graphs-container {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
  pointer-events: none;
}

body:hover .graphs-container {
  opacity: 0.9;
  pointer-events: auto;
}

.graph-panel {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.graph-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 8px;
  text-align: center;
}

#complexity-graph {
  display: block;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.graph-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 9px;
  color: #888;
}

.legend-item-small {
  display: flex;
  align-items: center;
  gap: 3px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot.white { background: rgba(255, 255, 255, 0.6); }
.dot.orange { background: rgba(255, 160, 0, 0.6); }
.dot.cyan { background: #0ff; }

/* Execution graph instruction colors (non-pastel, matching legend) */
.dot.exec-head0 { background: hsl(180, 100%, 50%); }  /* cyan - <> */
.dot.exec-head1 { background: hsl(320, 100%, 50%); }  /* magenta - {} */
.dot.exec-math { background: hsl(120, 100%, 50%); }   /* green - +- */
.dot.exec-copy { background: hsl(60, 100%, 50%); }    /* yellow - ., */
.dot.exec-loop { background: hsl(210, 100%, 50%); }   /* blue - [] */

.stat-value.exec-head0 { color: hsl(180, 100%, 50%); }
.stat-value.exec-head1 { color: hsl(320, 100%, 50%); }
.stat-value.exec-math { color: hsl(120, 100%, 50%); }
.stat-value.exec-copy { color: hsl(60, 100%, 50%); }
.stat-value.exec-loop { color: hsl(210, 100%, 50%); }

.graph-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-size: 9px;
  color: #666;
}

.stat-value {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.stat-value.cyan {
  color: #0ff;
}

.stat-value.orange {
  color: rgba(255, 160, 0, 0.8);
}

/* Legend */
.legend {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, rgba(20, 20, 25, 0.95), rgba(10, 10, 15, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px 20px;
  color: #ccc;
  font-size: 11px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

body:hover .legend {
  opacity: 0.9;
}

.legend:hover {
  opacity: 1 !important;
  pointer-events: auto;
}

.legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #666;
  margin-bottom: 10px;
  font-weight: 500;
}

.legend-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-label {
  width: 36px;
  color: #555;
  font-size: 10px;
}

.legend-items {
  display: flex;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-item code {
  font-family: monospace;
  color: #888;
  font-size: 12px;
  width: 12px;
  text-align: center;
  display: inline-block;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Instruction colors - bright to stand out */
.swatch[data-instr="<"] { background: hsl(180, 100%, 70%); }
.swatch[data-instr=">"] { background: hsl(160, 100%, 75%); }
.swatch[data-instr="{"] { background: hsl(320, 100%, 75%); }
.swatch[data-instr="}"] { background: hsl(340, 100%, 80%); }
.swatch[data-instr="+"] { background: hsl(120, 100%, 70%); }
.swatch[data-instr="-"] { background: hsl(90, 100%, 75%); }
.swatch[data-instr="."] { background: hsl(60, 100%, 70%); }
.swatch[data-instr=","] { background: hsl(45, 100%, 75%); }
.swatch[data-instr="["] { background: hsl(210, 100%, 75%); }
.swatch[data-instr="]"] { background: hsl(240, 100%, 80%); }

.legend-gradient {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, #000 0%, rgb(30, 0, 80) 33%, rgb(180, 20, 120) 66%, rgb(255, 120, 0) 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  margin-top: 6px;
}

.legend-gradient-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 9px;
  color: #555;
}

/* ===========================================
   TOOLTIP SYSTEM
   =========================================== */

.tooltip-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #ccc;
  font-size: 12px;
  line-height: 1.6;
  max-width: 320px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip[data-depth="1"] { z-index: 101; }
.tooltip[data-depth="2"] { z-index: 102; }
.tooltip[data-depth="3"] { z-index: 103; }

.tooltip-title {
  font-size: 10px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.tooltip-link {
  color: #0ff;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dotted rgba(0, 255, 255, 0.4);
  transition: border-color 0.2s, color 0.2s;
}

.tooltip-link:hover {
  color: #fff;
  border-bottom-color: #0ff;
}

a.tooltip-link::after {
  content: ' ↗';
  font-size: 9px;
  opacity: 0.5;
}

.tooltip-muted {
  color: #666;
  font-size: 11px;
}

/* Tooltip triggers */
.has-tooltip {
  cursor: help;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.2);
}

#epochs-label {
  pointer-events: auto;
  cursor: help;
}

.control-label > span {
  pointer-events: auto;
  cursor: help;
}

.graph-title {
  pointer-events: auto;
  cursor: help;
}

.legend-item-small {
  pointer-events: auto;
  cursor: help;
}

.stat-item {
  pointer-events: auto;
  cursor: help;
}

.legend-group {
  pointer-events: auto;
  cursor: help;
}

.legend-title {
  pointer-events: auto;
  cursor: help;
}

/* Hide legend and graphs on small screens to prevent overlap */
@media (max-width: 900px) {
  .legend {
    display: none;
  }
}

@media (max-width: 600px) {
  .graphs-container {
    display: none;
  }
}
