/* InfrAudit status page. One small stylesheet, no framework: the page has to
   load instantly, also when the main product is having a bad day. */

:root {
  /* Surfaces and ink */
  --plane: #f9f9f9;
  --surface: #ffffff;
  --ink: #191919;
  --ink-2: #666666;
  --hairline: #e7e7e7;
  --ring: rgba(11, 11, 11, 0.1);
  --focus: #191919;

  /* Status colours. Reserved for status and always shown with an icon and a
     word, never alone: two of them are low-contrast on a light surface. */
  --good: #0aac23;
  --warning: #fbb315;
  --critical: #dc3c3d;
  --no-data: #d4d4d4;
  --unknown: #8a8a8a;
  --maintenance: #5b6b7a;

  --icon-ink: #ffffff;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --plane: #0b0b0b;
    --surface: #191919;
    --ink: #efefef;
    --ink-2: #9c9c9c;
    --hairline: #303030;
    --ring: rgba(255, 255, 255, 0.1);
    --focus: #efefef;
    --no-data: #3d3d3d;
    --unknown: #8a8a8a;
    --maintenance: #8496a8;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

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

.top,
main,
.foot {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 28px;
  padding-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand img {
  display: block;
  border-radius: 6px;
}

.brand-page {
  color: var(--ink-2);
  font-weight: 400;
}

.top-link {
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
}

/* Cards */
.banner,
.incident,
.group,
.history-list {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
}

/* Icons take the status colour; the words beside them stay in ink. */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--unknown);
}

[data-tone="operational"] > .icon,
.icon[data-tone="operational"] {
  color: var(--good);
}

[data-tone="degraded"] > .icon,
.icon[data-tone="degraded"] {
  color: var(--warning);
  --icon-ink: #0b0b0b;
}

[data-tone="outage"] > .icon,
.icon[data-tone="outage"] {
  color: var(--critical);
}

[data-tone="maintenance"] > .icon,
.icon[data-tone="maintenance"] {
  color: var(--maintenance);
}

/* Headline */
.banner {
  --tone: var(--unknown);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  background: color-mix(in srgb, var(--tone) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--tone) 35%, var(--ring));
}

.banner[data-tone="operational"] {
  --tone: var(--good);
}

.banner[data-tone="degraded"] {
  --tone: var(--warning);
}

.banner[data-tone="outage"] {
  --tone: var(--critical);
}

.banner-icon {
  width: 32px;
  height: 32px;
}

.banner h1 {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.banner p {
  color: var(--ink-2);
  font-size: 14px;
  margin-top: 2px;
}

/* Sections */
section {
  margin-top: 20px;
}

.components,
.history {
  margin-top: 40px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2 {
  font-size: 16px;
  font-weight: 600;
}

.quiet {
  color: var(--ink-2);
  font-size: 14px;
}

/* Period switch */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 8px;
}

.segmented button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

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

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}

/* Component groups */
.group {
  margin-bottom: 16px;
  padding: 4px 20px;
}

.group h3 {
  padding: 14px 0 2px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.component {
  padding: 14px 0 12px;
}

.component + .component {
  border-top: 1px solid var(--hairline);
}

.component-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.component-name {
  font-size: 15px;
  font-weight: 600;
  margin-right: auto;
}

.component-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.component-status .icon {
  width: 16px;
  height: 16px;
  align-self: center;
}

.component-uptime {
  min-width: 64px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Daily bars. Each day's hit area is its whole column, gap included, so the
   pointer doesn't have to land on the painted bar. */
.days {
  display: flex;
  height: 34px;
  margin-top: 10px;
  border-radius: 4px;
  cursor: default;
}

.day {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 1px;
}

.day::before {
  content: "";
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--no-data);
}

.day[data-level="operational"]::before {
  background: var(--good);
}

.day[data-level="degraded"]::before {
  background: var(--warning);
}

.day[data-level="outage"]::before {
  background: var(--critical);
}

.day[data-active]::before {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.days-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 12px;
}

.only-narrow {
  display: none;
}

/* Table view of the same history: nothing is reachable only by hovering. */
.day-table {
  margin-top: 8px;
  font-size: 13px;
}

.day-table summary {
  display: inline-block;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  list-style: none;
}

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

.day-table table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.day-table th,
.day-table td {
  padding: 6px 8px 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
  font-weight: 400;
}

.day-table th {
  color: var(--ink-2);
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 13px;
}

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

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--no-data);
}

