/* docs.ohmmmm.com, in the ohm design system (design.ohmmmm.com): white paper and ink, Coconat
   for the page and section titles only, Helvetica Neue at reading size for everything else, the
   forest green kept for focus and diagrams, and no edges: columns and blocks are set apart by
   tone and space. The values below are the design system's tokens (ohm-ui, tokens.css).

   Page shell, the same on every page:
     .site-sidebar  left column, on its own tone: every page, in its group, the current one marked
     main           middle column: the page itself (one <article>)
     .site-toc      right column, on wide screens: the reader, this page's sections, the one being read marked
   On narrow screens: a menu control in document flow opens the sidebar above the page. */
@font-face {
  font-family: "Coconat";
  src: url("/assets/fonts/coconat-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ohm-font-serif: "Coconat", Georgia, "Times New Roman", serif;
  --ohm-font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ohm-font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Colour: one neutral set, the forest green, and red for the one warning. */
  --ohm-paper: #fff;
  --ohm-menu: #fafafa;     /* the sidebar's tone */
  --ohm-wash: #f5f5f5;     /* hover, code, figures, alternate table rows */
  --ohm-muted: #6b6b6b;    /* secondary text */
  --ohm-ink: #242424;      /* text */
  --ohm-forest: #013220;   /* focus, diagram marks */
  --ohm-red: #e5484d;
  --ohm-red-wash: color-mix(in oklab, var(--ohm-red) 9%, var(--ohm-paper));
  --ohm-current: rgb(36 36 36 / 0.08); /* the row you are on */
  --ohm-selection: rgb(1 50 32 / 0.14);

  /* Type: reading sizes of the five roles. */
  --ohm-size: 16px;
  --ohm-leading: 1.6;
  --ohm-size-small: 14px;  /* the sidebar and the reader */
  --ohm-size-label: 12px;  /* group labels */
  --ohm-text: 400 var(--ohm-size)/var(--ohm-leading) var(--ohm-font-sans);
  --ohm-tracking: -0.011em;
  --ohm-strong: 600;
  --ohm-title: 400 clamp(36px, 5vw, 48px)/1.1 var(--ohm-font-serif);  /* h1, Coconat has one weight */
  --ohm-title-tracking: -0.03em;
  --ohm-section: 400 24px/32px var(--ohm-font-serif);                 /* h2 */
  --ohm-section-tracking: -0.02em;

  /* Shape and space. */
  --ohm-radius-item: 12px;
  --ohm-radius-field: 16px;
  --ohm-radius-card: 24px;
  --ohm-measure: 680px;
  --ohm-rail: 248px;
  --ohm-toc: 220px;
  --ohm-gap: clamp(32px, 4vw, 64px);
  --ohm-top: 40px;
  --ohm-paragraph: 1em;

  font-family: var(--ohm-font-sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  background: var(--ohm-paper);
  color: var(--ohm-ink);
}

* { box-sizing: border-box; }

::selection { background: var(--ohm-selection); }

body,
h1, h2, h3, p, ul, ol, li {
  font: var(--ohm-text);
  letter-spacing: var(--ohm-tracking);
}

h1, h2, h3, p, ul, ol { margin: 0; }

h1 {
  font: var(--ohm-title);
  letter-spacing: var(--ohm-title-tracking);
}

h2 {
  font: var(--ohm-section);
  letter-spacing: var(--ohm-section-tracking);
}

h3 {
  font-weight: var(--ohm-strong);
  line-height: 1.5;
}

a {
  color: inherit;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: rgb(36 36 36 / 0.3);
}

a:hover { text-decoration-color: currentColor; }

a:focus-visible {
  outline: 2px solid var(--ohm-forest);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Icons are Lucide, drawn in the ink of the text around them. */
.icon {
  display: block;
  flex: none;
}

/* ---------- Shell ---------- */

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--ohm-rail) minmax(0, 1fr);
  grid-template-rows: 1fr;
  column-gap: var(--ohm-gap);
}

.skip {
  position: absolute;
  left: 16px;
  top: 8px;
  z-index: 3;
  padding: 6px 12px;
  border-radius: var(--ohm-radius-item);
  transform: translateY(-200%);
  background: var(--ohm-paper);
}

.skip:focus { transform: none; }

/* The sidebar is a column of its own tone, full height, with no edge. */
.site-sidebar {
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  padding: var(--ohm-top) 12px var(--ohm-top);
  background: var(--ohm-menu);
}

main {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  width: min(100%, var(--ohm-measure));
  padding: calc(var(--ohm-top) + 16px) 0 96px;
}

.site-toc { display: none; }

/* The menu button and its checkbox only exist on narrow screens. */
.menu-toggle,
.menu-button { display: none; }

@media (min-width: 761px) and (min-height: 480px) {
  .site-sidebar,
  .site-toc {
    position: sticky;
    top: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .site-toc { height: auto; }
}

/* The reader gets a third column when there is room for it. */
@media (min-width: 1240px) {
  body { grid-template-columns: var(--ohm-rail) minmax(0, 1fr) var(--ohm-toc); }

  .site-toc {
    display: block;
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    padding: calc(var(--ohm-top) + 16px) 24px 0 0;
  }
}

/* ---------- Sidebar ---------- */

.site-sidebar ul,
.site-toc ul {
  list-style: none;
  padding: 0;
}

/* A group's name: small and quiet, lined up with the rows' text. */
.sidebar-group {
  padding: 0 12px;
  color: var(--ohm-muted);
  font-size: var(--ohm-size-label);
  line-height: 16px;
  letter-spacing: 0;
}

.site-sidebar ul { margin-top: 6px; }

.site-sidebar ul + .sidebar-group { margin-top: 24px; }

.site-sidebar li + li { margin-top: 1px; }

/* Each page is a row; the one you are on sits on a tone. Rows highlight with tone, never a line. */
.site-sidebar a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--ohm-radius-item);
  color: var(--ohm-muted);
  font-size: var(--ohm-size-small);
  line-height: 20px;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: background-color 180ms cubic-bezier(.23, 1, .32, 1), color 180ms cubic-bezier(.23, 1, .32, 1);
}

