/* The styles every Uplink page shares: the operator console, the sign-in
   pages and the portal. Colour, type, shape, space and motion come from the
   brand tokens (brand/css/tokens.css, from adcl_assets): this file names no
   colour of its own. The rules it follows are the brand guidelines: ink on
   paper, petrol only for links and focus, elevation by a 1px border, sentence
   case, status as icon plus dot plus label. */

/* IBM Plex, the unmodified files (brand/fonts, SIL OFL 1.1). Only the faces
   the pages use: Sans 400, 500 and 600, and Mono 400. */
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('brand/fonts/ibm-plex-sans/woff2/IBMPlexSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('brand/fonts/ibm-plex-sans/woff2/IBMPlexSans-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('brand/fonts/ibm-plex-sans/woff2/IBMPlexSans-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('brand/fonts/ibm-plex-mono/woff2/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--type-ui-body-family);
  font-size: var(--type-ui-body-size);
  font-weight: var(--type-ui-body-weight);
  line-height: var(--type-ui-body-line-height);
  font-variant-numeric: tabular-nums lining-nums;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

b,
strong {
  font-weight: var(--font-weight-semibold);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sprite symbol,
.status svg {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* Focus is the same ring everywhere: 2px, 2px away. */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}

/* A text link is underlined at rest and thickens under the pointer. */
a {
  color: var(--primary);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}

a:hover {
  text-decoration-thickness: 2px;
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 2;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--elevation-overlay);
}

.skip:focus {
  top: var(--space-2);
}

/* ---- Header ---- */

.top {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.top__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-height: 56px;
}

.top__id,
.top__tools {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

/* The logo link shows the pointer and nothing else. */
.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.brand__logo {
  display: block;
  height: 18px;
  width: auto;
}

.brand__logo--dark,
[data-theme="dark"] .brand__logo--light {
  display: none;
}

[data-theme="dark"] .brand__logo--dark {
  display: block;
}

.top__product {
  padding-left: var(--space-3);
  border-left: 1px solid var(--logo-rule);
  color: var(--muted-foreground);
  font-size: var(--type-ui-control-size);
  font-weight: var(--type-ui-control-weight);
  line-height: 20px;
  white-space: nowrap;
}

.top__viewer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.top__deployment {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label {
  color: var(--muted-foreground);
  font-size: var(--type-ui-label-size);
  font-weight: var(--type-ui-label-weight);
  line-height: var(--type-ui-label-line-height);
}

/* ---- Buttons ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: var(--size-control-sm);
  padding: 0 var(--space-3);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  font-family: var(--type-ui-control-family);
  font-size: var(--type-ui-control-size);
  font-weight: var(--type-ui-control-weight);
  line-height: var(--type-ui-control-line-height);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-hover) var(--easing-enter);
}

.button:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.button--ghost {
  border-color: transparent;
  background: transparent;
}

.button[hidden] {
  display: none;
}

/* The one primary action in a region. */
.button--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.button--primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: var(--primary-foreground);
}

.button--lg {
  height: var(--size-control-lg);
  padding: 0 var(--space-4);
}

/* A button that reads as a link, for an action inside a sentence. */
.button--link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  text-decoration: underline;
}

.button--link:hover {
  background: none;
  color: var(--primary-hover);
}

/* ---- Gate: one small card in the middle of the page, for signing in and
   for a page that says why it cannot be shown ---- */

.gate {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: var(--space-16) var(--space-4) var(--space-8);
}

.gate > * + * {
  margin-top: 0;
}

.gate__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.gate__card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}

