/* Lem's site: Zensical's page in the board's look (skills/lem/assets/lem.css). The six hues have
   the same values as there, and the light and the dark palette take lem.css's values of --bg,
   --card, --fg, --dim and --line. Zensical picks the palette by the visitor's theme
   (zensical.toml), with no switch. The type is the system's: zensical.toml sets font = false,
   so no font comes from another host. */
:root {
  --lead: #33a6a0;
  --lem: #9a5d9e;
  --you: #b4902e;
  --bad: #ae4022;
  --gate: #3d73b6;
  --ok: #629742;
  --md-text-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
  --md-code-font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

/* the light palette: lem.css's light values */
[data-md-color-scheme="default"] {
  --lem-bg: #fbf9f5;
  --lem-card: #f1efeb;
  --lem-card-hi: #e9e8e3;
  --lem-line: #e2e1dc;
  --lem-line-strong: #cac8c4;
  --lem-fg: #191919;
  --lem-dim: #62615e;
  --lem-accent-ink: #735e25;
  --lem-link: color-mix(in srgb, var(--gate) 62%, var(--lem-fg));
}

/* the dark palette: lem.css's dark values */
[data-md-color-scheme="slate"] {
  --lem-bg: #1a1813;
  --lem-card: #23221d;
  --lem-card-hi: #2b2924;
  --lem-line: #312f2b;
  --lem-line-strong: #474642;
  --lem-fg: #e7e7e7;
  --lem-dim: #9d9d9b;
  --lem-accent-ink: #cab57c;
  --lem-link: color-mix(in srgb, var(--gate) 62%, var(--lem-fg));
}

/* Zensical's own variables, from the palette above, in both schemes */
[data-md-color-scheme="default"], [data-md-color-scheme="slate"] {
  --md-default-bg-color: var(--lem-bg);
  --md-default-fg-color: var(--lem-fg);
  --md-default-fg-color--light: var(--lem-dim);
  --md-default-fg-color--lighter: var(--lem-line-strong);
  --md-default-fg-color--lightest: var(--lem-line);
  --md-primary-fg-color: var(--lem-bg);
  --md-primary-fg-color--light: var(--lem-card);
  --md-primary-fg-color--dark: var(--lem-card-hi);
  --md-primary-bg-color: var(--lem-fg);
  --md-primary-bg-color--light: var(--lem-dim);
  --md-accent-fg-color: var(--you);
  --md-accent-fg-color--transparent: color-mix(in srgb, var(--you) 12%, transparent);
  --md-accent-bg-color: var(--lem-bg);
  --md-typeset-a-color: var(--lem-link);
  --md-code-bg-color: var(--lem-card);
  --md-code-fg-color: var(--lem-fg);
  --md-footer-bg-color: var(--lem-card);
  --md-footer-bg-color--dark: var(--lem-card-hi);
  --md-footer-fg-color: var(--lem-fg);
  --md-footer-fg-color--light: var(--lem-dim);
  --md-footer-fg-color--lighter: var(--lem-dim);
  /* a chart, drawn by Pele (lem-charts.js), as the board draws its charts (board.css, .pele) */
  --pele-bg: var(--lem-bg);
  --pele-fg: var(--lem-fg);
  --pele-muted: var(--lem-dim);
  --pele-line: var(--lem-dim);
  --pele-surface: var(--lem-card);
  --pele-surface-alt: var(--lem-card-hi);
  --pele-border: var(--lem-line-strong);
  --pele-accent: var(--gate);
}

.md-header { box-shadow: 0 1px 0 var(--lem-line); }
.md-typeset h1, .md-typeset h2, .md-typeset h3 { color: var(--lem-fg); font-weight: 700; letter-spacing: -.012em; }
.md-typeset code { border-radius: 6px; }
.md-typeset table:not([class]) { border: 1px solid var(--lem-line); border-radius: 10px; }

/* Keep the copy button above the code, clear of long lines as they scroll. */
.md-typeset pre:has(> .md-code__nav) { background: var(--md-code-bg-color); border-radius: .4rem; }
.md-typeset pre > .md-code__nav { position: static; justify-content: flex-end; background: none; }

/* the page menu (overrides/partials/actions.html): one quiet button, "This page", whose list holds
   the copy, the Markdown file and the assistants. On a wide screen it floats on the title's line, at
   its right; on a narrow one it takes a line of its own above the title, so that the title keeps the
   whole width. Zensical styles every details as a note: none of that reaches the menu. */
.md-typeset .lem-page-actions { display: flex; justify-content: flex-end; margin: -.6rem 0 .2rem; }
.md-typeset .lem-page-actions details { position: relative; display: block; margin: 0; padding: 0; overflow: visible; font-size: .7rem; color: var(--lem-fg); background: none; border: 0; border-radius: 0; box-shadow: none; }
.md-typeset .lem-page-actions details > summary {
  display: inline-flex; align-items: center; gap: .35rem; margin: 0; padding: .25rem .5rem .25rem .55rem;
  font-weight: 500; line-height: 1.4; color: var(--lem-dim); cursor: pointer; list-style: none; user-select: none;
  background: var(--lem-card); border: 1px solid var(--lem-line); border-radius: 8px;
}
.md-typeset .lem-page-actions details > summary::before, .md-typeset .lem-page-actions details > summary::after { display: none; }
.md-typeset .lem-page-actions details > summary::-webkit-details-marker { display: none; }
.md-typeset .lem-page-actions details > summary:hover, .md-typeset .lem-page-actions details[open] > summary { color: var(--lem-fg); border-color: var(--lem-line-strong); }
.md-typeset .lem-page-actions details > summary:focus-visible { outline: 2px solid var(--gate); outline-offset: 2px; }
.lem-page-icon, .lem-page-chevron { flex: none; width: .8rem; height: .8rem; }
.lem-page-chevron { transition: transform .15s; }
.lem-page-menu[open] .lem-page-chevron { transform: rotate(180deg); }
.md-typeset .lem-page-actions ul {
  position: absolute; top: calc(100% + .3rem); right: 0; z-index: 3; margin: 0; padding: .3rem; min-width: 11.5rem; list-style: none;
  background: var(--lem-bg); border: 1px solid var(--lem-line-strong); border-radius: 10px;
  box-shadow: 0 12px 32px -12px color-mix(in srgb, var(--lem-fg) 40%, transparent);
}
.md-typeset .lem-page-actions li { margin: 0; padding: 0; }
.md-typeset .lem-page-actions li a, .md-typeset .lem-page-actions li button {
  display: block; width: 100%; padding: .35rem .6rem; font: inherit; line-height: 1.4; text-align: left;
  color: var(--lem-fg); text-decoration: none; background: none; border: 0; border-radius: 6px; cursor: pointer;
}
.md-typeset .lem-page-actions li a:hover, .md-typeset .lem-page-actions li button:hover, .md-typeset .lem-page-actions li :focus-visible { background: var(--lem-card); outline: none; }
.md-typeset .lem-page-actions li + li:nth-child(3) { margin-top: .25rem; padding-top: .25rem; border-top: 1px solid var(--lem-line); }
@media (min-width: 60em) {
  .md-typeset .lem-page-actions { float: right; margin: .35rem 0 0 1rem; }
}

/* the footer's links: Lem's home page and the repository */
.lem-footer-links { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding-top: .6rem; padding-bottom: .8rem; font-size: .7rem; }

/* a chart: Pele's drawing at the width of the text, or its text with the line that says why not */
.md-typeset .lem-chart-drawn { margin: 1em 0; padding: .8rem; text-align: center; background: var(--lem-card); border: 1px solid var(--lem-line); border-radius: 12px; overflow-x: auto; }
.md-typeset .lem-chart-drawn svg { max-width: 100%; height: auto; }
/* on a narrow screen a chart is drawn at three quarters of its own size, so that its 14 px words
   stay readable at 10.5 px, and its box scrolls it sideways; squeezed to a phone's width, the flow's
   chart had words of 6 px. Pele writes max-width: 100% on the drawing itself, which only !important
   outranks. */
@media (max-width: 44.9375em) {
  .md-typeset .lem-chart-drawn svg { max-width: none !important; zoom: .75; }
}

/* a table on a narrow screen: a name in code keeps its line, each column keeps room for a few words,
   and the table's box scrolls it sideways */
@media (max-width: 44.9375em) {
  .md-typeset table:not([class]) code { white-space: nowrap; word-break: normal; }
  .md-typeset table:not([class]) :is(th, td) { min-width: 7.5rem; }
}
.md-typeset .lem-chart-error { color: var(--bad); font-weight: 600; }

/* a name in the menus that has no space to break at (a path such as ~/.config/lem/settings.toml)
   breaks where it must, so that the whole name shows */
.md-nav .md-ellipsis { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
