/* PIES Studio brand palette — mirrors pies-web/web/src/variables.scss and the
   Administration -> Branding panel. Keep these in sync with the product; the
   docs should never look like a different company's site. */
  :root {
    --brand-start: #7C5FDD;         /* primary button / gradient start */
    --brand-end:   #06CCC4;         /* gradient end */
    --brand-gradient: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    --danger: #B30D15;              /* destructive button */

    --paper: #f8fafc;               /* --bgLight */
    --ink: #0f172a;                 /* --fontColor */
    --muted: #64748b;               /* --secondaryFontColor */
    --accent: #7C5FDD;
    --accent-soft: #f1edfd;
    --line: #e2e8f0;                /* --borderColor */
    --card: #ffffff;
    --code-bg: #0f172a;
    --code-ink: #e2e8f0;
    --ok: #006655;                  /* --bgSuccess */
    --warn: #9a5b0f;
    --warn-bg: #fdf4e3;
  }
  /* Dark theme mirrors the product's dark branding: near-black surface
     (#080810), white body text, lighter accent so links stay legible. */
  @media (prefers-color-scheme: dark) {
    :root {
      --paper: #080810;
      --ink: #ffffff;
      --muted: #94a3b8;
      --accent: #a58cf7;
      --accent-soft: rgba(124, 95, 221, .18);
      --line: rgba(255, 255, 255, .10);
      --card: #111827;
      --code-bg: #030712;
      --code-ink: #e2e8f0;
      --ok: #34d3b5;
      --warn: #e0a659;
      --warn-bg: #2d2617;
    }
  }
  :root[data-theme="dark"] {
    --paper: #080810; --ink: #ffffff; --muted: #94a3b8; --accent: #a58cf7;
    --accent-soft: rgba(124, 95, 221, .18); --line: rgba(255, 255, 255, .10);
    --card: #111827; --code-bg: #030712; --code-ink: #e2e8f0;
    --ok: #34d3b5; --warn: #e0a659; --warn-bg: #2d2617;
  }
  :root[data-theme="light"] {
    --paper: #f8fafc; --ink: #0f172a; --muted: #64748b; --accent: #7C5FDD;
    --accent-soft: #f1edfd; --line: #e2e8f0; --card: #ffffff;
    --code-bg: #0f172a; --code-ink: #e2e8f0; --ok: #006655;
    --warn: #9a5b0f; --warn-bg: #fdf4e3;
  }

  * { box-sizing: border-box; }
  body {
    margin: 0; background: var(--paper); color: var(--ink);
    font: 16px/1.65 "Avenir Next", "Segoe UI", -apple-system, system-ui, sans-serif;
  }
  .wrap { max-width: 46rem; margin: 0 auto; padding: 0 1.25rem 5rem; }

  /* Prose stays at a readable measure, but commands are not prose: on a wide
     window a code block extends to the right of the text column instead of
     wrapping a one-line command into three. The left edge stays aligned, and
     the bleed never exceeds the free space beside the column, so the page
     itself never scrolls sideways. */
  :root { --code-bleed: max(0rem, min(20rem, (100vw - 48rem) / 2)); }

  header.masthead {
    border-bottom: 1px solid var(--line);
    padding: 2.75rem 0 2rem; margin-bottom: 2.5rem;
  }
  .eyebrow {
    font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
    color: var(--accent); font-weight: 600; margin: 0 0 .75rem;
  }
  h1 {
    font-size: 2.1rem; line-height: 1.2; margin: 0 0 .75rem;
    font-weight: 700; letter-spacing: -.01em; text-wrap: balance;
  }
  .lede { color: var(--muted); font-size: 1.06rem; max-width: 38rem; margin: 0; }

  header.masthead + h2 { border-top: none; padding-top: 0; margin-top: 2rem; }
  h2 {
    font-size: 1.3rem; font-weight: 700; letter-spacing: -.005em;
    margin: 3rem 0 1rem; padding-top: 2rem; border-top: 1px solid var(--line);
    text-wrap: balance;
  }
  h3 { font-size: 1.02rem; font-weight: 700; margin: 1.75rem 0 .5rem; }
  p { margin: 0 0 1rem; max-width: 42rem; }
  .muted { color: var(--muted); }
  strong { font-weight: 650; }

  code {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: .875em; background: var(--accent-soft);
    padding: .12em .35em; border-radius: 4px;
  }
  pre {
    background: var(--code-bg); color: var(--code-ink);
    border-radius: 10px; padding: 1rem 3.6rem 1rem 1.15rem;
    font-size: .84rem; line-height: 1.6; margin: 1rem 0 1.25rem;
    /* Commands must be readable in full, not clipped or hidden behind a
       horizontal scrollbar — a half-copied command is a broken install. */
    white-space: pre-wrap; overflow-wrap: anywhere;
  }
  /* Continuation of a wrapped command is indented so it reads as one line. */
  pre code { background: none; padding: 0; color: inherit; font-size: 1em;
    display: block; padding-left: 2ch; text-indent: -2ch; }
  pre .c { color: #8b90ad; }

  /* copy-to-clipboard (added by assets/docs.js) */
  .codeblock { position: relative; margin-right: calc(-1 * var(--code-bleed)); }
  .codeblock > pre { margin-top: 0; }
  .copy-btn {
    position: absolute; top: .55rem; right: .55rem;
    font: 600 .68rem/1 ui-monospace, "SF Mono", Menlo, monospace;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--code-ink); background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .18); border-radius: 5px;
    padding: .38rem .5rem; cursor: pointer; opacity: .55;
    transition: opacity .12s ease, background .12s ease;
  }
  .codeblock:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
  .copy-btn:hover { background: rgba(255, 255, 255, .2); }
  .copy-btn.done { opacity: 1; color: #7ee2a8; border-color: #7ee2a8; }

  table {
    border-collapse: collapse; width: 100%; margin: 1rem 0 1.5rem;
    font-size: .92rem;
  }
  .table-scroll { overflow-x: auto; }
  th {
    text-align: left; font-size: .72rem; letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted); font-weight: 600;
    padding: 0 .9rem .5rem 0; border-bottom: 1px solid var(--line);
  }
  td {
    padding: .55rem .9rem .55rem 0; border-bottom: 1px solid var(--line);
    vertical-align: top;
  }
  td code { white-space: nowrap; }

  ol.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.25rem 0; }
  ol.steps > li {
    counter-increment: step; position: relative;
    padding: 0 0 1.75rem 3rem;
  }
  ol.steps > li::before {
    content: counter(step);
    position: absolute; left: 0; top: .1rem;
    width: 1.9rem; height: 1.9rem; border-radius: 50%;
    background: var(--brand-gradient); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem; font-weight: 700;
  }
  ol.steps > li:not(:last-child)::after {
    content: ""; position: absolute; left: .93rem; top: 2.3rem; bottom: .2rem;
    width: 1px; background: var(--line);
  }
  ol.steps h3 { margin: 0 0 .4rem; }

  .callout {
    border-left: 3px solid var(--accent); background: var(--accent-soft);
    border-radius: 0 10px 10px 0; padding: .85rem 1.1rem; margin: 1.25rem 0;
    font-size: .94rem;
  }
  .callout.warn { border-left-color: var(--warn); background: var(--warn-bg); }
  .callout p:last-child { margin-bottom: 0; }

  .spec-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: .75rem; margin: 1.25rem 0 1.5rem;
  }
  .spec {
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: .85rem 1rem;
  }
  .spec .k {
    font-size: .7rem; letter-spacing: .11em; text-transform: uppercase;
    color: var(--muted); font-weight: 600; margin-bottom: .25rem;
  }
  .spec .v { font-weight: 650; font-variant-numeric: tabular-nums; }

  ul { padding-left: 1.2rem; margin: 0 0 1rem; }
  li { margin-bottom: .35rem; }

  footer {
    margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
    font-size: .85rem; color: var(--muted);
  }
  a { color: var(--accent); }

