/* Documentation & reference layer, on top of kevy.css.
 *
 * A reference manual is a place people arrive at from a search engine, read one
 * fact, and leave. So: the fact is above the fold, the page is scannable at a
 * glance, and nothing animates. Every rule here earns its place by making a
 * command page faster to read — there is no decoration.
 */

/* ── the reference page ─────────────────────────────────────────────────── */

.ref {
  max-width: 62rem;
}

.crumb {
  display: flex;
  gap: 0.5ch;
  align-items: baseline;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-bottom: 1.75rem;
  font-family: var(--mono);
}
.crumb a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.crumb a:hover {
  color: var(--blue);
  border-bottom-color: currentColor;
}
.crumb span {
  color: var(--edge);
}
.crumb b {
  color: var(--text);
  font-weight: 600;
}

h1.cmd {
  font-family: var(--mono);
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  /* A command name is an identifier, not a headline. Tight, monospaced,
   * and the same weight the reader will type it in. */
}

.ref .lede {
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text-2);
  max-width: 62ch;
  margin: 0 0 2rem;
}

/* The syntax line is the single thing most readers came for. It gets the
 * strongest frame on the page and sits directly under the summary. */
pre.syntax {
  margin: 0 0 2rem;
  padding: 1rem 1.15rem;
  background: var(--deep);
  border: 1px solid var(--edge);
  border-left: 3px solid var(--blue);
  border-radius: 3px;
  overflow-x: auto;
}
pre.syntax code {
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: none;
  padding: 0;
  white-space: pre;
}

/* ── the metadata strip ─────────────────────────────────────────────────── */

dl.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px;
  margin: 0 0 2.5rem;
  background: var(--edge);
  border: 1px solid var(--edge);
  border-radius: 3px;
  overflow: hidden;
}
dl.meta > div {
  background: var(--lift);
  padding: 0.75rem 1rem;
}
dl.meta dt {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 0.3rem;
  font-weight: 600;
}
dl.meta dd {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
}
dl.meta dd.mono {
  font-family: var(--mono);
}
dl.meta dd code {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  margin-right: 0.25rem;
  background: var(--deep);
  border: 1px solid var(--edge);
  border-radius: 2px;
  color: var(--text-2);
}

/* ── sections ───────────────────────────────────────────────────────────── */

.ref section {
  margin-bottom: 2.5rem;
}
.ref h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--text-3);
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--edge);
}

/* The complexity line is the column Redis's reference does not have. It is
 * rendered as code because it IS a claim about the machine, not prose. */
.cx-body {
  margin: 0 0 0.65rem;
}
.cx-body code {
  display: block;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
  padding: 0.85rem 1rem;
  background: var(--deep);
  border: 1px solid var(--edge);
  border-radius: 3px;
  color: var(--text);
  white-space: pre-wrap;
}
.engine-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-3);
  max-width: 68ch;
}

/* ── the compatibility callout ──────────────────────────────────────────── */
/* Three states, three colours, and the one that means "this will surprise you"
 * is the one that gets the loud one. Honesty is the design element here: the
 * --loss colour exists precisely so a difference cannot be quietly styled away. */

.call {
  padding: 0.9rem 1.1rem;
  border-radius: 3px;
  border: 1px solid var(--edge);
  border-left-width: 3px;
  background: var(--lift);
}
.call .h {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.4rem;
}
.call p {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text);
  max-width: 68ch;
}
.call.note {
  border-left-color: var(--blue-dim);
}
.call.note .h {
  color: var(--blue-dim);
}
.call.loss {
  border-left-color: var(--thin);
  background: var(--thin-wash);
}
.call.loss .h {
  color: var(--thin);
}
.call.warn {
  border-left-color: var(--blue);
  background: var(--blue-wash);
}
.call.warn .h {
  color: var(--blue);
}

/* ── see-also ───────────────────────────────────────────────────────────── */

.sees {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
}
.sees a {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--edge);
  border-radius: 2px;
  color: var(--text-2);
  text-decoration: none;
  background: var(--lift);
}
.sees a:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.back {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--edge);
  font-size: 0.875rem;
}
.back a {
  color: var(--text-2);
  text-decoration: none;
}
.back a:hover {
  color: var(--blue);
}

/* ── the index: filters ─────────────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 2rem 0 1.25rem;
  position: sticky;
  top: var(--mast-h);
  z-index: 5;
  padding: 0.85rem 0;
  background: var(--void);
  border-bottom: 1px solid var(--edge);
}
.filters input,
.filters select {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.65rem;
  background: var(--lift);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 3px;
}
.filters input {
  flex: 1 1 16rem;
  min-width: 0;
  font-family: var(--mono);
}
.filters input:focus,
.filters select:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
  border-color: var(--blue);
}
.hits {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-3);
  margin-left: auto;
  white-space: nowrap;
}

/* ── the index: table ───────────────────────────────────────────────────── */

