/* qixos.org
 *
 * One stylesheet, compiled into the binary. No JavaScript anywhere on the
 * site, so everything here is plain CSS: no custom-property fallbacks for
 * scripted theme switching, just prefers-color-scheme.
 *
 * The palette is Gruvbox, dark by default. Both themes are defined as
 * tokens on :root so components never reference a raw colour.
 *
 * Two widths, which is the whole idea of the layout:
 *
 *   --page      the site's full width. Header, footer and the blog index
 *               use it, so the page has horizontal structure.
 *   --measure   the reading column, about 70 characters. Prose and
 *               comments use it, because long lines are hard to read.
 *
 * Putting everything in --measure (as this file first did) makes a
 * laptop look like a stretched phone. Mobile does not benefit from it
 * either: on a narrow screen the viewport is the constraint and
 * max-width never comes into play.
 */

:root {
  /* Gruvbox dark, and the default: a visitor whose system explicitly
   * asks for light gets the light palette below, everyone else gets
   * this one. Names in comments are the canonical Gruvbox tones.
   *
   * One deliberate departure: Gruvbox normally draws borders in bg1
   * (#3c3836), which against bg0_h lands at a contrast ratio of 1.41 --
   * so faint the rules under the header and between posts are barely
   * there. --border uses bg3 instead, at 2.52. A 1px divider is
   * decorative rather than a UI control, so it is not held to WCAG's
   * 3.0, but 1.41 was invisible rather than subtle.
   */
  --bg: #1d2021;            /* bg0_h  */
  --surface: #282828;       /* bg0    */
  --border: #665c54;        /* bg3    */
  --text: #ebdbb2;          /* fg1    */
  --muted: #a89984;         /* gray   */
  --accent: #fabd2f;        /* bright yellow */
  --accent-hover: #fe8019;  /* bright orange */
  --on-accent: #1d2021;     /* label on an accent-filled button */

  /* Gruvbox's bright red reaches only 3.93 on this panel, so the text
   * uses the lighter red and the saturated one becomes the edge. */
  --error-bg: #3c2a28;
  --error-border: #a0483c;
  --error-text: #fb968c;

  --page: 60rem;
  --measure: 38rem;
  --gutter: 1.5rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Tell the browser the page is dark, so form controls, scrollbars and
   * the spot behind the page paint dark too rather than flashing light. */
  color-scheme: dark;
}

/* The site is dark for everyone, on purpose.
 *
 * There is no "dark unless the visitor asked for light" option to reach
 * for: `prefers-color-scheme` resolves an unset preference to `light`,
 * so a `prefers-color-scheme: light` block would catch everyone who has
 * never touched the setting -- the large majority -- and the site would
 * be light by default. The honest choices are dark for all, or
 * following the OS and being light for most people. This is the first.
 *
 * To follow the OS instead, uncomment the block below and move the dark
 * values above into a `@media (prefers-color-scheme: dark)` wrapper.
 * The light palette is tuned and ready; nothing else needs to change,
 * because no component references a raw colour.
 *
 * @media (prefers-color-scheme: light) {
 *   :root {
 *     --bg: #fbf1c7;            light bg0
 *     --surface: #f2e5bc;       light bg1
 *     --border: #bdae93;        light bg3
 *     --text: #3c3836;          dark fg1
 *     --muted: #665c54;         dark fg3
 *     --accent: #af3a03;        faded orange
 *     --accent-hover: #9d0006;  faded red
 *     --on-accent: #fbf1c7;
 *     --error-bg: #f7e2d4;
 *     --error-border: #d79a8b;
 *     --error-text: #9d0006;
 *   }
 * }
 */

/* ------------------------------------------------------------- structure */

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

body {
  margin: 0 auto;
  padding: 0 var(--gutter) 5rem;
  max-width: var(--page);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  /* Keep long URLs in comments from widening the page on a phone. */
  overflow-wrap: break-word;
}

main {
  margin-top: 3rem;
}

/* The reading column.
 *
 * Left-aligned rather than centred, so its left edge lines up with the
 * wordmark in the header and the text in the footer. One left spine
 * down the page reads as deliberate; a column centred under a
 * full-width header looks a few pixels off no matter what you do. The
 * balance comes from <body> itself being centred in the viewport. */
.column {
  max-width: var(--measure);
}

/* The blog index is a list, not paragraphs, so it uses the full page
 * width and spends it on a date gutter. */
.listing {
  max-width: 100%;
}

@media (min-width: 48rem) {
  :root {
    --gutter: 2.5rem;
  }

  main {
    margin-top: 4rem;
  }
}

/* ---------------------------------------------------------------- header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  align-items: baseline;
  justify-content: space-between;
  /* Full page width, not the reading measure: this is what stops the
   * layout reading as a narrow strip on a laptop. */
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.wordmark {
  font-weight: 650;
  font-size: 1.3rem;
  letter-spacing: -0.015em;
  color: var(--text);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  gap: 1.75rem;
  font-size: 0.9375rem;
}

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

.site-header nav a:hover,
.site-header nav a:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ------------------------------------------------------------- typography */

h1 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.022em;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 0.75rem;
}

h3 {
  font-size: 1.0938rem;
  margin: 1.75rem 0 0.5rem;
}

@media (min-width: 48rem) {
  h1 {
    font-size: 2.3rem;
  }
}

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

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

