/* note to self: you used your openBSD xresources files for the color scheme */

:root {
  /* Light */
  --desk:     #fff1e5;  /* *background */
  --sheet:    #fff8f0;  /* color15 */
  --ink:      #33302e;  /* *foreground / color0 */
  --body-ink: #33302e;
  --muted:    #6b6662;  /* color8 */
  --line:     #ccc5c0;  /* color7 */
  --soft:     #f7e6d8;
  --accent:   #990f3d;  /* color1 claret, URxvt cursor */
  --accent-text: #990f3d;
  --mark:     #f3dcda;  /* claret tint */
  --danger:   #cc1452;  /* color9 */
  --on-accent:#fff8f0;
  --ok:       #0f7c7c;  /* color2 */
  --pre-bg:   #fff1e5;  /* code blocks look like the terminaal */
  --pre-ink:  #33302e;
  --pre-line: #ccc5c0;
  --mono:    "Lucida Console", "Courier New", monospace;
  --display: var(--mono);
  --text:    var(--mono);
  --radius:  14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #17181a; --sheet: #1c1d20; --ink: #dddddd; --body-ink: #b1b1b1;
    --muted: #7d7e82; --line: #2d2e32; --soft: #232427;
    --accent: #cc1452;        /* color9: bars, cursor, underlines, buttons */
    --accent-text: #e0608c;   /* lighter claret for accent-coloured text */
    --mark: #2a2b2f; --ok: #14a5a5; --danger: #e0608c; --on-accent: #ffffff;
    --pre-bg: #121315; --pre-ink: #b1b1b1; --pre-line: transparent;
  }
}

/* ---- Layout ---- */
html { background: var(--desk); }
body {
  margin: 0; background: var(--desk); color: var(--body-ink);
  font: 14px/1.65 var(--text);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: minmax(12rem, 15rem) minmax(0, 52rem);
  grid-template-areas: "head head" "side main" "foot foot";
  grid-template-rows: auto 1fr auto;
  justify-content: center; column-gap: clamp(1.5rem, 3vw, 3rem);
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  min-height: 100vh;
}
body > header  { grid-area: head; }
body > nav     { grid-area: side; min-width: 0; }
body > article { grid-area: main; min-width: 0; }
body > footer  { grid-area: foot; }
body:not(:has(> nav)) {
  grid-template-columns: minmax(0, 52rem);
  grid-template-areas: "head" "main" "foot";
}

/* ---- Top bar ---- */
header nav {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .3rem 1.5rem;
  padding: 1.1rem 0 0; background: none; border: 0;
  font: 400 13px/1.4 var(--display);
  color: color-mix(in srgb, var(--muted) 45%, transparent);  /* the | separators */
}
header nav a { color: var(--muted); padding: 0 .15em; }
header nav a:hover { color: var(--accent-text); text-decoration: none; }

/* ---- Title ---- */
header h1 {
  margin: clamp(1.8rem, 5vw, 3.5rem) 0 clamp(1.5rem, 4vw, 2.75rem);
  padding: 0; background: none; border: 0;
  display: flex; align-items: baseline; gap: .12em;
  font: 400 clamp(2rem, 6vw, 3.25rem)/1.1 var(--display);
  letter-spacing: .2em; color: var(--ink);
}
header h1 a { color: inherit; }
header h1 a:hover { text-decoration: none; }
header h1 span {
  display: block; margin: .9rem 0 0 .03rem;
  font: 400 13px/1.4 var(--text);
  letter-spacing: 0; color: var(--body-ink);
}
/* Prompt subtitle */
header h1 span::before { content: "term% "; color: var(--ink); }
header h1 span::after {
  content: ""; display: inline-block; vertical-align: text-bottom;
  width: 8px; height: 15px; margin-left: .4em;
  background: var(--accent); animation: werc-blink 1s infinite;
}
@keyframes werc-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { header h1 span::after { animation: none; } }

