/* status.flambe.dev
   Hand-written and dependency-free on purpose: a status page has to render
   when everything else is broken, so there is no framework, no build step and
   nothing to fetch but one stylesheet, one script and one JSON document. */

:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --brand: #ea580c;

  --ok: #16a34a;
  --degraded: #d97706;
  --partial: #ea580c;
  --major: #dc2626;
  --unknown: #d4d4d8;

  --radius: 12px;
  --shell: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --panel: #111113;
    --border: #27272a;
    --text: #e4e4e7;
    --muted: #8b8b93;
    --brand: #fb923c;

    --ok: #22c55e;
    --degraded: #f59e0b;
    --partial: #fb923c;
    --major: #ef4444;
    --unknown: #3f3f46;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

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

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 6px;
  background: linear-gradient(135deg, #fbbf24, #f97316);
}

.masthead nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
}

.masthead nav a {
  color: var(--muted);
  text-decoration: none;
}

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

/* ---------- overall banner ---------- */

.banner {
  margin: 2.5rem 0 2rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--status, var(--unknown));
  background: var(--panel);
}

.banner h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.banner-sub {
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.banner--operational { --status: var(--ok); }
.banner--degraded { --status: var(--degraded); }
.banner--partial_outage { --status: var(--partial); }
.banner--major_outage { --status: var(--major); }
.banner--maintenance { --status: var(--muted); }

/* ---------- component groups ---------- */

.groups {
  display: grid;
  gap: 1.25rem;
}

.panel {
  margin: 1.25rem 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.component {
  padding: 0.9375rem 0;
  border-top: 1px solid var(--border);
}

.component:first-of-type {
  padding-top: 0;
  border-top: 0;
}

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

.component-name {
  font-weight: 500;
}

.component-desc {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.component-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  flex: none;
  font-size: 0.8125rem;
  color: var(--muted);
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--status, var(--unknown));
  flex: none;
}

.is-operational { --status: var(--ok); }
.is-degraded { --status: var(--degraded); }
.is-partial_outage { --status: var(--partial); }
.is-major_outage { --status: var(--major); }
.is-maintenance { --status: var(--muted); }

.component-detail {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.component-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
}

.component-metrics b {
  font-weight: 600;
  color: var(--text);
}

/* ---------- 90-day uptime bar ---------- */

.uptime {
  margin-top: 0.75rem;
}

.uptime-bar {
  display: flex;
  gap: 2px;
  height: 1.875rem;
  align-items: stretch;
}

.uptime-day {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
  background: var(--unknown);
}

.uptime-day[data-state='operational'] { background: var(--ok); }
.uptime-day[data-state='degraded'] { background: var(--degraded); }
.uptime-day[data-state='partial_outage'] { background: var(--partial); }
.uptime-day[data-state='major_outage'] { background: var(--major); }

.uptime-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 0.375rem;
  font-size: 0.6875rem;
  color: var(--muted);
}

/* Below ~30rem a 90-segment bar renders sub-pixel; drop the oldest 60 days
   rather than showing a smear. */
@media (max-width: 30rem) {
  .uptime-day:nth-child(-n + 60) {
    display: none;
  }
}

/* ---------- incidents ---------- */

.incident {
  padding: 0.9375rem 0;
  border-top: 1px solid var(--border);
}

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

.incident-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 500;
}

.incident-meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.incident-updates {
  margin: 0.625rem 0 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  list-style: none;
}

.incident-updates li {
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
}

.incident-updates li:last-child {
  margin-bottom: 0;
}

.incident-updates time {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.badge {
  flex: none;
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--status, var(--unknown));
}

/* ---------- subscribe ---------- */

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

input {
  flex: 1;
  min-width: 0;
  padding: 0.5625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}

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

button {
  flex: none;
  padding: 0.5625rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
}

button:hover:not(:disabled) {
  opacity: 0.9;
}

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

.form-message {
  margin: 0.625rem 0 0;
  min-height: 1.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.form-message[data-tone='error'] {
  color: var(--major);
}

.form-message[data-tone='success'] {
  color: var(--ok);
}

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

.webhook summary {
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--muted);
}

.webhook summary:hover {
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

code {
  padding: 0.0625rem 0.25rem;
  border-radius: 4px;
  background: color-mix(in oklab, var(--muted) 18%, transparent);
  font-size: 0.8125em;
}

/* ---------- footer ---------- */

.footer {
  margin: 2.5rem 0 3rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.footer p {
  margin: 0 0 0.375rem;
}

.footer a {
  color: var(--brand);
}
