/* ==========================================================================
   wheelgap brand: the design tokens, header and footer every wheelgap site shares.

   Source: wheelgap/tracker site/brand.css (the tokens are the tracker home's, site/home.css).
   Copied unchanged to wheelgap/wheelgap.github.io brand.css, wheelgap/wheelgap docs/stylesheets/brand.css
   and wheelgap/wheels site/brand.css: change it here first, then copy it to the other three.

   Every rule is a class (wg-*) or a --wg-* custom property, so it sits on top of each site's own stylesheet
   without restyling its pages. The one exception is the base block after the tokens: a few element defaults
   (link underlines, heading wrapping, table figures, focus rings), inside :where() so a site's own rules win.
   Sizes are in px, not rem: the docs theme sets a larger root font size.
   Light and dark follow prefers-color-scheme. A page's own toggle can force either: data-theme="light|dark" on
   <html> (the tracker home), or Material for MkDocs' data-md-color-scheme="default|slate" (the docs).
   No scripts, no fonts or images from other hosts.
   ========================================================================== */

:root,
[data-md-color-scheme="default"] {
  color-scheme: light;
  --wg-navy: #1f4e79;
  --wg-navy-dark: #143654;
  --wg-navy-light: #2b689e;
  --wg-amber: #f2a900;
  --wg-amber-dark: #b45309;
  --wg-amber-light: #fef3c7;
  --wg-mark: #1f4e79; /* the logo's wheel; the gap is always --wg-amber */

  --wg-bg: #f8f9fa;
  --wg-surface: #ffffff;
  --wg-surface-alt: #f1f3f5;
  --wg-surface-hover: #e9ecef;
  --wg-text: #1a1f2c;
  --wg-muted: #596579;
  --wg-faint: #646f81; /* text: >= 4.5:1 on --wg-bg, --wg-surface and --wg-surface-alt (as is the dark value) */
  --wg-line: #e2e8f0;
  --wg-line-strong: #cbd5e1;
  --wg-accent: #1f4e79; /* links */
  --wg-focus: #1f4e79;

  /* Wheel status colours, >= 4.5:1 as text on --wg-surface and on their own -bg (the status pills). */
  --wg-wheel: #15803d;
  --wg-wheel-bg: #dcfce7;
  --wg-bundled: #0e7490;
  --wg-bundled-bg: #cffafe;
  --wg-source: #b45309;
  --wg-source-bg: #fef3c7;
  --wg-missing: #c22020;
  --wg-missing-bg: #fee2e2;
  --wg-unknown: #5b6b80;
  --wg-unknown-bg: #f1f5f9;
  --wg-bar-bg: #e2e8f0;

  --wg-radius-sm: 6px;
  --wg-radius: 10px;
  --wg-radius-lg: 14px;
  --wg-radius-full: 9999px;
  --wg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --wg-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --wg-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --wg-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --wg-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --wg-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --wg-width: 1240px; /* the header's and footer's content width */

  /* Reading text and tables, the same on every site. */
  --wg-text-size: 16px; /* body text */
  --wg-measure: 64ch; /* the longest line of running text (never a table, card or bar) */
  --wg-row-height: 40px; /* a one-line table row */
  --wg-underline-offset: 0.2em;
  --wg-underline-thickness: 1px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --wg-navy: #58a6ff;
    --wg-navy-dark: #388bfd;
    --wg-navy-light: #79b8ff;
    --wg-amber: #f59e0b;
    --wg-amber-dark: #d97706;
    --wg-amber-light: rgba(245, 158, 11, 0.15);
    --wg-mark: #8fb8de;

    --wg-bg: #0d1117;
    --wg-surface: #161b22;
    --wg-surface-alt: #1c2128;
    --wg-surface-hover: #262c36;
    --wg-text: #f0f6fc;
    --wg-muted: #8b949e;
    --wg-faint: #808891;
    --wg-line: #3d444d;
    --wg-line-strong: #525a65;
    --wg-accent: #58a6ff;
    --wg-focus: #58a6ff;

    --wg-wheel: #22c55e;
    --wg-wheel-bg: rgba(34, 197, 94, 0.15);
    --wg-bundled: #22d3ee;
    --wg-bundled-bg: rgba(34, 211, 238, 0.15);
    --wg-source: #f59e0b;
    --wg-source-bg: rgba(245, 158, 11, 0.15);
    --wg-missing: #f87171;
    --wg-missing-bg: rgba(248, 113, 113, 0.15);
    --wg-unknown: #94a3b8;
    --wg-unknown-bg: rgba(148, 163, 184, 0.15);
    --wg-bar-bg: #21262d;

    --wg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --wg-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --wg-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
    --wg-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.7);
  }
}

