/* Speed Test Lab */

:root {
  --accent:       #004445;
  --accent-light: #006668;
  --focus-glow:   #FFD166;
  --ink:          #2C3E3E;
  --muted:        #5A6E6E;
  --panel-border: #D8E2DF;
  --chosen-bg:    #E3F0EE;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #F5F1E5;
  font-family: Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#sim-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#stage-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#sim-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#sim-canvas:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: -2px;
}

/* ── Control panel (right side, single vertical column) ── */
.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 3px 14px rgba(0, 40, 40, 0.12);
}

#control-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: 10px;
  width: 216px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

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

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.choice-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Speed stepper: [−] 40 mph [+] */
.speed-stepper {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.step-btn {
  font-family: Roboto, Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  width: 38px;
  padding: 6px 0;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.step-btn:hover:not(:disabled) {
  border-color: var(--accent-light);
}

.step-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.step-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 1px;
}

.speed-readout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: var(--chosen-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
}

.choice-btn {
  font-family: Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent-light);
}

.choice-btn.active {
  background: var(--chosen-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.choice-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.choice-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 1px;
}

/* Playback: how fast the run PLAYS (1×/2×/4×) — a viewing control, kept
   visually apart from the truck's experiment settings above Start Run. */
.playback-row {
  display: flex;
  gap: 6px;
}

.pb-btn {
  flex: 1;
  text-align: center;
  padding: 5px 0;
  font-size: 12px;
}

.primary-btn {
  font-family: Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 11px 10px;
  cursor: pointer;
  transition: background 0.12s;
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-light);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

/* ── Results card (pinned to the bottom of the panel) ── */
#results-card {
  margin-top: auto;
  background: #F4F8F7;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#run-tag {
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

#status-line {
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
}

#results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--ink);
}

#results-table td {
  padding: 3px 0;
}

#results-table td:last-child {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

#log-btn {
  font-family: Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: #ffffff;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

#log-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #ffffff;
}

#log-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#log-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

#log-btn.attention {
  animation: log-pulse 1.6s ease-in-out 2;
}

@keyframes log-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 68, 69, 0); }
  50%      { box-shadow: 0 0 0 5px rgba(0, 68, 69, 0.22); }
}

@media (prefers-reduced-motion: reduce) {
  #log-btn.attention { animation: none; }
}

.muted {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Narrow screens: slim the panel so the track stays visible */
@media (max-width: 620px) {
  #control-panel { width: 178px; padding: 10px; }
  .choice-btn { font-size: 12px; padding: 7px 8px; }
}

/* ── Accessibility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Reset confirmation dialog ── */
#reset-dialog {
  border: none;
  border-radius: 12px;
  padding: 20px;
  width: min(400px, calc(100vw - 32px));
  margin: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  background: #ffffff;
  color: var(--ink);
}

#reset-dialog::backdrop {
  background: rgba(30, 16, 48, 0.55);
}

#reset-dialog h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

#reset-dialog p {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.reset-dialog-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  font-family: Roboto, Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  border: none;
  background: #5c4738;
  color: #ffffff;
}

.modal-btn:hover { background: #7d6c60; }

.modal-btn.secondary {
  background: #ffffff;
  color: #5c4738;
  border: 1.5px solid #5c4738;
}

.modal-btn.secondary:hover { background: #efedeb; }

.modal-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

/* ── Info dialog ──
   The dialog is Tuva Sims "chrome", so its accent is the P1 purple (#5c4738),
   NOT the sim's green var(--accent). Header = purple with white text; active
   tab / h3 / footer button = purple; tabs/footer surface = #F8FBFB; body text =
   var(--ink). The shared toolbar stylesheet also injects these purple rules
   (scoped to #info-dialog) so existing green sims reskin automatically — keep
   this block in sync with it; do not redefine per sim. */
#info-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow: hidden;
  margin: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  background: #ffffff;
}

#info-dialog::backdrop {
  background: rgba(30, 16, 48, 0.55);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #5c4738;
  color: #ffffff;
}

.dialog-header h2 {
  font-size: 16px;
  font-weight: 600;
}

#dialog-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#dialog-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

#dialog-close-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

.dialog-tabs {
  display: flex;
  border-bottom: 2px solid #E5EAE9;
  background: #F8FBFB;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 10px 0;
  font-family: Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: #5c4738;
}

.tab-btn.active,
.tab-btn[aria-selected="true"] {
  color: #5c4738;
  border-bottom-color: #5c4738;
}

.tab-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: -3px;
}

.dialog-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 240px);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.dialog-body h3 {
  font-size: 14px;
  font-weight: 600;
  color: #5c4738;
  margin-top: 14px;
  margin-bottom: 6px;
}

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

.dialog-body p {
  margin-bottom: 8px;
}

.dialog-body ul,
.dialog-body ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.dialog-body li {
  margin-bottom: 4px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid #E5EAE9;
  background: #F8FBFB;
}

.dialog-close-footer {
  background: #5c4738;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-family: Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.dialog-close-footer:hover {
  background: #7d6c60;
}

.dialog-close-footer:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}
