/* ============================================================================
   The semantic layer, and the bridge onto Material's variables.

   The design system scopes its roles to `[data-theme="light"|"dark"]`; Material
   switches `[data-md-color-scheme="default"|"slate"]` on <html>. Rather than
   carry both attributes, the roles are re-declared here under Material's
   selectors, with the system's own values. Light is `default` and is the scheme
   the site opens in - the system is dark-first, a help centre is not.

   Role values and their contrast reasoning come from the design system's
   colors.css; the two cases it does not cover are marked below.
   ========================================================================= */

[data-md-color-scheme="default"] {
  --c-canvas:          var(--ref-neutral-50);
  --c-surface:         var(--ref-neutral-0);
  --c-surface-subtle:  var(--ref-neutral-75);
  --c-surface-hover:   var(--ref-neutral-75);
  --c-ink:             var(--ref-neutral-975);
  --c-body:            var(--ref-neutral-700);
  --c-muted:           var(--ref-neutral-650);
  --c-line:            var(--ref-neutral-150);
  --c-accent-ink:      var(--ref-accent-600);
  --c-accent-ink-hover: var(--ref-accent-700);

  /* icon-circle tints, light: the three the design uses on the topic cards */
  --c-tint-1: var(--ref-accent-100);
  --c-tint-2: var(--ref-warm-100);
  --c-tint-3: var(--ref-green-100);
  --c-tint-ink: var(--ref-neutral-975);

  --c-elevation-1: 0 0 0 1px var(--ref-neutral-200);
  --c-elevation-2: 0 0 0 1px var(--ref-neutral-200), 0 4px 12px rgba(15, 16, 25, .08);
  --c-elevation-3: 0 0 0 1px var(--ref-neutral-200), 0 12px 32px rgba(15, 16, 25, .12);
}

[data-md-color-scheme="slate"] {
  --c-canvas:          var(--ref-neutral-975);
  --c-surface:         var(--ref-neutral-950);
  --c-surface-subtle:  var(--ref-neutral-900);
  --c-surface-hover:   var(--ref-neutral-850);
  --c-ink:             var(--ref-neutral-100);
  --c-body:            var(--ref-neutral-300);
  --c-muted:           var(--ref-neutral-400);
  --c-line:            var(--ref-neutral-825);
  --c-accent-ink:      var(--ref-accent-200);
  --c-accent-ink-hover: var(--ref-accent-100);

  /*
    Not from the design system: the board draws the light theme only, and the
    three tints it uses are light washes that disappear on a dark card. These
    are the system's own dark surfaces of the same three hues, with the glyph
    stepping up to the -200 inks so it keeps its 4.5:1 on them.
  */
  --c-tint-1: var(--ref-accent-900);
  --c-tint-2: var(--ref-warm-900);
  --c-tint-3: var(--ref-green-900);
  --c-tint-ink: var(--ref-neutral-100);

  --c-elevation-1: 0 0 0 1px var(--ref-neutral-750);
  --c-elevation-2: 0 0 0 1px var(--ref-neutral-750), 0 8px 24px rgba(0, 0, 0, .5);
  --c-elevation-3: 0 0 0 1px var(--ref-neutral-750), 0 16px 40px rgba(0, 0, 0, .5);
}

/*
  The accent flood is accent-600 in BOTH themes, and so are the roles drawn on
  it - a decision in the design system, not a coincidence. The hero is the only
  place in this site that uses them.
*/
:root {
  --c-flood:            var(--ref-accent-600);
  --c-on-flood-ink:     var(--ref-neutral-0);
  /*
    accent-200, which the board uses for the eyebrow, clears the contract by
    0.01 (4.51:1) at 11px. accent-100 is 5.7:1 and visually almost the same.
  */
  --c-on-flood-muted:   var(--ref-accent-100);
  --c-on-flood-surface: rgba(255, 255, 255, .16);
  --c-on-flood-border:  rgba(255, 255, 255, .28);
}

/* ------------------------------------------------- bridge onto Material ---- */

/*
  The attribute lives on <body>, and the theme's palette writes its own values
  with compound selectors - `[data-md-color-primary=indigo]:not([data-md-color-scheme=slate])`
  and friends, specificity (0,2,0). A bridge on the scheme attribute alone is
  (0,1,0): it tied with nothing and lost, which is why links in the dark scheme
  came out indigo while everything painted from --c-accent-ink stayed right.
  Naming all three attributes the theme emits puts this at (0,3,0), above
  anything the palette writes, in both schemes.
*/
[data-md-color-scheme="default"][data-md-color-primary][data-md-color-accent],
[data-md-color-scheme="slate"][data-md-color-primary][data-md-color-accent] {
  --md-default-bg-color:          var(--c-canvas);
  --md-default-fg-color:          var(--c-ink);
  --md-default-fg-color--light:   var(--c-body);
  --md-default-fg-color--lighter: var(--c-muted);
  --md-default-fg-color--lightest: var(--c-line);

  /*
    The brand fill, not the link ink: this paints the drawer's header band, and
    --c-accent-ink flips to a pale lavender in the dark scheme, which turned
    that band into an odd light purple. The flood is accent-600 in both schemes
    by the design system's own decision, and --md-primary-bg-color below is the
    ink that goes on it.
  */
  --md-primary-fg-color:          var(--c-flood);
  --md-primary-bg-color:          var(--ref-neutral-0);
  --md-accent-fg-color:           var(--c-accent-ink);

  --md-typeset-a-color:           var(--c-accent-ink);
  --md-typeset-mark-color:        var(--c-tint-1);

  --md-code-bg-color:             var(--c-surface-subtle);
  --md-code-fg-color:             var(--c-ink);

  --md-footer-bg-color:           var(--c-surface);
  --md-footer-bg-color--dark:     var(--c-surface);
  --md-footer-fg-color:           var(--c-ink);
  --md-footer-fg-color--light:    var(--c-muted);
  --md-footer-fg-color--lighter:  var(--c-muted);
}