/* ---- Sidebar ---- */
body > nav {
  position: sticky; top: 1.5rem; align-self: start;
  padding: 0; background: none; border: 0;
  font: 400 13px/1.4 var(--display);
}
body > nav > div { padding: 0 0 1rem; margin: 0 0 1rem; border-bottom: 1px solid var(--line); }
body > nav > div:last-child { border-bottom: 0; }
body > nav > div p { margin: 0 0 .4rem .75rem; font: 400 12px/1.4 var(--display); color: var(--muted); }
body > nav ul { margin: 0; padding: 0; list-style: none; gap: 1px; }
body > nav ul ul { margin: .15rem 0 .3rem .95rem; padding-left: .45rem; border-left: 1px solid var(--line); }
body > nav > div a {
  display: block; padding: .38rem .75rem; border-radius: 9px;
  color: var(--ink); text-transform: capitalize;
}
body > nav > div a:hover { background: var(--soft); color: var(--ink); text-decoration: none; }
body > nav .thisPage, body > nav .thisPage > a,
body > nav .thisPage:hover, body > nav .thisPage > a:hover {
  background: none; color: var(--ink); font-weight: 700;
  text-decoration: underline; text-decoration-color: var(--accent);
  text-decoration-thickness: 2px; text-underline-offset: 5px;
}

