/* membrane — one stylesheet, no framework, no webfonts, no animation.
   Monospace is for the things that are a grid: commands and the category
   rows. Prose is not a grid. */

:root {
  --bg: #ffffff;
  --fg: #16181d;
  --dim: #6b7079;
  --line: #e4e6ea;
  --pre: #f7f8f9;
  --acc: #2563eb;
  --sel: #eef2ff;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e10;
    --fg: #d6d9de;
    --dim: #868c96;
    --line: #23262b;
    --pre: #141619;
    --acc: #7aa2f7;
    --sel: #1b2030;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

code,
pre,
.mark,
.cat,
.cmd {
  font-family: var(--mono);
  font-size: 13.5px;
}

a {
  color: inherit;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--acc);
}

code {
  overflow-wrap: anywhere;
}

b {
  font-weight: 600;
}

.dim {
  color: var(--dim);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: baseline;
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}

.mark {
  text-decoration: none;
}
.mark::before {
  content: "└ ";
  color: var(--dim);
}

header nav {
  display: flex;
  gap: 1.25rem;
  color: var(--dim);
}

/* --------------------------------------------------------------- main */

main {
  container-type: inline-size;
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

h1 {
  margin: 3.5rem 0 1rem;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2 {
  margin: 4rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  max-width: 68ch;
}

.lede {
  max-width: 54ch;
  font-size: 1.0625rem;
  color: var(--dim);
}

.cap {
  margin-top: 0.4rem;
  color: var(--dim);
}

/* ----------------------------------------------------- pre + copy line */

pre {
  /* Declared per block with a style attribute; this is the fallback so a
     block that forgets one still has a definition to compute against. */
  --cols: 58;
  max-width: 100%;
  margin: 1.5rem 0 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: var(--pre);
  overflow: hidden;
  /* 0.62 is a safe upper bound on advance-width ÷ em for the mono stack,
     so --cols columns always fit the container and nothing wraps. */
  font-size: min(13.5px, calc(100cqi / var(--cols) / 0.62));
  line-height: 1.5;
}

.cmd {
  display: flex;
  align-items: stretch;
  max-width: 100%;
  width: fit-content;
  margin: 1.5rem 0 0;
  border: 1px solid var(--line);
}

.cmd > code {
  min-width: 0;
  padding: 0.5rem 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy {
  flex: none;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--pre);
  color: var(--dim);
  font: inherit;
  font-family: var(--mono);
  cursor: pointer;
}
.copy:hover {
  color: var(--fg);
}

/* ---------------------------------------------------------- categories */

.cats {
  display: flex;
  flex-direction: column;
  max-width: 44rem;
  margin-top: 1.5rem;
}

.cat {
  display: grid;
  grid-template-columns: 13ch minmax(0, 1fr);
  gap: 1ch;
  align-items: baseline;
  width: 100%;
  padding: 0.2rem 0.4rem;
  border: 0;
  background: none;
  color: var(--dim);
  font: inherit;
  font-family: var(--mono);
  text-align: left;
  cursor: pointer;
}

.cat .k {
  color: var(--fg);
}

.cat .w {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat:hover {
  background: var(--pre);
}

.cat[aria-pressed="true"] {
  background: var(--sel);
}
.cat[aria-pressed="true"] .k {
  color: var(--acc);
}

/* -------------------------------------------------------------- detail */

.detail {
  min-height: 5rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.detail .d-head {
  margin: 0 0 0.4rem;
}

#d-name {
  font-family: var(--mono);
}

#d-note {
  color: var(--dim);
}

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

footer {
  max-width: 62rem;
  margin: 4rem auto 0;
  padding: 1rem 1.25rem 3rem;
  border-top: 1px solid var(--line);
}

footer p {
  margin: 0.4rem 0;
}
