/* duckdown's site stylesheet.

   Everything below is drawn from these variables. A theme (a -theme.css,
   for pages with `theme: <name>`) sets a few of them on body.<name> rather
   than restyling elements. See the Themes guide. */

:root {
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --border: #d1d9e0;
  --surface: #f6f8fa; /* code, table headings, the contents list */

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* --font-heading: headings follow --font-body unless a theme sets it */
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 46rem; /* how wide the text runs: about 75 characters */
  --radius: 6px;

  /* Callouts: > [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION] */
  --note: #0969da;
  --tip: #1a7f37;
  --important: #8250df;
  --warning: #9a6700;
  --caution: #d1242f;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --text: #e6edf3;
    --muted: #9198a1;
    --accent: #4493f8;
    --border: #3d444d;
    --surface: #151b23;
    --note: #4493f8;
    --tip: #3fb950;
    --important: #ab7df8;
    --warning: #d29922;
    --caution: #f85149;
  }
}

/* --- Page --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- Headings: each links to itself (#…), quietly --- */

h1, h2, h3, h4, h5, h6 {
  margin: 2.2em 0 0.6em;
  font-family: var(--font-heading, var(--font-body));
  line-height: 1.25;
  scroll-margin-top: 1rem; /* a #heading link lands with room above */
}

h1 {
  margin-top: 0.5em;
  font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.5rem);
  letter-spacing: -0.01em;
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
h5, h6 { font-size: 0.9rem; color: var(--muted); }

:is(h1, h2, h3, h4, h5, h6) > a {
  color: inherit;
  text-decoration: none;
}

:is(h2, h3, h4) > a:hover::after {
  content: " #";
  color: var(--muted);
  font-weight: 400;
}

/* --- Text --- */

p, ul, ol, dl, table, pre, blockquote, figure {
  margin: 0 0 1.1em;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

ul, ol {
  padding-left: 1.5em;
}

li {
  margin: 0.25em 0;
}

li > ul, li > ol {
  margin: 0.25em 0;
}

/* Task lists: - [x] done */
li:has(> input[type="checkbox"]) {
  margin-left: -1.4em;
  list-style: none;
}

li > input[type="checkbox"] {
  margin: 0 0.45em 0 0;
  vertical-align: -0.1em;
  accent-color: var(--accent);
}

hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

img, video {
  max-width: 100%;
  height: auto;
}

::selection {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- The site navigation (each folder's index.md) --- */

ul.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0 0 3rem;
  padding: 0 0 0.9rem;
  border-bottom: 1px solid var(--border);
  list-style: none;
}

ul.nav li {
  margin: 0;
}

ul.nav a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

ul.nav a:hover,
ul.nav a[aria-current] {
  color: var(--text);
}

/* This page, or the section it's in */
ul.nav a[aria-current] {
  text-decoration: underline 2px var(--accent);
  text-underline-offset: 0.55em;
}

/* --- The contents list (toc: true) --- */

nav.toc {
  margin: 1.5rem 0 2.25rem;
  padding: 0.85rem 1.1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  font-size: 0.95em;
}

nav.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav.toc li {
  margin: 0.2em 0;
}

nav.toc .toc-h3 {
  padding-left: 1.1rem;
  font-size: 0.95em;
}

nav.toc a {
  color: var(--text);
  text-decoration: none;
}

nav.toc a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* --- A folder's pages ({{pages}}) --- */

ul.pages {
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

ul.pages li {
  margin: 0 0 1.4em;
}

ul.pages a {
  font-size: 1.1em;
  font-weight: 600;
  text-decoration: none;
}

ul.pages a:hover {
  text-decoration: underline;
}

ul.pages time {
  display: block;
  color: var(--muted);
  font-size: 0.9em;
}

ul.pages p {
  margin: 0.2em 0 0;
  color: var(--muted);
}

/* --- Edit this page (signed in) --- */

.user-edit {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  padding: 0.4em 0.9em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.user-edit:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* --- Code --- */

code, kbd, pre {
  font-family: var(--font-mono);
}

code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.875em;
}

pre {
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.875rem;
  line-height: 1.55;
}

pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

kbd {
  padding: 0.1em 0.4em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* --- Quotes and callouts --- */

blockquote {
  margin-right: 0;
  margin-left: 0;
  padding: 0.1em 1.1em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

blockquote > :last-child {
  margin-bottom: 0;
}

.callout {
  --tone: var(--note);
  padding: 0.7em 1.1em;
  border-left-color: var(--tone);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--tone) 8%, transparent);
  color: var(--text);
}

.callout.tip { --tone: var(--tip); }
.callout.important { --tone: var(--important); }
.callout.warning { --tone: var(--warning); }
.callout.caution { --tone: var(--caution); }

.callout-title {
  margin-bottom: 0.3em;
  color: var(--tone);
  font-weight: 600;
}

/* --- Tables --- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

th, td {
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface);
  font-weight: 600;
}
