/* Nomios web UI: the administrator's server page (U62). Design system: docs/design/DESIGN_SYSTEM.md.
   The stylesheets are linked in this order: tokens, base, shell, components, tasks, pages, modal,
   meetings, connection, search, viewing, confirm, server. */

@layer server {
  /* --- The server page (U62): the range links, the tiles, and one chart per series. -------------
     The charts are drawn on the server as SVG: the mean is the line, the peak the band above it, and
     a stretch with no readings is a hatched gap (never a zero). Text sits in the drawing at a size
     that stays readable when it scales down to a phone. */
  .server {
    display: grid;
    gap: var(--space-4);
    container-type: inline-size;
    container-name: server;
  }

  .server-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .server-ranges .btn {
    min-height: 2.75rem;
  }

  .server-ranges .btn.is-current {
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    border-color: var(--color-accent);
  }

  .server-step {
    margin: 0;
  }

  .server-section-title {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 650;
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .server-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
  }

  @container server (min-width: 40rem) {
    .server-tiles {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  @container server (min-width: 64rem) {
    .server-tiles {
      grid-template-columns: repeat(6, minmax(0, 1fr));
    }
  }

  .server-tile {
    display: grid;
    align-content: start;
    gap: var(--space-1);
    padding: var(--space-3);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .server-tile.is-stale {
    opacity: 0.8;
  }

  .server-tile-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
  }

  .server-tile-value {
    font-size: var(--text-lg);
    font-variant-numeric: tabular-nums;
  }

  .server-tile-scope,
  .server-tile-state {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .server-tile-state {
    font-weight: 650;
  }

  .server-tile-state[data-state="warning"] {
    color: var(--status-awaiting);
  }

  .server-tile-state[data-state="critical"] {
    color: var(--status-failed);
  }

  .server-group {
    display: grid;
    gap: var(--space-3);
  }

  .server-charts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  @container server (min-width: 52rem) {
    .server-charts {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .server-chart {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--color-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .server-chart.is-warning {
    border-color: var(--status-awaiting);
  }

  .server-chart.is-critical {
    border-color: var(--status-failed);
  }

  .server-chart-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-2);
  }

  .server-chart-title {
    margin: 0;
    font-size: var(--text-base);
    overflow-wrap: anywhere;
  }

  .server-summary,
  .server-empty,
  .server-stale {
    margin: 0;
    font-size: var(--text-sm);
  }

  .server-summary {
    color: var(--color-text-muted);
  }

  .server-numbers summary {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
  }

  .chart {
    display: block;
    width: 100%;
    height: auto;
  }

  .chart-defs {
    position: absolute;
  }

  .chart-grid line {
    stroke: var(--color-border);
    stroke-width: 1;
  }

  .chart-label {
    font-size: 12px;
    fill: var(--color-text-muted);
  }

  .chart-gaps rect {
    fill: url(#chart-hatch);
  }

  .chart-hatch-line {
    stroke: var(--color-border-strong);
    stroke-width: 1;
  }

  .chart-bands path {
    fill: var(--color-accent);
    fill-opacity: 0.3;
    stroke: none;
  }

  .chart-lines path {
    fill: none;
    stroke: var(--color-link);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
  }

  .chart-dots circle {
    fill: var(--color-link);
  }

  /* The state of the page and the findings: a word and a mark, the colour only helps. */
  .server-status,
  .server-finding {
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
    padding: var(--space-3) var(--space-4);
    background: var(--color-sunken);
    border: 1px solid var(--color-border);
    border-inline-start: 3px solid var(--status-neutral);
    border-radius: var(--radius-md);
    font-weight: 600;
  }

  .server-status::before,
  .server-finding::before {
    content: "?";
    flex: none;
    width: 1.25rem;
    text-align: center;
  }

  .server [data-state="ok"]::before {
    content: "\2713";
  }

  .server [data-state="warning"]::before {
    content: "\25B2";
  }

  .server [data-state="critical"]::before {
    content: "\25A0";
  }

  .server-status[data-state="ok"] {
    border-inline-start-color: var(--status-succeeded);
  }

  .server-status[data-state="warning"],
  .server-finding[data-state="warning"] {
    border-inline-start-color: var(--status-awaiting);
  }

  .server-status[data-state="critical"],
  .server-finding[data-state="critical"] {
    border-inline-start-color: var(--status-failed);
  }

  .server-findings {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) 0;
    padding: 0;
    list-style: none;
  }

  .server-finding-level {
    font-weight: 700;
  }

  .server-threshold {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .chart-threshold {
    stroke: var(--status-awaiting);
    stroke-width: 1;
    stroke-dasharray: 5 4;
  }

  /* The tables and lists of the processes, the versions and the host. */
  .server-table-wrap {
    max-width: 100%;
    overflow: auto;
  }

  .server-processes th,
  .server-processes td {
    white-space: nowrap;
  }

  .server-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--space-2) var(--space-4);
    margin: 0;
  }

  .server-fact {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--color-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .server-fact dt {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .server-fact dd {
    margin: 0;
    overflow-wrap: anywhere;
  }

  .server-fact dd[data-state="warning"] {
    font-weight: 650;
  }
}
