/* The Agentry theme for the developers site (developers.secureagentry.net).

   Redoc 3 is themed with CSS custom properties, one set for the light page
   and one for the dark one, and picks the scheme itself: the reader's stored
   choice (the sidebar's moon button), else prefers-color-scheme. Redoc writes
   its own defaults at `:root` and `:root.dark` from a style element it adds
   after this file, so both blocks below carry one more element in their
   selector to win on specificity rather than on order.

   Every colour is a token from agentry-web/app/globals.css §5, named in a
   trailing comment on the same line, spelled as the token's own name. The
   block's selector says which half of the palette it is: `html:root` is the light half and
   `html:root.dark` the dark half. scripts/theme-check.py reads every colour
   in this file, resolves the named token in that half against
   theme/manifest.json, and fails on a mismatch. A colour is spelled once per
   half, as the site's own token; every Redoc property below points at a
   token with var(), so no value is repeated and none can drift.

   The HTTP method badges are the one place Redoc spells colours as hex in
   rules instead of properties; the last block below sets them from tokens. */

/* Type: IBM Plex Sans / Plex Mono, the same four woff2 files the site and
   the docs serve, from this origin (fonts/ beside this file). */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/IBMPlexSans-var.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-italic.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexMono-400.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/IBMPlexMono-500.woff2") format("woff2");
}

body {
  margin: 0;
  padding: 0;
}

redoc {
  display: block;
}

/* The tokens and everything that does not depend on the half. */
html:root {
  color-scheme: light;

  --color-bg: #faf6ee; /* --color-bg */
  --color-fg: #231b12; /* --color-fg */
  --color-lead: #3d3328; /* --color-lead */
  --color-muted: #66584a; /* --color-muted */
  --color-border: #e6dccb; /* --color-border */
  --color-border-strong: #c4b59c; /* --color-border-strong */
  --color-surface: #f5efe4; /* --color-surface */
  --color-raised: #fffdf8; /* --color-raised */
  --color-accent: #0e7a63; /* --color-accent */
  --color-accent-hover: #0b6350; /* --color-accent-hover */
  --color-accent-fg: #ffffff; /* --color-accent-fg */
  --color-accent-soft: #eef0e7; /* --color-accent-soft */
  --color-warm: #8f4f22; /* --color-warm */
  --color-warm-soft: #f4ece2; /* --color-warm-soft */
  --color-sev-critical: #7f1d1d; /* --color-sev-critical */
  --color-sev-high: #b91c1c; /* --color-sev-high */
  --color-sev-high-bg: #f5e5dd; /* --color-sev-high-bg */
  --color-sev-medium: #9f4707; /* --color-sev-medium */
  --color-sev-low: #3f6b0c; /* --color-sev-low */
  --color-sev-info: #475569; /* --color-sev-info */
  --color-ok: #116f34; /* --color-ok */
  --hl-keyword: #7c2d92; /* --hl-keyword */
  --hl-string: #166534; /* --hl-string */
  --hl-comment: #5f6672; /* --hl-comment */
  --hl-number: #9f4707; /* --hl-number */
  --hl-name: #1e3a8a; /* --hl-name */
  --hl-type: #0f766e; /* --hl-type */
  --hl-error: #b91c1c; /* --hl-error */
}