.gate__message {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.gate__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each way in is a full-width button, with a line under it when it is not
   for everyone. */
.gate__actions li {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.gate__hint {
  color: var(--muted-foreground);
  font-size: var(--type-ui-caption-size);
  line-height: var(--type-ui-caption-line-height);
  text-align: center;
}

.gate__foot {
  color: var(--muted-foreground);
  font-size: var(--type-ui-caption-size);
  line-height: var(--type-ui-caption-line-height);
  text-align: center;
}

/* ---- Tabs ---- */

.tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: var(--size-control-lg);
  padding: 0 var(--space-3);
  border-bottom: var(--border-width-selected-rule) solid transparent;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  color: var(--foreground);
  font-size: var(--type-ui-control-size);
  font-weight: var(--type-ui-control-weight);
  text-decoration: none;
  transition: background-color var(--duration-hover) var(--easing-enter);
}

.tab:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

/* The current tab holds still: the selected fill and the rule, hover or not. */
.tab[aria-current="page"],
.tab[aria-current="page"]:hover {
  border-bottom-color: var(--primary);
  background: var(--selected);
  color: var(--foreground);
}

/* A tab spans the clipped tab row, so its ring is drawn inside. */
.tab:focus-visible {
  outline-offset: -2px;
}

/* ---- Page ---- */

main {
  flex: 1 0 auto;
  padding-block: var(--space-6) var(--space-12);
}

main > * + * {
  margin-top: var(--space-4);
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.head h1 {
  margin-right: auto;
}

.head__meta,
.card__note,
.sub,
.facts__note,
.quiet,
.foot {
  color: var(--muted-foreground);
}

.head__meta,
.card__note {
  font-size: var(--type-ui-caption-size);
  line-height: var(--type-ui-caption-line-height);
}

.lead {
  max-width: 72ch;
}

.stale {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}

.stale[hidden] {
  display: none;
}

/* ---- Cards: a fill and a 1px border, never a shadow ---- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--card-foreground);
  overflow: hidden;
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.card__head .card__note {
  flex: 1 1 100%;
}

.card__state {
  margin-left: auto;
}

.empty {
  padding: var(--space-4);
}

.pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* ---- The verdict ---- */

.verdict {
  padding: var(--space-5) var(--space-4) 0;
}

.verdict__summary {
  margin-top: var(--space-1);
  color: var(--muted-foreground);
}

.verdict .facts {
  margin: var(--space-4) calc(-1 * var(--space-4)) 0;
  border-top: 1px solid var(--border);
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.notice__state {
  flex: none;
}

.notice__text {
  flex: 1 1 320px;
}

/* ---- Status: an icon, a dot and a label, never colour alone ---- */

.status {
  --c: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  color: var(--foreground);
  font-size: var(--type-ui-label-size);
  font-weight: var(--type-ui-label-weight);
  line-height: var(--type-ui-label-line-height);
  white-space: nowrap;
}

.status svg {
  flex: none;
  width: 14px;
  height: 14px;
  stroke: var(--c);
}

.status .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--c);
}

.status--success {
  --c: var(--success);
}

.status--warning {
  --c: var(--warning);
}

.status--destructive {
  --c: var(--destructive);
}

.status--lg {
  gap: var(--space-2);
  font-size: var(--type-ui-h2-size);
  font-weight: var(--type-ui-h2-weight);
  line-height: var(--type-ui-h2-line-height);
  letter-spacing: var(--type-ui-h2-tracking);
  white-space: normal;
}

.status--lg svg {
  width: 20px;
  height: 20px;
}

/* ---- Facts ---- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.facts__row {
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.facts dt {
  color: var(--muted-foreground);
  font-size: var(--type-ui-label-size);
  font-weight: var(--type-ui-label-weight);
  line-height: var(--type-ui-label-line-height);
}

.facts dd {
  margin-top: var(--space-1);
  overflow-wrap: anywhere;
}

.facts__note,
.sub {
  display: block;
  font-size: var(--type-ui-caption-size);
  line-height: var(--type-ui-caption-line-height);
}

/* The grid's last row needs no rule under it: the card's border is there. */
.card > .facts:last-child {
  margin-bottom: -1px;
}

/* ---- Tables: 13px cells, 1px dividers, no stripes, no hover ---- */

.scroll {
  overflow-x: auto;
}

/* The region spans the card edge to edge, so its ring is drawn inside. */
.scroll:focus-visible {
  outline-offset: -2px;
}

/* A table keeps a readable width. In a window too narrow for it, its region
   scrolls sideways and the page does not. At phone width it becomes a list
   instead (the last section of this file). */
.table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: var(--type-ui-table-size);
  line-height: var(--type-ui-table-line-height);
}

