/* Styling for the simulator page. Deliberately plain: this is a personal
   exploration tool, so polish is low priority (docs/requirements.md). */

/* The page is a grid the size of the window: the title bar across the top,
   and under it the sidebar of controls on the left with the output (results
   and plot) on the right. The output column takes whatever width the sidebar
   leaves, so the page uses a wide window instead of sitting in a narrow
   centred column. The second row takes whatever height the title bar leaves,
   which is what lets the plot fill the window (see #plot below).

   The sidebar's column is `auto` so that it closes up to nothing when the
   sidebar is hidden; minmax(0, ...) lets the output column shrink below the
   width its content asks for instead of overflowing the page. */
body {
  font-family: system-ui, sans-serif;
  line-height: 1.4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  /* At least the window's height; taller, and scrolling, if the content
     needs it. `border-box` keeps the padding inside that height. */
  min-height: 100vh;
  box-sizing: border-box;
  margin: 0;
  padding: 1rem;
}

/* The sidebar's button at the left, over the sidebar it hides, and the title
   in the centre of the window. Three columns, the outer two equal: the
   button is in the first, the title in the middle one, and the third is
   empty and is there only to balance the first. With a single flexible
   column instead, the title would be centred in the space the button leaves
   and sit off to the right. Neither moves when the sidebar goes. */
.page-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

/* The button holds a single « or » character. It keeps to the left of its
   column rather than stretching across it, and the fixed minimum width keeps
   it the same size whichever of the two it shows. */
#sidebar-toggle {
  font: inherit;
  justify-self: start;
  min-width: 2.25rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
}

/* The sidebar, down the left-hand side. A fixed width, so
   the sliders do not change length as the figures beside them change. The
   space between it and the output is a margin and a border on the sidebar
   itself rather than a gap in the grid, so both go when it is hidden. */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  width: 17rem;
  margin-right: 1.5rem;
  padding-right: 1.5rem;
  border-right: 1px solid #bbb;
}

/* The results and the plot, stacked. A flex column so that the plot can be
   given the height the results leave over. */
.output {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
}

/* On a narrow screen there is no room for two columns, so the sidebar goes
   above the output, full width, and loses the rule down its side. */
@media (max-width: 40rem) {
  /* One column, the full width, and three rows: title bar, sidebar, output.
     The output keeps the row that takes the spare height. */
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 2;
    width: auto;
    margin-right: 0;
    padding-right: 0;
    border-right: none;
  }

  /* Into the one column, and down a row. */
  .output {
    grid-column: 1;
    grid-row: 3;
  }
}

/* The unit toggle, and the one for the kind of target: the two choices
   side by side. */
.units,
.target-mode {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0 0;
  border: 1px solid #bbb;
  border-radius: 4px;
}

/* The target toggle has inputs under it in the same section, where the unit
   toggle is followed by a heading that brings its own space. */
.target-mode {
  margin: 0 0 1rem;
}

/* The Drag (optional) box: a framed group under the launch inputs, so that
   the two drag inputs read as one optional set. The padding keeps the input
   rows clear of the frame, and the last row's own bottom margin is the
   space above the frame's lower edge. */
.drag {
  margin: 0 0 1rem;
  padding: 0.25rem 0.75rem 0;
  border: 1px solid #bbb;
  border-radius: 4px;
}

/* The headings over the two groups of readouts an aerial target has. */
h3 {
  font-size: 0.95rem;
  margin: 0.75rem 0 0.25rem;
}

/* One input, on two lines because the sidebar is narrow: the label, number
   field and unit on the first, and the slider underneath across the full
   width, which gives it the most travel the sidebar allows. The elements
   are placed by name, so their order in index.html does not matter. */
.input-row {
  display: grid;
  grid-template-columns: 1fr 6rem 2.5rem;
  grid-template-areas:
    "label  number unit"
    "slider slider slider";
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 1rem;
}

.input-row label {
  grid-area: label;
}

.input-row .unit {
  grid-area: unit;
}

.input-row input[type="range"] {
  grid-area: slider;
  /* Fill the row; a slider has a width of its own otherwise. */
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.input-row input[type="number"] {
  grid-area: number;
  /* Fill the grid column rather than the browser's default width. */
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  text-align: right;
}

/* The readouts: set out in a row across the output, wrapping onto
   further lines when the window is too narrow for them. A row rather than a
   list because the output is wide and its height is better spent on the
   plot. */
.readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.5rem;
  margin: 0;
}

/* One readout: a small label with its figure underneath. */
.readouts dt {
  font-size: 0.85rem;
  color: #555;
}

.readouts dd {
  margin: 0;
  font-size: 1.15rem;
  /* Digits of equal width, so the figures do not jitter sideways as a
     slider is dragged. */
  font-variant-numeric: tabular-nums;
}

/* The plot's section takes the height the results leave in the output
   column, and passes it on to the canvas in the same way. */
.plot {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* The trajectory plot: the full width of the output and the rest of the
   window's height, so the whole plot is on screen without scrolling. It is
   never shorter than 20rem; in a window too short for that the page scrolls
   instead. The stylesheet sets the size on the page; app.js reads that size
   and gives the canvas a matching number of pixels to draw on.

   The flex basis is 0 rather than `auto` on purpose. A canvas has a natural
   size equal to its pixel count, which app.js sets from the size it finds
   here; with `auto` that would feed back into the layout, and the plot could
   grow with the window but never shrink again. `display: block` stops the
   canvas sitting on a text baseline with a gap beneath it. */
#plot {
  display: block;
  width: 100%;
  flex: 1 1 0;
  min-height: 20rem;
}

/* The [hidden] attribute loses to an explicit `display`, such as the grid
   above, so it is restated here. Without this the readouts would stay on
   screen beside the no-flight message. */
[hidden] {
  display: none !important;
}

.no-flight {
  padding: 0.5rem 0.75rem;
  border-left: 4px solid #c60;
  background: #fff4e5;
}
