/*
 * The dashboard's styles (docs/design.md): a plain page, hairlines instead of boxes, one
 * accent, and motion only when something changes. Colours come from tokens.css.
 */

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

html {
  background: var(--bg);
  color: var(--body);
  font: 14px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 1200px;
  padding: 28px 24px 96px;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
}

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

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

.muted {
  color: var(--muted);
}

.num {
  font-variant-numeric: tabular-nums;
}

code,
pre {
  font: 12.5px/1.5 var(--mono);
}

code {
  color: var(--muted);
}

/* Header */

.top {
  display: flex;
  align-items: center;
  gap: 16px 24px;
  padding-bottom: 20px;
}

/* The views: words in a row, the one open underlined in the accent */

.views {
  display: flex;
  gap: 4px;
}

.views a {
  padding: 4px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
}

.views a:hover {
  background: var(--hover);
  color: var(--ink);
}

.views a[aria-current='page'] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

main[hidden] {
  display: none;
}

a.aside,
.more a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

a.aside:hover,
.more a:hover {
  color: var(--accent);
}

.more {
  margin: 12px 0 0;
}

/* The Jobs view: a line on the history, filters, the rows, and pages */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin-top: 12px;
}

.page-head p {
  margin: 0;
}

.page-title {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 16px;
  margin: 20px 0 12px;
}

.filters label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.filters #jobs-count {
  margin-left: auto;
  font-size: 13px;
}

select {
  min-width: 12em;
  padding: 5px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.history .times {
  min-width: 12em;
  text-align: right;
}

.history time {
  min-width: 8em;
  text-align: right;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 16px 0;
}

.pager a {
  text-decoration: none;
}

/* The Usage view (D25) */

.range {
  display: inline-flex;
  margin-left: auto;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--hover);
}

.range a {
  padding: 3px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.range a[aria-current='page'] {
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--rule);
}

.usage-figures {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin-top: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}

.stat .sub {
  color: var(--muted);
  font-size: 12px;
}

.swatch.linux,
.key.linux,
.block.linux {
  background: var(--viz-linux);
  fill: var(--viz-linux);
}

.swatch.macos,
.key.macos,
.block.macos {
  background: var(--viz-macos);
  fill: var(--viz-macos);
}

/* The History view's VMs, by kind, as areas. */
.area.linux {
  fill: var(--viz-linux);
  fill-opacity: 0.2;
}
.line.linux {
  stroke: var(--viz-linux);
}
.dot.linux {
  fill: var(--viz-linux);
}
.area.macos {
  fill: var(--viz-macos);
  fill-opacity: 0.2;
}
.line.macos {
  stroke: var(--viz-macos);
}
.dot.macos {
  fill: var(--viz-macos);
}

.history-pager {
  margin: -8px 0 8px;
}

.column {
  outline: none;
}

.column .hit {
  fill: transparent;
}

.column:hover .block,
.column:focus-visible .block {
  filter: brightness(1.12);
}

.column:focus-visible .hit {
  stroke: var(--accent);
  stroke-width: 2;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-head h2 {
  flex: 1;
}

/* A menu that opens under its button: the Providers list */

.menu {
  position: relative;
}

.menu summary {
  padding: 3px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu summary::after {
  content: ' ▾';
  color: var(--muted);
}

.menu summary:hover {
  background: var(--hover);
}

.menu-panel {
  position: absolute;
  right: 0;
  z-index: 3;
  display: grid;
  gap: 2px;
  min-width: 200px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
}

.menu-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

.menu-panel label:hover {
  background: var(--hover);
}

.menu-panel input {
  accent-color: var(--accent);
}

.compare .row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 180px 130px;
  align-items: center;
}

.compare .provider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
}

.compare .provider a {
  text-decoration: none;
}

.compare .runners {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.compare .runners select {
  width: 100%;
  min-width: 0;
  font-size: 13px;
}

.compare .price {
  display: grid;
  justify-items: end;
  text-align: right;
}

.compare .price b {
  color: var(--ink);
}

.compare .price .meta {
  color: var(--muted);
  font-size: 12px;
}

.notes p {
  max-width: 80ch;
  margin: 6px 0 0;
}

.own {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-top: 12px;
}

.own label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.own input {
  width: 10em;
  padding: 5px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

/* The log: a dialog over whichever view it was opened from */

#log-dialog {
  width: min(1100px, 94vw);
  max-width: none;
  max-height: 86vh;
  padding: 16px 18px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--body);
}

