/*
 * The CoCo Tools look for the Zensical theme: the logo's coconut colors (husk brown and leaf
 * green), a tinted navigation panel, and hairline separators.
 */

/* Colors ---------------------------------------------------------------------------------- */

:root,
[data-md-color-scheme="default"] {
  --coco-husk: #3a2417;
  --coco-husk-fg: #fbf6ee;
  --coco-leaf: #2f6a2b;
  --coco-leaf-dark: #24521f;
  --coco-panel: #f1f5ee;
  --coco-line: #e7e2db;
  --coco-amber: #9a5200;
  --coco-amber-tint: rgb(154 82 0 / 8%);

  --md-default-bg-color: #ffffff;
  --md-default-fg-color: #1f1b18;
  --md-default-fg-color--light: #5d554e;
  --md-default-fg-color--lighter: #766d64;
  --md-default-fg-color--lightest: #e7e2db;
  --md-primary-fg-color: var(--coco-leaf);
  --md-primary-fg-color--light: #4f8a3a;
  --md-primary-fg-color--dark: var(--coco-leaf-dark);
  --md-accent-fg-color: var(--coco-leaf-dark);
  --md-accent-fg-color--transparent: rgb(47 106 43 / 10%);
  --md-typeset-a-color: var(--coco-leaf);
  --md-code-bg-color: #f6f2ed;
  --md-code-fg-color: #3a2417;
  /* Syntax: keys and keywords in leaf green, values and strings in amber, constants in plum. */
  --md-code-hl-keyword-color: #2f6a2b;
  --md-code-hl-function-color: #2f6a2b;
  --md-code-hl-string-color: #9a5200;
  --md-code-hl-variable-color: #9a5200;
  --md-code-hl-name-color: #7a3a86;
  --md-code-hl-constant-color: #7a3a86;
  --md-code-hl-number-color: #7a3a86;
  --md-code-hl-comment-color: #75695e;
  --md-code-hl-punctuation-color: #5d554e;
  --md-code-hl-operator-color: #5d554e;
  --md-code-hl-special-color: #2f6a2b;

  /* The terminal colors of CoCoCheck's text report, see javascripts/report.js. */
  --coco-report-error: #b42318;
  --coco-report-warning: #8a5a00;
  --coco-report-gutter: #1d5fb8;
}

[data-md-color-scheme="slate"] {
  --coco-husk: #432c1c;
  --coco-husk-fg: #f3ebdf;
  --coco-leaf: #8fcf6c;
  --coco-leaf-dark: #a9dd8c;
  --coco-panel: #2e231c;
  --coco-line: #3a2d25;
  --coco-amber: #e8b46a;
  --coco-amber-tint: rgb(232 180 106 / 10%);

  --md-default-bg-color: #1a1411;
  --md-default-fg-color: #ece5dc;
  --md-default-fg-color--light: #c2b8ad;
  --md-default-fg-color--lighter: #9a9086;
  --md-default-fg-color--lightest: #3a2d25;
  --md-primary-fg-color: var(--coco-leaf);
  --md-primary-fg-color--light: #a9dd8c;
  --md-primary-fg-color--dark: #6fae4f;
  --md-accent-fg-color: var(--coco-leaf-dark);
  --md-accent-fg-color--transparent: rgb(143 207 108 / 12%);
  --md-typeset-a-color: var(--coco-leaf);
  --md-code-bg-color: #261d18;
  --md-code-fg-color: #f0e4d4;
  --md-code-hl-keyword-color: #a9dd8c;
  --md-code-hl-function-color: #a9dd8c;
  --md-code-hl-string-color: #e8b46a;
  --md-code-hl-variable-color: #e8b46a;
  --md-code-hl-name-color: #d7a6e8;
  --md-code-hl-constant-color: #d7a6e8;
  --md-code-hl-number-color: #d7a6e8;
  --md-code-hl-comment-color: #a0958a;
  --md-code-hl-punctuation-color: #c2b8ad;
  --md-code-hl-operator-color: #c2b8ad;
  --md-code-hl-special-color: #a9dd8c;

  --coco-report-error: #ff7b72;
  --coco-report-warning: #e3b341;
  --coco-report-gutter: #79b8ff;
}

/* Browser surfaces ------------------------------------------------------------------------ */

::selection {
  background-color: rgb(127 191 90 / 35%);
}

:focus-visible {
  outline-color: var(--coco-leaf);
}

html {
  scrollbar-color: var(--md-default-fg-color--lighter) transparent;
}

/* Header: the husk-brown bar that carries the logo ---------------------------------------- */

.md-header {
  color: var(--coco-husk-fg);
  background-color: var(--coco-husk);
  backdrop-filter: none;
  box-shadow: none;
}

