/**
 * Defines the anonymous Status shell layout, theme values, and stale-state
 * affordances. Fixed grid dimensions keep cached, stale, and fault snapshots
 * readable at narrow mobile widths, high zoom, and reduced-motion settings.
 */

:root {
  color-scheme: light dark;
  color: var(--text);
  background: var(--page);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;

  --page: #f7f8f4;
  --surface: #ffffff;
  --surface-muted: #eef4f8;
  --surface-strong: #e4edf4;
  --text: #142231;
  --text-muted: #566675;
  --border: #c5d2dd;
  --border-strong: #8fa2b4;
  --link: #075985;
  --focus: #2563eb;
  --summary-bg: #ffffff;
  --shadow: 0 12px 30px rgb(17 35 54 / 0.08);
  --operational: #147a52;
  --operational-bg: #e3f7ec;
  --degraded: #8a5a00;
  --degraded-bg: #fff4c2;
  --partial: #a64400;
  --partial-bg: #ffe4cc;
  --major: #b42318;
  --major-bg: #ffe1dd;
  --unknown: #52606d;
  --unknown-bg: #e8edf2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #03070d;
    --surface: #050a12;
    --surface-muted: #0b1420;
    --surface-strong: #111d2a;
    --text: #edf6ff;
    --text-muted: #aab8c7;
    --border: #213142;
    --border-strong: #43576d;
    --link: #88cdf6;
    --focus: #7dd3fc;
    --summary-bg: #07101a;
    --shadow: none;
    --operational: #63e6aa;
    --operational-bg: #062318;
    --degraded: #f5d05f;
    --degraded-bg: #2b2105;
    --partial: #ff9a4a;
    --partial-bg: #301605;
    --major: #ff7a70;
    --major-bg: #300b0b;
    --unknown: #a9b6c5;
    --unknown-bg: #141c26;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f7f8f4;
  --surface: #ffffff;
  --surface-muted: #eef4f8;
  --surface-strong: #e4edf4;
  --text: #142231;
  --text-muted: #566675;
  --border: #c5d2dd;
  --border-strong: #8fa2b4;
  --link: #075985;
  --focus: #2563eb;
  --summary-bg: #ffffff;
  --shadow: 0 12px 30px rgb(17 35 54 / 0.08);
  --operational: #147a52;
  --operational-bg: #e3f7ec;
  --degraded: #8a5a00;
  --degraded-bg: #fff4c2;
  --partial: #a64400;
  --partial-bg: #ffe4cc;
  --major: #b42318;
  --major-bg: #ffe1dd;
  --unknown: #52606d;
  --unknown-bg: #e8edf2;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #03070d;
  --surface: #050a12;
  --surface-muted: #0b1420;
  --surface-strong: #111d2a;
  --text: #edf6ff;
  --text-muted: #aab8c7;
  --border: #213142;
  --border-strong: #43576d;
  --link: #88cdf6;
  --focus: #7dd3fc;
  --summary-bg: #07101a;
  --shadow: none;
  --operational: #63e6aa;
  --operational-bg: #062318;
  --degraded: #f5d05f;
  --degraded-bg: #2b2105;
  --partial: #ff9a4a;
  --partial-bg: #301605;
  --major: #ff7a70;
  --major-bg: #300b0b;
  --unknown: #a9b6c5;
  --unknown-bg: #141c26;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
}

