/*
  ctl.fi base template
  A small, classless stylesheet for plain HTML pages.
*/

:root {
  color-scheme: light dark;
  --bg: #f8f6ef;
  --paper: #fffdf8;
  --field-bg: #fff;
  --text: #171717;
  --muted: #5d625f;
  --line: #4a4a45;
  --link: #0645ad;
  --accent: #d93f00;
  --accent-soft: #f4e5d8;
  --bar-bg: #eeeae0;
  --code-bg: #eeece5;
  --focus: #008f7a;
  --error: #b3261e;
  --error-soft: #fbe9e7;
  --success: #1f7a4d;
  --success-soft: #e6f4ec;
  --shadow: 0 1px 2px rgb(23 23 23 / 0.08);
  --max-width: 68rem;
  --font-body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Liberation Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161512;
    --paper: #201e18;
    --field-bg: #1b1a16;
    --text: #e8e6e0;
    --muted: #a3a59f;
    --line: #565650;
    --link: #6fb3ff;
    --accent: #ff7a45;
    --accent-soft: #322a22;
    --bar-bg: #201e18;
    --code-bg: #26241e;
    --focus: #2bb89b;
    --error: #f2776c;
    --error-soft: #3a1c1a;
    --success: #5ec98e;
    --success-soft: #16301f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  font-size: 18px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
}

body > header,
body > main,
body > footer {
  width: min(var(--max-width), calc(100% - 2rem));
  margin-inline: auto;
}

body > header {
  width: 100%;
  padding-block: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bar-bg);
}

body > main {
  padding-block: 1.5rem 2rem;
}

body > footer {
  padding-block: 1rem 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

body > header nav {
  width: min(var(--max-width), calc(100% - 2rem));
  margin-inline: auto;
  padding-block: 0.45rem;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  align-items: center;
  justify-content: space-between;
}

header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

header nav a {
  color: var(--text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

.wordmark,
.wordmark:visited,
.wordmark:hover {
  display: inline-flex;
  gap: 0.45rem;
  align-items: baseline;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
}

.wordmark::before {
  content: "Λ";
  color: var(--accent);
  display: inline-block;
  transition: transform 0.25s ease, text-shadow 0.25s ease;
}

.wordmark:hover::before {
  transform: scale(1.2);
  text-shadow: 0 0 0.4em var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .wordmark:hover::before {
    transform: none;
    text-shadow: none;
  }
}

h1,
h2,
h3 {
  margin: 1.4em 0 0.4em;
  line-height: 1.15;
}

h1 {
  max-width: 18ch;
  margin-top: 0;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  font-family: var(--font-body);
}

h2 {
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.45rem;
}

h3 {
  font-size: 1.1rem;
}

p,
ul,
ol,
dl,
blockquote,
pre,
table,
form,
fieldset,
details {
  margin-block: 0 1rem;
}

p:first-child,
ul:first-child,
ol:first-child {
  margin-top: 0;
}

a {
  color: var(--link);
  text-underline-offset: 0.16em;
}

a:visited {
  color: var(--link);
}

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

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

hr {
  height: 1px;
  margin: 1.5rem 0;
  border: 0;
  background: var(--line);
}

blockquote {
  margin-inline: 0;
  padding: 0.75rem 1rem;
  border-left: 0.25rem solid var(--accent);
  background: var(--paper);
}

.flash {
  margin-block: 0 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 0.25rem solid var(--muted);
  background: var(--paper);
}

.flash-error {
  border-left-color: var(--error);
  background: var(--error-soft);
}

.flash-success {
  border-left-color: var(--success);
  background: var(--success-soft);
}

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

code,
kbd,
samp {
  padding: 0.08em 0.25em;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--code-bg);
}

pre code {
  padding: 0;
  background: transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
}

th,
td {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead {
  background: var(--accent-soft);
}

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

figure {
  margin: 0 0 1rem;
}

figcaption {
  color: var(--muted);
  font-size: 0.9rem;
}

fieldset {
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  background: var(--paper);
}

legend {
  padding-inline: 0.35rem;
  font-family: var(--font-mono);
  font-weight: 700;
}

label {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0.7rem 0.45rem 0;
}

input,
select,
textarea,
button {
  max-width: 100%;
  color: inherit;
  font: inherit;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--field-bg);
}

button,
input[type="button"],
input[type="reset"],
input[type="submit"],
a[role="button"] {
  display: inline-block;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover,
a[role="button"]:hover {
  background: var(--paper);
}

details {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--paper);
}

summary {
  cursor: pointer;
  font-weight: 700;
}

section {
  margin-block: 1.5rem;
}

@media (max-width: 42rem) {
  html {
    font-size: 16px;
  }

  header nav {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    max-width: 12ch;
  }
}