#log-dialog::backdrop {
  background: color-mix(in oklab, var(--ink) 35%, transparent);
}

#log-dialog header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

#log-dialog h2 {
  flex: 1;
  margin: 0;
  overflow-wrap: anywhere;
}

.top h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.top p {
  margin: 0;
}

.top #live {
  margin-left: auto;
}

.top button {
  align-self: center;
}

/* Sections */

section {
  margin-top: 36px;
}

h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

h2 .count {
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

h2 button {
  margin-left: auto;
}

section > p {
  max-width: 70ch;
}

/* Rows: one line each, a hairline between */

.rows {
  border-top: 1px solid var(--rule);
}

.row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-height: 40px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
}

.row > * {
  flex: none;
}

.row > .status {
  width: 150px;
}

.row > .main {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.row .main a,
.row .main > span:first-child {
  font-weight: 500;
}

.row .meta a.author {
  color: inherit;
  font-weight: 400;
  text-decoration: none;
}

.row .meta a.author:hover {
  color: var(--accent);
  text-decoration: underline;
}

.row > .took {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* When it ended, under how long it took, as a job's repo is under its name. */
.row .took .ended,
.row .meta,
.row .note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.row code.fix {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--body);
  overflow-x: auto;
  white-space: pre;
  user-select: all;
}

.activity .row {
  min-height: 0;
  padding: 5px 0;
  border-bottom: 0;
  font-size: 13px;
}

.activity .row > .main {
  color: var(--body);
}

.activity time {
  width: 150px;
}

.warn-text {
  color: var(--warn);
}

.empty {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
}

/* A state: a glyph and a word in the state's colour */

.status {
  white-space: nowrap;
}

.status.ok {
  color: var(--ok);
}
.status.warn {
  color: var(--warn);
  white-space: normal;
}
.status.bad {
  color: var(--bad);
}
.status.busy {
  color: var(--busy);
}
.status.muted {
  color: var(--muted);
}

.alert {
  margin: 0 0 8px;
  padding: 10px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}

button {
  padding: 5px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--hover);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.primary:hover {
  filter: brightness(1.08);
}

button.quiet {
  padding: 1px 8px;
  border-color: transparent;
  color: var(--muted);
  font-size: 13px;
}

button.quiet:hover {
  color: var(--ink);
}

#settings {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-top: 16px;
}

#settings[hidden] {
  display: none;
}

#settings label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

#settings label.check {
  display: flex;
  flex-basis: 100%;
  align-items: baseline;
  gap: 8px;
  max-width: 70ch;
}

#settings label.check input {
  width: auto;
  accent-color: var(--accent);
}

#settings input {
  width: 9.5em;
  padding: 5px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

/* Now: one sentence that says what needs the owner, and four figures (docs/design.md) */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr));
  gap: 24px;
  align-items: end;
  margin-top: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}

.headline {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.headline em {
  color: var(--accent);
  font-style: normal;
}

.stat {
  display: grid;
  gap: 2px;
  margin: 0;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat b {
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
}

.stat small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

/* Charts (D23): minitart's VMs in the accent, everything else in one gray */

h2 .aside {
  margin-left: auto;
  color: var(--muted);
  font-weight: 500;
}

h2 .legend {
  margin-left: 8px;
  font-weight: 400;
}

#timeline-title {
  flex-wrap: wrap;
}

.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 40px;
}

.pair-legend {
  grid-column: 1 / -1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px;
}

.chart,
.timeline {
  position: relative;
  margin-top: 8px;
}

.chart svg,
.timeline svg {
  display: block;
  overflow: visible;
}

