/* Styles for the static half of the site: the landing page, the docs and the
   404. The app under /app/ has its own stylesheet -- these two are deliberately
   separate files, because the app's is loaded into shadow roots and this one
   never is -- but the design tokens below are the app's, verbatim, so the two
   halves of the site look like one thing. */

:root {
  color-scheme: dark light;

  --color-bg-base: #0f172a;
  --color-bg-surface: rgba(30, 41, 59, 0.7);
  --color-bg-surface-hover: rgba(30, 41, 59, 0.9);
  --color-bg-code: rgba(2, 6, 23, 0.55);

  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-secondary: #8b5cf6;

  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  --color-success: #10b981;

  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-strong: rgba(255, 255, 255, 0.18);

  --font-family-base: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;

  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 1rem;
  --border-radius-full: 9999px;

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);

  /* One column width for prose and one for the page, so the header, the hero
     and every section below it line up on the same two edges. */
  --measure: 42rem;
  --page: 72rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --color-bg-base: #f8fafc;
    --color-bg-surface: rgba(255, 255, 255, 0.8);
    --color-bg-surface-hover: rgba(255, 255, 255, 1);
    --color-bg-code: rgba(15, 23, 42, 0.04);

    --color-text-primary: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #64748b;

    --color-border: rgba(0, 0, 0, 0.1);
    --color-border-strong: rgba(0, 0, 0, 0.16);

    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  /* Anchored headings in the docs would otherwise land underneath the sticky
     header. */
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-family-base);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg-base);
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  /* The ambient gradient is painted on a fixed layer; without this a wide code
     block in the docs can push the whole page sideways on a phone. */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; }

a { color: var(--color-primary-hover); }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

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

.shell {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding-inline: var(--space-lg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-bg-base) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-header .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  text-decoration: none;
}

.brand img { width: 28px; height: 28px; }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.site-nav a:not(.btn) {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.site-nav a:not(.btn):hover { color: var(--color-text-primary); }

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--border-radius-md);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              transform var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-ghost {
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
  background: var(--color-bg-surface);
}

.btn-ghost:hover { background: var(--color-bg-surface-hover); }

.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.0625rem; }

@media (prefers-reduced-motion: reduce) {
  .btn, .feature, a { transition: none; }
  .btn-primary:hover { transform: none; }
}

/* --- hero ----------------------------------------------------------------- */

main { flex: 1; }

.hero {
  padding-block: var(--space-3xl) var(--space-2xl);
  text-align: center;
}

.hero-icon {
  width: 96px;
  height: 96px;
  margin-bottom: var(--space-lg);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.25));
}

.hero h1 {
  margin: 0 auto var(--space-md);
  max-width: 18ch;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  /* The gradient is a decoration on top of a colour that is already legible, so
     a browser that ignores background-clip still shows readable text. */
  background: linear-gradient(120deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* Descenders in a clipped gradient get cropped without a little breathing
     room below the line box. */
  padding-bottom: 0.1em;
}

.lede {
  margin: 0 auto var(--space-xl);
  max-width: var(--measure);
  font-size: clamp(1.0625rem, 2.2vw, 1.25rem);
  color: var(--color-text-secondary);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
}

.hero-note {
  margin: var(--space-lg) 0 0;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

/* --- sections ------------------------------------------------------------- */

.section { padding-block: var(--space-2xl); }

.section > .shell > h2,
.section-title {
  margin: 0 0 var(--space-sm);
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.section-lede {
  margin: 0 0 var(--space-xl);
  max-width: var(--measure);
  color: var(--color-text-secondary);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-md);
}

.feature {
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  background: var(--color-bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.feature:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-surface-hover);
}

.feature h3 {
  margin: 0 0 var(--space-xs);
  font-size: 1.0625rem;
}

.feature p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
}

.feature-icon {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: 1.5rem;
  line-height: 1;
}

/* --- code ----------------------------------------------------------------- */

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

:not(pre) > code {
  padding: 0.15em 0.4em;
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-code);
  border: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  background: var(--color-bg-code);
  /* Code is the one thing on the page allowed to be wider than its column, so
     it scrolls inside its own box rather than widening the document. */
  overflow-x: auto;
  line-height: 1.5;
  tab-size: 2;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
  white-space: pre;
}