.tbl {
  overflow-x: auto;
  border: 1px solid var(--edge);
  border-radius: 3px;
}
.tbl table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.tbl thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  background: var(--deep);
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}
.tbl tbody tr {
  border-bottom: 1px solid var(--edge);
}
.tbl tbody tr:last-child {
  border-bottom: 0;
}
.tbl tbody tr:hover {
  background: var(--lift);
}
.tbl td {
  padding: 0.6rem 0.85rem;
  vertical-align: top;
  line-height: 1.5;
}
.tbl td.k {
  white-space: nowrap;
}
.tbl td.k a {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text);
  text-decoration: none;
}
.tbl td.k a:hover {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tbl td.g {
  color: var(--text-3);
  white-space: nowrap;
  font-size: 0.8125rem;
}
/* The cost term, not the essay. `nowrap` on the full complexity line grew the
 * cell to several thousand pixels and pushed the compatibility badge and the
 * summary off the right edge of the page. */
.tbl td.cx {
  font-size: 0.75rem;
  color: var(--text-2);
  white-space: nowrap;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbl td.sum {
  color: var(--text-2);
  min-width: 22rem;
}

.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
  white-space: nowrap;
  border: 1px solid;
}
.badge.full {
  color: var(--blue-dim);
  border-color: color-mix(in srgb, var(--blue-dim) 35%, transparent);
  background: color-mix(in srgb, var(--blue-dim) 8%, transparent);
}
.badge.differs {
  color: var(--thin);
  border-color: color-mix(in srgb, var(--thin) 35%, transparent);
  background: var(--thin-wash);
}
.badge.only {
  color: var(--blue);
  border-color: color-mix(in srgb, var(--blue) 35%, transparent);
  background: var(--blue-wash);
}

/* ── phone ──────────────────────────────────────────────────────────────── */
/* The reference table does not collapse into cards. A command reference read on
 * a phone is still a table — the reader is comparing rows. It scrolls sideways,
 * with the command name pinned so the row never loses its subject. */

@media (max-width: 40rem) {
  .filters {
    gap: 0.45rem;
  }
  .filters input {
    flex-basis: 100%;
  }
  .hits {
    margin-left: 0;
  }
  .tbl td.k {
    position: sticky;
    left: 0;
    background: var(--void);
    border-right: 1px solid var(--edge);
  }
  .tbl tbody tr:hover td.k {
    background: var(--lift);
  }
  .tbl td.sum {
    min-width: 20rem;
  }
  dl.meta {
    grid-template-columns: 1fr 1fr;
  }
  h1.cmd {
    word-break: break-all;
  }
}

/* ═══════════════════════════════════════════════════════ the docs shell
 *
 * Three columns on a desktop: the whole map on the left, the argument in the
 * middle, this page's shape on the right. The middle column is capped at 72ch
 * because a line of prose longer than that is a line the eye loses its place in
 * — and these are documents people read while something is on fire.
 *
 * On a tablet the right column goes first, because a table of contents you have
 * to scroll past is worse than no table of contents. On a phone the left column
 * goes too, and the masthead's nav is the only navigation left — which is why
 * it had to stop hiding behind a drawer that was never built.
 */

.doc-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}
@media (min-width: 1280px) {
  .doc-shell {
    grid-template-columns: 260px minmax(0, 1fr) 220px;
  }
}

/* ── sidebar ────────────────────────────────────────────────────────────── */

.side {
  position: sticky;
  top: var(--mast-h);
  max-height: calc(100vh - var(--mast-h));
  overflow-y: auto;
  padding: 2rem 1.25rem 3rem var(--gut);
  border-right: 1px solid var(--edge);
  scrollbar-width: thin;
}
.side-h {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-3);
}
.side-h:first-child {
  margin-top: 0;
}
.side ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.side li a {
  display: block;
  padding: 0.32rem 0.55rem;
  margin-left: -0.55rem;
  border-radius: 3px;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-2);
  text-decoration: none;
}
.side li a:hover {
  background: var(--lift);
  color: var(--text);
}
.side li a[aria-current="page"] {
  background: var(--blue-wash);
  color: var(--blue);
  font-weight: 600;
}

/* ── the document ───────────────────────────────────────────────────────── */

.doc {
  padding: 2.5rem var(--gut) 5rem;
  min-width: 0;
}
.doc-head {
  margin-bottom: 2.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--edge);
}
.doc-head h1 {
  margin: 0;
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.018em;
  font-weight: 640;
  color: var(--text);
  text-wrap: balance;
}
.doc-head .lede {
  margin: 0.75rem 0 0;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text-2);
  max-width: 68ch;
}

