/* Shubo Status — vanilla CSS, no build. Mobile-first, accessible, light/dark.
   Status colour semantics are driven by a single set of CSS custom properties so
   adding/renaming a status only touches this block + js/app.js status maps. */

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --border: #d8dee4;
  --text: #1c2128;
  --text-muted: #57606a;
  --shadow: 0 1px 2px rgba(27, 33, 40, 0.06), 0 1px 3px rgba(27, 33, 40, 0.04);
  --radius: 12px;
  --maxw: 760px;

  /* status palette */
  --c-operational: #18b663;
  --c-degraded:    #d4a017;
  --c-partial:     #e8843c;
  --c-major:       #e5484d;
  --c-maintenance: #5b6df0;
  --c-unknown:     #8b949e;

  --banner-fg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2129;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #9198a1;
    --shadow: none;
    --c-operational: #2ea043;
    --c-degraded:    #d4a017;
    --c-partial:     #db6d28;
    --c-major:       #f85149;
    --c-maintenance: #6e7bf2;
    --c-unknown:     #6e7681;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

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

a { color: inherit; }

/* Accessibility: visible focus + skip link */
:focus-visible {
  outline: 2px solid var(--c-maintenance);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c-operational);
}
.brand__name { font-size: 16px; }

.header-meta { display: flex; align-items: center; gap: 12px; }
.last-updated { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.refresh-btn:hover { background: var(--border); }
.refresh-btn__icon { display: inline-block; line-height: 1; }
.refresh-btn.is-spinning .refresh-btn__icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Banner ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  padding: 18px 20px;
  border-radius: var(--radius);
  color: var(--banner-fg);
  box-shadow: var(--shadow);
}
.banner__icon {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-size: 18px; font-weight: 700;
}
.banner__title { margin: 0; font-size: 18px; line-height: 1.25; }
.banner__subtitle { margin: 2px 0 0; font-size: 13px; opacity: 0.92; }

.banner--operational  { background: var(--c-operational); }
.banner--degraded     { background: var(--c-degraded); }
.banner--down         { background: var(--c-major); }
.banner--maintenance  { background: var(--c-maintenance); }
.banner--unknown,
.banner--loading      { background: var(--c-unknown); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 16px 0;
  overflow: hidden;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card__title { margin: 0; font-size: 15px; font-weight: 600; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.legend__item { display: inline-flex; align-items: center; gap: 5px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot--operational  { background: var(--c-operational); }
.dot--degraded     { background: var(--c-degraded); }
.dot--down         { background: var(--c-major); }
.dot--maintenance  { background: var(--c-maintenance); }
.dot--unknown      { background: var(--c-unknown); }

/* ---------- Component list ---------- */
.component-list { list-style: none; margin: 0; padding: 0; }
.component-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.component-row:last-child { border-bottom: 0; }

.component-row__main { min-width: 0; }
.component-row__name {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500;
}
.component-row__desc {
  margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis;
}
.component-row__status {
  font-size: 13px; font-weight: 600; white-space: nowrap;
  text-align: right;
}
.status-text--operational  { color: var(--c-operational); }
.status-text--degraded     { color: var(--c-degraded); }
.status-text--down         { color: var(--c-major); }
.status-text--maintenance  { color: var(--c-maintenance); }
.status-text--unknown      { color: var(--c-unknown); }

.component-row__meta {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; gap: 6px;
}

/* Uptime bar */
.uptime { display: flex; flex-direction: column; gap: 4px; }
.uptime__summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.uptime__summary-label { font-weight: 600; }
.uptime__bar {
  display: flex; gap: 2px; align-items: flex-end;
  height: 26px;
}
.uptime__tick {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  border-radius: 2px;
  background: var(--c-unknown);
  opacity: 0.85;
}
.uptime__tick--operational  { background: var(--c-operational); }
.uptime__tick--degraded     { background: var(--c-degraded); }
.uptime__tick--down         { background: var(--c-major); }
.uptime__tick--maintenance  { background: var(--c-maintenance); }
.uptime__tick--unknown      { background: var(--c-unknown); opacity: 0.4; }
.uptime__tick--today {
  outline: 1px solid color-mix(in srgb, var(--text) 35%, transparent);
  outline-offset: -1px;
}
.uptime__labels {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--text-muted);
}
.uptime__ratio {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Skeleton loading rows */
.component-list__skeleton {
  height: 54px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Incidents ---------- */
.incident-list { list-style: none; margin: 0; padding: 0; }
.incident { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.incident:last-child { border-bottom: 0; }
.incident__head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.incident__title { margin: 0; font-size: 14.5px; font-weight: 600; }
.incident__badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 999px;
  color: var(--banner-fg);
}
.badge--investigating { background: var(--c-major); }
.badge--identified    { background: var(--c-partial); }
.badge--monitoring    { background: var(--c-degraded); }
.badge--resolved      { background: var(--c-operational); }
.incident__time { font-size: 12px; color: var(--text-muted); }
.incident__affected {
  margin: 6px 0 0; font-size: 12.5px; color: var(--text-muted);
}
.incident__updates { margin: 10px 0 0; padding: 0; list-style: none; }
.incident__update {
  display: grid; grid-template-columns: 84px 1fr; gap: 10px;
  font-size: 12.5px; padding: 4px 0;
  border-left: 2px solid var(--border); padding-left: 12px;
}
.incident__update-status { font-weight: 600; }
.incident__update-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.incident-list__empty { padding: 18px; color: var(--text-muted); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 28px;
  padding: 22px 0 40px;
  border-top: 1px solid var(--border);
}
.site-footer__inner p { margin: 4px 0; font-size: 12.5px; }

/* ---------- Stale / error states ---------- */
.is-stale .last-updated { color: var(--c-degraded); }

/* noscript fallback banner (CSP-safe: class, not inline style) */
.noscript-banner { margin-top: 1rem; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .refresh-btn.is-spinning .refresh-btn__icon,
  .component-list__skeleton { animation: none; }
}

/* Narrow screens */
@media (max-width: 480px) {
  .legend { display: none; }
  .banner__title { font-size: 16px; }
  .component-row__status { font-size: 12.5px; }
}