.code-figure {
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  background: var(--color-bg-surface);
  overflow: hidden;
}

.code-figure figcaption {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.code-figure pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

/* --- split section (copy beside a code sample) ---------------------------- */

.split {
  display: grid;
  gap: var(--space-xl);
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 60rem) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .split.sticky-copy > :first-child { position: sticky; top: 6rem; }
}

.split p { color: var(--color-text-secondary); }

.split h2 { margin-top: 0; }

.checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-sm);
}

/* The tick is positioned rather than laid out beside the text. A grid or flex
   item would be tidier to write, but every inline element inside the item --
   the <code> in one of them -- becomes a box of the container's own, so a list
   item with markup in it lays itself out in a column while its plain-text
   neighbours do not. */
.checklist li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--color-text-secondary);
}

.checklist li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--color-success);
  font-weight: 700;
}

/* --- callout -------------------------------------------------------------- */

.callout {
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--border-radius-md);
  background: var(--color-bg-surface);
}

.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

/* --- closing call to action ----------------------------------------------- */

.closing {
  padding: var(--space-2xl) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  background: var(--color-bg-surface);
  text-align: center;
}

.closing h2 { margin-top: 0; }

.closing p {
  margin: 0 auto var(--space-lg);
  max-width: var(--measure);
  color: var(--color-text-secondary);
}

/* --- footer --------------------------------------------------------------- */

.site-footer {
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-lg);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.site-footer .shell {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  align-items: center;
  justify-content: space-between;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
}

.site-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.site-footer a:hover { color: var(--color-text-primary); }

/* --- the AI prompt ------------------------------------------------------- */

.prompt-builder {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-width: 52rem;
  padding: var(--space-lg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--border-radius-lg);
  background: var(--color-bg-surface);
}

.prompt-topic {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-weight: 600;
}

.prompt-topic input {
  min-height: 2.75rem;
  padding: 0 var(--space-md);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--border-radius-md);
  background: var(--color-bg-code);
  color: var(--color-text-primary);
  font: inherit;
  font-weight: 400;
}

.prompt-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
}

.prompt-line code {
  flex: 1 1 22rem;
  min-width: 0;
  padding: var(--space-md);
  border-radius: var(--border-radius-md);
  background: var(--color-bg-code);
  color: var(--color-text-primary);
  /* Read as a sentence, so set as one: monospace would break the address
     mid-word on a phone. */
  font-family: var(--font-family-base);
  font-size: 1rem;
  line-height: 1.55;
  white-space: normal;
  overflow-wrap: break-word;
}

.prompt-line mark {
  padding: 0 0.2em;
  border-radius: var(--border-radius-sm);
  background: color-mix(in srgb, var(--color-primary) 30%, transparent);
  color: inherit;
}

.prompt-line .btn { flex: 0 0 auto; min-height: 2.75rem; }

.prompt-status {
  margin: 0;
  min-height: 1.4em;
  color: var(--color-success);
  font-size: 0.9375rem;
}

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

.docs-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  padding-block: var(--space-xl) var(--space-2xl);
  align-items: start;
}

@media (min-width: 60rem) {
  .docs-layout { grid-template-columns: 16rem minmax(0, 1fr); gap: var(--space-2xl); }
}

/* Two shapes for one outline. Narrow, where the page is a single column, it is
   a wrapped row of chips -- the sidebar's vertical list would otherwise be a
   screenful of links standing between the reader and the first word of the
   document, and the sub-headings are dropped for the same reason. Wide, where
   it has a column of its own, it becomes the sticky rail below. */
