/* Components shared by the website and the dashboard (docs/DESIGN.md
 * §"Components"). Reads the tokens from tokens.css and defines none of its own.
 */

/* ---------- mark ---------- */
/* The banked attitude indicator. Sky on top, ground below, never level. */

.mark__sky     { fill: var(--action); }
.mark__ground  { fill: var(--text); }
.mark__horizon { stroke: var(--surface); }
.mark__ring    { stroke: var(--text-strong); }

/* ---------- wordmark ---------- */

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.045em;
  color: var(--text-strong);
  text-decoration: none;
}

.wordmark__mark { width: 24px; height: 24px; flex: none; }

.wordmark--sm { font-size: 16px; gap: 7px; }
.wordmark--sm .wordmark__mark { width: 19px; height: 19px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  border: 0;
  border-radius: var(--radius);
  background: var(--action);
  color: var(--action-ink);
  font: inherit;
  font-weight: 600;
  letter-spacing: -.01em;
  padding: 12px 20px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn { transition: filter var(--motion), border-color var(--motion); }
.btn:hover { filter: brightness(1.12); }
.btn:active { filter: brightness(.94); }
.btn:disabled,
.btn[aria-disabled="true"] { cursor: not-allowed; filter: none; opacity: .5; }
.btn[aria-busy="true"] { cursor: progress; }
.btn--sm { padding: 9px 15px; font-size: 15px; }
.btn--lg { padding: 15px 26px; font-size: 17px; }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--ghost:hover { filter: none; border-color: var(--muted-2); }

/* A filter toggle: a ghost button that stays pressed. */
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.toggle { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 10px; font-size: var(--text-host); }
.toggle[aria-pressed="true"] {
  border-color: var(--action);
  background: var(--surface-2);
  color: var(--text-strong);
}
.toggle__count { font-family: var(--mono); font-size: var(--text-data); color: var(--muted); }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}


/* ---------- confirmation ---------- */
/* A button that asks in place: the question replaces it, with the action named
   again and Cancel beside it. Never the browser's own dialog. */
.confirm { display: inline-block; }
.confirm__question { align-items: center; flex-wrap: wrap; gap: 8px; }
.confirm__text { color: var(--text-strong); font-weight: 600; }

/* ---------- chip ---------- */
/* Mono, uppercase, status-coloured on its tint. Never colour alone: the label
   says the status in words. */

.chip {
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.chip--ok    { color: var(--ok);    background: var(--tint-ok); }
.chip--warn  { color: var(--warn);  background: var(--tint-warn); }
.chip--alert { color: var(--alert); background: var(--tint-alert); }
.chip--neutral { color: var(--muted); background: var(--surface-2); }
/* In a table cell a long chip ("a restart into 7.0.0-44-generic fixes it") wraps rather than overflow. */
.data-table .chip { display: inline-block; max-width: 100%; white-space: normal; }

/* ---------- status dot ---------- */
/* Decorative: the row says the same in text, so it is aria-hidden. */

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot--ok    { background: var(--ok); }
.dot--warn  { background: var(--warn); }
.dot--alert { background: var(--alert); box-shadow: 0 0 0 3px color-mix(in srgb, var(--alert) 14%, transparent); }


/* ---------- panel ---------- */
/* The surface a screen of the dashboard sits on, with a quieter head and
   foot. The landing page's product mock is the same panel. */

.panel {
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.panel__status {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px 34px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--text-data);
  color: var(--muted);
}

/* ---------- summary stat ---------- */
/* A number and its label. The number takes a status colour only when the
   label names that status in words. */

.stat { display: flex; align-items: baseline; gap: 9px; margin: 0; }
.stat__num { font-size: var(--text-stat); font-weight: 600; color: var(--text-strong); letter-spacing: -.04em; }
.stat--quiet .stat__num { font-size: var(--text-stat-quiet); color: var(--text); }
.stat--warn .stat__num { color: var(--warn); }
.stat--alert .stat__num { color: var(--alert); }
.stat__label { font-size: var(--text-host); color: var(--muted); }

/* ---------- fleet table ---------- */
/* One row per server. A real table, so a screen reader can walk it by row and
   column. When its panel is narrower than 760px — a phone, or a narrow column —
   the release and last-upgrade columns fold into a second line under the
   hostname instead of scrolling sideways. */

.fleet-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: var(--text-data);
  color: var(--text);
}

.fleet-table th {
  padding: 9px var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
}

