/* Layout for the two simulator pages, plus fixes for the dat.GUI control
   panel that the Abubu library creates. Colour tokens come from site.css. */

/* dat.GUI's own colours, checked by tests/check_site.py: */
/* contrast: #eeeeee on #1a1a1a */
/* contrast: #eeeeee on #000000 */
/* contrast: #2fa1d6 on #303030 */
/* contrast: #1ed36f on #303030 */
/* contrast(ui): #ffd08a on #1a1a1a */
/* contrast(ui): #ffd08a on #303030 */
/* contrast(ui): #8a8a8a on #1a1a1a */
/* contrast(ui): #8a8a8a on #303030 */

.sim-page .wrap {
  max-width: 96rem;
}

.sim-head {
  padding-block: 1.5rem 0.5rem;
}

.sim-head > * + * {
  margin-top: 1rem;
}

.sim-head .lede,
.sim-head .note {
  max-width: 46rem;
}

.sim-back {
  font-family: var(--font-ui);
  font-size: 1rem;
}

.sim-layout {
  display: grid;
  gap: 2rem 2.5rem;
  align-items: start;
  padding-block: 1.5rem 3rem;
}

@media (min-width: 66rem) {
  .sim-layout {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 23rem);
  }
}

.sim-views {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  align-items: start;
}

.sim-view {
  max-width: 514px;
}

.sim-canvas {
  position: relative;
  border: 1px solid var(--border);
  background: #ffffff;
  line-height: 0;
}

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

.sim-canvas canvas[data-pointer="stimulate"] {
  cursor: crosshair;
}

.sim-canvas canvas[data-pointer="rotate"] {
  cursor: grab;
}

/* Target for stimulating without a mouse. White ring with black edges so it
   shows against every colour map. */
.sim-target {
  position: absolute;
  width: 1.9rem;
  height: 1.9rem;
  margin: -0.95rem 0 0 -0.95rem;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #000000, inset 0 0 0 2px #000000;
  pointer-events: none;
}

.sim-target::before,
.sim-target::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: #ffffff;
  outline: 1px solid #000000;
}

.sim-target::before {
  width: 2px;
  height: 0.7rem;
  margin: -0.35rem 0 0 -1px;
}

.sim-target::after {
  width: 0.7rem;
  height: 2px;
  margin: -1px 0 0 -0.35rem;
}

.sim-view figcaption {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.45;
}

.sim-view figcaption b {
  color: var(--text);
}

.sim-side > * + * {
  margin-top: 1.5rem;
}

.sim-side h2 {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  letter-spacing: 0;
}

.sim-side h2 + * {
  margin-top: 0.7rem;
}

.sim-run {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.sim-page button.btn {
  min-width: 6.5rem;
}

.sim-status {
  min-height: 1.5em;
  font-family: var(--font-ui);
  font-size: 1rem;
}

.sim-caution {
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.sim-group {
  min-width: 0;
  margin: 0;
  padding: 0.9rem 1rem 1.1rem;
  border: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.98rem;
  line-height: 1.45;
}

.sim-group legend {
  padding: 0 0.4rem;
  font-weight: 700;
}

.sim-group > * + * {
  margin-top: 0.8rem;
}

.sim-group label {
  display: block;
  font-weight: 600;
}

.sim-group input[type="range"] {
  display: block;
  width: 100%;
  min-height: 1.75rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.sim-view-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.sim-view-buttons button {
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--accent);
  border-radius: 3px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.sim-help {
  font-family: var(--font-ui);
  font-size: 0.98rem;
  line-height: 1.5;
}

.sim-help ul {
  padding-left: 1.2em;
}

.sim-help li + li {
  margin-top: 0.4em;
}

/* Frame-rate counter added by the simulator (stats.js). */
#stats {
  position: static !important;
  width: auto !important;
  margin: 0 !important;
}

#stats #fps {
  padding: 0 !important;
  background: transparent !important;
}

#stats #fpsText {
  color: var(--text-muted) !important;
  font-family: var(--font-ui) !important;
  font-size: 0.85rem !important;
  font-weight: 400 !important;
  line-height: 1.4 !important;
}

#stats #fpsGraph {
  display: none !important;
}

/* ------------------------------------------------------------ dat.GUI */

/* The panel is created fixed to the top-right corner of the window, where it
   covers the page. sim-a11y.js moves it into #sim-panel; these rules let it
   sit in the page flow. */
#sim-panel .dg.ac {
  position: static;
  height: auto;
  z-index: auto;
}

#sim-panel .dg.main {
  float: none;
  width: 100% !important;
  margin: 0;
}

/* dat.GUI positions its Close Controls bar absolutely and sizes it in
   pixels, which pushes it outside the page here. */
#sim-panel .dg.main .close-button {
  position: static !important;
  width: auto !important;
  height: auto !important;
  min-height: 28px;
  line-height: 28px !important;
}

/* Real buttons that sim-a11y.js puts inside folder titles and action rows. */
#sim-panel .dg button.dg-native {
  display: block;
  width: 100%;
  min-height: 27px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  text-shadow: inherit;
  cursor: pointer;
  appearance: none;
}

#sim-panel .dg.main,
#sim-panel .dg.main input,
#sim-panel .dg.main select {
  font-size: 13px;
}

/* Show whole labels instead of cutting them off with an ellipsis. */
#sim-panel .dg li:not(.folder):not(.title) {
  height: auto;
  min-height: 27px;
  overflow: visible;
}

#sim-panel .dg li.cr::after {
  content: "";
  display: block;
  clear: both;
}

#sim-panel .dg .property-name {
  overflow: visible;
  white-space: normal;
  line-height: 1.25;
  padding-block: 6px;
}

/* Rows of a closed folder are squeezed to zero height by dat.GUI but stay in
   the tab order. Hiding them removes them from it. */
#sim-panel .dg ul.closed > li:not(.title) {
  visibility: hidden;
}

#sim-panel .dg ul.closed > li:not(.title),
#sim-panel .dg ul.closed > li:not(.title) .property-name {
  min-height: 0;
  height: 0;
  padding-block: 0;
  overflow: hidden;
}

/* dat.GUI removes focus outlines. Put a visible one back. */
#sim-panel .dg :focus-visible {
  outline: 3px solid #ffd08a !important;
  outline-offset: -3px;
}

/* dat.GUI shrinks itself and scrolls internally when it is taller than the
   window. In the page flow it should simply take the room it needs. */
#sim-panel .dg.main {
  overflow: visible !important;
}

#sim-panel .dg.main > ul {
  height: auto !important;
}

/* dat.GUI listens on the whole window and hides its panel whenever H is
   pressed outside a text box, for instance while choosing "hot" in the
   Colormap list. Nothing on the page says so, and nothing says H brings it
   back (WCAG 2.1.4). Keeping the panel displayed makes the shortcut harmless. */
#sim-panel .dg.main {
  display: block !important;
}

/* dat.GUI's text boxes are dark grey on a slightly darker row, with no edge
   to tell them apart, and on hover their background lightens until the blue
   numbers fall below 4.5:1. Give boxes and slider tracks an edge and keep the
   background that the numbers were chosen for. */
#sim-panel .dg .c input[type="text"] {
  box-shadow: inset 0 0 0 1px #8a8a8a;
}

#sim-panel .dg .c input[type="text"]:hover {
  background: #303030;
}

#sim-panel .dg .c .slider {
  box-shadow: inset 0 0 0 1px #8a8a8a;
}
