/* The review screen: a status report on the proxy, and the collections people can read. */

:root {
  color-scheme: light;
  --desk: #eef0ee;
  --sheet: #ffffff;
  --ink: #1b2233;
  --graphite: #586072;
  --line: #d6dad9;
  --highlight: #fff0a3;
  --highlight-ink: #3d3405;
  --margin: #b8322a;
  --focus: #2e5bdb;
  --sans: "Avenir Next", "Seravek", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --desk: #12151b;
    --sheet: #1a1f28;
    --ink: #e8ebf1;
    --graphite: #a3abba;
    --line: #2d3340;
    --highlight: #4b431c;
    --highlight-ink: #fbefb0;
    --margin: #f08a7e;
    --focus: #93acff;
  }
}

* {
  box-sizing: border-box;
}

/* Layout rules below set display, which would otherwise show hidden elements. */
[hidden] {
  display: none !important;
}

html {
  background: var(--desk);
}

body {
  margin: 0 auto;
  max-width: 70rem;
  padding: 2.5rem 1.5rem 5rem;
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

/* Masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem 2rem;
  margin-bottom: 2rem;
}

h1 {
  margin: 0;
  font-size: 2.25rem;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* The redaction bar is the screen's one mark of its own. */
h1::before {
  content: "";
  display: inline-block;
  width: 1.5em;
  height: 0.6em;
  margin-right: 0.35em;
  background: var(--ink);
  border-radius: 2px 1px 3px 1px;
  vertical-align: 0.06em;
}

.lede {
  margin: 0.6rem 0 0;
  max-width: 40rem;
  color: var(--graphite);
}

.who {
  margin: 0;
  color: var(--graphite);
  font-size: 0.875rem;
}

/* Tabs */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2rem;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  appearance: none;
  margin: 0 0 -1px;
  padding: 0.75rem 0;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--graphite);
  font: 600 1rem/1.2 var(--sans);
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

#count-waiting:not(:empty),
#count-waiting-view:not(:empty),
#count-unverified:not(:empty) {
  padding: 0 0.4em;
  border-radius: 3px;
  background: var(--highlight);
  color: var(--highlight-ink);
  font-weight: 600;
}

.status {
  min-height: 1.5rem;
  margin: 1rem 0;
  font-weight: 600;
}

.status.error {
  color: var(--margin);
}

/* The sheet that holds each view */

main {
  padding: 0 2rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.empty {
  max-width: 42rem;
  margin: 0;
  padding: 3rem 0;
  color: var(--graphite);
}

.exclusion {
  margin: 0 0 1rem;
}

.exclusion p {
  margin: 0;
}

.pick {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.pick:disabled {
  cursor: not-allowed;
}

/* The bar for excluding ticked collections together, which stays in view while scrolling. */
.bulk {
  position: sticky;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--sheet);
  border: 1px solid var(--ink);
  border-radius: 4px;
}

.bulk-count {
  margin-right: auto;
  font-weight: 600;
}

/* Buttons */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

button.primary,
button.secondary {
  padding: 0.65rem 1.05rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  font: 600 0.9375rem/1 var(--sans);
  cursor: pointer;
}

button.primary {
  background: var(--ink);
  color: var(--sheet);
}

button.secondary {
  background: transparent;
  color: var(--ink);
}

button.quiet {
  padding: 0.65rem 0.25rem;
  border: 0;
  background: none;
  color: var(--graphite);
  font: 600 0.9375rem/1 var(--sans);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

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

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

/* The panel that asks before excluding a cluster */

.panel {
  display: grid;
  gap: 0.9rem;
  max-width: 46rem;
  margin-top: 1.1rem;
  padding: 1.25rem;
  background: var(--desk);
  border-radius: 4px;
}

.panel h4 {
  margin: 0;
  font-size: 1.0625rem;
}

.panel label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.panel select,
.panel textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 400 1rem/1.4 var(--sans);
}

.panel textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.report .table {
  margin-top: 1.1rem;
}

.table {
  overflow-x: auto;
  padding-bottom: 1.5rem;
}

/* The collections people can read: each cluster, with its collections in a list that opens. */
.scope {
  padding: 1.75rem 0 0.5rem;
  border-top: 1px solid var(--line);
}

.scope > h2 {
  margin: 0;
  font-size: 1.3125rem;
  line-height: 1.3;
}

.scope-find {
  display: grid;
  gap: 0.35rem;
  max-width: 28rem;
  margin-top: 1.1rem;
  font-weight: 600;
}

.scope-find input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 400 1rem/1.4 var(--sans);
}

.cluster {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.cluster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.cluster-head h3 {
  min-width: 0;
  margin: 0;
  font: 600 1rem/1.4 var(--mono);
  overflow-wrap: anywhere;
}

.cluster.out .cluster-head h3,
.scope tr.out {
  color: var(--graphite);
}

.cluster .panel {
  margin-top: 0.9rem;
}

.cluster .collections {
  margin-top: 0.9rem;
}

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

.scope .table {
  margin-top: 0.75rem;
}

.scope .route {
  overflow-wrap: anywhere;
}

.scope .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scope .pick-cell {
  width: 1.5rem;
}

/* A hint from a collection's name, such as that it looks like a copy. */
.name-hint {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--graphite);
  font: 500 0.8125rem/1.4 var(--sans);
  white-space: nowrap;
}

