/*
SPDX-FileCopyrightText: 2026 Mike Coats <i.am@mikecoats.com>
SPDX-License-Identifier: GPL-3.0-or-later
*/

/* Fonts: Atkinson Hyperlegible, from the Braille Institute, served from this
   site rather than a font service. Each file covers weights 200 to 800. */
@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("/fonts/atkinson-hyperlegible-next.woff2") format("woff2");
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
}

@font-face {
    font-family: "Atkinson Hyperlegible Next";
    src: url("/fonts/atkinson-hyperlegible-next-italic.woff2") format("woff2");
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
}

@font-face {
    font-family: "Atkinson Hyperlegible Mono";
    src: url("/fonts/atkinson-hyperlegible-mono.woff2") format("woff2");
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
}

/* Colours: a groundskeeper's greens on paper, or on soil after dark. */
:root {
    color-scheme: light dark;

    --text: #1f2a1f;
    --muted: #556455;
    --background: #fbfbf7;
    --surface: #eff2e9;
    --border: #d5dccb;
    --accent: #2f6b2f;
    --accent-hover: #1f4f1f;
    --diff-add: #1e6b2e;
    --diff-del: #b42318;

    --body-font: "Atkinson Hyperlegible Next", system-ui, sans-serif;
    --code-font: "Atkinson Hyperlegible Mono", ui-monospace, monospace;
    --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text: #e3e8dc;
        --muted: #a3ae9b;
        --background: #161a15;
        --surface: #1f251d;
        --border: #343d31;
        --accent: #8fcf7f;
        --accent-hover: #b3e3a6;
        --diff-add: #8fd694;
        --diff-del: #ffa198;
    }
}

/* Page */

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

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

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: var(--body-font);
    font-size: 1.0625rem;
    line-height: 1.6;
}

header,
main,
footer {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header and navigation */

header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.site-name a {
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
}

/* The version beside it, which isn't part of the link. Its background fits
   the digits rather than the font's room for descenders, which left it
   hanging below the name. */
.site-name code {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0.15em 0.35em;
    line-height: 1;
    color: var(--muted);
}

nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

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

nav a:hover {
    color: var(--accent);
}

nav a[aria-current="page"] {
    color: var(--accent);
    font-weight: 600;
}

/* Content */

main {
    padding-top: 1rem;
    padding-bottom: 2rem;
}

section + section {
    margin-top: 2.5rem;
}

h1,
h2 {
    line-height: 1.25;
    text-wrap: balance;
}

h1 {
    margin: 1.5rem 0 1rem;
    font-size: 2.25rem;
}

h2 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
}

p,
ul,
table,
pre {
    margin: 0 0 1rem;
}

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

a:hover {
    color: var(--accent-hover);
}

/* Links that open in a new tab, or download a file, get an icon drawn in the
   link's own colour. Screen readers announce what it means instead; browsers
   without alternative text for `content` fall back to no text. */
a[target="_blank"]::after,
a[download]::after {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    margin-left: 0.2em;
    background-color: currentColor;
    mask: var(--icon) center / contain no-repeat;
}

a[target="_blank"]::after {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 3H3v10h10V9'/%3E%3Cpath d='M10 2h4v4M14 2 7.5 8.5'/%3E%3C/svg%3E");
    content: "";
    content: "" / " (opens in a new tab)";
}

a[download]::after {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v8.5M4 7l4 4 4-4M3 14h10'/%3E%3C/svg%3E");
    content: "";
    content: "" / " (download)";
}

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

/* Code */

code {
    font-family: var(--code-font);
    font-size: 0.9em;
}

:not(pre) > code {
    padding: 0.1em 0.3em;
    border-radius: 0.25rem;
    background: var(--surface);
    overflow-wrap: anywhere;
}

pre {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--surface);
    line-height: 1.45;
    overflow-x: auto;
}

/* Diffs: the + and - at the start of each line still say which is which
   without the colour. */

.diff-add {
    color: var(--diff-add);
}

.diff-del {
    color: var(--diff-del);
}

/* Text that reads wrongly when split across lines. */

.nowrap,
.nowrap code {
    white-space: nowrap;
    overflow-wrap: normal;
}

/* Tables scroll sideways on narrow screens rather than the page. */

table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

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

th {
    border-bottom-width: 2px;
}

/* Footer */

footer {
    padding-top: 1.5rem;
    padding-bottom: 2rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.875rem;
}

footer ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    padding: 0;
    list-style: none;
}
