/*
 * docs.css
 * OWNS: /docs. Three columns as on resend.com/docs: a sticky sidebar
 * (search + grouped pages), the article (max 46rem), and "On this page".
 * Built from tokens.css: black canvas, slate hairlines, gray-12 headings,
 * gray-11 prose, Commit Mono code, glass surfaces.
 */

.page-docs {
  min-height: 100dvh;
}

.docs {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 224px;
  gap: var(--s-10);
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ============================================================ sidebar */

.docs__side {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  height: calc(100dvh - var(--nav-h));
  padding-block: var(--s-8) var(--s-7);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-5) transparent;
}

.docs__menu {
  display: none;
}

.docs__search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 38px;
  margin-bottom: var(--s-7);
  padding: 0 var(--s-2) 0 var(--s-3);
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--slate-2);
  color: var(--text-muted);
  transition: border-color var(--dur-fast) var(--ease);
}

.docs__search:focus-within {
  border-color: var(--slate-8);
}

.docs__search svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.docs__search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: var(--text-sm);
  color: var(--text-emphasis);
  outline: none;
}

.docs__search input::placeholder {
  color: var(--gray-9);
}

.docs__search input::-webkit-search-cancel-button {
  display: none;
}

.docs__kbd {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-9);
}

.docs__group + .docs__group {
  margin-top: var(--s-7);
}

.docs__group-title {
  margin: 0 0 var(--s-2) var(--s-3);
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.docs__link {
  display: block;
  padding: 6px var(--s-3);
  border-radius: 10px;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.docs__link:hover {
  color: var(--text-emphasis);
  background: var(--slate-2);
}

.docs__link[aria-current="page"] {
  color: var(--text-strong);
  background: var(--slate-3);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.docs__empty {
  margin-left: var(--s-3);
  font-size: var(--text-sm);
  color: var(--gray-9);
}

/* ============================================================ article */

.docs__main {
  min-width: 0;
  padding-block: var(--s-10) var(--s-12);
}

.docs__article {
  max-width: 46rem;
}

.docs__head {
  padding-bottom: var(--s-7);
  margin-bottom: var(--s-7);
  border-bottom: var(--hairline) solid var(--line-hairline);
}

.docs__eyebrow {
  margin-bottom: var(--s-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
}

.docs__title {
  font-family: var(--font-head);
  font-size: clamp(1.875rem, 1.5rem + 1vw, 2.25rem);
  font-weight: var(--fw-medium);
  letter-spacing: -0.04em;
  line-height: 1.15;
  background: var(--heading-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.docs__lede {
  margin-top: var(--s-3);
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--text-muted);
}

/* ---- prose ---- */

.prose-docs {
  font-size: var(--text-base);
  line-height: 1.75;
  color: var(--text-muted);
}

.prose-docs > * + * {
  margin-top: var(--s-5);
}

.prose-docs h2 {
  position: relative;
  margin-top: var(--s-10);
  font-size: var(--text-2xl);
  font-weight: var(--fw-medium);
  letter-spacing: -0.03em;
  line-height: 1.3;
  color: var(--text-emphasis);
  scroll-margin-top: calc(var(--nav-h) + var(--s-6));
}

.prose-docs h3 {
  margin-top: var(--s-8);
  font-size: var(--text-lg);
  font-weight: var(--fw-medium);
  letter-spacing: -0.02em;
  color: var(--text-emphasis);
  scroll-margin-top: calc(var(--nav-h) + var(--s-6));
}

.prose-docs h2 + *,
.prose-docs h3 + * {
  margin-top: var(--s-3);
}

/* "#" anchor that appears beside a heading on hover (added by docs.js). */
.heading-anchor {
  position: absolute;
  left: -1.4em;
  padding-right: 0.4em;
  color: var(--gray-8);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}

.prose-docs h2:hover .heading-anchor,
.prose-docs h3:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.prose-docs a {
  color: var(--text-emphasis);
  text-decoration: underline;
  text-decoration-color: var(--slate-7);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur-fast) var(--ease);
}

.prose-docs a:hover {
  text-decoration-color: var(--text-emphasis);
}

.prose-docs strong {
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.prose-docs em {
  font-style: italic;
  color: var(--text-emphasis);
}

.prose-docs :not(pre) > code {
  padding: 2px 6px;
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-xs);
  background: var(--slate-2);
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--text-emphasis);
  white-space: nowrap;
}

/* Identifiers and hashes: the one place violet belongs. */
.prose-docs code.hash {
  color: var(--accent);
}

.prose-docs ul,
.prose-docs ol {
  padding-left: var(--s-5);
}

.prose-docs li + li {
  margin-top: var(--s-2);
}

.prose-docs ul li::marker {
  color: var(--gray-8);
}

.prose-steps-simple li::marker {
  color: var(--text-emphasis);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.docs-muted {
  color: var(--gray-9);
}

.method {
  display: inline-block;
  margin-right: var(--s-1);
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: rgb(58 211 137 / 0.12);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--ok);
}

/* ---- checklists (scope) ---- */

.prose-docs .checklist {
  padding: 0;
  list-style: none;
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-lg);
}

.checklist li {
  position: relative;
  margin: 0;
  padding: var(--s-3) var(--s-5) var(--s-3) calc(var(--s-5) + 24px);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.checklist li + li {
  border-top: var(--hairline) solid var(--line-hairline);
}

.checklist li::before {
  content: "";
  position: absolute;
  left: var(--s-5);
  top: calc(var(--s-3) + 0.45em);
  width: 9px;
  height: 5px;
  border-left: 1.5px solid var(--ok);
  border-bottom: 1.5px solid var(--ok);
  transform: rotate(-45deg);
}

.checklist--no li::before {
  top: calc(var(--s-3) + 0.75em);
  width: 10px;
  height: 0;
  border-left: 0;
  border-bottom-color: var(--flag);
  transform: none;
}

/* ---- tables ---- */

.prose-docs .docs-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-lg);
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
}

.docs-table th,
.docs-table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: var(--hairline) solid var(--line-hairline);
  text-align: left;
  vertical-align: top;
}

