/* The styles of the website: plain, light and dark, usable on a phone.
   See docs/10-website.md. The website loads no fonts: it uses the fonts of
   the system. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f5f6f8;
  --fg: #1d2127;
  --muted: #5d6673;
  --border: #d6dae0;
  --accent: #1f5fbf;
  --accent-fg: #ffffff;
  --danger: #b3261e;
  --danger-fg: #ffffff;
  --error-bg: #fdecea;
  --error-fg: #8c1d18;
  --code-bg: #eef0f3;
  --gray: #e7e9ed;
  --gray-fg: #3d4450;
  --blue: #dde9fb;
  --blue-fg: #174a94;
  --green: #dcf1e2;
  --green-fg: #1b5e2f;
  --amber: #fbefd5;
  --amber-fg: #7a4e00;
  --red: #fbe1df;
  --red-fg: #8c1d18;
  --font:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --mono:
    ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181d;
    --surface: #1d2127;
    --fg: #e3e6ea;
    --muted: #9aa3ae;
    --border: #353b44;
    --accent: #6ea4f5;
    --accent-fg: #0f1318;
    --danger: #f2877f;
    --danger-fg: #1a0b0a;
    --error-bg: #3a1d1b;
    --error-fg: #ffb4ab;
    --code-bg: #252a31;
    --gray: #2c3139;
    --gray-fg: #c4cad2;
    --blue: #1d3350;
    --blue-fg: #a9c8f7;
    --green: #183823;
    --green-fg: #9bdcab;
    --amber: #3d2e0f;
    --amber-fg: #f3c96b;
    --red: #43201d;
    --red-fg: #ffb4ab;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.5rem;
  margin: 0.4rem 0 0.8rem;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1.15rem;
  margin: 1.6rem 0 0.6rem;
}

h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

code,
pre,
.id {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  background: var(--code-bg);
  border-radius: 3px;
  padding: 0 0.25em;
  overflow-wrap: anywhere;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0;
  overflow: auto;
  padding: 0.75rem;
}

/* The header and the navigation. */

.top {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.5rem 1rem;
}

.brand {
  color: var(--fg);
  font-weight: 700;
}

#nav {
  display: flex;
  flex: 1 1 auto;
  gap: 0.15rem;
  overflow-x: auto;
}

#nav a {
  border-radius: 6px;
  color: var(--fg);
  padding: 0.3rem 0.6rem;
  white-space: nowrap;
}

#nav a[aria-current="page"] {
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  font-weight: 600;
}

#who {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  white-space: nowrap;
}

.role,
.muted,
.sub,
.hint {
  color: var(--muted);
}

.sub {
  font-size: 0.88em;
}

main {
  margin: 0 auto;
  max-width: 1280px;
  padding: 0.5rem 1rem 5rem;
}

#nav[hidden],
#who[hidden] {
  display: none;
}

/* Buttons and controls. */

button,
.button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  cursor: pointer;
  display: inline-block;
  font: inherit;
  line-height: 1.2;
  padding: 0.45rem 0.8rem;
}

button:hover,
.button:hover {
  border-color: var(--muted);
  text-decoration: none;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

button.primary,
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
}

button.close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 0.3rem;
}

input,
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font: inherit;
  max-width: 100%;
  padding: 0.4rem 0.5rem;
}

input[type="checkbox"] {
  height: 1.05rem;
  margin: 0;
  width: 1.05rem;
}

input[type="file"] {
  border: none;
  padding: 0.2rem 0;
}

