/* ============================================================================
   shapeshift docs — the tape, read slowly
   ----------------------------------------------------------------------------
   Loaded AFTER styles.css on every page under docs/. It declares no colour of
   its own: every colour is a token from styles.css's three palette blocks, so
   the light/dark rules there hold here unchanged. It adds a sidebar index, the
   article typography, terminal panels, reference tables and manifest rows —
   nothing else.

   The two working colours keep their meaning: amber is the JSON side (input
   records, spec keys), cyan is the columnar side (types, output) and the
   page's links. Neither is used as decoration.
   ============================================================================ */

/* ── Masthead additions ───────────────────────────────────────────────── */

.logo .crumb {
  color: var(--text-3);
  font-weight: 400;
}

/* On the narrowest phones the crumb is the one thing in the masthead that can
   go: the sidebar strip below already says where you are. */
@media (max-width: 23rem) {
  .logo .crumb {
    display: none;
  }
}

.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--out);
}

/* ── Layout: an index beside the article ──────────────────────────────── */

.docs {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  padding-block: clamp(1.75rem, 4vw, 3rem) clamp(2.5rem, 6vw, 4.5rem);
  align-items: start;
}

@media (max-width: 56rem) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
}

.docnav {
  position: sticky;
  top: 4.4rem;
  font-family: var(--mono);
  font-size: var(--t-sm);
}

.docnav h4 {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 0.45rem;
}

.docnav .grp + .grp {
  margin-top: 1.4rem;
}

.docnav a {
  display: block;
  padding: 0.38rem 0.75rem;
  border-left: 1px solid var(--rule);
  color: var(--text-2);
  text-decoration: none;
  line-height: 1.35;
}

.docnav a:hover {
  color: var(--text);
  border-left-color: var(--rule-lit);
}

.docnav a[aria-current="page"] {
  color: var(--out);
  border-left: 2px solid var(--out);
  padding-left: calc(0.75rem - 1px);
  font-weight: 700;
}

/* On a phone the index is a short ruled strip above the article, not a
   column: groups sit side by side and wrap. */
@media (max-width: 56rem) {
  .docnav {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1.5rem;
    border-block: 1px solid var(--rule);
    padding-block: 0.8rem;
  }
  .docnav .grp,
  .docnav .grp + .grp {
    min-width: 0;
    margin-top: 0;
  }
  .docnav h4 {
    margin: 0 0 0.25rem;
  }
  .docnav a {
    display: inline-block;
    border-left: 0;
    padding: 0.2rem 0.7rem 0.2rem 0;
  }
  .docnav a[aria-current="page"] {
    border-left: 0;
    padding-left: 0;
    text-decoration: underline;
    text-underline-offset: 0.25em;
  }
}

/* ── Article ──────────────────────────────────────────────────────────── */

.doc {
  min-width: 0;
  max-width: 78ch;
}

.doc-head {
  margin-bottom: 2rem;
}

.doc-head h1 {
  margin-top: 0.8rem;
  font-size: clamp(1.75rem, 1rem + 2.6vw, 2.75rem);
  max-width: 22ch;
}

.doc-head .lead {
  margin-top: 1rem;
}

/* A section is a ruled band, not a card: more room above a heading than
   below it, so the heading belongs to what follows. */
.doc h2 {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem);
  max-width: none;
  margin: 3rem 0 0.9rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 4.4rem;
}

.doc h3 {
  font-size: var(--t-md);
  margin: 2rem 0 0.6rem;
  scroll-margin-top: 4.4rem;
}

.doc p {
  color: var(--text-2);
  margin: 0 0 0.95rem;
  max-width: 72ch;
}

.doc b,
.doc strong {
  color: var(--text);
  font-weight: 600;
}

.doc ul,
.doc ol {
  margin: 0 0 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--text-2);
  max-width: 72ch;
}

.doc li {
  position: relative;
  padding-left: 1.1rem;
  line-height: 1.55;
}

.doc ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 0.45rem;
  height: 1px;
  background: var(--out);
}

.doc ol {
  counter-reset: step;
}

.doc ol > li {
  padding-left: 2rem;
}

.doc ol > li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.12em;
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 700;
  color: var(--out);
}

.doc a {
  overflow-wrap: anywhere;
}

/* Inline code: a quiet chip on the panel ground. Long identifiers and paths
   break rather than push the page sideways on a phone. */
.doc :not(pre) > code {
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 0.05em 0.35em;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* In a heading the face already says "code"; a chip there only adds weight. */
.doc h1 code,
.doc h2 code,
.doc h3 code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 1em;
  color: inherit;
}

.doc .dim {
  color: var(--text-3);
}

/* ── Terminal panels ──────────────────────────────────────────────────── */

.panel {
  border: 1px solid var(--rule);
  background: var(--panel);
  margin: 0 0 1.2rem;
  min-width: 0;
}

.panel-h {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Code scrolls inside its own frame; the page never does. */
.panel pre {
  margin: 0;
  padding: 0.9rem 1rem;
  font-family: var(--mono);
  font-size: var(--t-sm);
  line-height: 1.7;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

.panel .p {
  color: var(--out);
  font-weight: 700;
  user-select: none;
}

.panel .c {
  color: var(--text-3);
}

/* Amber: the JSON side — spec keys, input records. */
.panel .k,
.panel .j {
  color: var(--in);
}

/* Cyan: the columnar side — types, what landed. */
.panel .t {
  color: var(--out);
}

.panel .bad {
  color: var(--bad);
}

/* ── Reference tables ─────────────────────────────────────────────────── */

.doc .tw {
  margin: 0 0 1.3rem;
}

table.ref {
  white-space: normal;
  min-width: 34rem;
}

table.ref thead th {
  white-space: nowrap;
}

table.ref td {
  vertical-align: top;
  line-height: 1.5;
}

table.ref td:first-child {
  white-space: nowrap;
}

table.ref code {
  color: var(--text);
}

table.ref td:first-child code {
  color: var(--out);
}

/* The JSON-side column of a spec table (a key the user writes) is amber. */
table.ref.keys td:first-child code {
  color: var(--in);
}

/* ── Notes ────────────────────────────────────────────────────────────── */

.doc .caveat {
  margin: 0 0 1.3rem;
}

.doc .caveat p {
  margin: 0;
  max-width: none;
}

.doc .caveat p + p {
  margin-top: 0.5rem;
}

/* A neutral note: the same strip in the columnar colour, for things that are
   true rather than things that cost you. */
.notice {
  margin: 0 0 1.3rem;
  border-left: 2px solid var(--out);
  background: var(--out-wash);
  padding: 0.8rem 1.1rem;
  font-size: var(--t-sm);
  color: var(--text-2);
  line-height: 1.55;
}

.notice b {
  color: var(--text);
}

/* ── Hub: manifest rows, never a grid of identical cards ──────────────── */

.manifest {
  border-top: 1px solid var(--rule-lit);
  margin: 0 0 1.5rem;
}

.mrow {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.05rem 0.25rem;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}

.mrow:hover {
  background: var(--panel);
}

.mrow .row-k {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-top: 0.2rem;
}

.mrow h3 {
  margin: 0 0 0.3rem;
  color: var(--out);
}

.mrow:hover h3 {
  color: var(--text);
}

.mrow p {
  margin: 0;
  font-size: var(--t-sm);
}

@media (max-width: 40rem) {
  .mrow {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.3rem;
  }
}

/* ── Pager ────────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}

.doc .pager a {
  overflow-wrap: normal;
}