.docs-table tr:last-child th,
.docs-table tr:last-child td {
  border-bottom: 0;
}

.docs-table thead th {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  white-space: nowrap;
}

.docs-table tbody th {
  width: 34%;
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.docs-table td {
  color: var(--text-emphasis);
}

.docs-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- facts under a step ---- */

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-6);
  margin-top: var(--s-3);
  font-size: var(--text-sm);
}

.facts dt {
  font-size: var(--text-xs);
  color: var(--gray-9);
}

.facts dd {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-emphasis);
}

/* ============================================================ components */

/* ---- steps: numbered circles on a vertical rule ---- */
.prose-docs .steps {
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  position: relative;
  margin: 0;
  padding: 0 0 var(--s-7) 48px;
  counter-increment: step;
}

.prose-docs .step + .step {
  margin-top: 0;
}

.step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: var(--hairline) solid var(--slate-6);
  border-radius: 50%;
  background: linear-gradient(180deg, #17191c, #08090a);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-emphasis);
}

.step::after {
  content: "";
  position: absolute;
  left: 13.5px;
  top: 36px;
  bottom: 8px;
  width: 1px;
  background: var(--line-hairline);
}

.step:last-child {
  padding-bottom: 0;
}

.step:last-child::after {
  display: none;
}

.step__title {
  padding-top: 2px;
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.step__body {
  margin-top: var(--s-1);
}

.step__body > * + * {
  margin-top: var(--s-3);
}

/* ---- callouts ---- */
.callout {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--slate-2);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.callout__icon {
  padding-top: 2px;
  color: var(--info);
}

.callout__icon svg {
  width: 18px;
  height: 18px;
}

.callout--warning {
  border-color: rgb(255 202 22 / 0.22);
  background: rgb(255 202 22 / 0.05);
}

.callout--warning .callout__icon {
  color: var(--warn);
}

.callout--tip {
  border-color: rgb(58 211 137 / 0.22);
  background: rgb(58 211 137 / 0.05);
}

.callout--tip .callout__icon {
  color: var(--ok);
}

.callout__title {
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.callout__body > * + * {
  margin-top: var(--s-1);
}

/* ---- code window ---- */
.codewin {
  overflow: hidden;
  border: var(--hairline) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg);
}

.codewin__bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 44px;
  padding: 0 var(--s-2) 0 var(--s-3);
  border-bottom: var(--hairline) solid var(--line-soft);
}

.codewin__tab {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 var(--s-3);
  border: var(--hairline) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--slate-3);
  font-size: var(--text-xs);
  color: var(--text-emphasis);
}

.codewin__lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-9);
}

.codewin__copy {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: auto;
  border-radius: var(--r-sm);
  color: var(--text-muted);
}

.codewin__copy:hover {
  color: var(--text-emphasis);
  background: var(--slate-3);
}

.codewin__copy[data-copied="true"] {
  color: var(--ok);
}

.codewin__copy svg {
  width: 14px;
  height: 14px;
}

.codewin__pre {
  margin: 0;
  padding: var(--s-4) var(--s-5);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-emphasis);
  white-space: pre;
}

.c-dim { color: var(--gray-9); }
.c-str { color: var(--text-muted); }
.c-key { color: var(--text-emphasis); }
.log-cmd { color: var(--text-emphasis); }
.log-info { color: var(--text-muted); }
.log-flag { color: var(--flag); }
.log-ok { color: var(--ok); }