.table th,
.table td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-weight: var(--font-weight-regular);
}

.table thead th {
  height: var(--size-row-dense);
  color: var(--muted-foreground);
  font-size: var(--type-ui-label-size);
  font-weight: var(--type-ui-label-weight);
  line-height: var(--type-ui-label-line-height);
  vertical-align: middle;
  white-space: nowrap;
}

.table tbody th,
.table tbody td {
  height: var(--size-row-default);
}

.table tbody tr:last-child th,
.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody th {
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

.table .num {
  text-align: right;
  white-space: nowrap;
}

.table .problem {
  min-width: 260px;
}

.table--fixed td {
  overflow-wrap: anywhere;
}

/* Tables that repeat down a page share their column widths, so the columns
   line up from one card to the next. */
.table--fixed {
  table-layout: fixed;
}

.table--narrow {
  min-width: 440px;
}

.col-name {
  width: 22%;
}

.col-state {
  width: 190px;
}

.col-took {
  width: 96px;
}

.col-var {
  width: 30%;
}

.col-from {
  width: 150px;
}

/* A status sits on the first line of its row, level with the text beside it. */
.table .status {
  min-height: 20px;
}

.name {
  font-weight: var(--font-weight-medium);
}

.table .sub {
  font-weight: var(--font-weight-regular);
  white-space: normal;
}

/* Machine identifiers only: versions, addresses, variable names. */
.mono {
  font-family: var(--type-ui-mono-dense-family);
  font-size: var(--type-ui-mono-dense-size);
  line-height: var(--type-ui-mono-dense-line-height);
}

.value {
  overflow-wrap: anywhere;
}

/* ---- Footer ---- */

.foot {
  flex: none;
  padding-block: var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--card);
  font-size: var(--type-ui-caption-size);
  line-height: var(--type-ui-caption-line-height);
}

/* ---- Phone width ---- */

@media (max-width: 640px) {
  .wrap {
    padding-inline: var(--space-4);
  }

  /* Three rows: the logo and the page's name, then the deployment and the
     theme button, then who is signed in and the way out. */
  .top__row {
    flex-direction: column;
    align-items: stretch;
    padding-block: var(--space-3) var(--space-1);
  }

  .top__tools {
    flex-wrap: wrap;
    justify-content: space-between;
    row-gap: var(--space-1);
  }

  .top__deployment {
    flex: 1 1 0;
  }

  .top__viewer {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    min-width: 0;
  }

  /* A long address is cut short and never pushes the button off the row. */
  .top__viewer .mono {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tabs {
    padding-inline: var(--space-2);
  }

  main {
    padding-block: var(--space-4) var(--space-8);
  }

  /* A table becomes a list: each row a block, each cell under its column's
     name. Nothing is hidden off to the side on a phone. */
  .scroll {
    overflow-x: visible;
  }

  .table,
  .table--narrow {
    display: block;
    min-width: 0;
  }

  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table tbody,
  .table tbody tr {
    display: block;
  }

  .table tbody tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }

  .table tbody tr:last-child {
    border-bottom: 0;
  }

  .table tbody th,
  .table tbody td {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: var(--space-2);
    width: auto;
    min-width: 0;
    height: auto;
    padding: var(--space-0-5) 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .table tbody th {
    display: block;
    padding-bottom: var(--space-1);
  }

  .table tbody .num {
    text-align: left;
  }

  .table tbody td::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: var(--type-ui-label-size);
    font-weight: var(--type-ui-label-weight);
    line-height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .tab {
    transition: none;
  }
}