.site-sidebar a:hover {
  background: var(--ohm-wash);
  color: var(--ohm-ink);
}

.site-sidebar a[aria-current="page"] {
  background: var(--ohm-current);
  color: var(--ohm-ink);
  font-weight: 500;
}

/* The first row is the docs' name, set like the design system's sidebar heading. */
.site-sidebar > ul:first-child a {
  padding-block: 4px 12px;
  background: none;
  color: var(--ohm-ink);
  font: 400 24px/1 var(--ohm-font-serif);
  letter-spacing: -0.02em;
}

.site-sidebar > ul:first-child a::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ohm-forest);
  vertical-align: 0.12em;
}

/* ---------- The reader: On this page ---------- */

.site-toc > p {
  color: var(--ohm-muted);
  font-size: var(--ohm-size-label);
  line-height: 16px;
  letter-spacing: 0;
}

.site-toc > ul { margin-top: 10px; }

.site-toc ul ul { padding-left: 12px; }

/* The section being read is marked by its ink and weight, not by a rail. */
.site-toc a {
  display: block;
  padding: 4px 0;
  color: var(--ohm-muted);
  font-size: var(--ohm-size-small);
  line-height: 20px;
  letter-spacing: -0.01em;
  text-decoration: none;
  /* one line each, as on the page's own headings; the full heading shows on hover */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 180ms cubic-bezier(.23, 1, .32, 1);
}

.site-toc a:hover { color: var(--ohm-ink); }

.site-toc a[aria-current] {
  color: var(--ohm-ink);
  font-weight: 500;
}

/* ---------- The page ---------- */

.group { color: var(--ohm-muted); }

/* The notice on every page: ohm is still being made, and these pages say how it is meant to
   work. It is a warning, so it sits on the red's wash, with no edge; its words stay in ink. */
.alert {
  margin-block: var(--ohm-top) 0;
  padding: 14px 18px;
  border-radius: var(--ohm-radius-field);
  background: var(--ohm-red-wash);
  color: var(--ohm-ink);
  font-size: var(--ohm-size-small);
  line-height: 1.55;
}

.alert::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--ohm-red);
  vertical-align: 0.1em;
}

.alert a { color: inherit; }

/* The group a page is in, above its title. */
article > header > .group {
  font-size: var(--ohm-size-small);
}

article > header > .group + h1 { margin-top: 8px; }

article > header > h1 + * { margin-top: 20px; }

article > header > * + * { margin-top: var(--ohm-paragraph); }

.introduction { color: var(--ohm-ink); }

section {
  margin-top: 3.25em;
  scroll-margin-top: 24px;
}

section :is(h2, h3) { scroll-margin-top: 24px; }

section > * + * { margin-top: var(--ohm-paragraph); }

section > h2 + * { margin-top: 0.75em; }

section > * + h3 { margin-top: 1.75em; }

section p,
section li {
  text-wrap: pretty;
  overflow-wrap: break-word;
}

section :is(ul, ol) { padding-left: 1.2em; }

