/* Mobile-first adjustments.
 *
 * The dashboard previously used a fill layout, which divided the viewport height
 * between two charts. On a 375px-wide phone that left each chart 99px tall with a
 * legend on top of the axis. Charts now have explicit heights and the page
 * scrolls instead.
 */

/* Chart heights. The wrapper carries a definite height so the plotly widget
 * inside it (height:100%) has something to resolve against. */
.hamilton-chart {
  height: 380px;
}

.hamilton-chart > *,
.hamilton-chart .js-plotly-plot {
  /* Plotly sizes itself a little taller than its container, which pushed it into
   * the chart below. Pin both the widget wrapper and the plot to the wrapper. */
  height: 100% !important;
}

@media (max-width: 767.98px) {
  .hamilton-chart {
    height: 340px;
  }

  /* Vertical space above the first chart is the scarcest thing on a phone. The
   * button text already says what it does, so its column label is redundant. */
  .hamilton-export-label {
    display: none;
  }

  .hamilton-controls .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
  }

  /* "to" was rendering as a clipped "t" between the two date fields. */
  .hamilton-controls .shiny-date-range-input .input-group-text {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    min-width: 2rem;
    justify-content: center;
    flex: 0 0 auto;
  }

  /* Four full-width status pills cost about 200px before the first chart. Two
   * per row keeps every station and its state visible in a quarter of that.
   * An explicit grid rather than flex-basis: the pill text does not wrap, so it
   * overflowed a percentage basis and each pill still claimed its own row. */
  .hamilton-status {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.2rem 0.5rem;
    font-size: 0.72rem;
  }

  .hamilton-status > div {
    margin-right: 0 !important;
  }

  .hamilton-note {
    font-size: 0.72rem;
  }

  .hamilton-controls .shiny-date-range-input input {
    min-width: 0;
    font-size: 0.85rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  /* The plotly toolbar overlays the plotting area on a narrow screen and invites
   * mis-taps while scrolling. Pinch-zoom and drag still work without it. */
  .modebar-container,
  .js-plotly-plot .modebar {
    display: none !important;
  }

  /* Full-width controls read better than cramped columns once they stack. */
  .hamilton-controls .form-control,
  .hamilton-controls .form-select,
  .hamilton-controls .btn,
  .hamilton-controls .shiny-date-range-input {
    width: 100%;
  }

  .hamilton-controls .shiny-date-range-input .input-group {
    flex-wrap: nowrap;
  }

  /* Reclaim horizontal space that is scarce on a phone. */
  .card-body {
    padding: 0.75rem;
  }

  .card-header {
    font-size: 1rem;
  }
}

/* Status pills wrap rather than overflow, and stay legible when they do. */
.hamilton-status {
  gap: 0.25rem 1rem;
}

.hamilton-status > div {
  white-space: nowrap;
}

/* Nothing should ever scroll sideways. */
html,
body {
  overflow-x: hidden;
}

/* Give the stacked controls a little breathing room from the status row. */
.hamilton-controls {
  margin-bottom: 0.5rem;
}