/* ---- The sheet ---- */
body > article {
  background: var(--sheet);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 3.25rem);
  box-shadow: 0 0 24px color-mix(in srgb, var(--ink) 7%, transparent);
}
article > * { max-width: 66ch; }
article > :first-child { margin-top: 0; }
article h1, article h2, article h3, article h4 {
  font-family: var(--display); color: var(--ink); border: 0; padding: 0;
}
article h1 { font-size: 1.6rem; font-weight: 400; line-height: 1.25; letter-spacing: .08em; margin: 0 0 .7em; }
article h2 { font-size: 1.15rem; font-weight: 700; line-height: 1.3; letter-spacing: .02em; margin: 2.2em 0 .5em; }
article h3 { font-size: 1.02rem; font-weight: 700; margin: 1.8em 0 .4em; }
article h4 { font-size: 1rem; font-weight: 700; margin: 1.5em 0 .3em; }
article p, article ul, article ol { margin: 0 0 1.1em; }
article a {
  color: var(--ink); text-decoration: underline;
  text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
article a:hover { color: var(--accent-text); }
::selection { background: var(--mark); color: var(--ink); }

code, kbd, tt { font-family: var(--mono); font-size: .95em; }
code { background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: .08em .35em; }
pre {
  background: var(--pre-bg); color: var(--pre-ink);
  border: 1px solid var(--pre-line); border-radius: 10px; margin: 1.5em 0; padding: 1.1rem 1.3rem;
  font: 13px/1.55 var(--mono); overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
blockquote {
  margin: 1.8em 0; padding: .1em 0 .1em 1.2rem;
  border-left: 3px solid var(--accent);
  font-style: normal; font-size: 1em; line-height: 1.65; color: var(--ink);
}
img, video { max-width: 100%; height: auto; border-radius: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
dt { font: 700 1em var(--display); color: var(--ink); }
dd { margin: 0 0 1em 1.5em; }

table {
  display: block; overflow-x: auto; max-width: 100%;
  border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: .95em; margin: 1.5em 0;
}
th, td { padding: .6rem .9rem; text-align: left; border: 0; background: none; }
th { font: 700 12px/1.4 var(--display); color: var(--muted); background: var(--soft); }
td { border-top: 1px solid var(--line); }
tr:nth-child(odd) { background: none; }

/* ---- Directory listings and sitemap ---- */
h1.dir-list-head, ul.dir-list { text-transform: capitalize; }
ul.sitemap-list { list-style: none; margin: 0; padding-left: 1.1rem; border-left: 1px solid var(--line); }
article > ul.sitemap-list { padding-left: 0; border-left: 0; }
ul.sitemap-list li { margin: .35rem 0; color: var(--muted); }
ul.sitemap-list ul.sitemap-list { margin: .2rem 0 .6rem .3rem; }
ul.sitemap-list a {
  font: 700 14px var(--display); text-transform: capitalize;
  color: var(--ink); text-decoration: none;
}
ul.sitemap-list a:hover { color: var(--accent-text); }

/* ---- Notices ---- */
.notify_errors, .notify_notes, .notify_success {
  padding: .8rem 1rem; margin: 0 0 1.4rem; max-width: 60ch;
  border: 1px solid; border-radius: 10px;
  font: 400 13px/1.5 var(--display); color: var(--ink);
}
.notify_errors  { background: color-mix(in srgb, var(--danger) 10%, var(--sheet)); border-color: color-mix(in srgb, var(--danger) 45%, var(--sheet)); }
.notify_notes   { background: var(--soft); border-color: var(--line); }
.notify_success { background: color-mix(in srgb, var(--ok) 10%, var(--sheet)); border-color: color-mix(in srgb, var(--ok) 45%, var(--sheet)); }
.notify_errors a, .notify_notes a, .notify_success a { color: inherit; }

/* ---- Forms ---- */
.login-form fieldset { border: 0; margin: 0; padding: 0; max-width: 24rem; display: grid; gap: 1rem; background: none; }
.login-form legend { padding: 0; margin-bottom: .6rem; font: 700 14px var(--display); color: var(--muted); }
.login-form label { display: grid; gap: .35rem; font: 400 13px var(--display); color: var(--ink); }
input[type=text], input[type=password], input[type=search], textarea {
  font: 16px var(--display); color: var(--ink);
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px;
  padding: .7rem .85rem; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
textarea { font-family: var(--mono); font-size: 14px; width: 100%; box-sizing: border-box; }
button, input[type=submit] {
  font: 700 13px var(--display); cursor: pointer; justify-self: start;
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px;
  padding: .7rem 1.4rem;
}
button:hover, input[type=submit]:hover { background: color-mix(in srgb, var(--accent) 82%, #000); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Footer ---- */
footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem 2rem;
  padding: 2.5rem 0 2rem; background: none; border: 0;
  font: 400 12px/1.4 var(--display); color: var(--muted);
}
footer div { padding: 0; }
footer a { color: var(--muted); }
footer a:hover { color: var(--accent-text); text-decoration: none; }
footer .site-search { display: flex; align-items: center; gap: .5rem; margin: 0; }
footer .site-search label { display: flex; align-items: center; gap: .6rem; }
footer .site-search input { width: 13rem; padding: .45rem .9rem; font-size: 13px; border-radius: 999px; background: var(--sheet); }
footer .site-search button { padding: .45rem 1rem; font-size: 12px; border-radius: 999px; }

/* ---- Narrow screens ---- */
@media (max-width: 820px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "side" "main" "foot"; grid-template-rows: auto; padding: 0 1rem; }
  body > nav { position: static; margin-bottom: 1rem; }
  body > nav > div { border: 0; margin: 0; padding: 0; }
  body > nav > div + div { display: none; }
  body > nav > div > ul { flex-direction: row; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }
  body > nav > div > ul > li { flex: none; }
  body > nav ul ul { display: none; }
  body > nav > div a { background: var(--sheet); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .9rem; }
  body > nav .thisPage, body > nav .thisPage > a { background: var(--sheet); border-color: var(--accent); }
  body > article { border-radius: 12px; }
  footer { flex-direction: column; align-items: flex-start; }
}

@media print {
  body { display: block; background: #fff; padding: 0; }
  body > nav, header nav, footer { display: none; }
  body > article { border: 0; box-shadow: none; padding: 0; }
  pre { background: #f4f5f8; color: #000; }
}
