/*
 * WildBotics site theme.
 *
 * Gives the Zensical site the same identity as the WildBotics slide template
 * (wildbotics-marp-template): the green header band with the white wordmark
 * and the curved edge, the navy footer rule, Trebuchet typography, green-ruled
 * code blocks and green table heads. The layout follows the Bristol Flight Lab
 * site theme; only the colours and artwork are WildBotics.
 *
 * The palette in zensical.toml uses the stock `default` and `slate` schemes, so
 * both inherit a complete set of theme variables. Everything below is a brand
 * override on top of them.
 *
 * Artwork in assets/brand/ is generated by brand/make_artwork.py from the logo.
 */

:root {
  /* Brand palette, sampled from the logo. Keep in step with the slide theme. */
  --wb-green: #408a34;        /* "Wild", the leaf, the ring */
  --wb-green-dark: #2f7328;   /* green for text on white: 5.8:1 */
  --wb-leaf: #8dc63f;         /* highlight stroke; green on dark grounds */
  --wb-navy: #0d3a56;         /* "Botics", the ring's outer arc */
  --wb-sky: #4a90b8;          /* the river */
  --wb-bark: #7a4a2a;         /* the bear */
  --wb-amber: #e0a526;
  --wb-grey: #e6eae4;

  --md-text-font: "Trebuchet MS", "Fira Sans", "Helvetica Neue";
  --md-code-font: "SF Mono", Menlo, Consolas, "Liberation Mono";
}

/* ---------- Colour schemes ---------- */

:root,
[data-md-color-scheme="default"] {
  --md-primary-fg-color:          #408a34;
  --md-primary-fg-color--light:   #6aa85f;
  --md-primary-fg-color--dark:    #2f7328;
  --md-primary-bg-color:          #ffffff;
  --md-primary-bg-color--light:   #ffffffb3;

  --md-accent-fg-color:           #2f7328;
  --md-accent-fg-color--transparent: #408a341a;

  --md-typeset-a-color:           #2f7328;
  --md-code-bg-color:             #eef1ec;

  --md-footer-bg-color:           #0d3a56;
  --md-footer-bg-color--dark:     #0a2e45;
}

[data-md-color-scheme="slate"] {
  --md-hue: 200;

  --md-primary-fg-color:          #408a34;
  --md-primary-fg-color--light:   #6aa85f;
  --md-primary-fg-color--dark:    #2f7328;
  --md-primary-bg-color:          #ffffff;
  --md-primary-bg-color--light:   #ffffffb3;

  /* Brand green is too dark to read as a link on a dark ground, so links and
     hover states lift to the leaf green from the logo. */
  --md-accent-fg-color:           #8dc63f;
  --md-accent-fg-color--transparent: #8dc63f1f;
  --md-typeset-a-color:           #8dc63f;

  --md-default-bg-color:          #16202a;
  --md-code-bg-color:             #223040;
  --md-code-fg-color:             #e0e6e0;
  --md-footer-bg-color:           #0a2e45;
  --md-footer-bg-color--dark:     #07243a;
}

/* ---------- Header: the green band ---------- */

.md-header {
  color: var(--md-primary-bg-color);
  background-color: var(--wb-green);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background-repeat: no-repeat;
  background-position: right 0 top 0;
  background-size: auto 100%;
}

/* The edge sits at the right end of the band, as on a slide, once the window
   is wide enough to clear the content column. */
@media screen and (min-width: 80em) {
  .md-header {
    background-image: url("../assets/brand/edge-header.svg");
  }
}

/* The white wordmark replaces the logo image in the band. */
.md-header .md-logo {
  width: 5.2rem;
  height: 1.3rem;
  background: url("../assets/brand/wordmark-white.png") no-repeat center /
    contain;
}

.md-header .md-logo svg,
.md-header .md-logo img {
  display: none;
}

.md-header__title {
  font-weight: 700;
}

/* The wordmark already says WildBotics, so the site name beside it goes. Only
   the page title is left, which the theme slides in once the page scrolls. */
.md-header__topic:first-child {
  visibility: hidden;
}

/* Line the wordmark up with the tabs and the sidebar below it: both start
   1rem inside the grid, and the logo button's own margin gives 0.6rem. */
.md-header__button.md-logo {
  margin-left: 0.6rem;
}

/* With the sidebar showing, the page title that appears on scroll sits over
   the content column, where the page's own heading was. That column starts
   13.3rem inside the grid: the 12.1rem sidebar plus the content's 1.2rem
   margin. The topic is positioned against the header row to put it there. */
@media screen and (min-width: 76.25em) {
  .md-header__inner {
    position: relative;
  }
  .md-header__title .md-header__ellipsis {
    position: static;
  }
  .md-header__topic + .md-header__topic {
    left: 13.3rem;
  }
}

/* The search button's default tints are near-invisible on green. */
.md-search__button {
  color: var(--md-primary-bg-color);
  background-color: #ffffff26;
}

.md-search__button:hover {
  color: var(--md-primary-bg-color);
  background-color: #ffffff40;
}

