/* design tokens: web/src/styles/tokens.css */

/* Plus for Things 3 design tokens: the one source for the site, the server
   pages (a byte-identical mirror in server/internal/web/assets/tokens.css,
   copied by `make tokens`) and the status page (Phase 5 reads this file at
   build time). Custom properties and @font-face only. The names are a
   contract: announce a rename in the PR. docs/design-system.md explains
   every token. Light mode only; the text colours meet WCAG AA on white and
   on --surface. */

/* Inter 4.1 variable (opsz 14-32, wght 400-700), latin subset, SIL OFL
   (web/public/fonts). The file name carries the version, so it can be
   cached for a year. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/inter-4.1-latin.woff2') format('woff2');
}

/* Arial (or Helvetica) scaled to Inter's width and vertical metrics, so
   text does not move when Inter arrives. */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('ArialMT'), local('Helvetica');
  size-adjust: 107.4%;
  ascent-override: 90.2%;
  descent-override: 22.48%;
  line-gap-override: 0%;
}

:root {
  /* Colour: blues. Text and buttons use --blue-600 and --blue-700;
     --blue (#3B82F6) is 3.7:1 on white, so it is for marks and
     decoration only, never for text. */
  --blue: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --blue-50: #F5F9FF;
  --blue-100: #DBEAFE;
  --blue-200: #BFDBFE;
  --blue-300: #93C5FD;

  /* Colour: surfaces, text, lines */
  --white: #FFFFFF;
  --surface: #EAF3FF;
  --ink: #0F172A;
  --muted: #475569;
  --line: #D6E0EC;
  --field: #8093AA;
  --red: #B91C1C;
  --red-line: #DC2626;

  /* Colour: status (Phase 5's status page). The dot and bar colours are
     for shapes; text uses the -text variants, which meet AA on --white,
     --blue-50 and --surface. */
  --status-ok: #16A34A;
  --status-degraded: #D97706;
  --status-down: #DC2626;
  --status-ok-text: #127234;
  --status-degraded-text: #A14B06;
  --status-down-text: #B91C1C;

  /* Colour: the sky behind hero and server pages */
  --sky-top: #F7FAFF;
  --sky-bottom: #DDE9FB;

  /* Type */
  --font-sans: 'Inter', 'Inter Fallback', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.3125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2.25rem;
  --text-3xl: 3rem;
  --text-4xl: 3.75rem;
  --text-h1: clamp(2rem, 1.5rem + 2vw, 3rem);
  --text-h2: clamp(1.625rem, 1.35rem + 1.1vw, 2.25rem);
  --text-display: clamp(2.25rem, 1.4rem + 3.4vw, 3.75rem);
  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.55;
  --leading-relaxed: 1.7;
  --tracking-display: -0.022em;
  --tracking-tight: -0.012em;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Space: an 8-point scale (--space-N is N x 8 px) */
  --space-half: 4px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;
  --space-16: 128px;

  /* Layout */
  --container: 1232px;
  --container-narrow: 760px;
  --measure: 68ch;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 64px;

  /* Shape */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 16px 40px rgba(37, 99, 235, 0.10);
  --shadow-lg: 0 2px 6px rgba(15, 23, 42, 0.05), 0 28px 64px rgba(37, 99, 235, 0.16);

  /* Motion: interface motion answers an action; the sky is the only
     ambient motion. Everything stops under prefers-reduced-motion. */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 400ms;
}

/*
 * The status page. Colours, radii and the font come from the design tokens
 * (Phase 4's tokens.css, prepended at build time); every var() carries the
 * token's value as a fallback, so a renamed token never breaks the page.
 * Text colours sit on white cards: the -text status colours pass WCAG AA
 * there (5:1), not on the blue surface.
 */

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

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