a {
  color: var(--link);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.status-shell {
  width: min(1080px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 0 32px;
}

.status-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 28px;
  align-items: start;
  padding: 0 0 28px;
}

.status-brand-block {
  display: grid;
  gap: 12px;
}

.status-brand {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 16ch;
  font-size: clamp(36px, 6vw, 58px);
  line-height: 1.02;
}

.theme-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 4px;
  align-self: start;
  min-width: min(100%, 280px);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.theme-control button {
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.theme-control button[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.status-summary {
  width: fit-content;
  max-width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left: 6px solid var(--unknown);
  border-radius: 8px;
  background: var(--summary-bg);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.status-summary[data-overall-state="operational"] {
  border-left-color: var(--operational);
}

.status-summary[data-overall-state="degraded"] {
  border-left-color: var(--degraded);
}

.status-summary[data-overall-state="partial_outage"] {
  border-left-color: var(--partial);
}

.status-summary[data-overall-state="major_outage"] {
  border-left-color: var(--major);
}

.status-summary[data-overall-state="unknown"],
.status-summary[data-overall-state="stale"] {
  border-left-color: var(--unknown);
}

.status-clock,
.status-footer {
  color: var(--text-muted);
  font-size: 14px;
}

.status-clock {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: baseline;
}

.status-stale-banner {
  width: fit-content;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px dashed var(--degraded);
  border-radius: 8px;
  background: var(--degraded-bg);
  color: var(--text);
  font-weight: 700;
}

.service-list {
  display: grid;
  gap: 18px;
}

.incident-list,
.deployment-list,
.activity-list,
.calendar-list,
.freshness-list {
  display: grid;
  gap: 14px;
  margin-block: 0 18px;
}

.incident-list h2,
.deployment-list h2,
.activity-list h2,
.calendar-list h2,
.freshness-list h2 {
  font-size: 22px;
  line-height: 1.2;
}

.service-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.fact-list,
#deployments,
#activity,
#release-calendar,
#freshness,
#incidents {
  display: grid;
  gap: 10px;
}

.fact-card,
.deployment-row,
.calendar-group,
.timeline > li,
#freshness li {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow-wrap: anywhere;
}

.deployment-row {
  border-left: 6px solid var(--unknown);
}

.deployment-row.is-verified {
  border-left-color: var(--operational);
}

.deployment-row.is-stale {
  border-left-color: var(--degraded);
  border-left-style: dashed;
}

.deployment-row h3,
.fact-card h3,
.calendar-group h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.deployment-row p,
.fact-card p,
.calendar-group li,
.timeline p,
#freshness li,
.section-note {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.commit-text {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  word-break: break-all;
}

.fact-meta {
  text-transform: capitalize;
}

details {
  margin-top: 8px;
}

summary {
  min-height: 44px;
  cursor: pointer;
  color: var(--link);
  font-weight: 700;
}

.timeline,
.calendar-group ul,
#freshness ul,
.fact-card ol {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.more-activity {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 44px;
  padding: 8px 12px;
}

.more-activity:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.more-activity[aria-disabled='true'] {
  color: var(--text-muted);
  cursor: default;
}

.service-card > p {
  color: var(--text-muted);
}

.component-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.component-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 8px 12px;
  min-height: 124px;
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--unknown);
  border-radius: 8px;
  background: var(--surface-muted);
}

.component-row.is-operational {
  border-left-color: var(--operational);
}

.component-row.is-degraded {
  border-left-color: var(--degraded);
  border-left-style: dashed;
}

.component-row.is-partial_outage {
  border-left-color: var(--partial);
  border-left-style: double;
}

.component-row.is-major_outage {
  border-left-color: var(--major);
  border-left-width: 8px;
}

.component-row.is-unknown,
.component-row.is-stale {
  border-left-color: var(--unknown);
  border-left-style: dotted;
}

.component-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.component-state {
  align-self: start;
  min-width: 104px;
  padding: 5px 8px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}

.component-row.is-operational .component-state {
  background: var(--operational-bg);
  color: var(--operational);
}

.component-row.is-degraded .component-state {
  background: var(--degraded-bg);
  color: var(--degraded);
}

.component-row.is-partial_outage .component-state {
  background: var(--partial-bg);
  color: var(--partial);
}

.component-row.is-major_outage .component-state {
  background: var(--major-bg);
  color: var(--major);
}

.component-row.is-unknown .component-state,
.component-row.is-stale .component-state {
  background: var(--unknown-bg);
  color: var(--unknown);
}

.component-summary,
.component-observed {
  grid-column: 1 / -1;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.component-observed {
  font-size: 13px;
}

.status-footer {
  display: grid;
  gap: 8px;
  padding: 24px 0 0;
}

.status-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-footer p {
  max-width: 72ch;
}

@media (max-width: 760px) {
  .status-shell {
    width: min(100vw - 24px, 640px);
    padding-top: 24px;
  }

  .status-header {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .theme-control {
    width: 100%;
    min-width: 0;
  }

  h1 {
    max-width: none;
    font-size: 34px;
  }

  .component-list {
    grid-template-columns: 1fr;
  }

  .fact-card,
  .deployment-row,
  .calendar-group,
  .timeline > li,
  #freshness li {
    padding: 12px;
  }

  .component-row {
    min-height: 0;
  }
}

@media (max-width: 420px) {
  .theme-control {
    grid-template-columns: 1fr;
  }
}

@media (forced-colors: active) {
  .theme-control,
  .status-summary,
  .service-card,
  .component-row,
  .fact-card,
  .deployment-row,
  .calendar-group,
  .timeline > li,
  #freshness li,
  .status-stale-banner {
    border: 1px solid CanvasText;
  }
}
