/* The project's look, which the dashboard set first and every surface now takes
 * from one file: neutral greys in four steps and one line colour, the accent
 * only on what can be acted on or is selected, and the system's own fonts.
 * The values are not set here. stylesheets/tokens.css is the dashboard's
 * cpersona/dashboard/static/tokens.css, added to the build by
 * scripts/docs_tokens.py and loaded before this file; this file maps the
 * theme's variables onto its names. Both schemes come out of the same mapping,
 * because tokens.css switches its values on the scheme attribute the theme puts
 * on <body>. tests/test_design_tokens.py checks that no colour is written here
 * directly, and the contrast of each text colour on the page.
 *
 * The header and the footer sit on the recessed step, as the dashboard's strip
 * and side panel do, with one line between them and the page; the page is the
 * base step; cards are raised; code sits on the recessed step.
 */
:root {
  --md-text-font: var(--font-sans);
}

:root > * {
  --md-primary-fg-color: var(--recessed);
  --md-primary-fg-color--light: var(--recessed);
  --md-primary-fg-color--dark: var(--recessed);
  --md-primary-bg-color: var(--text);
  --md-primary-bg-color--light: var(--muted);
  --md-accent-fg-color: var(--accent);
  --md-accent-fg-color--transparent: var(--accent-soft);
  --md-accent-bg-color: var(--on-accent);
  --md-default-bg-color: var(--base);
  --md-default-fg-color: var(--text);
  --md-default-fg-color--light: var(--muted);
  --md-default-fg-color--lighter: var(--faint);
  --md-default-fg-color--lightest: var(--line);
  --md-typeset-color: var(--text);
  --md-typeset-a-color: var(--accent);
  --md-code-bg-color: var(--recessed);
  --md-code-fg-color: var(--text);
  --md-footer-bg-color: var(--recessed);
  --md-footer-bg-color--dark: var(--recessed);
  --md-footer-fg-color: var(--text);
  --md-footer-fg-color--light: var(--muted);
  --md-footer-fg-color--lighter: var(--faint);
}

/* One line under the header instead of the theme's shadow, and one over the footer. */
.md-header,
.md-header--shadow {
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}
.md-footer,
.md-footer-meta {
  border-top: 1px solid var(--line);
}

/* The theme darkens the search field against the header colour, which on the
 * recessed step leaves almost no field; draw it as a raised field with a line. */
@media screen and (min-width: 60em) {
  .md-search__input,
  .md-search__input:hover {
    background-color: var(--raised);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  .md-search__input::placeholder,
  .md-search__icon {
    color: var(--faint);
  }
}

/* On a phone the header holds the menu, the name, the colour scheme, the
 * version, the language and search. At the theme's spacing the name was cut to
 * "CPerso..." at 375 px (73 px left for 78) and to two letters at 320 px.
 * Tighter margins give it room down to 360 px; below that the colour scheme
 * switch goes, since the scheme already follows the system setting. */
@media screen and (max-width: 44.984375em) {
  /* [dir] matches the theme's own [dir=ltr] rule, which would otherwise win. */
  [dir] .md-header__title {
    margin-left: 0.4rem;
    margin-right: 0.2rem;
  }
  .md-header__option .md-header__button,
  .md-header__inner > .md-header__button[for="__search"] {
    margin-left: 0;
    margin-right: 0;
  }
}
@media screen and (max-width: 22.484375em) {
  form.md-header__option[data-md-component="palette"] {
    display: none;
  }
}

/* Headings in the text's own colour and a weight that reads as a heading. */
.md-typeset h1 {
  color: var(--md-default-fg-color);
  font-weight: 700;
  letter-spacing: -0.015em;
}
.md-typeset h2,
.md-typeset h3 {
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* A link in running text is in the accent and keeps its underline, so that colour is not the only sign. */
.md-typeset a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--md-default-fg-color--lighter);
}
.md-typeset a:hover,
.md-typeset a:focus {
  text-decoration-color: currentColor;
}
.md-typeset .headerlink {
  text-decoration: none;
}
.md-nav__link--active {
  font-weight: 600;
}

/* Cards are raised, with the line colour and an 8 px corner, and no shadow. */
.md-typeset .grid.cards > ul > li,
.md-typeset .grid > .card {
  border-color: var(--line);
  border-radius: 8px;
  background: var(--raised);
  box-shadow: none;
}
.md-typeset pre > code,
.md-typeset .highlight {
  border-radius: 6px;
}
.md-typeset .admonition,
.md-typeset details {
  border-radius: 8px;
}

/* Between 60em and 76.25em the theme hides the left sidebar and lets the text
 * run the whole remaining width: 977 px, 105 to 110 characters a line (measured
 * 2026-10-12). Hold it to the width it has beside both sidebars. */
@media screen and (min-width: 60em) and (max-width: 76.234375em) {
  .md-content {
    max-width: 38rem;
    margin-inline: auto;
  }
}