.swatch[data-level="operational"] {
  background: var(--good);
}

.swatch[data-level="degraded"] {
  background: var(--warning);
}

.swatch[data-level="outage"] {
  background: var(--critical);
}

/* Incidents */
.incident {
  padding: 18px 20px;
  margin-bottom: 12px;
}

.incident-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.incident-head .icon {
  margin-top: 3px;
}

.incident h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.incident-meta {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 13px;
}

.updates {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.updates li {
  padding: 10px 0 0 14px;
  margin-left: 4px;
  border-left: 2px solid var(--hairline);
}

.updates li + li {
  margin-top: 0;
  padding-top: 14px;
}

.update-label {
  font-weight: 600;
  font-size: 14px;
}

.update-time {
  margin-left: 6px;
  color: var(--ink-2);
  font-size: 13px;
}

.update-message {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.history-list {
  padding: 0 20px;
}

.history-list .incident {
  padding: 16px 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.history-list .incident + .incident {
  border-top: 1px solid var(--hairline);
}

.history-list details summary {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}

.history .quiet {
  padding: 16px 0;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  max-width: 240px;
  padding: 8px 10px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.tooltip-value {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

.tooltip-date,
.tooltip-detail {
  display: block;
  opacity: 0.78;
}

/* Footer */
.foot {
  margin-top: 48px;
  padding-top: 20px;
  padding-bottom: 40px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-2);
  font-size: 13px;
}

.foot p + p {
  margin-top: 6px;
}

.noscript {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* Phones: 30 days of bars instead of 90, so each one stays wide enough to
   read and to touch. */
@media (max-width: 640px) {
  .day:nth-last-child(n + 31) {
    display: none;
  }

  .only-wide {
    display: none;
  }

  .only-narrow {
    display: inline;
  }

  .banner {
    padding: 18px;
  }

  .banner h1 {
    font-size: 19px;
  }

  .group {
    padding: 4px 16px;
  }

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

  .component-name {
    flex-basis: 100%;
  }

  .component-uptime {
    margin-left: auto;
  }
}

/* High-contrast modes and print lose the colours, so the bars switch to
   patterns: clear, striped, solid, dotted. */
@media (forced-colors: active), print {
  .day::before {
    forced-color-adjust: none;
    background: none;
    border: 1px dotted CanvasText;
  }

  .day[data-level="operational"]::before {
    background: none;
    border: 1px solid CanvasText;
  }

  .day[data-level="degraded"]::before {
    background: repeating-linear-gradient(45deg, CanvasText 0 2px, Canvas 2px 5px);
    border: 1px solid CanvasText;
  }

  .day[data-level="outage"]::before {
    background: CanvasText;
    border: 1px solid CanvasText;
  }

  .swatch {
    forced-color-adjust: none;
    background: none;
    border: 1px dotted CanvasText;
  }

  .swatch[data-level="operational"] {
    background: none;
    border: 1px solid CanvasText;
  }

  .swatch[data-level="degraded"] {
    background: repeating-linear-gradient(45deg, CanvasText 0 2px, Canvas 2px 5px);
    border: 1px solid CanvasText;
  }

  .swatch[data-level="outage"] {
    background: CanvasText;
    border: 1px solid CanvasText;
  }
}

@media print {
  .segmented,
  .top-link,
  .tooltip {
    display: none;
  }
}