html:root.dark {
  color-scheme: dark;

  --color-bg: #16110d; /* --color-bg */
  --color-fg: #ece4d8; /* --color-fg */
  --color-lead: #d6cbbb; /* --color-lead */
  --color-muted: #b3a48f; /* --color-muted */
  --color-border: #33291f; /* --color-border */
  --color-border-strong: #4d3f31; /* --color-border-strong */
  --color-surface: #201914; /* --color-surface */
  --color-raised: #241d17; /* --color-raised */
  --color-accent: #4fd1b0; /* --color-accent */
  --color-accent-hover: #74dfc4; /* --color-accent-hover */
  --color-accent-fg: #16110d; /* --color-accent-fg */
  --color-accent-soft: #1c241d; /* --color-accent-soft */
  --color-warm: #e2a86f; /* --color-warm */
  --color-warm-soft: #261d15; /* --color-warm-soft */
  --color-sev-critical: #fca5a5; /* --color-sev-critical */
  --color-sev-high: #f87171; /* --color-sev-high */
  --color-sev-high-bg: #3a201d; /* --color-sev-high-bg */
  --color-sev-medium: #fbbf24; /* --color-sev-medium */
  --color-sev-low: #a3e635; /* --color-sev-low */
  --color-sev-info: #94a3b8; /* --color-sev-info */
  --color-ok: #4ade80; /* --color-ok */
  --hl-keyword: #d8b4fe; /* --hl-keyword */
  --hl-string: #86efac; /* --hl-string */
  --hl-comment: #9ca3af; /* --hl-comment */
  --hl-number: #fbbf24; /* --hl-number */
  --hl-name: #93c5fd; /* --hl-name */
  --hl-type: #5eead4; /* --hl-type */
  --hl-error: #fca5a5; /* --hl-error */
}

/* Redoc's properties, from the tokens above. Both halves share these rules:
   the tokens change under them. */
html:root,
html:root.dark {
  /* The site's stacks, from globals.css --font-sans and --font-mono with the
     Next font variable replaced by the family the @font-face blocks above
     declare. */
  --font-family-base: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  --font-family-monospaced: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, "Liberation Mono", monospace;

  /* Neutral ramp. Redoc builds every grey from eleven steps, lightest first
     in the light page and darkest first in the dark one; each step is the
     nearest token, so a hover, a divider or a disabled label lands on the
     site's own colours. */
  --color-warm-grey-1: var(--color-raised);
  --color-warm-grey-2: var(--color-surface);
  --color-warm-grey-3: var(--color-border);
  --color-warm-grey-4: var(--color-border-strong);
  --color-warm-grey-5: var(--color-border-strong);
  --color-warm-grey-6: var(--color-muted);
  --color-warm-grey-7: var(--color-muted);
  --color-warm-grey-8: var(--color-muted);
  --color-warm-grey-9: var(--color-lead);
  --color-warm-grey-10: var(--color-fg);
  --color-warm-grey-11: var(--color-fg);

  /* The page, and the layers on it. */
  --bg-color: var(--color-bg);
  --bg-color-raised: var(--color-raised);
  --bg-color-tonal: var(--color-surface);
  --layer-color: var(--color-surface);
  --sidebar-bg-color: var(--color-surface);
  --sidebar-text-color: var(--color-fg);
  --panel-samples-bg-color: var(--color-surface);
  --panel-samples-body-bg-color: var(--color-surface);
  --panel-samples-heading-bg-color: var(--color-surface);
  --code-block-bg-color: var(--color-surface);
  --text-color-primary: var(--color-fg);
  --text-color-secondary: var(--color-muted);
  --text-color-description: var(--color-muted);
  --bg-color-hover: var(--color-surface);
  --bg-color-active: var(--color-border);
  --tree-bg-color-hover: var(--color-border);
  --tree-bg-color-active: var(--color-border);
  --tree-content-color-hover: var(--color-fg);
  --border-color-primary: var(--color-border-strong);
  --border-color-secondary: var(--color-border);

  /* The action colour. */
  --color-primary-base: var(--color-accent);
  --color-primary-hover: var(--color-accent-hover);
  --color-primary-active: var(--color-accent-hover);
  --color-primary-bg: var(--color-accent-soft);
  --color-primary-bg-hover: var(--color-accent-soft);
  --color-primary-border: var(--color-border-strong);
  --color-primary-border-hover: var(--color-accent);
  --color-primary-text: var(--color-accent);
  --color-primary-text-hover: var(--color-accent-hover);
  --color-primary-text-active: var(--color-accent-hover);
  --text-color-on-color: var(--color-accent-fg);
  --link-color-primary-palette: var(--color-accent);

  /* Status colours: the severity tokens. */
  --color-success-base: var(--color-ok);
  --color-success-active: var(--color-ok);
  --color-success-text: var(--color-ok);
  --color-success-bg: color-mix(in srgb, var(--color-ok) 12%, transparent);
  --color-success-border: color-mix(in srgb, var(--color-ok) 40%, transparent);
  --color-warning-base: var(--color-sev-medium);
  --color-warning-active: var(--color-sev-medium);
  --color-warning-text: var(--color-sev-medium);
  --color-warning-bg: color-mix(in srgb, var(--color-sev-medium) 12%, transparent);
  --color-warning-border: color-mix(in srgb, var(--color-sev-medium) 40%, transparent);
  --color-error-base: var(--color-sev-high);
  --color-error-active: var(--color-sev-high);
  --color-error-text: var(--color-sev-high);
  --color-error-bg: var(--color-sev-high-bg);
  --color-error-border: color-mix(in srgb, var(--color-sev-high) 40%, transparent);
  --color-info-base: var(--color-sev-info);
  --color-info-active: var(--color-sev-info);
  --color-info-text: var(--color-sev-info);
  --color-info-bg: color-mix(in srgb, var(--color-sev-info) 12%, transparent);
  --color-info-border: color-mix(in srgb, var(--color-sev-info) 40%, transparent);
  --schema-required-color: var(--color-sev-high);

  /* Code: the site's highlight tokens. */
  --code-block-text-color: var(--color-fg);
  --code-block-tokens-default-color: var(--color-fg);
  --code-block-tokens-comment-color: var(--hl-comment);
  --code-block-tokens-keyword-color: var(--hl-keyword);
  --code-block-tokens-string-color: var(--hl-string);
  --code-block-tokens-number-color: var(--hl-number);
  --code-block-tokens-boolean-color: var(--hl-keyword);
  --code-block-tokens-property-color: var(--hl-name);
  --code-block-tokens-property-string-color: var(--hl-string);
  --code-block-tokens-operator-color: var(--color-fg);
  --code-block-tokens-function-color: var(--hl-name);
  --code-block-tokens-class-name-color: var(--hl-type);
  --code-block-tokens-link-color: var(--hl-name);
  --code-block-tokens-invalid-color: var(--hl-error);
  --inline-code-text-color: var(--color-fg);
  --inline-code-bg-color: var(--color-surface);
  --schema-inline-code-text-color: var(--color-muted);
}

