/*
 * Our overrides on top of the Assan theme (templates/theme/README.md).
 *
 * Hand-written and committed. bin/sync-theme.php only copies theme files in and never
 * deletes ours, so this file survives a theme update — but check it after one.
 */

/* SPEC §20.3: 44 px touch targets (48 on the console theme), mobile-first.
 *
 * inline-flex, not just min-height: a <button> or <a class="btn"> lays its text out from
 * the top of the box, so min-height alone adds the extra height *below* the label and
 * leaves it looking top-aligned. Flex centring puts it back in the middle whatever the
 * height ends up being. */
.ubc-touch {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* A touch target that is a block-level button (w-100 in a form row) must still fill its
 * column, so keep it flex but let it stretch. */
.ubc-touch.w-100 { display: flex; }

/* Inputs and selects centre their own text, so they only need the height. */
.form-control.ubc-touch,
.form-select.ubc-touch { display: block; }

/* The theme sizes icon controls with .size-40; under a finger that is below the 44 px
   target, so raise it for coarse pointers only and leave the desktop header height alone.
   .size-40 already centres its own content, which is why those are exempt from
   .ubc-touch — see ThemeShellTest::testEveryButtonIsATouchTarget. */
@media (pointer: coarse) {
  .size-40 { min-height: 44px; min-width: 44px; }
}

/* Tables and charts scroll rather than forcing the page wide (§20.3). */
.table-responsive { overflow-x: auto; }

/* The theme's sidebar labels fade out in mini mode; keep our disabled items legible. */
.page-sidebar .nav-link.disabled { opacity: .55; }

/* Sheet forms are dense; keep field groups from touching on a phone. */
#ubc-sheet .card-body .row > [class^="col"] { margin-bottom: .25rem; }

/* Sheet fields (templates/sheets/_field.twig).
 *
 * Rendered ~150 times per sheet, so the sizing is here rather than inline on each one —
 * and the console skin (SPEC §13.6) can raise it to 48 px by overriding one rule. */
.ubc-field-group .form-control { min-height: 44px; }
.ubc-field-group .ubc-status   { min-width: 2.5rem; }

/* The autosave indicator must not shift the field as it changes (§9.9). */
.ubc-status { justify-content: center; font-variant-numeric: tabular-nums; }

/* §14's chart wrapper. §20.3: a fixed-height box that scales with the breakpoint, with
 * Chart.js responsive inside it — a canvas sized by its own aspect ratio ends up either
 * letterboxed on a phone or taller than the screen on a desktop. */
.ubc-chart-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

@media (min-width: 768px)  { .ubc-chart-wrap { height: 420px; } }
@media (min-width: 1200px) { .ubc-chart-wrap { height: 520px; } }

/* The console reads this from further away and has the screen to spare. */
.ubc-console .ubc-chart-wrap { height: 480px; }

/* §15.5's bell count. Small and tucked into the corner of the icon — it is a number
 * someone glances at, not a control, and a full-size badge would make the top bar look
 * like it is asking for something on every page. */
.ubc-bell-count {
  font-size: .6rem;
  padding: .15rem .3rem;
  transform: translate(25%, -25%);
}

/* The trend on a sensor tile (SPEC §13.2).
 *
 * Deliberately quiet: it is context for the number above it, not a chart. Sized in rem
 * so it scales with the console's larger base font rather than needing its own override,
 * and `currentColor` so it follows the theme — including the dark console skin — without
 * a second colour to keep in step.
 *
 * The height is fixed while the width is fluid: the SVG carries preserveAspectRatio="none",
 * so the browser rescales the drawing on resize and there is no resize handler (§20.3). */
.ubc-spark {
  height: 1.75rem;
  width: 100%;
  min-width: 0;
  opacity: .65;
  /* A tile with no history yet has an empty polyline, which draws nothing — better than
     a flat line that would read as "steady" when the truth is "not loaded". */
}

.ubc-trend { min-height: 1.75rem; }

.ubc-trend-arrow {
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Read from the loader seat, so bigger and more opaque than on a desk (§13.6). */
.ubc-console .ubc-spark { height: 2.5rem; opacity: .8; }
.ubc-console .ubc-trend { min-height: 2.5rem; }
.ubc-console .ubc-trend-arrow { font-size: 1.25rem; }

/* §11's provenance chip: what a bound field's value is, and the way to take the sensor's
 * value back. The refresh control is a real 44 px target rather than a tiny link — on a
 * tablet in a cab a text link is not tappable — so the chip row is sized to hold one
 * instead of letting the button stretch the layout around it. */
.ubc-chip { min-height: 44px; }
.ubc-chip .ubc-chip-refresh { min-width: auto; padding-inline: .25rem; }

/* Which commit is running (SPEC §20). Deliberately quiet: it is for whoever is
 * diagnosing a deploy, and noise for everyone else filling in a sheet.
 *
 * It sits under the account block in the sidebar, where "what is this and what is it
 * running" reads as one group. The login page has no sidebar, so there it stays a
 * centred page footer. */
.ubc-version {
  font-size: .75rem;
  opacity: .7;
}
.ubc-version code { font-size: inherit; }

/* Login page: centred under the card rather than pinned to a sidebar. */
.page-content .ubc-version { margin-top: 2rem; text-align: center; }

/* ---------------------------------------------------------------------------
 * Console tablet (SPEC §13.6)
 *
 * A rugged tablet in a loader cab, read at arm's length by someone wearing gloves,
 * often in direct sun or at night. So: larger everything, 48 px targets rather than 44,
 * and no interaction that depends on hovering — there is no pointer to hover with.
 * ------------------------------------------------------------------------- */

.ubc-console body { font-size: 1.125rem; }

/* 48 px, per §20.3's console rule, and it has to beat the 44 px base rule. */
.ubc-console .ubc-touch,
.ubc-console .btn {
  min-height: 48px;
  min-width: 48px;
  font-size: 1.05rem;
}

/* The numbers are the whole point of the screen; they are read from further away than
   anything else on it. */
.ubc-console .display-6 { font-size: 3rem; font-weight: 600; }
.ubc-console .fs-4      { font-size: 1.75rem !important; }
.ubc-console .card-body { padding: 1.25rem; }

/* Higher contrast than the theme's dark default: a cab in daylight washes out greys. */
.ubc-console .text-body-secondary { color: #b9c0c7 !important; }
.ubc-console .card { border-color: #3a4048; }

/* Nothing hover-dependent (§13.6): a title attribute is invisible without a pointer, so
   anything that mattered is rendered as text on the console rather than hidden in one. */
.ubc-console [title] { cursor: default; }

/* Sheet field sizing follows the same 48 px rule. */
.ubc-console .ubc-field-group .form-control { min-height: 48px; }

/* ---------------------------------------------------------------------------
 * Forms inside a horizontally-scrolling table (§6 item 12's danger zone, and the
 * retention panel beside it).
 *
 * §20.3 puts every table in an `overflow-x: auto` wrapper, which is right for reading —
 * but a form in the last cell then inherits whatever width is left, and at 390 px that is
 * a day field two characters wide beside a slug box somebody has to type into exactly.
 * Giving the form a floor lets the table scroll to it instead of squeezing it, which is
 * what the wrapper is for.
 * ------------------------------------------------------------------------- */

.ubc-cell-form { min-width: 20rem; }

/* §13.2's gauge. A cap rather than a size: in a `lg` widget on a 1366 px screen an
   uncapped dial becomes a billboard, and the figure under it is what people read. The
   console enlarges it, which is why this is a class and not an inline style — an inline
   max-width wins against the rule below and the tablet would keep the web size. */
.ubc-gauge-wrap { max-width: 16rem; }

.ubc-console .ubc-gauge-wrap { max-width: 22rem; }

/* Identifiers rendered exactly as stored, inside a control that capitalises.
   The theme ships `.btn { text-transform: capitalize }`, which is right for a button
   whose label is a verb and wrong the moment one carries *data*. CSS treats a hyphen as
   a word boundary, so a firmware version `0.5.4-b1` renders `0.5.4-B1` — and versions are
   case-sensitive, so that is not a style choice, it is a wrong fact on screen beside a
   row that says `0.5.4-b1`.
   Narrow on purpose: the theme's capitalisation stays everywhere it belongs, and this
   says "this span is a value, not a label". Digits are unaffected by `capitalize`, which
   is why batch numbers and times in buttons need nothing. */
.ubc-exact { text-transform: none; }
