/* The status page's stylesheet. It borrows the public site's look (site/src/styles/public.css): the white
   header bar with the wordmark, a card on a neutral ground, and the dark footer, with the same brand values.
   It is its own file because the page is served from another host with a CSP that allows nothing but this
   stylesheet and status.js, and it cannot load the site's. The brand values are copies of web/src/app/globals.css;
   the spacing steps are copies of common/src/spacing.ts, and spacing.spec.ts holds this file's in step. */
:root {
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-base: 16px;
  --space-md: 20px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;

  --brand: #4f9a35;
  --brand-dark: #2e6b22;
  --brand-wash: #edf4e9;
  --brand-text: #3f7c2b;
  --brand-ink: #0f172a;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;

  --column-max: 48em;
  --bar-h: 64px;

  /* The four states: text and the tint behind it. Each text colour is at least 4.5:1 on its tint and on white. */
  --ok: var(--brand-text);
  --ok-wash: var(--brand-wash);
  --warn: #8a5a00;
  --warn-wash: #fdf3dc;
  --bad: #b42318;
  --bad-wash: #fdecea;
  --unknown: #475467;
  --unknown-wash: #eef0f3;

  --ink: #1a1a1a;
  --muted: #555;
  --line: #e4e7ec;
  --day-none: #d0d5dd;
  --day-warn: #e0a100;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  /* The ground the mesh sits on, and what shows if it does not load: the site's near-neutral at hue 220. */
  background: #d5dae4;
}

/* The site's landing backdrop (web/public/hero-mesh-0.svg): one fixed, viewport-sized layer, cover-fitted. A fixed
   layer rather than background-attachment: fixed, which iOS Safari ignores. Behind the page's content, above the
   canvas: a negative z-index in the root stacking context paints exactly there. */
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('mesh.svg') center / cover no-repeat;
  content: '';
  pointer-events: none;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--bar-h);
}

/* The bar is full width; its contents sit on the card's edges, as on the site. */
.bar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar-h);
  padding: 0 max(var(--space-lg), calc((100% - var(--column-max)) / 2));
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.logo {
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  text-decoration: none;
}

.logo .dot {
  color: var(--brand);
}

.bar-label {
  color: var(--muted);
  font-size: 15px;
}

.skip {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: 1000;
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  background: #fff;
  color: var(--brand-dark);
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

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

main {
  flex: 1;
  padding: var(--space-xxl) var(--space-lg);
}

/* A skip target is focused by the jump, not by the reader: no ring on the whole page. */
main:focus {
  outline: none;
}

.card {
  max-width: var(--column-max);
  margin: 0 auto;
  padding: var(--space-xxl) var(--space-xl);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

h1 {
  margin: 0 0 var(--space-lg);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

/* The headline says the overall state: a tinted banner, a dot and the words. */
.headline {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0 0 var(--space-lg);
  padding: var(--space-base) var(--space-lg);
  border-radius: 8px;
  font-size: 20px;
  font-weight: 600;
}

.headline::before,
.state::before {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.headline-operational {
  background: var(--ok-wash);
  color: var(--ok);
}
.headline-degraded {
  background: var(--warn-wash);
  color: var(--warn);
}
.headline-outage {
  background: var(--bad-wash);
  color: var(--bad);
}
.headline-unknown {
  background: var(--unknown-wash);
  color: var(--unknown);
}

.stale {
  margin: 0 0 var(--space-lg);
  padding: var(--space-sm) var(--space-base);
  border-radius: 8px;
  background: var(--warn-wash);
  color: var(--warn);
  font-weight: 600;
}

.stale[hidden] {
  display: none;
}

.surfaces {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Name and how long it has been so on the left; the state, in words as well as colour, on the right. */
.surface {
  padding: var(--space-base) 0;
  border-top: 1px solid var(--line);
}

.surface:last-child {
  border-bottom: 1px solid var(--line);
}

/* The summary is the whole row, so the state and the uptime are there with the details closed. The native marker is
   replaced by a chevron that turns when it opens; the summary stays a real <summary>, so the keyboard and screen
   readers get open and close for free, and nothing needs a script. */
.surface-head {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'name state'
    'since state';
  gap: var(--space-xxs) var(--space-base);
  align-items: center;
  padding-right: var(--space-xl);
  cursor: pointer;
  list-style: none;
}

.surface-head::-webkit-details-marker {
  display: none;
}

.surface-head::after {
  position: absolute;
  top: 50%;
  right: var(--space-xxs);
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  content: '';
}

.surface-details[open] > .surface-head::after {
  transform: translateY(-30%) rotate(-135deg);
}

.surface-head:focus-visible {
  outline: 2px solid var(--brand-dark);
  outline-offset: 4px;
}

.name {
  grid-area: name;
  font-weight: 600;
}

.since {
  grid-area: since;
  color: var(--muted);
  font-size: 14px;
}

.state {
  display: flex;
  grid-area: state;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 600;
}

.state-operational {
  color: var(--ok);
}
.state-degraded {
  color: var(--warn);
}
.state-outage {
  color: var(--bad);
}
.state-unknown {
  color: var(--unknown);
}

/* Thirty squares, one per UTC day, oldest first. Colour is the state, but each square also carries its day and
   verdict as text (title, and a visually hidden span), so colour is never the only signal. */
.rows {
  margin-top: var(--space-base);
}

.row + .row {
  margin-top: var(--space-base);
}

.row-name {
  margin: 0 0 var(--space-xxs);
  font-size: 14px;
  font-weight: 600;
}

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

.day {
  height: 28px;
  border-radius: 2px;
  background: var(--day-none);
}

.day-operational {
  background: var(--brand);
}
.day-degraded {
  background: var(--day-warn);
}
.day-outage {
  background: var(--bad);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  margin: var(--space-xxs) 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.meta {
  margin: var(--space-lg) 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* One line: the copyright on the card's left edge, the links on its right. On a phone they stack and centre. */
.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-lg);
  padding: var(--space-lg) max(var(--space-lg), calc((100% - var(--column-max)) / 2));
  background: var(--brand-ink);
  color: rgba(255, 255, 255, 0.8);
}

/* The size is on the children, not on .foot: --column-max is in em, and on a 14px footer it would be a narrower column
   than the card's, so the footer's edges would sit inside it. */
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-lg);
  font-size: 14px;
}

.foot a {
  color: inherit;
  text-decoration: none;
}

.foot a:hover {
  color: #fff;
  text-decoration: underline;
}

.foot a:focus-visible {
  outline-color: #fff;
}

.copy {
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

@media (max-width: 599px) {
  .foot {
    flex-direction: column;
    text-align: center;
  }

  .foot-links {
    justify-content: center;
  }

  main {
    padding: var(--space-lg) var(--space-base);
  }

  .card {
    padding: var(--space-xl) var(--space-base);
  }

  .headline {
    font-size: 18px;
  }

  .days {
    gap: 1px;
  }

  .day {
    height: 24px;
  }
}