/* Show the site name and the page title side by side instead of swapping them on scroll. */
.md-header__title > .md-header__ellipsis {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.md-header__topic,
.md-header__topic + .md-header__topic,
.md-header__title--active .md-header__topic,
.md-header__title--active .md-header__topic + .md-header__topic {
  position: static;
  z-index: auto;
  pointer-events: auto;
  opacity: 1;
  transform: none;
}

.md-header__topic + .md-header__topic {
  min-width: 0;
  overflow: hidden;
  font-weight: 400;
  text-overflow: ellipsis;
  opacity: 0.75;
}

/* On phones the header has room for the site name only. */
@media screen and (max-width: 44.984375em) {
  .md-header__topic + .md-header__topic {
    display: none;
  }
}

.md-header__title--active .md-header__topic + .md-header__topic {
  opacity: 0.75;
}

/* The dark scheme sets the title to pure white; keep it on the header's cream. */
.md-header .md-header__title {
  color: inherit;
}

.md-header__button.md-logo img {
  border-radius: 3px;
}

.md-header .md-search__button {
  color: var(--coco-husk-fg);
  background-color: rgb(255 255 255 / 12%);
}

.md-header .md-search__button:hover,
.md-header .md-search__button:focus {
  color: var(--coco-husk-fg);
  background-color: rgb(255 255 255 / 20%);
}

.md-header .md-search__button::before {
  background-color: var(--coco-husk-fg);
}

/* The keyboard shortcut hint. */
.md-header .md-search__button::after {
  color: var(--coco-husk-fg);
  background-color: rgb(255 255 255 / 16%);
}

@media screen and (max-width: 76.234375em) {
  .md-header__button.md-logo {
    display: block;
    order: 1;
  }

  .md-header__button[for="__drawer"] {
    order: 0;
  }

  .md-header__title {
    order: 2;
  }

  .md-header__option,
  .md-header__button[for="__search"],
  .md-search,
  .md-header__source {
    order: 3;
  }
}

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

.md-typeset h1 {
  margin-bottom: 0.75em;
}

/* Headings that name a rule or setting: monospace, but not a heavy code chip. */
.md-typeset :is(h1, h2, h3, h4) code {
  padding: 0;
  font-size: 0.9em;
  color: inherit;
  background: none;
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3 {
  letter-spacing: -0.015em;
}

/* Table text a step below body text; the theme's default is much smaller. */
.md-typeset table:not([class]) {
  font-size: 0.7rem;
}

/* Code in a link: no chip, so the link reads as one continuous underlined phrase. */
.md-typeset a code {
  padding: 0;
  background: none;
}

/* Keep setting and option names in the first table column on one line. */
.md-typeset table:not([class]) td:first-child code {
  white-space: nowrap;
}

/*
 * Table of contents: rule names as plain text, wrapped rather than truncated. javascripts/toc.js
 * lets them break after an underscore; breaking anywhere is the fallback.
 */
.md-nav--secondary code {
  display: inline;
  padding: 0;
  overflow-wrap: anywhere;
  font-size: inherit;
  color: inherit;
  background: none;
}

.md-nav--secondary .md-ellipsis {
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Callouts: notes in leaf green, warnings in amber, instead of the theme's blue and orange. */
.md-typeset .admonition,
.md-typeset details {
  font-size: 0.7rem;
}

.md-typeset :is(.admonition, details):is(.note, .info, .tip) {
  background-color: var(--md-accent-fg-color--transparent);
}

.md-typeset :is(.note, .info, .tip) > :is(.admonition-title, summary)::before {
  background-color: var(--coco-leaf);
}

.md-typeset :is(.admonition, details):is(.warning, .caution, .attention) {
  background-color: var(--coco-amber-tint);
}

.md-typeset :is(.warning, .caution, .attention) > :is(.admonition-title, summary)::before {
  background-color: var(--coco-amber);
}

/* Tabs: the selected tab is underlined in leaf green, like a selected item elsewhere. */
.js .md-typeset .tabbed-labels::before {
  height: 2px;
  background: var(--coco-leaf);
}

/* Footer: the "Made with" bar closes the page in husk, like the header opens it. */
.md-footer-meta {
  color: var(--coco-husk-fg);
  background-color: var(--coco-husk);
}

.md-footer-meta .md-copyright {
  color: inherit;
}

html .md-footer-meta.md-typeset a:not(:focus, :hover),
html .md-footer-meta.md-typeset a {
  color: var(--coco-husk-fg);
}

/*
 * Sidebars: the theme sticks them below the header but starts them 1.5rem lower, so they slide up
 * when the page scrolls. Start them at the sticky position and move the gap inside instead.
 */
@media screen and (min-width: 60em) {
  .md-sidebar--secondary {
    padding-top: 2.6rem;
    margin-top: -1.5rem;
  }
}

@media screen and (min-width: 76.25em) {
  .md-sidebar--primary {
    padding-top: 2.6rem;
    margin-top: -1.5rem;
  }
}

/* Navigation: a tinted panel, the current page as a white tab ----------------------------- */

@media screen and (min-width: 76.25em) {
  .md-sidebar--primary .md-sidebar__scrollwrap {
    /*
     * Shrink the panel to its links instead of stretching it to the window height. The theme's
     * script sets the height inline to fill the window, hence the !important.
     */
    height: auto !important;
    max-height: calc(100vh - 6rem);
    padding: 0.4rem 0.3rem;
    background-color: var(--coco-panel);
    border-radius: 0.4rem;
  }

  .md-sidebar--primary .md-nav--primary .md-nav__link--active,
  .md-sidebar--primary .md-nav--primary .md-nav__link--active:hover {
    font-weight: 700;
    background-color: var(--md-default-bg-color);
    box-shadow: 0 1px 2px rgb(58 36 23 / 12%);
  }

  /* A hairline separates the content from the page contents. */
  .md-content {
    border-right: 1px solid var(--coco-line);
  }

  /* Pages without headings, like the home and 404 pages, have no contents to separate. */
  .md-main__inner:not(:has(.md-nav--secondary > .md-nav__list)) .md-content {
    border-right: none;
  }
}

/* Text report examples, colored by javascripts/report.js ---------------------------------- */

.cc-report :is(.cc-error, .cc-warning, .cc-message, .cc-gutter) {
  font-weight: 700;
}

.cc-report .cc-error {
  color: var(--coco-report-error);
}

.cc-report .cc-warning {
  color: var(--coco-report-warning);
}

.cc-report .cc-gutter {
  color: var(--coco-report-gutter);
}
