/*
  Shared design tokens and primitives. Every page links this file first.

  The palette is one watch dial at two times of day. Light mode is a silvered dial in
  daylight with blued-steel hands (--accent). Dark mode is the same dial at night, when
  the only thing you can see is the lume (--accent turns lume green).

  Contract for other pages (light and dark are both defined):
    --bg --surface --text --muted --accent --accent-contrast --border --radius
    --font-sans --font-display

  The product name is written once, as the two tokens below: --agent-name is what
  people call it in a sentence, --agent-full-name is how it is introduced (masthead,
  page title, footer). Markup says <span data-agent-name></span> or
  <span data-agent-full-name></span> wherever a name belongs; CSS shows the token at
  first paint and assets/brand.js then writes it in as real text (and prefers the
  names /api/health reports).
*/

:root {
  --agent-name: "Stuffy";
  --agent-full-name: "Stuffy Stufferton";

  color-scheme: light dark;

  /* Type. System faces only: nothing is fetched from a font CDN.
     Display is the DIN family, the lettering of gauges and tool-watch dials: DIN
     Alternate on Apple devices, Bahnschrift on Windows, Roboto Condensed on Android. */
  --font-display: "DIN Alternate", Bahnschrift, "Roboto Condensed", sans-serif-condensed, "Avenir Next Condensed",
    "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-sans: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue",
    Arial, sans-serif;

  /* Day: silvered dial, printed ink, blued steel. */
  --day-bg: #e9eceb;
  --day-surface: #f8f9f8;
  --day-sunken: #dfe4e3;
  --day-text: #121821;
  --day-muted: #55606c;
  --day-accent: #23408f;
  --day-accent-strong: #1a3172;
  --day-accent-contrast: #ffffff;
  --day-accent-wash: #e3e8f4;
  --day-border: #c9d0d0;
  --day-rule: #a9b2b5;
  --day-field-border: #78838c;
  --day-signal: #b4321a;
  --day-ok: #1f6b4a;

  /* Night: midnight dial, lume. */
  --night-bg: #101822;
  --night-surface: #18222e;
  --night-sunken: #0b1219;
  --night-text: #e7ecef;
  --night-muted: #9aa6b2;
  --night-accent: #a5ebcb;
  --night-accent-strong: #c6f6e0;
  --night-accent-contrast: #0a2018;
  --night-accent-wash: #1b3a36;
  --night-border: #2b3848;
  --night-rule: #3d4b5c;
  --night-field-border: #647488;
  --night-signal: #ff9076;
  --night-ok: #a5ebcb;

  --bg: var(--day-bg);
  --surface: var(--day-surface);
  --sunken: var(--day-sunken);
  --text: var(--day-text);
  --muted: var(--day-muted);
  --accent: var(--day-accent);
  --accent-strong: var(--day-accent-strong);
  --accent-contrast: var(--day-accent-contrast);
  --accent-wash: var(--day-accent-wash);
  --border: var(--day-border);
  --rule: var(--day-rule);
  /* The edge of anything you can type in or tick: 3:1 against its surroundings. */
  --field-border: var(--day-field-border);
  --signal: var(--day-signal);
  --ok: var(--day-ok);
  --glow: 0 0 0 0 transparent;
  --shadow-panel: 0 1px 0 #ffffff inset, 0 24px 48px -28px rgb(18 24 33 / 45%);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --gutter: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--night-bg);
    --surface: var(--night-surface);
    --sunken: var(--night-sunken);
    --text: var(--night-text);
    --muted: var(--night-muted);
    --accent: var(--night-accent);
    --accent-strong: var(--night-accent-strong);
    --accent-contrast: var(--night-accent-contrast);
    --accent-wash: var(--night-accent-wash);
    --border: var(--night-border);
    --rule: var(--night-rule);
    --field-border: var(--night-field-border);
    --signal: var(--night-signal);
    --ok: var(--night-ok);
    /* Lume glows. Used on the primary action only. */
    --glow: 0 0 24px -4px rgb(165 235 203 / 45%);
    --shadow-panel: 0 1px 0 rgb(255 255 255 / 4%) inset;
  }
}

@media (min-width: 720px) {
  :root {
    --gutter: 32px;
  }
}

/* A section that is always shown at night, whatever the page scheme. */
.night {
  --bg: var(--night-bg);
  --surface: var(--night-surface);
  --sunken: var(--night-sunken);
  --text: var(--night-text);
  --muted: var(--night-muted);
  --accent: var(--night-accent);
  --accent-strong: var(--night-accent-strong);
  --accent-contrast: var(--night-accent-contrast);
  --accent-wash: var(--night-accent-wash);
  --border: var(--night-border);
  --rule: var(--night-rule);
  --field-border: var(--night-field-border);
  --signal: var(--night-signal);
  --ok: var(--night-ok);
  background: var(--bg);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  .night {
    --bg: var(--night-sunken);
  }
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.005em;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-strong);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

[hidden] {
  display: none !important;
}

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

[data-agent-name]:empty::before {
  content: var(--agent-name);
}

[data-agent-full-name]:empty::before {
  content: var(--agent-full-name);
}

.wrap {
  width: min(100% - 2 * var(--gutter), 1120px);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
  color: var(--accent-contrast);
}

/* The railroad minute track from the edge of a dial, used as a rule. Every fifth tick
   is heavier, as on a watch. */
.track {
  --major-tick-spacing: 40px;
  height: 9px;
  border: solid var(--rule);
  border-width: 1px 0;
  background:
    repeating-linear-gradient(90deg, var(--muted) 0 2px, transparent 2px var(--major-tick-spacing)),
    repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px calc(var(--major-tick-spacing) / 5));
}

/* Primitives */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--glow);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.button:hover {
  background: var(--accent-strong);
  color: var(--accent-contrast);
}

.button:active {
  transform: translateY(1px);
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.45;
  box-shadow: none;
  cursor: not-allowed;
}

.button--quiet {
  min-height: 0;
  padding: 0;
  background: none;
  box-shadow: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.button--quiet:hover {
  background: none;
  color: var(--accent-strong);
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 600;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  /* 16px or more, or iOS zooms the page when the field takes focus. */
  font: inherit;
  font-size: 1.0625rem;
  font-variant-numeric: tabular-nums lining-nums;
}

.input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.input[aria-invalid="true"] {
  border-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal);
}

.hint {
  color: var(--muted);
  font-size: 0.9375rem;
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  font-size: 0.9375rem;
  line-height: 1.5;
  cursor: pointer;
}

.check input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}

.tag--on {
  border-color: transparent;
  background: var(--accent-wash);
  color: var(--text);
}

.error-text {
  color: var(--signal);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