body {
  margin: 0;
  background: var(--surface, #eaf3ff);
  color: var(--ink, #0f172a);
  font: 400 1rem/1.6 var(--font-sans, Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

a {
  color: var(--primary, #2563eb);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--primary-hover, #1d4ed8);
}

a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--primary, #2563eb);
  outline-offset: 2px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

h2 {
  font-size: 1.25rem;
  margin: 2.5rem 0 1rem;
}

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted,
.empty {
  color: var(--muted, #475569);
}

/* Header and footer */

.top {
  padding: 1.5rem 0 0.25rem;
}

.top .wrap {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.brand {
  font-weight: 700;
  color: var(--ink, #0f172a);
  text-decoration: none;
}

a.brand:hover {
  color: var(--ink, #0f172a);
  text-decoration: underline;
}

.top__label {
  color: var(--muted, #475569);
}

main {
  padding-top: 0.75rem;
  padding-bottom: 3rem;
}

.foot {
  border-top: 1px solid var(--line, #d6e0ec);
  padding: 1.5rem 0 3rem;
  color: var(--muted, #475569);
  font-size: 0.9375rem;
}

.foot p {
  margin: 0.25rem 0;
}

/* Cards */

.summary,
.rows,
.banner {
  background: #fff;
  border: 1px solid var(--line, #d6e0ec);
  border-radius: var(--radius-lg, 16px);
}

/* The one line at the top */

.summary {
  margin-top: 1rem;
  padding: 1.25rem 1.5rem;
}

.summary h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: clamp(1.375rem, 4vw, 1.75rem);
}

.summary__checked {
  margin: 0.25rem 0 0 1.75rem;
  color: var(--muted, #475569);
}

/* Dots */

.dot {
  display: inline-block;
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--muted, #475569);
}

.summary .dot {
  width: 1rem;
  height: 1rem;
}

.dot--ok {
  background: var(--status-ok, #16a34a);
}

.dot--degraded {
  background: var(--status-degraded, #d97706);
}

.dot--down {
  background: var(--status-down, #dc2626);
}

.dot--maintenance {
  background: var(--primary, #2563eb);
}

.dot--unknown {
  background: transparent;
  border: 2px solid var(--muted, #475569);
}

/* Banner when the service can't be reached */

.banner {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  border-color: var(--status-down, #dc2626);
  border-left-width: 6px;
  border-radius: var(--radius, 12px);
}

.banner p {
  margin: 0.25rem 0 0;
}

.banner .banner__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--status-down-text, #b91c1c);
}

.note {
  margin: 1rem 0 0;
  color: var(--muted, #475569);
}

/* Component rows */

.rows {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.row + .row {
  border-top: 1px solid var(--line, #d6e0ec);
}

/* dot | name | state | chevron; the loading wait sits under the name. */
.row summary {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.125rem 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
}

.row summary::-webkit-details-marker {
  display: none;
}

.row summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 0.25rem 0.2rem 0.25rem;
  border-right: 2px solid var(--muted, #475569);
  border-bottom: 2px solid var(--muted, #475569);
  transform: rotate(45deg);
}

.row details[open] summary::after {
  margin-bottom: -0.2rem;
  transform: rotate(-135deg);
}

.row__name {
  font-weight: 600;
}

.row__state {
  font-weight: 600;
  text-align: right;
}

.row__extra {
  grid-row: 2;
  grid-column: 2 / -1;
  color: var(--muted, #475569);
  font-size: 0.875rem;
}

.state--ok {
  color: var(--status-ok-text, #15803d);
}

.state--degraded {
  color: var(--status-degraded-text, #b45309);
}

.state--down {
  color: var(--status-down-text, #b91c1c);
}

.state--maintenance {
  color: var(--primary, #2563eb);
}

.state--unknown {
  color: var(--muted, #475569);
}

.row__body {
  padding: 0 1.25rem 1.25rem 2.75rem;
}

.row__body p {
  margin: 0.5rem 0;
}

.row__message {
  font-weight: 600;
}

/* The 30-day bar: one cell per day, oldest first */

.bar {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 2px;
  height: 2rem;
  margin-top: 0.75rem;
}

.day {
  border-radius: 3px;
  background: var(--line, #d6e0ec);
}

.day--ok {
  background: var(--status-ok, #16a34a);
}

.day--degraded {
  background: var(--status-degraded, #d97706);
}

.day--down {
  background: var(--status-down, #dc2626);
}

.day--maintenance {
  background: var(--primary, #2563eb);
}

.bar__legend {
  display: flex;
  justify-content: space-between;
  margin: 0.25rem 0 0;
  color: var(--muted, #475569);
  font-size: 0.8125rem;
}

@media (max-width: 30rem) {
  .row__body {
    padding-left: 1.25rem;
  }

  .summary__checked {
    margin-left: 0;
  }
}

