/* style.css — Grid layout, dark theme, entity colors */

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

body {
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  min-height: 100vh;
}

h1 {
  font-size: 18px;
  color: #a0c4ff;
  margin-bottom: 8px;
}

/* Control panel */
#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#controls button {
  background: #2a2a4a;
  color: #c0c0e0;
  border: 1px solid #4a4a6a;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 3px;
}

#controls button:hover {
  background: #3a3a5a;
}

#controls button.active {
  background: #4a6a8a;
  border-color: #6a8aaa;
}

#controls label {
  font-size: 13px;
  color: #a0a0c0;
}

#controls select {
  background: #2a2a4a;
  color: #c0c0e0;
  border: 1px solid #4a4a6a;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
}

#tick-display {
  font-size: 13px;
  color: #a0a0c0;
}

/* Scenario description */
#scenario-desc {
  font-size: 11px;
  color: #8888aa;
  margin-bottom: 4px;
  text-align: center;
  font-style: italic;
  max-width: 600px;
}

/* Spawn panel — per-species starting group count adjusters */
#spawn-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  justify-content: center;
  margin-bottom: 6px;
  font-size: 11px;
  max-width: 800px;
}

#spawn-panel .spawn-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

#spawn-panel .spawn-icon {
  font-size: 12px;
}

#spawn-panel .spawn-name {
  color: #a0a0b0;
  min-width: 32px;
}

#spawn-panel .spawn-btn {
  background: #2a2a4a;
  color: #c0c0e0;
  border: 1px solid #4a4a6a;
  width: 16px;
  height: 16px;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  border-radius: 2px;
  font-family: inherit;
}

#spawn-panel .spawn-btn:hover {
  background: #3a3a5a;
}

#spawn-panel .spawn-val {
  color: #ccccee;
  min-width: 16px;
  text-align: center;
}

/* Stats bar */
#stats {
  font-size: 13px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

#stats span {
  font-size: 14px;
  margin-right: 1px;
}

/* Legend */
#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  justify-content: center;
  max-width: 960px;
}

#legend .legend-group {
  display: flex;
  align-items: center;
  gap: 4px 8px;
  flex-wrap: wrap;
}

#legend .legend-label {
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  margin-right: 2px;
}

#legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  cursor: help;
}

#legend .legend-item:hover {
  color: #fff;
}

#legend .legend-icon {
  font-size: 13px;
}

#legend .legend-name {
  color: #a0a0b0;
}

#legend .legend-sep {
  color: #444;
  margin: 0 2px;
}

/* Sim container — side-by-side when viewport is wide enough */
#sim-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

@media (min-width: 1340px) {
  #sim-container {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
  }
}

/* Grid */
#grid {
  display: grid;
  gap: 0;
  line-height: 12px;
  font-size: 11px;
  border: 1px solid #333;
  user-select: none;
  flex-shrink: 0;
}

.cell {
  width: 12px;
  height: 12px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  border: none;
}

.cell:hover {
  outline: 1px solid #fff3;
}

/* Inspector */
#inspector {
  font-size: 12px;
  color: #b0b0d0;
  min-height: 18px;
  max-width: 960px;
  width: 100%;
}

@media (min-width: 1340px) {
  #inspector {
    max-width: 360px;
    min-width: 280px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    position: sticky;
    top: 10px;
  }
}

#inspector b {
  color: #d0d0f0;
}

#inspector .insp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 4px;
}

#inspector .insp-toggle {
  background: #2a2a4a;
  color: #a0a0c0;
  border: 1px solid #4a4a6a;
  padding: 1px 8px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
}

#inspector .insp-toggle:hover {
  background: #3a3a5a;
}

#inspector .insp-toggle.active {
  background: #4a6a8a;
  border-color: #6a8aaa;
}

/* Hierarchy rows */
#inspector .insp-hierarchy {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 6px;
}

@media (min-width: 1340px) {
  #inspector .insp-hierarchy {
    flex-direction: column;
  }

  #inspector .insp-level {
    max-width: none;
    max-height: none;
  }

  #inspector .insp-body {
    flex-direction: column;
  }
}

#inspector .insp-level {
  background: #1e1e36;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  text-align: left;
  min-width: 180px;
  max-width: 320px;
  max-height: 200px;
  overflow-y: auto;
}

#inspector .insp-level-selected {
  border-color: #6a8aaa;
}

#inspector .insp-level-hl {
  background: #252548;
  border-color: #7a9abb;
}

#inspector .insp-level-header {
  cursor: pointer;
  margin-bottom: 1px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#inspector .insp-level-header:hover {
  color: #e0e0ff;
}

#inspector .insp-arrow {
  font-size: 9px;
  color: #666;
}

#inspector .insp-cat {
  margin-top: 2px;
  padding-left: 4px;
  border-left: 2px solid #333;
}

#inspector .insp-cat-label {
  color: #8888aa;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

#inspector .insp-entity {
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#inspector .insp-entity-sel {
  background: #2a3a5a;
  border-radius: 2px;
  padding: 0 3px;
}

#inspector .insp-sample {
  color: #886644;
  font-size: 10px;
  margin-right: 2px;
  cursor: help;
}

/* Selected entity detail */
#inspector .insp-detail {
  border-top: 1px solid #333;
  padding-top: 4px;
  margin-top: 4px;
}

#inspector .insp-detail-header {
  text-align: center;
  margin-bottom: 4px;
}

#inspector .insp-body {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

#inspector .insp-section {
  background: #1e1e36;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: pre;
  line-height: 1.5;
  text-align: left;
  max-height: 300px;
  overflow-y: auto;
}

#inspector .insp-section .insp-label {
  color: #8888aa;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 2px;
}

#inspector .insp-key {
  color: #8888bb;
}

#inspector .insp-val {
  color: #ccccee;
}

#inspector .insp-null {
  color: #666;
}

/* Foldable section headers (individual preview, group detail) */
#inspector .insp-fold-header {
  cursor: pointer;
  line-height: 1.5;
  padding: 2px 4px;
  border-radius: 3px;
}

#inspector .insp-fold-header:hover {
  color: #e0e0ff;
  background: #2a2a4a;
}

/* Probabilistic individual preview — muted to indicate not a realized entity */
#inspector .insp-individual-preview {
  background: #16162a;
  border: 1px dashed #3a3a5a;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  opacity: 0.75;
}

#inspector .insp-individual-body {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Group detail section */
#inspector .insp-group-detail {
  background: #1e1e36;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
}
