/* Shared dark theme.
 *
 * One palette for every dark surface in the product. It is opt-in per page, so
 * a template only goes dark when it asks for it:
 *
 *   `.user-body--dark`  – public / site-user pages and the shared error page
 *   `.admin-body`       – the administrator panel and its sign-in page
 *
 * Nothing here restyles a component. tokens.css declares the palette, and
 * base.css, admin.css, table-browser.css, table-editor.css and records.css are
 * all written against those tokens, so redeclaring the tokens on the body
 * flips cards, fields, tables, alerts, dialogs and the panel chrome in one
 * place. The rules after the token block are only for the few places where a
 * token meaning "a pale tint" needs a readable foreground once the tint has
 * become translucent, or where a colour was written as a literal rather than
 * as a token.
 */

.user-body--dark,
.admin-body {
  color-scheme: dark;

  /* Surfaces: a midnight-navy canvas is the darkest layer, cards sit above it. */
  --color-background: #0a0e1c;
  --color-surface: #121831;
  --color-surface-muted: #0e1328;
  --color-surface-inverse: #eef0fb;

  /* Panel chrome: header and sidebar sit between the canvas and the cards. */
  --color-chrome: #0d1226;
  --color-chrome-raised: #182042;
  --color-chrome-border: rgba(148, 160, 220, 0.14);
  --color-chrome-text: #eef0fb;
  --color-chrome-text-muted: #a3abcb;

  /* Text */
  --color-text: #eef0fb;
  --color-text-muted: #a3abcb;
  --color-text-subtle: #7f88ab;
  --color-text-inverse: #0a0e1c;

  /* Lines and focus */
  --color-border: rgba(148, 160, 220, 0.14);
  --color-border-strong: rgba(148, 160, 220, 0.26);
  --color-focus-ring: var(--color-brand);

  /* The violet is lifted so it reads on navy; text on it turns dark. */
  --color-brand: #a594ff;
  --color-brand-hover: #bcafff;
  --color-brand-soft: rgba(165, 148, 255, 0.14);
  --color-brand-contrast: #120c33;
  --color-company: #eef0fb;

  /* Accents lightened until they carry their own weight on a dark surface. */
  --color-primary: #8ea2ff;
  --color-primary-hover: #a8b8ff;
  --color-primary-active: #c2ceff;
  --color-primary-contrast: #0a0e1c;
  --color-primary-soft: rgba(142, 162, 255, 0.16);
  --color-accent: #5ee0a0;

  --color-success: #5ee0a0;
  --color-success-soft: rgba(94, 224, 160, 0.14);
  --color-warning: #f0a83c;
  --color-warning-soft: rgba(240, 168, 60, 0.14);
  --color-error: #ff8080;
  --color-error-hover: #ff9a9a;
  --color-error-contrast: #0a0e1c;
  --color-error-soft: rgba(255, 128, 128, 0.14);
  --color-info: #8ea2ff;
  --color-info-soft: rgba(142, 162, 255, 0.16);

  /* Shadows read as depth against a dark page only when they are this deep. */
  --shadow-sm: 0 1px 2px rgba(2, 4, 14, 0.5);
  --shadow-md: 0 6px 16px -6px rgba(2, 4, 14, 0.7);
  --shadow-lg: 0 24px 48px -24px rgba(2, 4, 14, 0.9);
}

/* Chrome paints its own near-white box over an autofilled field, which would
   otherwise leave one light rectangle in the middle of a dark form. */
.user-body--dark .field__control:-webkit-autofill,
.user-body--dark .field__control:-webkit-autofill:hover,
.user-body--dark .field__control:-webkit-autofill:focus,
.admin-body .field__control:-webkit-autofill,
.admin-body .field__control:-webkit-autofill:hover,
.admin-body .field__control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-text);
  -webkit-box-shadow: 0 0 0 1000px var(--color-surface-muted) inset;
  caret-color: var(--color-text);
}

.user-body--dark .skip-link,
.admin-body .skip-link {
  background-color: var(--color-brand);
  color: var(--color-brand-contrast);
  font-weight: var(--font-weight-bold);
}
