/*
 * The status page stylesheet.
 *
 * This is the whole design system, in one file, with no build step:
 *
 *   - The :root block holds every raw value — the light and dark palettes,
 *     the spacing, radius and type scales, and the border and focus widths.
 *   - The dark scheme is a single @media block that repoints the same
 *     semantic variables at the dark palette, so the two schemes cannot
 *     drift apart.
 *   - Every rule below the tokens uses var() only. There is not one raw
 *     colour or size outside :root.
 *
 * To rebrand the site, change --accent in :root. That single value drives
 * the link colour, the focus ring and the dark-mode accent alike.
 */

/* ------------------------------------------------------------------ */
/* Design tokens                                                       */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  /* Light palette. */
  --light-bg: #eef0f4;
  --light-surface: #ffffff;
  --light-text: #16181d;
  --light-text-muted: #4d5666;
  --light-border: #6f7788;
  --light-ok: #10633a;
  --light-ok-surface: #e7f6ec;
  --light-issue: #8a1c1c;
  --light-issue-surface: #fdeaea;
  --light-unknown: #6b5700;
  --light-unknown-surface: #fdf6dd;

  /* Dark palette. */
  --dark-bg: #14171c;
  --dark-surface: #1d2229;
  --dark-text: #eef1f5;
  --dark-text-muted: #b4bdc8;
  --dark-border: #9aa4b3;
  --dark-ok: #7fe0a8;
  --dark-ok-surface: #143524;
  --dark-issue: #ffa8a0;
  --dark-issue-surface: #3a1a1a;
  --dark-unknown: #f2d675;
  --dark-unknown-surface: #3a3116;

  /*
   * The accent, on its own. Links, the hover colour, the focus ring and
   * the dark-mode accent are all derived from this one value, so
   * rebranding is a single edit. The strong variant is the same hue
   * darkened, the dark variants are the same hue lightened so they keep
   * their contrast on the dark background. The flattened values come first
   * so a browser without color-mix still gets a readable accent.
   */
  --accent: #0b5cab;
  --accent-strong: #08417a;
  --accent-strong: color-mix(in srgb, var(--accent) 75%, black);
  --accent-dark: #689acb;
  --accent-dark-strong: #91b6d9;
  --accent-dark: color-mix(in srgb, var(--accent) 62%, white);
  --accent-dark-strong: color-mix(in srgb, var(--accent) 45%, white);

  /* Semantic colours — the names the rest of the stylesheet uses. */
  --color-bg: var(--light-bg);
  --color-surface: var(--light-surface);
  --color-text: var(--light-text);
  --color-text-muted: var(--light-text-muted);
  --color-border: var(--light-border);
  --color-accent: var(--accent);
  --color-accent-strong: var(--accent-strong);
  --color-focus: var(--accent);
  --color-ok: var(--light-ok);
  --color-ok-surface: var(--light-ok-surface);
  --color-issue: var(--light-issue);
  --color-issue-surface: var(--light-issue-surface);
  --color-unknown: var(--light-unknown);
  --color-unknown-surface: var(--light-unknown-surface);

  /* Spacing scale. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;

  /* Border-radius scale. */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-pill: 999px;

  /* Type scale. */
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-xs: 0.875rem;
  --font-size-sm: 0.9375rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: 2rem;
  --font-size-display: clamp(1.25rem, 1rem + 1.5vw, 2rem);
  --font-size-heading: clamp(1.05rem, 1rem + 0.4vw, 1.375rem);
  --line-height: 1.5;
  --line-height-tight: 1.25;

  /* Borders and focus. */
  --border-width: 1px;
  --stroke-width: 2px;
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;

  /* The status mark inside a badge. */
  --badge-mark-size: 0.75rem;
  --badge-mark-height: 0.6rem;
  --color-transparent: transparent;

  /* Layout. */
  --page-max-width: 68rem;
  --card-min-width: 18rem;
  --measure-max-width: 46rem;
  --page-padding-block: clamp(var(--space-4), 4vw, var(--space-7));
  --page-padding-inline: clamp(var(--space-3), 3vw, var(--space-4));
}

/* ------------------------------------------------------------------ */
/* Dark scheme — the same semantic variables, the dark palette.         */
/* ------------------------------------------------------------------ */

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: var(--dark-bg);
    --color-surface: var(--dark-surface);
    --color-text: var(--dark-text);
    --color-text-muted: var(--dark-text-muted);
    --color-border: var(--dark-border);
    --color-accent: var(--accent-dark);
    --color-accent-strong: var(--accent-dark-strong);
    --color-focus: var(--accent-dark);
    --color-ok: var(--dark-ok);
    --color-ok-surface: var(--dark-ok-surface);
    --color-issue: var(--dark-issue);
    --color-issue-surface: var(--dark-issue-surface);
    --color-unknown: var(--dark-unknown);
    --color-unknown-surface: var(--dark-unknown-surface);
  }
}