.fleet-table td {
  padding: 13px var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.fleet-table tbody tr:last-child td { border-bottom: 0; }
.fleet-table tbody tr { transition: background var(--motion); }
.fleet-table tbody tr:hover { background: var(--surface-2); }

.fleet-table__dot { width: 7px; padding-right: 0; }
.fleet-table__host { font-size: var(--text-host); color: var(--text-strong); white-space: nowrap; }
.fleet-table__host a { color: inherit; text-decoration: none; }
.fleet-table__host a:hover { text-decoration: underline; text-decoration-color: var(--muted-2); }
.fleet-table__contact { margin-top: 2px; font-size: var(--text-data); color: var(--muted); white-space: nowrap; }
.fleet-table__meta { display: none; margin-top: 2px; font-size: var(--text-data); color: var(--muted); white-space: normal; }
.fleet-table__release { color: var(--muted); white-space: nowrap; }
.fleet-table__pending { white-space: nowrap; }
.fleet-table__pending em { font-style: normal; color: var(--warn); }
.fleet-table__clear { color: var(--muted); }
.fleet-table__flags { display: flex; flex-wrap: wrap; gap: 5px; }
.fleet-table__when { color: var(--muted); text-align: right; white-space: nowrap; }

.fleet-table__row--alert,
.fleet-table__row--alert:hover { background: var(--tint-alert-row); }
.fleet-table__row--alert .fleet-table__host { color: var(--alert); }
.fleet-table__row--offline .fleet-table__host { color: var(--muted); }

.fleet-table__empty { padding: var(--space-5) var(--space-4); color: var(--muted); font-family: var(--sans); font-size: var(--text-ui); }

@container (max-width: 760px) {
  .fleet-table th,
  .fleet-table td { padding-left: var(--space-3); padding-right: var(--space-3); }
  .fleet-table__col-release,
  .fleet-table__col-when { display: none; }
  .fleet-table__meta { display: block; }
}

/* A phone: each row becomes a small grid — dot, then host, pending and flags
   on their own lines. The cells keep explicit ARIA roles, because a row that
   is no longer displayed as a table row loses its table semantics in some
   browsers. */
@container (max-width: 480px) {
  .fleet-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fleet-table tbody tr {
    display: grid;
    grid-template-columns: 7px minmax(0, 1fr);
    column-gap: var(--space-3);
    row-gap: var(--space-1);
    padding: 12px var(--space-3);
    border-bottom: 1px solid var(--border-soft);
  }
  .fleet-table tbody tr:last-child { border-bottom: 0; }
  .fleet-table tbody td { display: block; padding: 0; border: 0; }
  .fleet-table tbody td.fleet-table__col-release,
  .fleet-table tbody td.fleet-table__col-when { display: none; }
  .fleet-table__dot { grid-row: 1 / span 3; padding-top: 6px; }
  .fleet-table__host { white-space: normal; }
  .fleet-table__flags:empty { display: none; }
}

/* ---------- utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- text field ---------- */
/* A real label above, the field below, the error under it. */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--text-host); font-weight: 600; color: var(--text-strong); }
.field__input {
  font: inherit;
  font-size: var(--text-ui);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-field);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
}
.field__input::placeholder { color: var(--muted); }
.field__input[aria-invalid="true"] { border-color: var(--alert); }
.field__hint { font-size: var(--text-host); color: var(--muted); margin: 0; }
.field__error { font-size: var(--text-host); color: var(--alert); margin: 0; }

/* ---------- notice ---------- */

.notice {
  margin: 0 0 var(--space-4);
  padding: 12px var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-ui);
}
.notice--info { background: var(--surface-2); color: var(--text); }
.notice--error { background: var(--tint-alert); color: var(--alert); }

/* ---------- data table ---------- */
/* The fleet table's look for any other list. */

.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-data); color: var(--text); }
.data-table th {
  padding: 9px var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
}
.data-table td { padding: 12px var(--space-4); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table__mono { font-family: var(--mono); color: var(--text-strong); }
.data-table__muted { color: var(--muted); }
.data-table__actions { text-align: right; white-space: nowrap; }
.data-table__actions form { display: inline; }
.data-table__empty { padding: var(--space-4); color: var(--muted); font-size: var(--text-ui); }

@container (max-width: 560px) {
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table tbody tr { display: block; padding: 12px var(--space-3); border-bottom: 1px solid var(--border-soft); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table tbody td { display: block; padding: 2px 0; border: 0; text-align: left; }
}

/* ---------- app bar ---------- */

.app-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
.app-bar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px var(--space-4);
}
.app-bar__nav { display: flex; gap: var(--space-4); flex: 1; min-width: 0; }
.app-bar__nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-ui);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color var(--motion), border-color var(--motion);
}
.app-bar__nav a:hover { color: var(--text-strong); }
.app-bar__nav a[aria-current="page"] { color: var(--text-strong); border-bottom-color: var(--text-strong); }
.app-bar__account { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-host); color: var(--muted); }
.app-bar__account form { margin: 0; }

.switcher { position: relative; }
.switcher summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-strong);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary::after { content: " ▾"; color: var(--muted); }
.switcher__menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.switcher__menu a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.switcher__menu a:hover { background: var(--surface-2); }
.switcher__menu a[aria-current="true"] { font-weight: 600; color: var(--text-strong); }
.switcher__new { border-top: 1px solid var(--border-soft); margin-top: 6px; padding-top: 6px; }

@media (max-width: 640px) {
  .app-bar__nav { order: 3; flex-basis: 100%; }
}

/* ---------- auth panel ---------- */

.auth { max-width: 420px; margin: 0 auto; padding: var(--space-6) var(--space-4); }
.auth > .wordmark { margin-bottom: var(--space-4); }
.auth .panel { padding: var(--space-5) var(--space-4); }
.auth h1 { font-size: var(--text-stat-quiet); margin-bottom: var(--space-2); }
.auth p { margin: 0 0 var(--space-4); color: var(--muted); }
.auth form { display: flex; flex-direction: column; gap: var(--space-3); }

/* ---------------------------------------------------------------- command */
/* A command to copy, shown whole: it wraps instead of scrolling sideways. */
.command { display: flex; align-items: flex-start; gap: var(--space-2); }
.command__text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: var(--text-data);
  color: var(--text-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.command__copy { flex: none; }

/* ---------------------------------------------------------------- facts */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3) var(--space-4); margin: 0; }
.facts__item { min-width: 0; }
.facts dt {
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { margin: 2px 0 0; font-family: var(--mono); font-size: var(--text-data); color: var(--text-strong); overflow-wrap: anywhere; }