/* ---- link cards ---- */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

.prose-docs .doc-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-5);
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--card-sheen);
  text-decoration: none;
  transition: border-color var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease);
}

.prose-docs .doc-card:hover {
  border-color: var(--slate-8);
}

.doc-card__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: var(--s-3);
  border: var(--hairline) solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #17191c, #08090a);
  color: var(--text-emphasis);
}

.doc-card__icon svg {
  width: 16px;
  height: 16px;
}

.doc-card__title {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.doc-card__text {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---- prev / next ---- */
.docs__pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-12);
}

.docs__pager-link {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-4) var(--s-5);
  border: var(--hairline) solid var(--line-soft);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-base) var(--ease);
}

.docs__pager-link:hover {
  border-color: var(--slate-8);
}

.docs__pager-link--next {
  grid-column: 2;
  align-items: flex-end;
  text-align: right;
}

.docs__pager-dir {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.docs__pager-dir svg {
  width: 14px;
  height: 14px;
}

.docs__pager-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.docs__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-9);
  padding-top: var(--s-6);
  border-top: var(--hairline) solid var(--line-hairline);
  font-size: var(--text-xs);
  color: var(--gray-9);
}

.docs__foot a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================ on this page */

.docs__toc {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  max-height: calc(100dvh - var(--nav-h));
  padding-block: var(--s-10) var(--s-7);
  overflow-y: auto;
}

.docs__toc-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--text-emphasis);
}

.docs__toc-title svg {
  width: 14px;
  height: 14px;
}

.docs__toc ul {
  border-left: var(--hairline) solid var(--line-hairline);
}

.docs__toc a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px var(--s-3);
  border-left: var(--hairline) solid transparent;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.docs__toc a.is-sub {
  padding-left: var(--s-6);
}

.docs__toc a:hover {
  color: var(--text-emphasis);
}

.docs__toc a[aria-current="true"] {
  border-left-color: var(--text-emphasis);
  color: var(--text-emphasis);
}

/* ============================================================ responsive */

@media (max-width: 1240px) {
  .docs {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--s-9);
  }

  .docs__toc {
    display: none;
  }
}

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

  /* The sidebar folds into a breadcrumb bar that opens the page list. */
  .docs__side {
    position: sticky;
    z-index: calc(var(--z-nav) - 2);
    height: auto;
    margin-inline: calc(var(--gutter) * -1);
    padding: 0;
    overflow: visible;
    border-bottom: var(--hairline) solid var(--line-hairline);
    background-color: var(--chrome-fill);
    background-image: var(--texture);
    backdrop-filter: blur(var(--chrome-blur));
    -webkit-backdrop-filter: blur(var(--chrome-blur));
  }

  .docs__menu {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    width: 100%;
    height: 48px;
    padding: 0 var(--gutter);
    font-size: var(--text-sm);
    color: var(--text-muted);
    text-align: left;
  }

  .docs__menu svg {
    width: 15px;
    height: 15px;
    flex: none;
  }

  .docs__menu-sep {
    color: var(--gray-8);
  }

  .docs__menu-page {
    overflow: hidden;
    color: var(--text-emphasis);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .docs__nav-wrap {
    display: none;
    max-height: calc(100dvh - var(--nav-h) - 48px);
    padding: var(--s-4) var(--gutter) var(--s-6);
    overflow-y: auto;
    border-top: var(--hairline) solid var(--line-hairline);
  }

  .docs__side[data-open="true"] .docs__nav-wrap {
    display: block;
  }

  .docs__main {
    padding-top: var(--s-8);
  }

  .doc-cards,
  .docs__pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs__pager-link--next {
    grid-column: auto;
  }

  .heading-anchor {
    display: none;
  }
}

/* ============================================================ legal */
/* Shares the docs shell. Numbered clauses keep the "01, 02, 03" format of
   the original Terms, set in Commit Mono on hairline rows. */

.legal__meta {
  margin-top: var(--s-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--gray-9);
}

.prose-docs .clauses {
  padding: 0;
  list-style: none;
  counter-reset: clause;
  border-top: var(--hairline) solid var(--line-hairline);
}

.clause {
  position: relative;
  margin: 0;
  padding: var(--s-4) 0 var(--s-4) 3.25rem;
  border-bottom: var(--hairline) solid var(--line-hairline);
  counter-increment: clause;
}

.prose-docs .clause + .clause {
  margin-top: 0;
}

.clause::before {
  content: counter(clause, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: var(--s-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.75rem;
  color: var(--gray-9);
}

.clause strong {
  color: var(--text-emphasis);
}

.docs__link--button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}