/* The HTTP method badges: Redoc spells each verb's colours as hex in its own
   `.tag-<verb>` rules, in both halves. Each verb takes a token that reads at
   4.5:1 or better on its own tint, and the tint is that token over the page. The dark half's rules are
   `:root.dark .tag-<verb>`, so these carry `:root` twice to outrank them. */
html:root:root .tag-get,
html:root:root .tag-query {
  --tag-color: var(--color-ok);
}

html:root:root .tag-post {
  --tag-color: var(--hl-name);
}

html:root:root .tag-put {
  --tag-color: var(--color-sev-medium);
}

html:root:root .tag-patch {
  --tag-color: var(--hl-keyword);
}

html:root:root .tag-delete {
  --tag-color: var(--color-sev-high);
}

html:root:root .tag-head {
  --tag-color: var(--hl-type);
}

html:root:root .tag-http-additional-operation {
  --tag-color: var(--color-warm);
}

html:root:root .tag-get,
html:root:root .tag-query,
html:root:root .tag-post,
html:root:root .tag-put,
html:root:root .tag-patch,
html:root:root .tag-delete,
html:root:root .tag-head,
html:root:root .tag-http-additional-operation {
  --tag-bg-color: color-mix(in srgb, var(--tag-color) 12%, transparent);
  --tag-bg-color-hover: color-mix(in srgb, var(--tag-color) 20%, transparent);
}
