/* The docs site's styling. Every colour, font, space and radius comes from tokens.css (the
   tangramflex.com theme, D15); this file only decides how the docs use them. */

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-padding-top: 88px; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection { background: var(--accent-deep); color: #fff; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.skip-link {
  position: absolute;
  left: var(--s2);
  top: -100px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--btn-solid-bg);
  color: var(--btn-solid-text);
  border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--s2); }

/* ---------- Header (modelled on the tangramflex.com header) ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 64px;
  padding-inline: var(--s3);
}

/* The Tenon mark, in the version for the current theme, then the product's name. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; height: 28px; width: 28px; }
:root[data-theme="dark"] .brand-mark-light,
:root[data-theme="light"] .brand-mark-dark { display: none; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-product {
  padding-left: 12px;
  border-left: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.version-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  white-space: nowrap;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.header-link { color: var(--muted); font-size: 14.5px; font-weight: 500; }
.header-link:hover { color: var(--text); text-decoration: none; }

.theme-toggle,
.nav-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-out);
}
.theme-toggle:hover,
.nav-toggle:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.theme-toggle .icon-sun { display: var(--toggle-sun); }
.theme-toggle .icon-moon { display: var(--toggle-moon); }

/* ---------- Layout: contents on the left, the page on the right ---------- */

/* The page uses the whole window, as the Stripe CLI docs do: the contents stay against its left
   edge, reading text keeps to a comfortable width, and examples take what's left on the right. */
:root { --read: 40rem; --example: 700px; --sidebar: 280px; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 65px;
  height: calc(100vh - 65px);
  overflow-y: auto;
  padding: var(--s4) var(--s3) var(--s6);
  border-right: 1px solid var(--border);
  font-size: 14.5px;
}

.toc-part + .toc-part { margin-top: 6px; }
div.toc-part { margin-bottom: var(--s2); }

/* A part's title folds it open and shut (<details>, no script). The caret sits in the title's
   left padding, and the part's links are indented by the same amount, so their text lines up
   with the title's text rather than with the caret. */
.sidebar { --toc-indent: 16px; }

.toc-part-title {
  position: relative;
  display: block;
  padding: 7px 0 7px var(--toc-indent);
  list-style: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.toc-part-title::-webkit-details-marker { display: none; }
.toc-part-title::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 13px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease-out);
}
.toc-part[open] > .toc-part-title::before { top: 11px; transform: rotate(45deg); }
.toc-part-title:hover { color: var(--text); }
details.toc-part > ul { margin: 2px 0 10px var(--toc-indent); }

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar ul ul { margin: 2px 0 4px 12px; padding-left: 10px; border-left: 1px solid var(--border); }

.sidebar a,
.toc-group {
  display: block;
  padding: 4px 10px;
  margin-left: -10px;
  border-radius: var(--radius-md);
  color: var(--text);
  line-height: 1.4;
}
.sidebar a:hover { color: var(--accent); background: var(--bg-panel); text-decoration: none; }
.sidebar a[aria-current="page"],
.sidebar a[aria-current="location"] {
  color: var(--accent);
  background: var(--bg-panel-2);
  box-shadow: inset 2px 0 0 var(--accent);
  font-weight: 600;
}
.toc-group { color: var(--text); font-weight: 500; }

.content {
  min-width: 0;
  padding: var(--s5) var(--s3) var(--s8) var(--s6);
}

article { max-width: var(--read); }

/* ---------- Page text ---------- */

/* As on tangramflex.com: muted mono capitals behind a short accent rule. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--accent);
}

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h1 { margin: 0 0 var(--s3); font-size: 2.25rem; }
h2 {
  margin: var(--s6) 0 var(--s2);
  padding-top: var(--s3);
  border-top: 1px solid var(--border);
  font-size: 1.5rem;
}
h3 { margin: var(--s4) 0 12px; font-size: 1.2rem; }
h4 { margin: var(--s3) 0 8px; font-size: 1rem; }

p, ul, ol, dl, table, pre, blockquote, figure { margin: 0 0 var(--s2); }
ul, ol { padding-left: 1.4em; }
li + li { margin-top: 4px; }
li > ul, li > ol { margin: 4px 0 0; }
dt { font-weight: 600; }
dd { margin: 0 0 12px var(--s3); }
img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s5) 0; }
strong { font-weight: 650; }

code, kbd, pre { font-family: var(--font-mono); font-size: 0.875em; }

:not(pre) > code {
  padding: 1px 5px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

pre {
  padding: 14px 18px;
  overflow-x: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  line-height: 1.55;
}
pre code { font-size: inherit; }
div.sourceCode { margin: 0 0 var(--s2); }
div.sourceCode pre { margin: 0; }
pre a[aria-hidden="true"] { display: none; }

/* Pandoc's highlighting classes, kept to a few theme colours. */
.sourceCode .kw, .sourceCode .cf { color: var(--accent); }
.sourceCode .st, .sourceCode .ss, .sourceCode .ch { color: var(--pass); }
.sourceCode .dv, .sourceCode .fl, .sourceCode .bn, .sourceCode .cn { color: var(--warn); }
.sourceCode .co, .sourceCode .do { color: var(--faint); font-style: italic; }
.sourceCode .at, .sourceCode .op, .sourceCode .va { color: var(--muted); }
.sourceCode .fu, .sourceCode .ex { color: var(--text); }