/* ------------------------------------------------------------------ */
/* Base                                                                 */
/* ------------------------------------------------------------------ */

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

body {
  margin: 0;
  padding: var(--page-padding-block) var(--page-padding-inline);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  line-height: var(--line-height);
  -webkit-text-size-adjust: 100%;
}

/*
 * The page is one grid: the headline, the banner and the footer span the
 * full width, and the three source cards flow into as many columns as the
 * viewport allows — three up on a wide screen, one up on a phone.
 */
main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--card-min-width)), 1fr));
  column-gap: var(--space-5);
  row-gap: var(--space-5);
  max-width: var(--page-max-width);
  margin: 0 auto;
}

h1,
.subtitle,
.fresh-banner,
.stale-banner,
footer {
  grid-column: 1 / -1;
}

h1 {
  margin: 0;
  font-size: var(--font-size-display);
  line-height: var(--line-height-tight);
}

h2 {
  margin: 0;
  font-size: var(--font-size-heading);
  line-height: var(--line-height-tight);
}

h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  line-height: var(--line-height-tight);
}

p {
  margin: 0;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

a:hover {
  color: var(--color-accent-strong);
}

/* Every interactive element gets a visible focus ring. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
}

.subtitle {
  color: var(--color-text-muted);
  max-width: var(--measure-max-width);
}

/* ------------------------------------------------------------------ */
/* Banners                                                              */
/* ------------------------------------------------------------------ */

.stale-banner,
.fresh-banner {
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid currentColor;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.fresh-banner {
  color: var(--color-ok);
  background: var(--color-ok-surface);
}

.stale-banner {
  color: var(--color-unknown);
  background: var(--color-unknown-surface);
}

/* ------------------------------------------------------------------ */
/* Source cards                                                         */
/* ------------------------------------------------------------------ */

.source {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.source-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

/*
 * The status is always spelled out in words, so colour is never the only
 * signal. The mark drawn next to the words is a second, non-colour cue:
 * a tick for ok, a bar for an issue, a dot for unknown. It is drawn with
 * borders rather than a font glyph, so it never depends on the reader
 * having a particular symbol font installed.
 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: var(--border-width) solid currentColor;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  display: inline-block;
  flex: none;
  width: var(--badge-mark-size);
  height: var(--badge-mark-size);
}

/* Ok: a tick, drawn from two borders. */
.badge-ok::before {
  box-sizing: border-box;
  width: calc(var(--badge-mark-size) * 0.55);
  height: calc(var(--badge-mark-size) * 0.3);
  border-left: var(--stroke-width) solid currentColor;
  border-bottom: var(--stroke-width) solid currentColor;
  transform: rotate(-45deg);
}

/* Issue: a solid triangle, the usual warning shape. */
.badge-issue::before {
  width: 0;
  height: 0;
  border-left: calc(var(--badge-mark-size) * 0.42) solid var(--color-transparent);
  border-right: calc(var(--badge-mark-size) * 0.42) solid var(--color-transparent);
  border-bottom: var(--badge-mark-height) solid currentColor;
}

/* Unknown: a hollow dot. */
.badge-unknown::before {
  width: calc(var(--badge-mark-size) * 0.7);
  height: calc(var(--badge-mark-size) * 0.7);
  border: var(--stroke-width) solid currentColor;
  border-radius: var(--radius-pill);
  background: var(--color-transparent);
}

.badge-ok {
  color: var(--color-ok);
  background: var(--color-ok-surface);
}

.badge-issue {
  color: var(--color-issue);
  background: var(--color-issue-surface);
}

.badge-unknown {
  color: var(--color-unknown);
  background: var(--color-unknown-surface);
}

/* ------------------------------------------------------------------ */
/* Items                                                                */
/* ------------------------------------------------------------------ */

.items {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
}

.item {
  padding: var(--space-4) 0;
  border-top: var(--border-width) solid var(--color-border);
}

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

.item-title {
  margin: 0 0 var(--space-1);
}

.item-status {
  margin: 0 0 var(--space-1);
  font-weight: 600;
}

.item-time {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.item-description {
  margin: var(--space-2) 0 0;
}

.item-link {
  margin: var(--space-2) 0 0;
  font-size: var(--font-size-sm);
}

.no-items {
  margin: var(--space-4) 0 0;
  color: var(--color-text-muted);
}

footer {
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ------------------------------------------------------------------ */
/* Motion                                                               */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