.doc h2 {
  margin: 3rem 0 1rem;
  padding-top: 0.5rem;
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 620;
  letter-spacing: -0.012em;
  color: var(--text);
  scroll-margin-top: calc(var(--mast-h) + 1rem);
  text-transform: none;
  border: 0;
}
.doc h3 {
  margin: 2rem 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 620;
  color: var(--text);
  scroll-margin-top: calc(var(--mast-h) + 1rem);
}
.doc h4 {
  margin: 1.5rem 0 0.6rem;
  font-size: 0.9375rem;
  font-weight: 620;
  color: var(--text);
}
.doc p {
  margin: 0 0 1.1rem;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-2);
  max-width: 72ch;
}
.doc ul,
.doc ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
  max-width: 72ch;
}
.doc li {
  margin-bottom: 0.4rem;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-2);
}
.doc li::marker {
  color: var(--text-3);
}
.doc a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.doc b {
  color: var(--text);
  font-weight: 620;
}
.doc code {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  background: var(--deep);
  border: 1px solid var(--edge);
  color: var(--text);
  word-break: break-word;
}
.doc figure.code {
  margin: 0 0 1.4rem;
  border: 1px solid var(--edge);
  border-radius: 4px;
  overflow: hidden;
  background: var(--deep);
}
.doc figure.code pre {
  margin: 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
}
.doc figure.code code {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.75;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-2);
  white-space: pre;
  word-break: normal;
}
.doc blockquote {
  margin: 0 0 1.3rem;
  padding: 0.85rem 1.1rem;
  border-left: 3px solid var(--blue);
  background: var(--blue-wash);
  border-radius: 0 3px 3px 0;
  max-width: 72ch;
}
.doc blockquote p {
  margin: 0;
  font-size: 0.9375rem;
}
.doc hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--edge);
}
.doc .tbl {
  margin-bottom: 1.4rem;
}
.doc .tbl table {
  font-size: 0.875rem;
}
.doc .tbl td:first-child {
  font-family: inherit;
  font-weight: 400;
}

/* ── the on-this-page rail ──────────────────────────────────────────────── */

.toc {
  display: none;
}
@media (min-width: 1280px) {
  .toc {
    display: block;
    position: sticky;
    top: var(--mast-h);
    max-height: calc(100vh - var(--mast-h));
    overflow-y: auto;
    padding: 2.5rem var(--gut) 3rem 0;
  }
}
.toc-h {
  margin: 0 0 0.6rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-3);
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--edge);
}
.toc li a {
  display: block;
  padding: 0.25rem 0 0.25rem 0.75rem;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-3);
  text-decoration: none;
}
.toc li.l3 a {
  padding-left: 1.5rem;
  font-size: 0.75rem;
}
.toc li a:hover {
  color: var(--blue);
  border-left-color: var(--blue);
}

/* ── the hub ────────────────────────────────────────────────────────────── */

.hub-sec {
  margin-bottom: 2.75rem;
}
.hub-sec h2 {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--text-3);
  border: 0;
  padding: 0;
}
.hub-sec .cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  background: var(--void);
  border: 1px solid var(--edge);
  border-radius: 4px;
  overflow: hidden;
}
.hub-sec .card {
  padding: 1rem 1.1rem 1.1rem;
  text-decoration: none;
  border-right: 1px solid var(--edge);
  border-bottom: 1px solid var(--edge);
  margin: 0 -1px -1px 0;
  min-width: 0;
}
.hub-sec .card:hover {
  background: var(--lift);
}
.hub-sec .card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.9375rem;
  font-weight: 620;
  color: var(--text);
  line-height: 1.35;
}
.hub-sec .card p {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-2);
  max-width: none;
}

/* ── tablet & phone ─────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .doc-shell {
    grid-template-columns: 1fr;
  }
  .side {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--edge);
    padding: 1.25rem var(--gut);
    /* A twenty-four-item map is not what someone on a phone wants above the
     * document they clicked. It folds; the masthead nav stays. */
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
  }
  .side-h {
    flex: 1 0 100%;
    margin: 0.75rem 0 0.25rem;
  }
  .side-h:first-child {
    margin-top: 0;
  }
  .side ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
  }
}

/* A language we do not have this page in. The link still works — it goes to
 * that language's hub — but it does not pretend the translation exists. */
.lang a.untranslated {
  opacity: 0.4;
}
.lang a.untranslated:hover {
  opacity: 0.7;
}

/* Same reason as pages.css: CJK display type is heavier at the same size, and
 * CJK prose needs more leading and a narrower measure than Latin. */
:lang(zh) .doc-head h1,
:lang(ja) .doc-head h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.15rem);
  line-height: 1.35;
  letter-spacing: 0;
  font-weight: 700;
}
:lang(zh) .doc h2,
:lang(ja) .doc h2 {
  font-size: 1.25rem;
  line-height: 1.45;
  letter-spacing: 0;
}
:lang(zh) .doc p,
:lang(ja) .doc p,
:lang(zh) .doc li,
:lang(ja) .doc li {
  line-height: 1.95;
}
:lang(zh) .doc p,
:lang(ja) .doc p {
  max-width: 45ch;
}
:lang(zh) h1.cmd,
:lang(ja) h1.cmd {
  letter-spacing: -0.01em; /* a command name is Latin even on a Chinese page */
}
