/* Clever storefront — one stylesheet, no framework.
 *
 * **CSS custom properties rather than utility classes**, matching `admin.html`, so
 * the two surfaces read as one product and a colour is changed in one place.
 * Dark by default: this is a developer tool, and the operator dashboard already is.
 */

:root {
  --bg: #0b1220;
  --panel: #111b2e;
  --panel-2: #16233b;
  --line: #24324d;
  --ink: #e8eefc;
  --dim: #93a4c4;
  --faint: #64748b;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --accent: #5eead4;
  --accent-ink: #042f2e;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f9fc; --panel: #fff; --panel-2: #f0f4fa; --line: #dde5f0;
    --ink: #0d1526; --dim: #4a5b78; --faint: #7a8aa3; --accent-ink: #042f2e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- shell -------------------------------------------------------------- */

header.site {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); z-index: 10;
}
header.site .brand { font-weight: 700; letter-spacing: -0.02em; font-size: 1.05rem; color: var(--ink); }
header.site nav { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
header.site nav a { color: var(--dim); font-size: 0.92rem; }
header.site nav a:hover, header.site nav a[aria-current="page"] { color: var(--ink); text-decoration: none; }

main { max-width: 62rem; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
main.narrow { max-width: 32rem; }
footer.site {
  border-top: 1px solid var(--line); margin-top: 4rem;
  padding: 1.5rem; color: var(--faint); font-size: 0.85rem; text-align: center;
}

/* --- type --------------------------------------------------------------- */

h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 0.6rem; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
p.lede { font-size: 1.1rem; color: var(--dim); margin: 0 0 1.75rem; max-width: 44rem; }
.muted { color: var(--dim); }
.faint { color: var(--faint); font-size: 0.85rem; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-2); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; overflow-x: auto; position: relative; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* --- components --------------------------------------------------------- */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }

.grid { display: grid; gap: 1rem; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }

.plan { display: flex; flex-direction: column; gap: 0.5rem; }
.plan.featured { border-color: var(--accent); }
.plan .price { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.plan .price small { font-size: 0.9rem; font-weight: 400; color: var(--dim); }
.plan ul { margin: 0; padding-left: 1.1rem; color: var(--dim); font-size: 0.92rem; }
.plan li { margin: 0.2rem 0; }
/* The one-line promise under the plan name. `margin: 0` because `.plan` is a flex
   column with its own gap — a browser default margin would double it. */
.plan .tagline { margin: 0; font-size: 0.92rem; }
.card .tagline { margin: 0.2rem 0 0; }
/* The home page's question list. `details`/`summary` work unstyled; the cursor and the
   rule between items are what a browser default leaves ambiguous. */
details { border-top: 1px solid var(--line); padding: 0.55rem 0; }
summary { cursor: pointer; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.75rem; margin: 1rem 0 1.5rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; }
.kpi .label { font-size: 0.75rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 0.15rem; }
.kpi .value.good { color: var(--good); }
.kpi .value.bad { color: var(--bad); }

/* A usage bar, because a percentage hides the period. */
.meter { background: var(--panel-2); border-radius: 999px; height: 0.55rem; overflow: hidden; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.meter-label { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--dim); margin-bottom: 0.3rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); }
th { color: var(--faint); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

label { display: block; font-size: 0.88rem; color: var(--dim); margin-bottom: 0.85rem; }
label span.name { display: block; margin-bottom: 0.3rem; }
input, select, textarea {
  width: 100%; padding: 0.6rem 0.7rem; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=checkbox] { width: auto; }

button {
  padding: 0.6rem 1.1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }

.notice { padding: 0.75rem 0.9rem; border-radius: 8px; font-size: 0.9rem; margin: 1rem 0; border: 1px solid; }
.notice.info { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: var(--accent); }
.notice.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: var(--bad); }
.notice.good { background: color-mix(in srgb, var(--good) 12%, transparent); border-color: var(--good); }
.notice.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: var(--warn); }

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