/* --- docs site chrome (shared across pages) --------------------------- */
/* Brand bar: the product's button gradient, used as the page's top edge. */
body::before {
  content: ""; display: block; height: 3px; background: var(--brand-gradient);
}
.sitebar {
  border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: 0; z-index: 10;
}
.sitebar .inner {
  max-width: 46rem; margin: 0 auto; padding: .55rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.sitebar a { text-decoration: none; font-size: .88rem; color: var(--muted); }
.sitebar a:hover { color: var(--accent); }
.sitebar a.brand {
  font-weight: 700; letter-spacing: -.01em;
  display: inline-flex; align-items: center; gap: .55rem; color: var(--ink);
}
/* The platform logo, exported from Administration > Branding. Two variants:
   the light-background lockup has near-black type, so it disappears on the
   dark surface — swap to the dark-background variant with the theme. */
.brand-logo { height: 2.3rem; width: auto; display: block; }
.brand-logo.on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .brand-logo.on-light { display: none; }
  .brand-logo.on-dark { display: block; }
}
:root[data-theme="dark"] .brand-logo.on-light { display: none; }
:root[data-theme="dark"] .brand-logo.on-dark { display: block; }
:root[data-theme="light"] .brand-logo.on-light { display: block; }
:root[data-theme="light"] .brand-logo.on-dark { display: none; }
.sitebar a.brand:hover { color: var(--accent); }

/* index cards */
.doc-list { display: grid; gap: .85rem; margin: 1.5rem 0 2rem; }
.doc-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.15rem; transition: border-color .12s ease;
}
.doc-card:hover { border-color: var(--accent); }
.doc-card .t { font-weight: 700; margin-bottom: .2rem; }
.doc-card .d { color: var(--muted); font-size: .92rem; }
.doc-card .meta {
  margin-top: .5rem; font-size: .72rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: .1rem .5rem; font-size: .68rem;
  letter-spacing: .08em; text-transform: uppercase; font-weight: 650;
}

/* Site search — lives in the top bar on every page. */
.docsearch { position: relative; margin-left: auto; }
.docsearch input {
  width: 13rem; max-width: 40vw;
  padding: .34rem .6rem;
  font: inherit; font-size: .84rem;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 7px;
  -webkit-appearance: none; appearance: none;
}
.docsearch input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.docsearch input::placeholder { color: var(--muted); }
.docsearch-results {
  position: absolute; right: 0; top: calc(100% + .4rem);
  width: min(26rem, 92vw); max-height: 70vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.16);
  z-index: 50; padding: .3rem;
}
.docsearch-results a {
  display: grid; grid-template-columns: 1fr auto; gap: 0 .6rem;
  padding: .5rem .6rem; border-radius: 7px; text-decoration: none;
}
.docsearch-results a:hover,
.docsearch-results a:focus { background: var(--paper); outline: none; }
.docsearch-results .r-h { font-size: .88rem; font-weight: 600; color: var(--ink); }
.docsearch-results .r-p {
  font-size: .7rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; align-self: center; white-space: nowrap;
}
.docsearch-results .r-t {
  grid-column: 1 / -1; font-size: .8rem; color: var(--muted);
  line-height: 1.45; margin-top: .15rem;
}
.docsearch-empty { padding: .7rem .6rem; font-size: .85rem; color: var(--muted); }
@media (max-width: 640px) { .docsearch input { width: 8.5rem; } }
