/* ABOUTME: CSS styling for the relativity simulator interface */
/* ABOUTME: Dark theme with physics simulation layout and controls */

:root {
  --bg:#0b0c0f;
  --fg:#e8eaf0;
  --muted:#9aa3b2;
  --panel:#151823;
  --border:#22283a;
}

html, body {
  height:100%;
}

body {
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font:14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
}

a {
  color:#7adfff;
  text-decoration:none;
}

a:hover {
  color:#a8ecff;
  text-decoration:underline;
}

.app {
  display:grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: 100%;
  height:100%;
}

aside {
  padding:12px;
  overflow:auto;
}

aside h1 {
  font-size:16px;
  margin:0 0 8px;
}

aside .note {
  color:var(--muted);
  margin:8px 0 12px;
}

main {
  display:grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  gap:8px;
  padding:8px;
}

.panel {
  display:grid;
  grid-template-rows: auto 76% 20%;  /* Label, plot (reduced slightly), animation */
  gap:6px;
  min-height:0;
  height:100%;
}

.frame-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:4px 8px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:6px 6px 0 0;
  gap:8px;
}

.frame-header select {
  flex:1;
  min-width:0;
  font-size:14px;
  font-weight:600;
}

.frame-time {
  font-size:14px;
  font-weight:600;
  color:var(--fg);
  white-space:nowrap;
}

canvas {
  width:100%;
  height:100%;
  min-height:0; /* Allow canvas to shrink below intrinsic size */
  display:block;
  background:#0e111a;
  border:1px solid #1a2030;
  border-radius:8px;
}

.row {
  display:flex;
  align-items:center;
  gap:8px;
  margin:6px 0;
}

label {
  color:var(--muted);
  font-size:12px;
  min-width:120px;
}

input, select, button {
  background:#0f1320;
  color:var(--fg);
  border:1px solid #2a3248;
  border-radius:6px;
  padding:6px 8px;
  font-size:13px;
  flex:1; /* Fill available space in flex containers */
  min-width:0; /* Allow shrinking below content size */
}

/* Speed label styling */
#speed-label {
  color:var(--fg);
  font-size:13px;
  font-weight:600;
  min-width:50px;
  text-align:center;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:4px;
  padding:4px 8px;
  margin-left:8px;
}

/* Style number input spin buttons for dark theme */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Style range slider for dark theme */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-track {
  background: #2a3248;
  height: 4px;
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--fg);
  height: 16px;
  width: 16px;
  border-radius: 50%;
  cursor: pointer;
}

input[type="range"]::-moz-range-track {
  background: #2a3248;
  height: 4px;
  border-radius: 2px;
  border: none;
}

input[type="range"]::-moz-range-thumb {
  background: var(--fg);
  height: 16px;
  width: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

button.primary {
  background:#19233a;
  border-color:#2a3b66;
}

details {
  border:1px solid #20273a;
  border-radius:8px;
  padding:6px 8px;
  margin:8px 0;
  background:var(--panel);
}

summary {
  cursor:pointer;
  color:#cdd7f6;
}

.obj-card {
  margin:8px 0;
}

.obj-card details {
  border:1px solid #27304a;
  border-radius:8px;
  padding:8px;
  background:#0f1422;
}

.obj-card .hdr {
  display:flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
  list-style:none;
}

.obj-card .hdr::-webkit-details-marker {
  display:none;
}

.obj-card .hdr::before {
  content:"▶";
  font-size:12px;
  color:var(--muted);
  transition:transform 0.2s;
  margin-right:4px;
}

.obj-card details[open] .hdr::before {
  transform:rotate(90deg);
}

.obj-card .obj-type {
  font-size:16px;
  font-weight:bold;
  color:var(--fg);
}

.obj-card .hdr .nm {
  font-size:16px;
  font-weight:bold;
  background:transparent;
  border:none;
  color:var(--fg);
  flex:1;
}

.obj-card .hdr .color {
  width:28px;
  height:28px;
  padding:0;
  border-radius:4px;
}

.obj-card .hdr .del {
  width:28px;
  height:28px;
  padding:0;
  border-radius:4px;
}

.kv {
  display:grid;
  grid-template-columns: 120px 1fr;
  gap:6px 8px;
  margin:8px 0;
  align-items:center;
}

.accel-label {
  display:block;
  font-size:12px;
  font-weight:600;
  color:var(--muted);
  margin:8px 0 4px 0;
}

.accel {
  width:100%;
  table-layout:fixed;
  border-collapse:collapse;
  margin-top:6px;
}

.accel th:nth-child(1), .accel td:nth-child(1) {
  width:25%; /* τ column - reduced from ~33% */
}

.accel th:nth-child(2), .accel td:nth-child(2) {
  width:25%; /* a column - reduced from ~33% */
}

.accel th:nth-child(3), .accel td:nth-child(3) {
  width:50%; /* Actions column - increased from ~33% */
}

.accel th, .accel td {
  border:1px solid #2a3248;
  padding:3px 6px;
  text-align:right;
  font-variant-numeric: tabular-nums;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  line-height:1.2;
  font-size:13px;
}

.accel td[contenteditable="true"] {
  background:#0f1320;
  outline:none;
  cursor:text;
}

.accel td[contenteditable="true"]:hover {
  background:#161a2a;
}

.accel td[contenteditable="true"]:focus {
  background:#1a2030;
  box-shadow:inset 0 0 0 2px #3a4a66;
}

.accel th {
  color:#aab4d4;
  font-weight:600;
  text-align:left;
}

.accel td.actions {
  text-align:left;
}

.accel td.actions button {
  border:none;
  padding:2px 4px;
  margin:0 1px;
  background:transparent;
  color:var(--muted);
  font-size:11px;
  cursor:pointer;
}

.accel td.actions button:hover {
  background:var(--border);
  color:var(--fg);
}

.err {
  color:#ff7b7b;
  font-size:12px;
  margin-top:4px;
}

pre.log {
  background:#0f1320;
  border:1px solid #2a3248;
  border-radius:6px;
  padding:8px;
  color:#cfe1ff;
  max-height:160px;
  overflow:auto;
}

/* Help Button */
.help-button {
  width: 100%;
  margin: 8px 0;
  background: #1a2642;
  border-color: #2a3b66;
  color: #7adfff;
  font-weight: 600;
}

.help-button:hover {
  background: #243052;
  color: #a8ecff;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 80%;
  max-height: 90%;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.modal-header h2 {
  margin: 0;
  color: var(--fg);
  font-size: 18px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.close-btn:hover {
  background: var(--border);
  color: var(--fg);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 70vh;
}

.modal-body h3 {
  color: var(--fg);
  font-size: 16px;
  margin: 20px 0 8px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  margin: 8px 0;
  line-height: 1.5;
}

.modal-body ul {
  margin: 8px 0 16px 20px;
  line-height: 1.6;
}

.modal-body li {
  margin: 4px 0;
}

.modal-body strong {
  color: var(--fg);
}

/* Preset Management */
.preset-current {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.preset-current span {
  color: var(--fg);
  font-weight: 600;
}