.chat { display: flex; flex-direction: column; gap: 0.75rem; }
.bubble { padding: 0.8rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.bubble.them { background: var(--panel); }
.bubble.me { background: var(--panel-2); border-color: var(--accent); }

.pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; }
/* **A base style, so a state this file has not seen is still legible.** `.pill.trialing`
   and its siblings set a colour; the bare `.pill` had none, so an unrecognised state
   rendered as plain unspaced text. */
.pill { background: var(--panel-2); color: var(--dim); }
.pill.trialing { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.expired { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill.entitled { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }

/* --- docs --------------------------------------------------------------- */

.docs-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; font-size: 0.9rem; }
.docs-filter { margin-bottom: 1rem; max-width: 24rem; }
/* A copy button inside the `pre`, positioned against it — `pre` is `position:
   relative` above, and the button is added by `VIEWS.docs`, never inline. */
.codecopy { position: absolute; top: 0.5rem; right: 0.5rem; }
.endpoint { font-family: var(--mono); font-size: 0.85rem; }
.endpoint .verb { color: var(--accent); font-weight: 700; }

/* --- playground ---------------------------------------------------------- */

/* Actions and provenance sit *under* a reply, not in it: the transcript is
   model output written with `textContent`, so anything this file adds is
   appended as its own element rather than concatenated into the text. */
/*
 * **The cursor that says "still writing".** The latency research is specific about this:
 * without it, a mid-stream pause — the model choosing a hard word — reads as a finished or
 * crashed response rather than a working one.
 */
.cursor {
  display: inline-block;
  width: 0.5rem;
  height: 1rem;
  margin-left: 0.15rem;
  vertical-align: text-bottom;
  background: var(--dim);
  animation: cursor-pulse 1s steps(2, start) infinite;
}
@keyframes cursor-pulse {
  to { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}
/* The bubble that exists before the first token does — an empty one reads as broken. */
.waiting { color: var(--faint); font-style: italic; }

/* --- payment rail picker ---
 *
 * **A radio group, because that is what this is.** `aria-pressed` on two buttons is the
 * *toggle button* pattern (W3C APG) and this is pick-one-of-two, so the control is a
 * `fieldset` of native radios: correct semantics, arrow keys for free, and — the reason it
 * also fixes a bug — the checked state lives in the DOM rather than in a closure variable
 * that an ordering race could lose before checkout.
 *
 * **The checked state is visible, and that is the point of the rule.** The previous buttons
 * had *no* style for their state at all, so the selected rail looked exactly like the
 * unselected one; WCAG 1.4.11 wants a non-text state to reach 3:1 against its surroundings.
 * `:has` gives the whole label the border and tint; without it the native dot still shows,
 * so the state is visible either way.
 */
.rail-group { border: 0; padding: 0; margin: 0; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.rail-group legend { padding: 0; }
.rail-option { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.85rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.rail-option input { accent-color: var(--accent); margin: 0; }
.rail-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.rail-option:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.msg-actions { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.45rem; flex-wrap: wrap; }
.msg-meta { font-size: 0.78rem; color: var(--faint); margin-top: 0.4rem; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.78rem; font-weight: 500; }

.hidden { display: none !important; }

/* --- inline-style utilities
 *
 * **Generated from the markup's `style="…"` attributes, which the Content-Security-Policy
 * blocked.** `style-src 'self'` refuses inline style *attributes* without
 * `'unsafe-hashes'`, and the browser console filled with
 * "Content-Security-Policy: The page's settings blocked an inline style" for every
 * one - which is how the playground's layout arrived unstyled.
 *
 * **Not `'unsafe-inline'`, and not `'unsafe-hashes'`.** Both would let any injected
 * markup restyle the page, on a document that authenticates with a cookie. Moving
 * fifteen declarations into a stylesheet keeps the policy strict and the layout
 * working, which is the whole point of having one.
 */
.sp-margin-bottom-2rem { margin-bottom: 2rem; }
.sp-margin-top-0 { margin-top: 0; }
.sp-margin-top-1rem { margin-top: 1rem; }
.sp-margin-0 { margin: 0; }
.sp-margin-bottom-1rem { margin-bottom: 1rem; }
.sp-margin-bottom-0-75rem { margin-bottom: 0.75rem; }
.sp-margin-top-0-75rem { margin-top: 0.75rem; }