blockquote {
  margin-left: 0;
  padding: 2px 0 2px var(--s2);
  border-left: 2px solid var(--accent-deep);
  color: var(--muted);
}

table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 15px;
}
th, td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--bg-panel-2); font-weight: 600; }

/* Fenced divs: `::: note`, `::: tip`, `::: warning`. */
.note, .tip, .warning, .draft-banner {
  margin: 0 0 var(--s2);
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
}
.note { border-left-color: var(--accent); }
.tip { border-left-color: var(--pass); }
.warning, .draft-banner { border-left-color: var(--warn); }
.draft-banner { margin-bottom: var(--s3); color: var(--muted); }
.draft-banner strong { color: var(--warn); }
.note > :last-child, .tip > :last-child, .warning > :last-child { margin-bottom: 0; }

/* The front page's version table. */
.pins td:first-child { color: var(--muted); }
.pins td:last-child { font-family: var(--font-mono); font-size: 14px; }

/* ---------- The page title's one-line summary ---------- */

.subtitle {
  margin: -12px 0 var(--s4);
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- Examples: terminal windows with a copy button ---------- */

/* Dark in both themes, like the terminals on tangramflex.com; every colour is a --win-* token. */
.example {
  margin: 0 0 var(--s2);
  border: 1px solid var(--win-border);
  border-radius: var(--radius-lg);
  background: var(--win-bg);
  overflow: hidden;
  color-scheme: dark;
}
.example-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--win-border-soft);
  background: var(--win-bg-2);
}
.example-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--win-muted);
}
.example-copy {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--win-dim);
  cursor: pointer;
}
.example-copy:hover { color: var(--win-text); border-color: var(--win-border); }
.example-copy.is-copied { color: var(--win-pass); border-color: rgba(99, 214, 164, 0.45); }
.example pre,
.example div.sourceCode { margin: 0; }
.example pre {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--win-code);
  padding: 14px 18px 16px;
  line-height: 1.75;
}

/* Console examples: a command per line after an ice-blue prompt, then muted output. */
pre.console .cmd,
pre.console .out { display: block; white-space: pre; min-height: 1.75em; }
pre.console .cmd { color: var(--win-code); }
pre.console .cmd:not(.cont)::before { content: "$ "; color: var(--win-ice); user-select: none; }
pre.console .out { color: var(--win-muted); }
pre.console .t-cmd { color: var(--win-text); font-weight: 600; }
pre.console .t-sub { color: var(--win-text); }
pre.console .t-flag { color: var(--win-teal); }
pre.console .t-arg { color: var(--win-path); }
pre.console .t-str { color: var(--win-type); }
pre.console .t-var { color: var(--win-ice); }
pre.console .t-dim { color: var(--win-dim); }
pre.console .t-pass { color: var(--win-pass); font-weight: 600; }
pre.console .t-fail { color: var(--win-red); font-weight: 600; }
pre.console .t-warn { color: var(--win-warn); }

/* Other examples (TOML, YAML, Flex) get pandoc's highlighting, in the same palette. */
.example .sourceCode .kw, .example .sourceCode .cf { color: var(--win-ice); }
.example .sourceCode .dt, .example .sourceCode .bu { color: var(--win-type); }
.example .sourceCode .st, .example .sourceCode .ss, .example .sourceCode .ch { color: var(--win-pass); }
.example .sourceCode .dv, .example .sourceCode .fl, .example .sourceCode .bn, .example .sourceCode .cn { color: var(--win-warn); }
.example .sourceCode .co, .example .sourceCode .do { color: var(--win-dim); font-style: normal; }
.example .sourceCode .at, .example .sourceCode .va, .example .sourceCode .fu { color: var(--win-teal); }
.example .sourceCode .op, .example .sourceCode .ot { color: var(--win-muted); }

/* ---------- Reference pages: prose on the left, examples on the right ---------- */

.layout-reference article { max-width: none; }
.layout-reference .pager { max-width: var(--read); }

