/**
 * Surfaces: background colours that recolour everything inside them.
 *
 * The style guide's rule is that a container's background is reflected in the
 * components within it (buttons, accordion bars, links, separators). Any
 * element with [data-surface] paints its background and redefines these
 * custom properties; children only ever read the variables.
 *
 * - --surface-bg / --surface-fg: background and text colour.
 * - --control-bg / --control-fg: default buttons and closed accordion bars.
 * - --control-hover-bg / --control-hover-fg: hover state (gold).
 * - --link-color: inline links and chevron links.
 * - --rule-color: separators and divider lines.
 * - --focus-ring-color: keyboard focus outline. The outline is offset from the
 *   element, so it sits on the surface and must contrast with it (3:1+).
 */
:root,
[data-surface="white"] {
  --surface-bg: var(--dal-white);
  --surface-fg: var(--dal-black);
  --control-bg: var(--dal-gray);
  --control-fg: var(--dal-black);
  --control-hover-bg: var(--dal-gold);
  --control-hover-fg: var(--dal-black);
  --link-color: var(--dal-black);
  --rule-color: var(--dal-black);
  --focus-ring-color: var(--dal-black);
}

[data-surface="gray"] {
  --surface-bg: var(--dal-gray);
  --surface-fg: var(--dal-black);
  --control-bg: var(--dal-gray-dark);
  --control-fg: var(--dal-white);
  --control-hover-bg: var(--dal-gold);
  --control-hover-fg: var(--dal-black);
  --link-color: var(--dal-black);
  --rule-color: var(--dal-black);
  --focus-ring-color: var(--dal-black);
}

[data-surface="dark-gray"] {
  --surface-bg: var(--dal-gray-dark);
  --surface-fg: var(--dal-white);
  --control-bg: var(--dal-gray);
  --control-fg: var(--dal-black);
  --control-hover-bg: var(--dal-gold);
  --control-hover-fg: var(--dal-black);
  --link-color: var(--dal-white);
  --rule-color: var(--dal-white);
  --focus-ring-color: var(--dal-gold);
}

[data-surface="black"] {
  --surface-bg: var(--dal-black);
  --surface-fg: var(--dal-white);
  --control-bg: var(--dal-gray);
  --control-fg: var(--dal-black);
  --control-hover-bg: var(--dal-gold);
  --control-hover-fg: var(--dal-black);
  --link-color: var(--dal-white);
  --rule-color: var(--dal-white);
  --focus-ring-color: var(--dal-gold);
}

[data-surface="gold"] {
  --surface-bg: var(--dal-gold);
  --surface-fg: var(--dal-black);
  --control-bg: var(--dal-black);
  --control-fg: var(--dal-white);
  --control-hover-bg: var(--dal-white);
  --control-hover-fg: var(--dal-black);
  --link-color: var(--dal-black);
  --rule-color: var(--dal-black);
  --focus-ring-color: var(--dal-black);
}

[data-surface] {
  background-color: var(--surface-bg);
  color: var(--surface-fg);
}

/*
 * Stripes: siblings marked [data-stripe] take turns between the surface they
 * sit on and its neighbour (white and gray), counted among themselves. Rows
 * can be added, removed or left out without restyling the rest. Used by
 * striped Person cards and by Sections set to the Alternating background.
 */
[data-stripe] {
  background-color: var(--surface-bg);
  color: var(--surface-fg);
}

[data-stripe]:nth-child(even of [data-stripe]) {
  --surface-bg: var(--dal-gray);
  --surface-fg: var(--dal-black);
  --control-bg: var(--dal-gray-dark);
  --control-fg: var(--dal-white);
  --control-hover-bg: var(--dal-gold);
  --control-hover-fg: var(--dal-black);
  --link-color: var(--dal-black);
  --rule-color: var(--dal-black);
  --focus-ring-color: var(--dal-black);
}

/* On gray, the second of each pair is white. */
[data-surface="gray"] > [data-stripe]:nth-child(even of [data-stripe]),
[data-surface="gray"] > .section__inner > [data-stripe]:nth-child(even of [data-stripe]) {
  --surface-bg: var(--dal-white);
  --control-bg: var(--dal-gray);
  --control-fg: var(--dal-black);
}