textarea {
  width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.toolbar,
.row-actions,
.actions,
.pager {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toolbar {
  margin: 0.5rem 0 0.75rem;
}

.actions {
  justify-content: flex-end;
  margin-top: 1rem;
}

.pager {
  justify-content: space-between;
  margin-top: 0.75rem;
}

/* Forms. */

.inline-form {
  display: flex;
  gap: 0.5rem;
  max-width: 48rem;
}

.inline-form input {
  flex: 1 1 auto;
  font-family: var(--mono);
  min-width: 0;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form h2 {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.field input:not([type="checkbox"]),
.field select {
  width: 100%;
}

.label {
  font-weight: 600;
}

.hint {
  font-size: 0.85em;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0;
  padding: 0.5rem 0.75rem 0.75rem;
}

legend {
  font-weight: 600;
  padding: 0 0.3rem;
}

.check {
  align-items: center;
  display: inline-flex;
  gap: 0.35rem;
  white-space: nowrap;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 16rem;
  overflow-y: auto;
}

.sign-in {
  margin: 2rem auto;
  max-width: 28rem;
}

/* The filters of the job list. */

.filter-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.75rem;
}

.filter-box summary {
  cursor: pointer;
  font-weight: 600;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.filter-row {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-row .field {
  min-width: 10rem;
}

.filter-row .grow {
  flex: 1 1 14rem;
}

.filter-row .mine {
  padding-bottom: 0.5rem;
}

/* Tables. On a narrow screen each row becomes a block. */

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}

td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}

td.select,
th.select {
  width: 2rem;
}

td.empty {
  color: var(--muted);
  text-align: center;
}

tbody tr:hover {
  background: var(--surface);
}

.times {
  white-space: nowrap;
}

ul.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (max-width: 720px) {
  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0;
  }

  td,
  td.num {
    border: none;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 7.5rem 1fr;
    padding: 0.2rem 0.25rem;
    text-align: left;
    white-space: normal;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.85em;
    font-weight: 600;
  }

  td.select {
    width: 100%;
  }

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

  td.empty {
    display: block;
  }

  td.empty::before {
    content: none;
  }
}

/* Fields of one record. */

.fields {
  display: grid;
  gap: 0.35rem 1rem;
  grid-template-columns: max-content 1fr;
  margin: 0;
}

.fields dt {
  color: var(--muted);
  font-weight: 600;
}

.fields dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .fields {
    grid-template-columns: 1fr;
  }

  .fields dd {
    margin-bottom: 0.4rem;
  }
}

.page-head h1 {
  margin-bottom: 0.3rem;
}

.head-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.head-actions {
  margin-left: auto;
}

/* Badges of states. */

.badge {
  background: var(--gray);
  border-radius: 999px;
  color: var(--gray-fg);
  display: inline-block;
  font-size: 0.82em;
  font-weight: 600;
  padding: 0.05rem 0.55rem;
  white-space: nowrap;
}

.badge-queued,
.badge-starting,
.badge-running {
  background: var(--blue);
  color: var(--blue-fg);
}

.badge-done,
.badge-ready {
  background: var(--green);
  color: var(--green-fg);
}

.badge-timed-out,
.badge-resting,
.badge-drain {
  background: var(--amber);
  color: var(--amber-fg);
}

.badge-error,
.badge-broken,
.badge-lost {
  background: var(--red);
  color: var(--red-fg);
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  background: var(--code-bg);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 0.05rem 0.4rem;
}

/* The overview. */

.cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.counts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.count-row {
  align-items: center;
  color: var(--fg);
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
}

.number {
  font-weight: 600;
}

.meter {
  margin: 0.5rem 0 0.9rem;
  max-width: 48rem;
}

.meter-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.meter-bar {
  background: var(--gray);
  border-radius: 999px;
  height: 0.6rem;
  overflow: hidden;
}

.meter-fill {
  background: var(--accent);
  height: 100%;
}

/* The log and JSON. */

.log {
  font-size: 0.82rem;
  line-height: 1.35;
  max-height: 70vh;
  min-height: 4rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.log-status {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.4rem;
}

.json {
  font-size: 0.85rem;
  max-height: 32rem;
}

pre.text {
  white-space: pre-wrap;
}

/* Errors, notices, and dialogs. */

.error {
  background: var(--error-bg);
  border-radius: 6px;
  color: var(--error-fg);
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
  padding: 0.5rem 0.75rem;
}

.error .code {
  font-family: var(--mono);
}

.warning {
  color: var(--amber-fg);
  font-weight: 600;
}

#notice {
  bottom: 0.75rem;
  left: 50%;
  max-width: calc(100% - 1.5rem);
  position: fixed;
  transform: translateX(-50%);
  width: 40rem;
  z-index: 10;
}

.notice {
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
}

.notice-error {
  background: var(--error-bg);
}

.notice .error {
  margin: 0;
  padding: 0;
}

dialog {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  max-height: calc(100% - 2rem);
  max-width: 36rem;
  padding: 1.25rem;
  width: calc(100% - 2rem);
}

dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

textarea.secret {
  font-family: var(--mono);
  resize: none;
}