section li + li { margin-top: 0.4em; }

/* The first page: each page and what it covers. */
section ul.pages {
  list-style: none;
  padding-left: 0;
}

section ul.pages a { font-weight: 500; }

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

code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: var(--ohm-wash);
  font-size: 0.88em;
}

pre {
  margin: 0;
  padding: 16px 18px;
  border-radius: var(--ohm-radius-field);
  background: var(--ohm-wash);
  font-size: var(--ohm-size-small);
  line-height: 1.6;
  overflow-x: auto;
}

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

/* A diagram: drawn by build.py as SVG with a class on every shape, and set on a quiet panel. On a
   narrow screen it keeps its size and scrolls sideways, so its words stay readable. */
.figure { margin: 0; }
section > .figure { margin-block: 1.5em; }

.figure-scroll {
  padding: 24px;
  border-radius: var(--ohm-radius-card);
  background: var(--ohm-wash);
  overflow-x: auto;
}

.figure svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
  font-family: var(--ohm-font-sans);
}

.figure figcaption {
  margin-top: 10px;
  color: var(--ohm-muted);
  font-size: var(--ohm-size-small);
}

.d-group { fill: rgb(36 36 36 / 0.04); }
.d-box { fill: var(--ohm-paper); }
.d-outside { fill: none; stroke: rgb(36 36 36 / 0.18); stroke-width: 1.5; stroke-dasharray: 4 4; }
.d-note { fill: var(--ohm-forest); }
.d-title { fill: var(--ohm-ink); font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.d-sub { fill: var(--ohm-muted); font-size: 12px; }
.d-caption { fill: var(--ohm-muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; }
.d-label { fill: var(--ohm-muted); font-size: 12px; }
/* A step's words can sit across another part's line, so they carry the panel's colour behind them. */
.d-step { fill: var(--ohm-ink); font-size: 12.5px; paint-order: stroke; stroke: var(--ohm-wash); stroke-width: 6px; stroke-linejoin: round; }
.d-note + .d-step { fill: var(--ohm-paper); stroke: none; }
.d-arrow { fill: none; stroke: var(--ohm-forest); stroke-width: 1.5; }
.d-dashed { stroke-dasharray: 5 4; }
.d-head { fill: var(--ohm-forest); }
.d-life { fill: none; stroke: rgb(36 36 36 / 0.18); stroke-width: 1.5; }

/* A table is set apart by tone alone: no rules, alternate rows on the wash, the heading in weight. */
.table { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  min-width: 7em;
  padding: 8px 16px;
  font: var(--ohm-text);
  font-size: 15px;
  letter-spacing: var(--ohm-tracking);
  text-align: left;
  vertical-align: top;
}

th { font-weight: var(--ohm-strong); }

thead th { color: var(--ohm-muted); font-size: var(--ohm-size-small); font-weight: 500; }

tbody tr:nth-child(odd) > * { background: var(--ohm-wash); }
tbody tr > :first-child { border-radius: var(--ohm-radius-item) 0 0 var(--ohm-radius-item); }
tbody tr > :last-child { border-radius: 0 var(--ohm-radius-item) var(--ohm-radius-item) 0; }

/* A list of facts has no heading row, and its names keep one width down a page of such lists. */
.facts thead { display: none; }
.facts th { width: 8.5em; }

/* The page before and the page after: two quiet buttons. */
.page-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4em;
}

.page-pager a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ohm-wash);
  font-size: var(--ohm-size-small);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 180ms cubic-bezier(.23, 1, .32, 1), scale 130ms cubic-bezier(.23, 1, .32, 1);
}

.page-pager a:hover { background: #ebebeb; }
.page-pager a:active { scale: 0.97; }

.page-pager a[rel="next"] { margin-left: auto; }

/* ---------- Narrow screens ---------- */

@media (max-width: 760px) {
  body { display: block; padding: 0 20px; }

  main { padding: 24px 0 56px; }

  /* The checkbox stays focusable; its visible label is an ordinary flow control. */
  .menu-toggle {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 10px 0; /* icon and padding give a 44px touch target */
    cursor: pointer;
  }

  .menu-toggle:focus-visible + .menu-button {
    outline: 2px solid var(--ohm-forest);
    outline-offset: 4px;
    border-radius: 4px;
  }

  .site-sidebar {
    display: none;
    margin: 8px -20px 0;
    padding: 16px 12px 24px;
  }

  .menu-toggle:checked ~ .site-sidebar { display: block; }

  .site-sidebar a {
    padding-block: 10px;
    font-size: var(--ohm-size);
  }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