.chart-empty {
  position: absolute;
  inset: 40% 0 auto;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.grid {
  stroke: var(--rule);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.tick {
  fill: var(--muted);
  font: 11px var(--font);
  font-variant-numeric: tabular-nums;
}

.area.vm {
  fill: var(--viz-vm);
  fill-opacity: 0.16;
}
.area.other {
  fill: var(--viz-other);
  fill-opacity: 0.18;
}
/* A whole that is not split by who: the disk in use. Neither of the legend's two. */
.area.whole {
  fill: var(--body);
  fill-opacity: 0.07;
}

.line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.line.vm {
  stroke: var(--viz-vm);
}
.line.other {
  stroke: var(--viz-other);
}
.line.whole {
  stroke: var(--body);
}

.dot {
  stroke: var(--bg);
  stroke-width: 2;
}
.dot.vm {
  fill: var(--viz-vm);
}
.dot.other {
  fill: var(--viz-other);
}
.dot.whole {
  fill: var(--body);
}

.cross {
  stroke: var(--rule-strong);
  stroke-width: 1;
}

.chart svg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* The tooltip: values first, then names, a short line keying each series */

.tip {
  position: absolute;
  z-index: 2;
  min-width: 168px;
  padding: 8px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 12px;
  pointer-events: none;
}

.tip[hidden] {
  display: none;
}

.tip-time {
  margin-bottom: 4px;
  color: var(--muted);
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  line-height: 1.7;
}

.tip-row.total {
  margin-top: 2px;
  padding-top: 2px;
  border-top: 1px solid var(--rule);
}

.key {
  flex: none;
  width: 12px;
  height: 2px;
  border-radius: 1px;
}
.key.vm {
  background: var(--viz-vm);
}
.key.other {
  background: var(--viz-other);
}
.key.whole {
  background: var(--body);
}

.legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--body);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.swatch.vm {
  background: var(--viz-vm);
}
.swatch.start {
  background: color-mix(in oklab, var(--viz-vm) 32%, var(--bg));
}
.swatch.other {
  background: var(--viz-other);
}
.swatch.free {
  background: var(--viz-free);
  box-shadow: inset 0 0 0 1px var(--rule-strong);
}

/* The timeline: a lane per slot, a bar per VM */

.lane-name {
  fill: var(--muted);
  font: 12px var(--font);
}

.lane-rule {
  stroke: var(--rule);
  stroke-width: 1;
}

.vm-bar {
  cursor: pointer;
  outline: none;
}

.vm-bar .hit {
  fill: transparent;
}

.phase-start {
  fill: color-mix(in oklab, var(--viz-vm) 32%, var(--bg));
}

.phase-job {
  fill: var(--viz-vm);
}

.vm-bar:hover .phase-job,
.vm-bar:hover .phase-start,
.vm-bar:focus-visible .phase-job,
.vm-bar:focus-visible .phase-start {
  filter: brightness(1.12);
}

.vm-bar:focus-visible .hit {
  stroke: var(--accent);
  stroke-width: 2;
}

.end-mark {
  font: 600 12px var(--font);
}
.end-mark.ok {
  fill: var(--ok);
}
.end-mark.bad {
  fill: var(--bad);
}
.end-mark.muted {
  fill: var(--muted);
}

/* Disk: used against free, then what Tart keeps */

.meter {
  display: flex;
  gap: 2px;
  height: 8px;
  margin: 12px 0 8px;
}

.meter-part {
  min-width: 3px;
  border-radius: 4px;
}
.meter-part.other {
  background: var(--viz-other);
}
.meter-part.free {
  background: var(--viz-free);
}

.disk-head {
  margin: 16px 0 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.disk-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}

.disk-row .num {
  color: var(--ink);
}

.small {
  font-size: 12px;
}

/* The log */

#log {
  max-height: calc(86vh - 80px);
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--body);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-color: var(--rule-strong) transparent;
  scrollbar-width: thin;
}

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

  .headline {
    grid-column: 1 / -1;
    font-size: 21px;
  }

  .pair,
  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}

@media (max-width: 700px) {
  body {
    padding: 20px 16px 64px;
  }

  .top {
    flex-wrap: wrap;
  }

  .views {
    order: 3;
    flex-basis: 100%;
    margin-left: -10px;
  }

  .compare .row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .compare .price {
    justify-items: start;
    text-align: left;
  }

  .compare .runners {
    grid-template-columns: minmax(0, 1fr);
  }

  .usage-figures {
    grid-template-columns: 1fr 1fr;
  }

  .range {
    margin-left: 0;
  }

  .history .times,
  .history time {
    min-width: 0;
    text-align: left;
  }

  .top {
    flex-wrap: wrap;
    gap: 4px 12px;
  }

  .row {
    flex-wrap: wrap;
    gap: 2px 12px;
  }

  .row > .status {
    width: auto;
  }

  .row > .main {
    flex-basis: 100%;
    order: -1;
  }

  .activity time {
    width: auto;
  }

  /* On a phone the facts share a line: how long it took, then when it ended. */
  .row > .took {
    flex-direction: row;
    align-items: baseline;
  }

  .row .took .ended::before {
    content: ' · ';
    white-space: pre;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
