/*
 * Helix, consumer components.
 *
 * The second of two consumer stylesheets, loaded after brand.css.
 * Semetrika ships nothing that says "this service is degraded" or
 * "here is the last hour of ingest", so Helix builds those three
 * components itself, following the conventions on the Extending page
 * of the docs site:
 *
 *   1. Every color, radius, font, and spacing step is a `var(--…)`
 *      reading a Semetrika token, so a brand swap in brand.css re-themes
 *      these components with the rest of the site and dark mode arrives
 *      for free. The handful of literal lengths below are intrinsic
 *      dimensions of the drawing itself - a status dot, a severity
 *      rule, a bar - for which Semetrika ships no token.
 *   2. Value words come from Semetrika's capability vocabulary. A
 *      degraded service is `.warning`, not `.amber`.
 *   3. Selectors are standalone. Each component works anywhere in the
 *      DOM without a parent.
 *
 * Component tokens are declared first so a page can retarget one
 * region by re-declaring them on an ancestor, the same way Semetrika's
 * own components behave.
 */

:root {
  --service-border-color: var(--border-color-subtle);
  --service-color: var(--text-color-neutral);
  --service-gap: var(--space-x-2);
  --service-padding-block: var(--space-y-2);
  --service-status-color: var(--text-color-subtle);
  --service-status-size: 0.625rem;

  --logline-gap: var(--space-x-2);
  --logline-padding-block: var(--space-y-1);
  --logline-padding-inline: var(--space-x-2);
  --logline-rule-color: var(--text-color-subtle);
  --logline-rule-width: 0.1875rem;

  --sparkline-bar-color: var(--text-color-accent);
  --sparkline-bar-min-height: 0.125rem;
  --sparkline-bar-width: 1.5rem;
  --sparkline-gap: var(--space-x-1);
  --sparkline-height: 7rem;
}

/* ── Service ──
   One row of the service health list: a status dot, the service name
   with its region, and the metric being watched. */

.service {
  align-items: center;
  border-block-end: 0.0625rem solid var(--service-border-color);
  color: var(--service-color);
  display: grid;
  gap: var(--service-gap);
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding-block: var(--service-padding-block);
}

.service-status {
  background: var(--service-status-color);
  block-size: var(--service-status-size);
  border-radius: var(--radius-circle);
  display: block;
  inline-size: var(--service-status-size);
}

.service-name {
  display: block;
  font-weight: var(--font-weight-semibold);
}

.service-meta {
  color: var(--text-color-subtle);
  display: block;
  font-size: var(--font-size-xs);
}

.service-metric {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Intent values, borrowed from Semetrika's vocabulary rather than
   invented. A degraded service is `.warning`, never `.amber`. */

.service.success {
  --service-status-color: var(--text-color-success);
}

.service.warning {
  --service-status-color: var(--text-color-warning);
}

.service.danger {
  --service-status-color: var(--text-color-danger);
}

.service.info {
  --service-status-color: var(--text-color-info);
}

/* ── Log line ──
   A single entry in a log stream: timestamp, severity, message. The
   severity rule down the leading edge is the only color, so a long
   stream stays scannable without becoming a traffic light. */

.logline {
  border-inline-start: var(--logline-rule-width) solid var(--logline-rule-color);
  display: grid;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  gap: var(--logline-gap);
  grid-template-columns: auto auto minmax(0, 1fr);
  padding-block: var(--logline-padding-block);
  padding-inline-start: var(--logline-padding-inline);
}

.logline-time {
  color: var(--text-color-subtle);
  font-variant-numeric: tabular-nums;
}

.logline-level {
  color: var(--logline-rule-color);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
}

.logline-message {
  min-width: 0;
  overflow-wrap: anywhere;
}

.logline.info {
  --logline-rule-color: var(--text-color-info);
}

.logline.warning {
  --logline-rule-color: var(--text-color-warning);
}

.logline.danger {
  --logline-rule-color: var(--text-color-danger);
}

/* ── Sparkline ──
   A bar per bucket, height driven by `--sparkline-value` set on the
   item as a percentage. The list stays readable without CSS and the
   accessible summary lives in the caption beside it. */

.sparkline {
  align-items: end;
  block-size: var(--sparkline-height);
  display: flex;
  gap: var(--sparkline-gap);
  list-style: none;
  margin: 0;
  padding: 0;
}

.sparkline > li {
  --sparkline-value: 0;

  background: var(--sparkline-bar-color);
  block-size: calc(var(--sparkline-value) * 1%);
  border-radius: calc(var(--radius-xs) * var(--option-rounded-corners));
  inline-size: var(--sparkline-bar-width);
  margin: 0;
  min-block-size: var(--sparkline-bar-min-height);
}

/* ── Overriding a shipped component ──
   Two cases where a token cannot say what Helix needs.

   Every number in this product is read down a column, so tables opt
   into tabular figures throughout. There is no token for a font
   feature, which is exactly when a consumer selector is the right tool
   rather than a variable. */

table th,
table td,
.table th,
.table td {
  font-variant-numeric: tabular-nums;
}

/* Semetrika shares one hover slot across every emphasis, so a solid
   accent button would invert to the neutral light surface on hover.
   The resting colors stay in brand.css; only the state that has no
   token of its own is written as a rule. */

button.accent:hover,
.btn.accent:hover {
  --btn-hover-background-color: var(--btn-accent-hover-background-color);
  --btn-hover-border-color: var(--btn-accent-hover-background-color);
  --btn-hover-color: var(--btn-accent-color);
}