.md-search__button::before {
  background-color: var(--md-primary-bg-color);
}

/* ---------- Navigation ---------- */

.md-nav__title {
  color: var(--wb-navy);
}

[data-md-color-scheme="slate"] .md-nav__title {
  color: var(--md-accent-fg-color);
}

/* The mobile drawer header carries the band too. These match the specificity
   of the theme's own `.md-nav .md-nav__title[for=__drawer]` rules. */
.md-nav .md-nav__title[for="__drawer"] {
  color: var(--md-primary-bg-color);
  background: var(--wb-green);
  border-bottom: 0;
}

.md-nav .md-nav__title[for="__drawer"] .md-logo {
  width: 6rem;
  height: 1.6rem;
  background: url("../assets/brand/wordmark-white.png") no-repeat left center /
    contain;
}

.md-nav .md-nav__title[for="__drawer"] .md-logo img,
.md-nav .md-nav__title[for="__drawer"] .md-logo svg {
  display: none;
}

/* ---------- Typography ---------- */

/* A green rule under the page title, echoing the band above a slide title. */
.md-typeset h1 {
  padding-bottom: 0.3em;
  margin-bottom: 0.9em;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--md-default-fg-color);
  border-bottom: 0.15rem solid var(--wb-green);
}

.md-typeset h2 {
  color: var(--wb-navy);
}

[data-md-color-scheme="slate"] .md-typeset h2 {
  color: var(--md-default-fg-color);
}

/* Third-level headings are green on a slide, and green here. */
.md-typeset h3 {
  font-weight: 700;
  color: var(--wb-green-dark);
}

[data-md-color-scheme="slate"] .md-typeset h3 {
  color: var(--md-accent-fg-color);
}

/* ---------- Code, tables, quotes ---------- */

.md-typeset pre > code {
  border-left: 0.2rem solid var(--wb-green);
  border-radius: 0 0.2rem 0.2rem 0;
}

.md-typeset table:not([class]) th {
  font-weight: 700;
  color: var(--md-primary-bg-color);
  background-color: var(--wb-green);
}

.md-typeset table:not([class]) tr:nth-child(even) td {
  background-color: var(--md-typeset-table-color--light);
}

.md-typeset blockquote {
  padding: 0.6rem 0.8rem;
  color: var(--md-default-fg-color);
  background-color: var(--md-default-fg-color--lightest);
  border-left: 0.2rem solid var(--wb-green);
}

.md-typeset .admonition,
.md-typeset details {
  border-radius: 0.1rem;
}

/* Tabs pick up the brand green rather than the default ink. */
.md-typeset .tabbed-labels::before {
  background: var(--wb-green);
}

.md-typeset .tabbed-set > input:checked + label {
  font-weight: 700;
  color: var(--wb-green-dark);
}

.md-typeset .tabbed-labels > label:hover {
  color: var(--wb-green-dark);
}

[data-md-color-scheme="slate"] .md-typeset .tabbed-labels::before {
  background: var(--md-accent-fg-color);
}

[data-md-color-scheme="slate"] .md-typeset .tabbed-set > input:checked + label,
[data-md-color-scheme="slate"] .md-typeset .tabbed-labels > label:hover {
  color: var(--md-accent-fg-color);
}

/* ---------- Footer: the navy rule ---------- */

.md-footer-meta {
  color: var(--md-primary-bg-color);
  background-color: var(--wb-navy);
}

/* The `html` here is load-bearing: Zensical's own rule starts with it and would
   otherwise outspecify a bare class, leaving near-black links on navy.
   Underlined in every state, so links read as links by shape, not colour. */
html .md-footer-meta.md-typeset a,
html .md-footer-meta.md-typeset a:not(:focus, :hover) {
  color: var(--md-primary-bg-color);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

html .md-footer-meta.md-typeset a:focus,
html .md-footer-meta.md-typeset a:hover {
  color: var(--md-primary-bg-color);
  text-decoration-thickness: 0.15em;
}

html .md-footer-meta.md-typeset a:focus-visible {
  outline: 2px solid var(--md-primary-bg-color);
  outline-offset: 2px;
  border-radius: 2px;
}

.md-copyright,
.md-copyright__highlight {
  color: var(--md-primary-bg-color);
}

html .md-footer-meta .md-copyright {
  font-size: 0.7rem;
  line-height: 1.5;
}

/* A thin leaf-green line between the page and the navy footer. */
.md-footer-meta {
  border-top: 0.2rem solid var(--wb-leaf);
}

/* ---------- Accent text, matching the deck's utility classes ---------- */

.md-typeset .green { color: var(--wb-green-dark); }
.md-typeset .navy { color: var(--wb-navy); }
.md-typeset .leaf { color: var(--wb-leaf); }
.md-typeset .sky { color: var(--wb-sky); }
.md-typeset .bark { color: var(--wb-bark); }
.md-typeset .amber { color: var(--wb-amber); }

@media print {
  .md-typeset h1 {
    border-bottom-color: var(--wb-green);
  }
}