.bulk-ask {
  flex-basis: 100%;
  margin: 0;
}

/* Read by screen readers, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: 0.7rem 1rem 0.7rem 0;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--graphite);
  font-size: 0.875rem;
  font-weight: 600;
}

.route {
  font-family: var(--mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

/* Dashboard: a short status report, one question for each section */

.dashboard-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--graphite);
}

.dashboard-head p {
  margin: 0;
}

.periods {
  display: flex;
  gap: 0.5rem;
}

.periods button.chosen {
  cursor: default;
}

.report {
  padding: 1.6rem 0 1.4rem;
  border-bottom: 1px solid var(--line);
}

.report:last-child {
  border-bottom: 0;
}

.report h2 {
  margin: 0;
  font-size: 1.3125rem;
  line-height: 1.3;
}

.note {
  max-width: 64ch;
  margin: 0.35rem 0 0;
  color: var(--graphite);
  font-size: 0.9375rem;
}

.fact {
  max-width: 64ch;
  margin: 0.85rem 0 0;
  font-size: 1.0625rem;
}

.fact strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.report > button {
  margin-top: 1rem;
}

.trend {
  max-width: 24rem;
  margin: 1.1rem 0 0;
}

.trend svg {
  display: block;
  width: 100%;
  height: 3.5rem;
}

.trend path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.trend figcaption {
  margin-top: 0.35rem;
  color: var(--graphite);
  font-size: 0.875rem;
}

caption {
  padding: 0 0 0.5rem;
  text-align: left;
  color: var(--graphite);
  font-size: 0.875rem;
  font-weight: 600;
}

td.number,
th.number {
  padding-right: 1.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Query log: each query people ran, newest first, as they typed it */

.log-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--graphite);
}

.log-head p {
  max-width: 56ch;
  margin: 0;
}

.log-person {
  display: grid;
  gap: 0.35rem;
  min-width: min(18rem, 100%);
  color: var(--ink);
  font-weight: 600;
}

.log-person select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 400 1rem/1.4 var(--sans);
}

.log-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
}

/* The same height as the select beside it, so the two line up. */
.log-all {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.log-all input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--focus);
}

/* A connection in the list says what the client was and how it went, in at most two lines. */
.connection-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--graphite);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

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

.queries li + li {
  border-top: 1px solid var(--line);
}

.query {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  margin: 0;
  padding: 0.9rem 0.75rem;
  background: none;
  border: 0;
  border-radius: 4px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.query:hover {
  background: var(--desk);
}

.query-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.9rem;
  font-size: 0.9375rem;
}

.query-meta time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.query-took {
  margin-left: auto;
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
}

/* A list item shows at most three lines of its query. */
.query-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  color: var(--graphite);
  font: 400 0.8125rem/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.tag {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--graphite);
  font: 600 0.75rem/1.5 var(--sans);
  white-space: nowrap;
}

.tag.warn {
  border-color: var(--margin);
  color: var(--margin);
}

.unverified-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.unverified-actions button {
  padding: 0.25rem 0.6rem;
  font-size: 0.8125rem;
}

.unverified-list {
  margin-top: 1rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 0 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
}

/* One query's details, over the page */

.sheet-dialog {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  margin: auto;
  padding: 0;
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sheet-dialog::backdrop {
  background: rgb(18 21 27 / 0.55);
}

.dialog-body {
  padding: 1.5rem 1.75rem 1.75rem;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.dialog-head h2 {
  min-width: 0;
  margin: 0;
  font-size: 1.3125rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.4rem 1.25rem;
  margin: 1.1rem 0 0;
  font-size: 0.9375rem;
}

.facts div {
  display: contents;
}

.facts dt {
  color: var(--graphite);
  font-weight: 600;
}

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

.code-block {
  margin-top: 1.5rem;
}

.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 2.4rem;
}

.code-head h3 {
  margin: 0;
  font-size: 1.0625rem;
}

/* A code block shows at most 16 lines, and scrolls for the rest. */
.code {
  max-height: calc(16 * 1.55em + 1.5rem);
  margin: 0.6rem 0 0;
  padding: 0.75rem 0.9rem;
  overflow: auto;
  background: var(--desk);
  border-radius: 4px;
  font: 400 0.8125rem/1.55 var(--mono);
  tab-size: 2;
}

.code code {
  font: inherit;
}

/* Motion that answers an action: a panel or a query's details open. */

@media (prefers-reduced-motion: no-preference) {
  .panel,
  .sheet-dialog[open] {
    animation: open 0.18s ease-out;
  }

  @keyframes open {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }

}

@media (max-width: 760px) {
  body {
    padding: 1.5rem 1rem 3rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  main {
    padding: 0 1rem;
  }

  .tabs {
    flex-wrap: nowrap;
    gap: 0 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs button {
    flex: none;
  }

  .query {
    padding: 0.9rem 0.25rem;
  }

  .query-took {
    margin-left: 0;
  }

  .dialog-body {
    padding: 1.25rem 1rem 1.5rem;
  }

  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.1rem;
  }

  .facts div + div dt {
    margin-top: 0.5rem;
  }

}
