/* Nomios web UI: tokens (the only place with raw values). Design system: docs/design/DESIGN_SYSTEM.md.
   The four stylesheets are linked in this order: tokens, base, shell, components. */

@layer tokens, base, shell, components, tasks, pages, modal, meetings, connection, search, viewing, confirm, planner, bell, server, knowledge, signin;

@layer tokens {
  :root {
    color-scheme: dark;

    /* --- Palette: Admetos (dark grey, dark blue), measured from the Admetos background. --- */
    --ink-950: #0a121d;
    --ink-900: #0f1b2a;
    --ink-800: #1b2838;
    --ink-700: #324154;
    --ink-100: #e9eef6;
    --ink-300: #b9c3d3;
    --ink-400: #a3afc2;
    --ice-300: #9cc4ff;
    --ice-500: #66a3e6;
    --ice-900: #0a1a33;

    /* --- Semantic colour. Text pairs are checked against the worst-case backdrop in tests. --- */
    --color-bg: var(--ink-950);
    --color-text: var(--ink-100);
    --color-text-muted: var(--ink-300);
    --color-text-subtle: var(--ink-400);
    --color-link: var(--ice-300);
    --color-accent: var(--ice-500);
    --color-accent-contrast: var(--ice-900);
    --color-focus: #ffffff;
    --color-border: rgb(255 255 255 / 0.12);
    --color-border-strong: rgb(255 255 255 / 0.32);
    --color-field-border: rgb(255 255 255 / 0.5); /* form controls need 3:1 (WCAG 1.4.11) */
    --color-hover: rgb(255 255 255 / 0.07);
    --color-field-bg: rgb(8 14 24 / 0.5);
    --color-sunken: rgb(8 14 24 / 0.35);
    --color-selection: rgb(102 163 230 / 0.4);
    --color-column: rgb(8 14 24 / 0.3); /* a board column: a calm well for the cards */

    /* Status colours: one meaning each, used the same way everywhere (pills, dots, charts). */
    --status-running: #7db4ff;
    --status-awaiting: #f2b84b;
    --status-succeeded: #4cc38a;
    --status-failed: #ff8f8f;
    --status-neutral: #a3afc2;
    --pill-alpha: 0.18; /* how strongly a status pill is tinted with its colour */

    /* The administrator's read-only view of a person (U31): a violet nothing else uses, solid so
       that it reads the same on any backdrop, and the one strong colour of the page. */
    --viewing-bg: #3a2766;
    --viewing-text: #f4efff;
    --viewing-edge: #b9a3ff;
    --viewing-button-bg: #f4efff;
    --viewing-button-text: #2b1b52;

    /* --- Glass. Three depths: panel, raised (cards on a panel), overlay (dialogs). --- */
    --backdrop-worst: #3f5576; /* lightest spot of the photo after the glass blur (#394d6b) plus margin */
    --backdrop-photo: "sha256:367ffc6ac6bc4584f90c0e30dd1425270dc3043f2cf436d4831344858d15d93b"; /* the file --backdrop-worst was measured on; a test checks it */
    --glass-bg: rgb(15 27 42 / 0.5);
    --glass-raised-bg: rgb(52 68 94 / 0.5);
    --glass-overlay-bg: rgb(12 21 33 / 0.84);
    --glass-blur: 28px;
    --glass-overlay-blur: 36px;
    --glass-saturate: 1.5;
    --glass-highlight: rgb(255 255 255 / 0.16);
    /* The confirm window and the notices (U52): the glass of the dialogs, but lighter on the page
       behind it. The text is read on this tint over the lightest backdrop (checked in a test). */
    --glass-confirm-bg: rgb(15 27 42 / 0.62);
    --glass-confirm-sheen: rgb(255 255 255 / 0.1); /* a faint light from the top left */
    --glass-confirm-highlight: rgb(255 255 255 / 0.3); /* the fine specular edge on top */
    --glass-confirm-blur: 22px;
    --glass-confirm-backdrop-blur: 12px; /* the page behind the window */
    --glass-confirm-solid: #1b2838;
    --glass-solid: #1b2838; /* the same surfaces without transparency */
    --glass-raised-solid: #2b3b52;
    --glass-overlay-solid: #121c2b;
    --scrim: rgb(5 8 14 / 0.45);

    /* Fixed data colours: one per client (Okabe-Ito, colour-blind safe). Do not retheme these. */
    --client-1: #e69f00;
    --client-2: #56b4e9;
    --client-3: #009e73;
    --client-4: #f0e442;
    --client-5: #0072b2;
    --client-6: #d55e00;
    --client-7: #cc79a7;
    --client-na: #9a9a9a;
    --chart-neutral: #7f8ea6;

    /* The page background: the Admetos photo over a gradient with the same tones, which shows
       while the photo loads or if it is missing. See docs/design/ASSETS.md. */
    --bg-image:
      url("/static/img/admetos-bg.webp"),
      radial-gradient(1400px 800px at 25% -15%, rgb(50 65 84 / 0.9), transparent 65%),
      linear-gradient(180deg, var(--ink-700) 0%, var(--ink-900) 55%, var(--ink-800) 100%);

    /* --- Spacing: a 4px 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-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* --- Type. System stacks until fonts are decided; ui-serif is New York on macOS. --- */
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: ui-serif, "New York", Georgia, serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;
    --leading-tight: 1.2;
    --leading-base: 1.5;
    --tracking-eyebrow: 0.1em;

    /* --- Shape. Nest radii: inner = outer minus padding. --- */
    --radius-xs: 0.375rem;
    --radius-sm: 0.625rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
    --radius-pill: 999px;
    --fab-size: 3.5rem; /* the floating "+" of the board; the notices stand above it */

    /* --- Depth. --- */
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.25);
    --shadow-2: 0 8px 24px -8px rgb(0 0 0 / 0.45);
    --shadow-glass: inset 0 1px 0 var(--glass-highlight), 0 12px 40px -12px rgb(0 0 0 / 0.55);
    --shadow-glass-confirm:
      inset 0 1px 0 var(--glass-confirm-highlight), inset 0 0 0 1px rgb(255 255 255 / 0.04),
      0 18px 48px -14px rgb(0 0 0 / 0.6);

    /* --- Motion: tactile, short, springy. All of it collapses under reduced motion. --- */
    --dur-fast: 140ms;
    --dur-base: 240ms;
    --dur-slow: 380ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --press-scale: 0.97;
    --lift: -1px;

    /* --- Layout. --- */
    --sidebar-w: 15rem;
    --content-max: 84rem;
    --shell-gap: var(--space-5);
    --z-sticky: 10;
    --z-overlay: 100;
  }

  @supports (transition-timing-function: linear(0, 1)) {
    :root {
      --ease-spring: linear(
        0,
        0.35 8%,
        0.8 17%,
        1.05 27%,
        1.09 35%,
        1.04 46%,
        0.99 60%,
        1.005 78%,
        1
      );
    }
  }

  @media (prefers-reduced-motion: reduce) {
    :root {
      --dur-fast: 0.01ms;
      --dur-base: 0.01ms;
      --dur-slow: 0.01ms;
      --press-scale: 1;
      --lift: 0px;
    }
  }

  /* The user asks for no transparency: glass becomes a solid, still readable surface. The system
     setting does it (below); so does the switch of the Settings page (U60), which marks the page
     with data-glass="solid" and sets exactly the same values. */
  :root[data-glass="solid"] {
    --glass-bg: var(--glass-solid);
    --glass-raised-bg: var(--glass-raised-solid);
    --glass-overlay-bg: var(--glass-overlay-solid);
    --glass-confirm-bg: var(--glass-confirm-solid);
    --glass-confirm-sheen: transparent;
    --glass-confirm-blur: 0px;
    --glass-confirm-backdrop-blur: 0px;
    --glass-blur: 0px;
    --glass-overlay-blur: 0px;
    --scrim: rgb(5 8 14 / 0.7);
  }

  /* The switch goes one step further than the system setting: no surface asks the graphics card to
     blur what is behind it at all (a blur of 0 px still costs a layer). Important in the first
     layer: it wins over every later one. */
  :root[data-glass="solid"] *,
  :root[data-glass="solid"] ::backdrop,
  :root[data-glass="solid"] *::backdrop {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  @media (prefers-reduced-transparency: reduce) {
    :root {
      --glass-bg: var(--glass-solid);
      --glass-raised-bg: var(--glass-raised-solid);
      --glass-overlay-bg: var(--glass-overlay-solid);
      --glass-confirm-bg: var(--glass-confirm-solid);
      --glass-confirm-sheen: transparent;
      --glass-confirm-blur: 0px;
      --glass-confirm-backdrop-blur: 0px;
      --glass-blur: 0px;
      --glass-overlay-blur: 0px;
      --scrim: rgb(5 8 14 / 0.7);
    }
  }
}