.toc {
  /* min-width: 0 keeps a long heading from widening the grid column instead of
     wrapping inside it. */
  min-width: 0;
  font-size: 0.9375rem;
}

.toc h2 {
  margin: 0 0 var(--space-sm);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li { margin: 0; }

.toc .toc-sub { display: none; }

.toc a {
  display: block;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-full);
  background: var(--color-bg-surface);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.toc a:hover {
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}

@media (min-width: 60rem) {
  .toc {
    position: sticky;
    top: 5rem;
    max-height: calc(100dvh - 7rem);
    overflow-y: auto;
  }

  .toc ul {
    display: block;
    border-left: 1px solid var(--color-border);
  }

  .toc .toc-sub { display: list-item; }

  .toc a {
    padding: 0.3rem var(--space-md);
    margin-left: -1px;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0;
    background: none;
  }

  .toc a:hover { border-left-color: var(--color-border-strong); }

  .toc .toc-sub a { padding-left: calc(var(--space-md) * 2); font-size: 0.875rem; }
}

.prose {
  min-width: 0;
  max-width: 46rem;
}

.prose > :first-child { margin-top: 0; }

.prose h1 {
  margin: 0 0 var(--space-md);
  font-size: clamp(1.875rem, 4.5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.prose h2 {
  margin: var(--space-2xl) 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: var(--space-xl) 0 var(--space-sm);
  font-size: 1.1875rem;
}

.prose h4 {
  margin: var(--space-lg) 0 var(--space-sm);
  font-size: 1rem;
  color: var(--color-text-secondary);
}

/* Inline code inherits the heading's size, and at 2.5rem the box around it is
   heavier than the words either side of it. */
.prose :is(h1, h2, h3, h4) code {
  font-size: 0.75em;
  padding: 0.1em 0.3em;
  font-weight: 600;
}

.prose p, .prose li { color: var(--color-text-secondary); }

.prose p { margin: 0 0 var(--space-md); }

.prose strong { color: var(--color-text-primary); }

.prose ul, .prose ol {
  margin: 0 0 var(--space-md);
  padding-left: 1.35rem;
}

.prose li { margin-bottom: var(--space-xs); }

.prose li > ul, .prose li > ol { margin: var(--space-xs) 0 0; }

.prose hr {
  margin: var(--space-2xl) 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

.prose blockquote {
  margin: 0 0 var(--space-md);
  padding-left: var(--space-md);
  border-left: 3px solid var(--color-border-strong);
  color: var(--color-text-muted);
}

.prose table {
  width: 100%;
  margin-bottom: var(--space-md);
  border-collapse: collapse;
}

.prose th, .prose td {
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  text-align: left;
}

/* An anchor the heading owns, revealed on hover, so a section can be linked
   without the permanent visual noise of a always-visible link glyph. */
.heading-anchor {
  margin-left: 0.4em;
  color: var(--color-text-muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

/* The documentation's pages, as a row of tabs above whichever one is open. */
.docs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding-top: var(--space-xl);
}

.docs-tabs a {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-full);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.docs-tabs a:hover { color: var(--color-text-primary); border-color: var(--color-border-strong); }

.docs-tabs a[aria-current="page"] {
  color: var(--color-text-primary);
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 18%, transparent);
}

.docs-layout { padding-top: var(--space-lg); }

.table-scroll { overflow-x: auto; margin-bottom: var(--space-md); }
.table-scroll table { margin-bottom: 0; }
.prose td, .prose th { vertical-align: top; }
.prose td { color: var(--color-text-secondary); }

.docs-raw {
  margin-top: var(--space-2xl);
  font-size: 0.9rem;
}

/* --- error page ----------------------------------------------------------- */

.centered {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}

.centered h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: -0.02em;
}

.centered p {
  margin: 0;
  max-width: var(--measure);
  color: var(--color-text-secondary);
}
