/* AIDE AI brand tokens (light), redefined for dark below. Status colours are fixed in both. */
:root {
  --canvas: #fafaf8;
  --surface: #ffffff;
  --surface-sunk: #f4f4f0;
  --text: #111820;
  --text-mid: #3d4451;
  --text-muted: #6b7280;
  --border: #e5e5e0;
  --no-data: #ebebe6;
  --brand: #0db763;
  --brand-text: #0a9451;
  --up: #0db763;
  --partial: #f59e0b;
  --down: #ef4444;
  --unknown: #9ca3af;
  /* Deep enough that white text on them reads at body sizes, in both themes. */
  --banner-up: #065f46;
  --banner-down: #b91c1c;
  --banner-unknown: #475569;
  --on-banner: #ffffff;
  --tooltip-bg: #111820;
  --tooltip-text: #fafaf8;
  --shadow: 0 1px 3px rgba(17, 24, 32, 0.06), 0 4px 20px rgba(17, 24, 32, 0.05);
  --tooltip-shadow: 0 6px 24px rgba(17, 24, 32, 0.18);
  --r-md: 12px;
  --r-lg: 20px;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --canvas: #0d1319;
    --surface: #151d26;
    --surface-sunk: #1b2530;
    --text: #f4f4f0;
    --text-mid: #d1d5db;
    --text-muted: #9ca3af;
    --border: #26313d;
    --no-data: #26313d;
    --brand-text: #34d399;
    --tooltip-bg: #f4f4f0;
    --tooltip-text: #111820;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --canvas: #0d1319;
  --surface: #151d26;
  --surface-sunk: #1b2530;
  --text: #f4f4f0;
  --text-mid: #d1d5db;
  --text-muted: #9ca3af;
  --border: #26313d;
  --no-data: #26313d;
  --brand-text: #34d399;
  --tooltip-bg: #f4f4f0;
  --tooltip-text: #111820;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Rules that set display (the tooltip's grid) would otherwise show hidden elements. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* An outline rather than a shadow: it keeps 3:1 against the page and survives forced colours. */
a:focus-visible,
summary:focus-visible,
.bars:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

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

.page {
  max-width: 820px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 28px 56px;
  display: grid;
  gap: 36px;
}

main {
  display: grid;
  gap: 44px;
}

/* ── Masthead ── */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  font-size: 24px;
  text-decoration: none;
  letter-spacing: -0.5px;
}

.wordmark-aide {
  color: var(--text);
  font-weight: 800;
}

.wordmark-ai {
  color: var(--brand);
  font-weight: 300;
}

.masthead-label {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
}

.masthead-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
  font-weight: 500;
}

.masthead-links a {
  color: var(--text-mid);
  text-decoration: none;
}

.masthead-links a:hover {
  color: var(--brand-text);
}

/* ── Status icons: a shape per state, so the state never rests on colour ── */
.status-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--unknown);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.status-icon::before {
  content: '?';
}

[data-level='up'] > .status-icon,
[data-level='resolved'] > .status-icon {
  background: var(--up);
}

[data-level='up'] > .status-icon::before,
[data-level='resolved'] > .status-icon::before {
  content: '✓';
}

[data-level='down'] > .status-icon {
  background: var(--down);
}

[data-level='down'] > .status-icon::before {
  content: '✕';
}

[data-level='loading'] > .status-icon::before {
  content: '';
}

/* ── Summary banner ── */
.summary {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px 28px;
  border-radius: var(--r-lg);
  background: var(--banner-unknown);
  color: var(--on-banner);
  box-shadow: var(--shadow);
}

.summary[data-level='up'] {
  background: var(--banner-up);
}

.summary[data-level='down'] {
  background: var(--banner-down);
}

/* On the banner the icon is a translucent disc; the banner's own colour carries the state. */
.summary[data-level] > .status-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 20px;
}

.summary h1 {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.4px;
}

.summary p {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.notice {
  padding: 12px 16px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--partial);
  background: var(--surface);
  color: var(--text-mid);
  font-size: 14px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--brand-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* ── Systems: one card, a row per part ── */
.components {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.component {
  display: grid;
  gap: 14px;
  padding: 22px 24px;
}

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

.component-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.component-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.component h3 {
  font-size: 17px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.pill .status-icon {
  width: 18px;
  height: 18px;
  font-size: 11px;
}

.bars-wrap {
  position: relative;
}

.bars {
  display: grid;
  grid-template-columns: repeat(90, 1fr);
  gap: 2px;
  /* Room under the bars for the mark on a day with downtime. */
  padding-bottom: 10px;
  touch-action: manipulation;
}

.bars li {
  position: relative;
  height: 34px;
  border-radius: 3px;
  background: var(--no-data);
}

.bars li[data-level='up'] {
  background: var(--up);
}

.bars li[data-level='partial'] {
  background: var(--partial);
}

.bars li[data-level='down'] {
  background: var(--down);
}

/* A shape under each day with downtime, so its level never rests on colour alone: a ring for a
   brief outage, a filled dot for a longer one. */
.bars li[data-level='partial']::after,
.bars li[data-level='down']::after,
.mark {
  content: '';
  box-sizing: border-box;
  width: 6px;
  height: 6px;
  border: 1.5px solid var(--text);
  border-radius: 50%;
}

.bars li[data-level='partial']::after,
.bars li[data-level='down']::after {
  position: absolute;
  left: 50%;
  bottom: -10px;
  margin-left: -3px;
}

.bars li[data-level='down']::after,
.mark[data-level='down'] {
  background: var(--text);
}

.bars li:hover {
  opacity: 0.7;
}

.bars li[data-chosen] {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

/* Below the bars, so it never covers the part's name or state. */
.tooltip {
  position: absolute;
  top: calc(100% - 2px);
  z-index: 1;
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: var(--tooltip-shadow);
}

.axis {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.uptime {
  color: var(--text-mid);
  font-weight: 600;
}

.narrow-only {
  display: none;
}

/* On a phone, the last 30 days: 90 bars would be under 4px each. */
@media (max-width: 640px) {
  .bars {
    grid-template-columns: repeat(30, 1fr);
  }

  .bars li:nth-child(-n + 60) {
    display: none;
  }

  .wide-only {
    display: none;
  }

  .narrow-only {
    display: inline;
  }

  .component {
    padding: 18px;
  }

  .summary {
    padding: 22px 20px;
  }

  .summary h1 {
    font-size: 22px;
  }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
}

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

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

.swatch[data-level='up'] {
  background: var(--up);
}

.swatch[data-level='partial'] {
  background: var(--partial);
}

.swatch[data-level='down'] {
  background: var(--down);
}

/* ── Past incidents: a log by day, quiet days included ── */
.incident-day {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 8px 16px;
  padding-block: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .incident-day {
    grid-template-columns: 1fr;
  }
}

.incident-day:first-child {
  padding-top: 0;
  border-top: 0;
}

.incident-day h3 {
  font-size: 15px;
  font-weight: 700;
}

.incident-list {
  display: grid;
  gap: 10px;
}

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

.incident .status-icon {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  font-size: 11px;
}

.incident > div {
  display: grid;
}

.earlier {
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface-sunk);
}

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

.earlier .incident-list {
  margin-top: 12px;
}

/* The sunk panel is darker than the page, so muted grey would fall under 4.5:1 on it. */
.earlier .muted {
  color: var(--text-mid);
}

.footer {
  display: grid;
  gap: 4px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

@media (forced-colors: active) {
  .bars li,
  .swatch,
  .mark {
    forced-color-adjust: none;
  }
}