/* The same dark values, when a page's toggle asks for them whatever the system says. */
:root[data-theme="dark"],
[data-md-color-scheme="slate"] {
  color-scheme: dark;
  --wg-navy: #58a6ff;
  --wg-navy-dark: #388bfd;
  --wg-navy-light: #79b8ff;
  --wg-amber: #f59e0b;
  --wg-amber-dark: #d97706;
  --wg-amber-light: rgba(245, 158, 11, 0.15);
  --wg-mark: #8fb8de;

  --wg-bg: #0d1117;
  --wg-surface: #161b22;
  --wg-surface-alt: #1c2128;
  --wg-surface-hover: #262c36;
  --wg-text: #f0f6fc;
  --wg-muted: #8b949e;
  --wg-faint: #808891;
  --wg-line: #3d444d;
  --wg-line-strong: #525a65;
  --wg-accent: #58a6ff;
  --wg-focus: #58a6ff;

  --wg-wheel: #22c55e;
  --wg-wheel-bg: rgba(34, 197, 94, 0.15);
  --wg-bundled: #22d3ee;
  --wg-bundled-bg: rgba(34, 211, 238, 0.15);
  --wg-source: #f59e0b;
  --wg-source-bg: rgba(245, 158, 11, 0.15);
  --wg-missing: #f87171;
  --wg-missing-bg: rgba(248, 113, 113, 0.15);
  --wg-unknown: #94a3b8;
  --wg-unknown-bg: rgba(148, 163, 184, 0.15);
  --wg-bar-bg: #21262d;

  --wg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --wg-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --wg-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
  --wg-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.7);
}

/* --------------------------------------------------------------------------
   Base: element defaults every site shares, inside :where() so the elements add no specificity: (0,0,0), and
   (0,1,0) for the focus ring (its :focus-visible counts). A site's own rule for the same thing wins; these only fill
   the gaps.
   -------------------------------------------------------------------------- */

/* No sideways jump when a fold opens and the page starts to scroll (classic scrollbars only). */
html { scrollbar-gutter: stable; }

:where(a) {
  text-underline-offset: var(--wg-underline-offset);
  text-decoration-thickness: var(--wg-underline-thickness);
}
:where(h1, h2, h3) { text-wrap: balance; }
:where(p, li) { text-wrap: pretty; }
/* Figures line up digit for digit down a column. */
:where(table) { font-variant-numeric: tabular-nums; }
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--wg-focus);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Skip link: the first thing in <body>, shown when it has keyboard focus.
   -------------------------------------------------------------------------- */