.prose > :first-child {
  margin-top: 0;
}

.prose blockquote {
  margin: 1.75rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.prose ul,
.prose ol {
  padding-left: 1.4rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.875em;
}

code {
  padding: 0.15em 0.35em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

pre {
  margin: 1.75rem 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  /* Wide code scrolls in its own box rather than the whole page. */
  overflow-x: auto;
}

pre code {
  padding: 0;
  background: none;
  border: 0;
}

/* Code is the one thing allowed out of the reading column: snippets are
 * often wider than prose wants to be, and there is spare room beside it. */
@media (min-width: 60rem) {
  .prose > pre {
    /* Extends right into the empty margin, never left: the spine stays
     * unbroken. */
    width: calc(var(--measure) + 7rem);
  }
}

table {
  width: 100%;
  margin: 1.75rem 0;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

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

.meta,
.fineprint {
  color: var(--muted);
  font-size: 0.875rem;
}

.meta {
  margin: 0 0 2rem;
}

.draft-tag {
  padding: 0.05em 0.4em;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------ post lists */

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The short list on the front page: title left, date right. */
.post-list li {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
}

.post-list time {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* The blog index: title, date and summary per entry. */
.post-list.detailed li {
  display: block;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list.detailed li:first-child {
  padding-top: 0.5rem;
}

.post-list.detailed h2 {
  margin: 0 0 0.3rem;
  font-size: 1.25rem;
}

.post-list.detailed h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-list.detailed h2 a:hover,
.post-list.detailed h2 a:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

.post-list.detailed .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin: 0 0 0.45rem;
}

/* Once there is room, the date and comment count move into a gutter to
 * the left of the title, which is what makes the index look composed
 * rather than like a phone list. */
@media (min-width: 52rem) {
  .post-list.detailed li {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 0 2.5rem;
  }

  .post-list.detailed h2 {
    grid-area: 1 / 2;
  }

  .post-list.detailed .summary {
    grid-area: 2 / 2;
  }

  .post-list.detailed .meta {
    grid-area: 1 / 1;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    margin: 0;
    text-align: right;
    /* Line up with the first line of the title beside it. */
    padding-top: 0.3rem;
  }
}

.summary {
  margin: 0;
  color: var(--muted);
}

.recent {
  margin-top: 3.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------------ docs */

.doc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-list li {
  display: grid;
  gap: 0.2rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.doc-list li:first-child {
  padding-top: 0.4rem;
}

.doc-list > li > a {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.doc-list > li > a:hover,
.doc-list > li > a:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

.breadcrumb {
  margin: 0 0 1.5rem;
}

.doc-source {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

/* Single column by default; the sidebar is just a list at the end. */
.doc-layout {
  max-width: var(--measure);
}

.doc-nav {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.doc-nav-title {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.doc-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
  font-size: 0.9375rem;
}

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

.doc-nav a:hover,
.doc-nav a:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* The current page, which is a span rather than a link. */
.doc-nav [aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* Once there is room beside the reading column, the index moves into it
 * and stays put while the page scrolls. */
@media (min-width: 64rem) {
  .doc-layout {
    display: grid;
    grid-template-columns: var(--measure) minmax(0, 1fr);
    gap: 0 3rem;
    max-width: 100%;
  }

  .doc-body {
    grid-column: 1;
  }

  .doc-nav {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 2rem;
    align-self: start;
    margin-top: 0.4rem;
    padding-top: 0;
    border-top: 0;
  }

  /* Code blocks break out of the reading column elsewhere on the site.
   * Here that space belongs to the sidebar, so the breakout is cancelled
   * rather than allowed to slide underneath it. */
  .doc-layout .prose > pre {
    width: auto;
  }
}

/* -------------------------------------------------------------- comments */

.comments {
  margin-top: 4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.comment {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-meta {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.comment-author {
  color: var(--text);
  font-weight: 600;
}

.comment-body > p {
  margin: 0 0 0.6rem;
}

.comment-body > p:last-child {
  margin-bottom: 0;
}

/* ----------------------------------------------------------- comment form */

.comment-form {
  margin-top: 2.5rem;
}

.comment-form p {
  margin: 0 0 1rem;
}

.comment-form label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9375rem;
  font-weight: 550;
}

.comment-form input[type="text"],
.comment-form textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
  font-size: 1rem;
}

/* The name field does not need to be as wide as the comment box. */
@media (min-width: 36rem) {
  .comment-form input[type="text"] {
    max-width: 22rem;
  }
}

.comment-form textarea {
  resize: vertical;
  line-height: 1.55;
}

.comment-form input[type="text"]:focus-visible,
.comment-form textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.comment-form button {
  padding: 0.5rem 1.2rem;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: 5px;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.comment-form button:hover,
.comment-form button:focus-visible {
  background: var(--accent-hover);
}

.form-error {
  padding: 0.6rem 0.8rem;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-left-width: 3px;
  border-radius: 4px;
  color: var(--error-text);
  font-size: 0.9375rem;
}

/* The honeypot. Moved off-screen rather than hidden with display:none,
 * because plenty of bots skip fields they can tell are not rendered.
 * aria-hidden and tabindex="-1" in the markup keep it away from people
 * using a screen reader or the keyboard. */
.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.5rem;
  justify-content: space-between;
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0;
}

.empty {
  color: var(--muted);
}