.ref-section {
  display: grid;
  /* The prose gives way before the examples do, down to 28rem; below 1200px they stack. */
  grid-template-columns: minmax(28rem, var(--read)) minmax(340px, var(--example));
  gap: var(--s6);
  padding: var(--s5) 0;
  border-top: 1px solid var(--border);
}
.ref-section:first-of-type { border-top: 0; padding-top: 0; }
.ref-section.no-examples { grid-template-columns: minmax(0, var(--read)); }
.ref-section h2 { margin-top: 0; padding-top: 0; border-top: 0; }
.ref-prose > :last-child { margin-bottom: 0; }
.ref-examples { position: sticky; top: 88px; align-self: start; min-width: 0; }

/* Options and arguments: a definition list, as in the Stripe CLI reference. */
.ref-prose dl { margin: 0 0 var(--s3); border-top: 1px solid var(--border); }
.ref-prose dt {
  padding-top: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}
.ref-prose dt code { padding: 0; border: 0; background: none; font-size: inherit; }
.ref-prose dd {
  margin: 4px 0 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.ref-prose dd > :last-child { margin-bottom: 0; }

@media (max-width: 1200px) {
  .ref-section,
  .ref-section.no-examples { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .ref-examples { position: static; }
}

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

.layout-landing article { max-width: none; }
.layout-landing h1 { font-size: 2.75rem; margin-bottom: var(--s2); }
.layout-landing .subtitle { margin-top: 0; font-size: 1.4rem; }
.layout-landing .pager { display: none; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, var(--read)) minmax(0, var(--example));
  gap: var(--s6);
  align-items: center;
  padding: var(--s5) 0 var(--s6);
  border-bottom: 1px solid var(--border);
}
.hero-text p { font-size: 1.05rem; color: var(--muted); }
.hero-example .example { margin: 0; box-shadow: var(--shadow-card); }

a.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  background: var(--btn-solid-bg);
  color: var(--btn-solid-text);
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.25s var(--ease-out);
}
a.cta:hover { background: var(--btn-solid-hover); text-decoration: none; transform: translateY(-2px); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--s2);
  margin: var(--s5) 0;
}
a.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
a.card:hover { text-decoration: none; border-color: var(--accent-deep); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.card-title { color: var(--link); font-weight: 600; }
.card-text { color: var(--muted); font-size: 15px; line-height: 1.5; }

.versions { margin-top: var(--s6); padding-top: var(--s3); border-top: 1px solid var(--border); color: var(--muted); font-size: 14.5px; }
.versions table { font-size: 14px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .layout-landing h1 { font-size: 2.1rem; }
}

/* ---------- Previous / next ---------- */

.pager {
  max-width: var(--read);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  margin-top: var(--s8);
}
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.pager-link:hover { text-decoration: none; border-color: var(--accent-deep); transform: translateY(-2px); box-shadow: var(--shadow-card); }
.pager-next { grid-column: 2; text-align: right; }
.pager-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.pager-title { font-weight: 600; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--s3);
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
}
.site-footer p { margin: 0; }

/* ---------- Wide screens: the contents button hides the sidebar ---------- */

@media (min-width: 901px) {
  html[data-sidebar="hidden"] .layout { grid-template-columns: minmax(0, 1fr); }
  html[data-sidebar="hidden"] .sidebar { display: none; }
  /* With no sidebar, the page sits in the middle of the window: the reading column on most pages,
     and the reading column plus its examples on reference and landing pages. */
  html[data-sidebar="hidden"] .content { padding-inline: var(--s6); }
  html[data-sidebar="hidden"] article,
  html[data-sidebar="hidden"] .pager { margin-inline: auto; }
  html[data-sidebar="hidden"] .layout-reference article,
  html[data-sidebar="hidden"] .layout-landing article {
    max-width: calc(var(--read) + var(--s6) + var(--example));
  }
  html[data-sidebar="hidden"] .layout-reference .pager { max-width: calc(var(--read) + var(--s6) + var(--example)); }
}

/* ---------- Narrow screens: the contents become a drop-down ---------- */

@media (max-width: 900px) {
  .header-link, .version-chip { display: none; }
  .layout { display: block; }
  .sidebar {
    display: none;
    position: fixed;
    inset: 65px 0 0 0;
    z-index: 40;
    height: auto;
    background: var(--bg);
    border-right: 0;
  }
  .sidebar.is-open { display: block; }
  .content { padding: var(--s4) var(--s3) var(--s6); }
  h1 { font-size: 1.85rem; }
}

@media (max-width: 480px) {
  .brand-product { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}

@media print {
  .site-header, .sidebar, .pager, .skip-link { display: none; }
  .layout { display: block; }
  .content { padding: 0; }
}