/* Sidebar sub-category labels, one step quieter than the page links.
 *
 * The nav groups pages by what the reader came to do, so the group labels are
 * signposts rather than destinations. The theme draws the top-level section in
 * --md-default-fg-color--light (the muted token) but leaves a nested
 * sub-section at the ordinary link weight, which made the sub-sections the
 * brightest thing in the sidebar once the nav grew a third level. They take the
 * faint token here. Not the dashboard's label token: that one is tuned to the
 * recessed side panel it sits on there, and on this page's base step it falls
 * just short of 4.5:1 in the dark scheme. tests/test_design_tokens.py checks
 * the faint token against the page's surfaces in both schemes.
 */
:root > * {
  --cp-nav-subcategory-color: var(--faint);
}

/* Scoped to the primary sidebar: the table of contents on the right is built
 * from the same md-nav classes, and dimming a heading the reader is actively
 * tracking is a different question from dimming a static signpost. */
.md-nav--primary .md-nav__item--nested:not(.md-nav__item--section) > .md-nav__link[for] {
  color: var(--cp-nav-subcategory-color);
}

/* Version selector, rendered into the header by
 * overrides/partials/alternate.html on md-select -- the same component the
 * language selector is built on, so both open the same way, in the same place,
 * with the same arrow pointing back at their button.
 *
 * md-select places its panel at `top: calc(100% - .2rem)` of the control, so
 * the two controls have to be the same height or the shorter one opens its
 * panel inside the header. That is not tuned here to a number that looked
 * right: the button is given the theme's own button box and a line box of
 * exactly the height the theme gives an icon, so the two are the same by
 * construction and stay so if the theme changes either.
 *
 * Note what is NOT set on the wrapper: font-size. The line box of an
 * inline-block is measured against its parent's strut, so sizing the wrapper
 * would make this control's box differ from the language one's again, in a way
 * no rule here would name.
 *
 * Every rule below overrides one the theme sets, at equal specificity, and wins
 * on order -- extra_css is emitted after the theme stylesheet. */
.cp-version__current {
  font-size: 0.8rem;
  /* .md-icon gives its svg height: 1.2rem. This is that, for a word. */
  line-height: 1.2rem;
}

/* The theme's margins for this label assume it sits just after the site title,
 * on the left. Replaced by the margin every button in this corner carries. */
.cp-version .md-version__current {
  margin: 0.2rem;
  /* The .05rem nudge that lines the label up against a site title, which is not
   * what it is lined up against here. */
  top: 0;
}

/* The line being read. Marked by weight alone: the row is still a link, because
 * from a subpage it is the way back to that line's root. Scoped to the version
 * list, though no language row carries the attribute today -- an unscoped rule
 * would quietly start styling one that did. */
.cp-version .md-select__link[aria-current="true"] {
  font-weight: 700;
}

/* The note that tells a reader this page is also in their language
 * (overrides/main.html). Drawn like the one on the project's home page: white
 * (or the slate ground) with a thin rule, in the corner, never dimming the page.
 * The colours come from the theme, so the dark scheme carries along.
 */
.cp-lang-note {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: 1rem;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.1rem;
  max-width: min(16rem, calc(100vw - 2rem));
  padding: 0.2rem 0.2rem 0.2rem 0;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.6rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.7rem;
  line-height: 1.45;
}
.cp-lang-note-go {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.3rem 0.4rem 0.7rem;
  color: inherit;
}
.md-typeset .cp-lang-note-go, .cp-lang-note-go:visited { color: inherit; }
.cp-lang-note-go:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.cp-lang-note-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  border-radius: 0.3rem;
  background: none;
  color: var(--md-default-fg-color--light);
  cursor: pointer;
}
.cp-lang-note-x:hover { color: var(--md-default-fg-color); }
.cp-lang-note-x svg { display: block; width: 0.8rem; height: 0.8rem; }
.cp-lang-note :focus-visible { outline: 2px solid var(--md-accent-fg-color); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .cp-lang-note { animation: cp-lang-note-in 0.382s ease-out; }
  @keyframes cp-lang-note-in { from { opacity: 0; } }
}

/* A notice from the CPersona project (javascripts/notice.js): the recessed step with an 8 px corner, no
 * colour of its own. It sits under the table of contents or at the end of the page. */
.cp-notice {
  margin: 1.6rem 0 0;
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  background: var(--md-code-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.64rem;
  line-height: 1.5;
}
.md-sidebar .cp-notice {
  margin: 1.2rem 0.6rem 0;
}
.cp-notice p,
.md-typeset .cp-notice p {
  margin: 0 0 0.3rem;
}
.cp-notice-label {
  color: var(--md-default-fg-color--light);
  font-size: 0.6rem;
}
.cp-notice-heading {
  font-weight: 650;
}
.cp-notice-note,
.md-typeset .cp-notice p.cp-notice-note {
  margin: 0.5rem 0 0;
  color: var(--md-default-fg-color--light);
  font-size: 0.56rem;
}
.cp-notice-link,
.md-typeset .cp-notice-link {
  color: var(--md-typeset-a-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