.wg-skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 16px;
  border-radius: var(--wg-radius-sm);
  background: var(--wg-navy);
  color: var(--wg-surface);
  font: 600 15px/1.4 var(--wg-sans);
  text-decoration: none;
  transform: translateY(-200%);
}
.wg-skip:focus {
  transform: none;
  outline: 2px solid var(--wg-amber);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Header: <header class="wg-header"> with the logo, the menu button and the cross-site links, then (on the
   tracker) the section's own links in <nav class="wg-subnav">, which scrolls away with the page. The links are a
   popover (<nav id="wg-nav" class="wg-nav" popover>, opened by <button class="wg-menu-btn" popovertarget="wg-nav">):
   in the bar where they fit beside the logo, and behind the button on a phone. No script: the browser opens and
   closes it (Escape or a tap outside closes it). A browser without popovers shows the links in the bar as before.
   -------------------------------------------------------------------------- */

.wg-header {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0;
  padding: 0;
  background: var(--wg-surface);
  color: var(--wg-text);
  border-bottom: 1px solid var(--wg-line);
  box-shadow: var(--wg-shadow-sm);
  font: 15px/1.4 var(--wg-sans);
}

.wg-bar {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px 24px;
  max-width: var(--wg-width);
  height: 56px;
  margin: 0 auto;
  padding: 0 20px;
}

.wg-brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  color: var(--wg-text);
  font: 700 18px/1 var(--wg-sans);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.wg-brand:hover {
  color: var(--wg-text);
  text-decoration: none;
}
.wg-mark {
  display: block;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.wg-mark-wheel { fill: var(--wg-mark); }
.wg-mark-gap { fill: #f2a900; }

.wg-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0 22px;
  height: 100%;
  margin: 0 0 0 auto;
  padding: 0;
}
/* In the bar, the popover is an ordinary row of links (the browser's own popover box undone). */
.wg-nav[popover] {
  position: static;
  inset: auto;
  width: auto;
  height: 100%;
  overflow: visible;
  border: 0;
  background: none;
  color: inherit;
}

/* The menu button: only where the links don't fit beside the logo. */
.wg-menu-btn {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 -8px 0 auto;
  padding: 0;
  border: 0;
  border-radius: var(--wg-radius-sm);
  background: none;
  color: var(--wg-muted);
  cursor: pointer;
}
.wg-menu-btn:hover,
.wg-menu-btn:has(+ .wg-nav:popover-open) {
  background: var(--wg-surface-hover);
  color: var(--wg-text);
}
.wg-menu-btn svg {
  display: block;
  width: 22px;
  height: 22px;
}
/* The open menu's backdrop (shown below, only while the menu is open). */
.wg-menu-close { display: none; }
.wg-nav a {
  display: inline-flex;
  align-items: center;
  margin: 0;
  color: var(--wg-muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 -3px 0 transparent;
}
.wg-nav a:hover {
  color: var(--wg-text);
  text-decoration: none;
}
.wg-nav a[aria-current] {
  color: var(--wg-text);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--wg-amber);
}

.wg-subnav {
  margin: 0;
  padding: 0;
  background: var(--wg-surface);
  border-bottom: 1px solid var(--wg-line);
  font: 14px/1.4 var(--wg-sans);
}
.wg-subnav-inner {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  max-width: var(--wg-width);
  min-height: 44px;
  margin: 0 auto;
  padding: 4px 20px;
}
.wg-subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--wg-muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 -2px 0 transparent;
}
.wg-subnav a:hover {
  color: var(--wg-text);
  text-decoration: none;
}
.wg-subnav a[aria-current] {
  color: var(--wg-text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--wg-navy);
}
/* The row's links, in a box of their own: part of the row here, a one-row sideways scroller on a phone (below). */
.wg-subnav-links { display: contents; }
/* Page controls in the row (the tracker home's search and export), pushed to its end. */
.wg-subnav-end {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.wg-header a:focus-visible,
.wg-subnav a:focus-visible,
.wg-footer a:focus-visible {
  outline: 2px solid var(--wg-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* A sticky header hides what a #link scrolls to unless the page leaves room for it. */
html { scroll-padding-top: 72px; }

/* A phone: the header scrolls away with the page. Without popovers the links wrap onto their own rows under the
   logo; with them (below), the bar is one row and the links are behind the menu button. */
@media (max-width: 719px) {
  .wg-header { position: static; }
  html { scroll-padding-top: 0; }
  .wg-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px 8px;
  }
  .wg-nav {
    flex-basis: 100%;
    gap: 2px 18px;
    height: auto;
    margin: 0;
  }
  .wg-nav a {
    min-height: 34px;
    font-size: 15px;
  }
  .wg-subnav-inner {
    flex-wrap: nowrap;
    gap: 0 12px;
    padding: 2px 16px;
  }
  .wg-subnav-inner > * { flex-shrink: 0; }
  /* One row: the links scroll sideways (no scrollbar, a fade at the right edge) between the tracker home's search
     button and its export and theme buttons, which stay put. */
  .wg-subnav-links {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 0 18px;
    min-width: 0;
    padding-right: 24px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }
  .wg-subnav-links::-webkit-scrollbar { display: none; }
  .wg-subnav-links a:focus-visible { outline-offset: -2px; }
}

@supports selector(:popover-open) {
  @media (max-width: 719px) {
    .wg-bar {
      flex-wrap: nowrap;
      height: 56px;
      padding: 0 16px;
    }
    .wg-menu-btn { display: inline-flex; }
    .wg-nav[popover]:not(:popover-open) { display: none; }
  }

  /* The open menu: a panel under the header at its right edge, one 40px row a link. It can only be opened where
     the button shows, so it needs no breakpoint of its own. */
  .wg-nav[popover]:popover-open {
    position: absolute;
    inset: 56px 16px auto auto;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    width: min(240px, calc(100vw - 32px));
    height: auto;
    margin: 0;
    padding: 6px 0;
    overflow: auto;
    border: 1px solid var(--wg-line);
    border-radius: var(--wg-radius);
    background: var(--wg-surface);
    color: var(--wg-text);
    box-shadow: none;
    font: 15px/1.4 var(--wg-sans);
  }
  .wg-nav[popover]:popover-open a {
    min-height: 40px;
    padding: 0 16px;
    font-size: 15px;
    box-shadow: none;
  }
  .wg-nav[popover]:popover-open a:hover { background: var(--wg-surface-hover); }
  /* The current site, as in the bar: bold, in the text colour, with the yellow mark (down its side here). */
  .wg-nav[popover]:popover-open a[aria-current] { box-shadow: inset 3px 0 0 var(--wg-amber); }
  .wg-nav[popover]:popover-open a:focus-visible { outline-offset: -2px; }
  /* A tap outside the open menu's links lands on this transparent button over the whole window (under the links),
     which closes the menu (popovertargetaction="hide"), so the tap doesn't reach the page underneath. */
  .wg-nav[popover]:popover-open > .wg-menu-close {
    display: block;
    position: fixed;
    inset: 0;
    z-index: -1;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: default;
  }
}

/* --------------------------------------------------------------------------
   Footer: <footer class="wg-footer">, with the page's own lines (if any) first, then the same links as the
   header, the source and the licence.
   -------------------------------------------------------------------------- */

.wg-footer {
  margin: 56px 0 0;
  padding: 0;
  border-top: 1px solid var(--wg-line);
  background: transparent;
  color: var(--wg-muted);
  font: 14px/1.6 var(--wg-sans);
}
.wg-footer-inner {
  box-sizing: border-box;
  max-width: var(--wg-width);
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.wg-footer-inner > p {
  max-width: 80ch;
  margin: 0 0 16px;
}
.wg-footer a { color: var(--wg-muted); }
.wg-footer a:hover { color: var(--wg-text); }
.wg-footer .wg-footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  margin: 0;
  padding: 0;
}
.wg-footer .wg-footer-nav a {
  color: var(--wg-muted);
  text-decoration-line: none;
  white-space: nowrap;
}
.wg-footer .wg-footer-nav a:hover {
  color: var(--wg-text);
  text-decoration-line: underline;
}
.wg-footer .wg-footer-nav .wg-brand {
  gap: 8px;
  color: var(--wg-text);
  font-size: 15px;
}
.wg-footer .wg-footer-nav .wg-brand:hover { text-decoration: none; }
.wg-footer .wg-mark {
  width: 20px;
  height: 20px;
}
.wg-footer .wg-footer-meta {
  margin: 10px 0 0;
  color: var(--wg-muted);
  font-size: 13px;
}
.wg-footer .wg-footer-meta a { text-decoration-line: underline; }

@media (max-width: 719px) {
  .wg-footer-inner { padding: 20px 16px 32px; }
}

@media print {
  .wg-header, .wg-subnav, .wg-skip { position: static; box-shadow: none; }
  .wg-nav, .wg-subnav, .wg-menu-btn { display: none; }
}
