@layer reset, tokens, base, layout, components, pages;

/* Design tokens. Every colour, size, radius, shadow and duration the site uses is defined here, so a component never
   holds a raw value. These are the neutral defaults every association starts from; an association's own look is set
   by its primary colour (the --brand values on <html>) and, optionally, a theme file that overrides the palette
   tokens below (see Organization settings, "theme"). */
@layer tokens {
  :root {
    color-scheme: light dark;

    --brand: #1a5fb4;
    --brand-text: #ffffff;

    /* Palette. Names say what a colour is for, not what it looks like. */
    --color-ink: light-dark(#1b2733, #e8edf2);
    --color-ink-soft: light-dark(#3b4a58, #bcc7d1);
    --color-muted: light-dark(#4d5b69, #9eacb9);
    --color-bg: light-dark(#fbfaf7, #11171d);
    --color-surface: light-dark(#ffffff, #19212a);
    --color-surface-sunken: light-dark(#f2f4f6, #141b22);
    --color-band: light-dark(#e6edf3, #172431);
    --color-tint: light-dark(#e9f1f8, #1d2d3d);
    --color-band-ink: light-dark(#1b2733, #0b1015);
    --color-on-ink: #ffffff;
    --color-border: light-dark(#dde3e8, #2b3744);
    --color-border-strong: light-dark(#c5ced6, #3d4c5b);
    /* Footer: a dark band with light text in both themes (the text colours are fixed, only the band follows the theme). */
    --footer-bg: light-dark(#1b2733, #0d1318);
    --footer-text: rgb(255 255 255 / 0.88);
    --footer-text-soft: rgb(255 255 255 / 0.72);
    --footer-text-muted: rgb(255 255 255 / 0.62);
    --footer-line: rgb(255 255 255 / 0.14);
    --footer-chip: rgb(255 255 255 / 0.12);
    --footer-chip-hover: rgb(255 255 255 / 0.22);
    --color-primary: light-dark(var(--brand), color-mix(in oklab, var(--brand) 65%, white));
    --color-primary-hover: color-mix(in oklab, var(--color-primary) 82%, black);
    --color-on-primary: light-dark(var(--brand-text), #0b0d10);
    --color-sun: #f6c445;
    --color-sun-soft: light-dark(#fff0c2, #4a3b0f);
    --color-celeste: #74acdf;

    /* Roles the existing pages already use. */
    --color-text: var(--color-ink);
    --color-link: light-dark(color-mix(in oklab, var(--brand) 88%, black), color-mix(in oklab, var(--brand) 55%, white));
    --color-accent: var(--color-primary);
    --color-accent-text: var(--color-on-primary);
    --color-focus: light-dark(#0b57d0, #8ab4f8);
    --color-danger: light-dark(#b3261e, #f2b8b5);
    --color-danger-bg: light-dark(#fce8e6, #4a1f1c);
    --color-success: light-dark(#146c2e, #a8dab5);
    --color-success-bg: light-dark(#e6f4ea, #17341f);
    --color-info: light-dark(#1b4f8f, #aecbfa);
    --color-info-bg: light-dark(#e8f0fe, #1a2b45);

    /* Space */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2.5rem;
    --space-7: 4rem;
    --space-8: 6rem;

    /* Shape */
    --radius: 0.625rem;
    --radius-md: 1rem;
    --radius-card: 1.25rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --shape-blob: 48% 52% 40% 60% / 55% 45% 55% 45%;
    --shape-blob-image: 44% 56% 42% 58% / 52% 48% 52% 48%;
    --radius-pill: 999px;
    --shadow-card: 0 1px 3px color-mix(in oklab, var(--color-ink) 15%, transparent);
    --shadow-raised: 0 12px 32px color-mix(in oklab, var(--color-ink) 16%, transparent);
    --shadow-float: 0 24px 48px color-mix(in oklab, var(--color-ink) 18%, transparent);
    --shadow-ring: 0 0 0 8px color-mix(in oklab, var(--color-primary) 22%, transparent);

    /* Type */
    --font-body: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "DM Sans Variable", "DM Sans", var(--font-body);
    --font-sans: var(--font-body);
    --font-size: 1rem;
    --line-height: 1.55;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1.125rem;
    --text-lg: 1.375rem;
    --text-xl: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem);
    --text-2xl: clamp(2rem, 1.4rem + 2.2vw, 3rem);
    --text-hero: clamp(2.4rem, 1.4rem + 4vw, 4rem);
    --text-display: clamp(2.75rem, 1.2rem + 5.4vw, 5.25rem);
    --text-3xl: clamp(2.1rem, 1.2rem + 3.4vw, 3.5rem);
    --tracking-tight: -0.04em;
    --tracking-eyebrow: 0.08em;

    /* Widths */
    --content-width: 75rem;
    --text-width: 42rem;
    --narrow-width: 48rem;

    /* Motion */
    --duration-fast: 0.15s;
    --duration: 0.25s;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  /* The appearance switcher sets data-theme to force one scheme; without it the page follows the system. */
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }

  /* Fallback for browsers without light-dark(): follow the system preference with raw values. */
  @supports not (color: light-dark(white, black)) {
    :root {
      --color-ink: #1b2733;
      --color-ink-soft: #3b4a58;
      --color-muted: #4d5b69;
      --color-bg: #fbfaf7;
      --color-surface: #ffffff;
      --color-surface-sunken: #f2f4f6;
      --color-band: #e6edf3;
      --color-tint: #e9f1f8;
      --color-band-ink: #1b2733;
      --color-border: #dde3e8;
      --color-border-strong: #c5ced6;
      --color-primary: var(--brand);
      --color-on-primary: var(--brand-text);
      --color-sun-soft: #fff0c2;
      --color-link: #174a8c;
      --color-focus: #0b57d0;
      --color-danger: #b3261e;
      --color-danger-bg: #fce8e6;
      --color-success: #146c2e;
      --color-success-bg: #e6f4ea;
      --color-info: #1b4f8f;
      --color-info-bg: #e8f0fe;
    }
    @media (prefers-color-scheme: dark) {
      :root {
        --color-ink: #e8edf2;
        --color-ink-soft: #bcc7d1;
        --color-muted: #9eacb9;
        --color-bg: #11171d;
        --color-surface: #19212a;
        --color-surface-sunken: #141b22;
        --color-band: #172431;
        --color-tint: #1d2d3d;
        --color-band-ink: #0b1015;
        --color-border: #2b3744;
        --color-border-strong: #3d4c5b;
        --color-sun-soft: #4a3b0f;
        --color-link: #8ab4f8;
        --color-focus: #8ab4f8;
        --color-danger: #f2b8b5;
        --color-danger-bg: #4a1f1c;
        --color-success: #a8dab5;
        --color-success-bg: #17341f;
        --color-info: #aecbfa;
        --color-info-bg: #1a2b45;
      }
    }
  }
}
