/* ASOgenic design system. Direction: a plain, technical developer-tool look — the
   audience reads API docs, not paper documents. Sans throughout; monospace only for
   things that are literally code or a credential. One ink, one accent, hairline
   borders. No gradients, no glass, no drop shadows, no pill buttons.

   Theme: light is the default for everyone regardless of system preference. Dark is
   an explicit opt-in only — a cookie (`asogenic_theme`) that public/index.php reads
   server-side to stamp <html data-theme="dark"> before first paint (no flash), plus
   a header toggle (assets/js/theme.js) that flips the cookie and the attribute live.
   There is deliberately no prefers-color-scheme auto-switch. */

:root {
  --bg: #fcfcfc;
  --surface: #f4f4f5;
  --surface-2: #ececee;
  --ink: #18181b;
  --muted: #52525b;
  --subtle: #71717a;
  --rule: #e4e4e7;
  --rule-strong: #d4d4d8;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-wash: #eef2ff;
  --accent-ink: #ffffff;
  --warn-ink: #92600a;
  --warn-wash: #fdf6e3;
  --good-ink: #156a43;
  --good-wash: #e7f4ec;
  --danger-ink: #b0281c;
  --danger-wash: #fbeae7;
  --term-bg: #18181b;
  --term-ink: #e7e8ea;

  --font-sans: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shell: 52rem;        /* one content width for every page */
  --shell-wide: 52rem;   /* kept as an alias; no page is wider than --shell */
}

html[data-theme="dark"] {
  --bg: #0b0b0d;
  --surface: #161619;
  --surface-2: #202024;
  --ink: #f4f4f5;
  --muted: #a1a1aa;
  --subtle: #8b8b93;
  --rule: #27272a;
  --rule-strong: #3f3f46;
  --accent: #9d97f5;
  --accent-strong: #b7b2f8;
  --accent-wash: #1c1a33;
  --accent-ink: #0b0b0d;
  --warn-ink: #e7c56b;
  --warn-wash: #2a2213;
  --good-ink: #7fd1a6;
  --good-wash: #12241b;
  --danger-ink: #f0a79b;
  --danger-wash: #2a1613;
  --term-bg: #09090b;
  --term-ink: #e7e8ea;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.22;
  margin: 0 0 0.6em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.85rem, 4.2vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.5rem); margin-top: 2.4em; }
h3 { font-size: 1.05rem; margin-top: 1.6em; }
section > h2:first-child, section > h3:first-child { margin-top: 0; }
section + section { margin-top: 2.75rem; }

p { margin: 0 0 1em; }
p.lede { font-size: 1.12rem; color: var(--muted); line-height: 1.6; }
ul, ol { padding-left: 1.3rem; }
li { margin: 0.3rem 0; }
li::marker { color: var(--subtle); }

a { color: var(--accent); text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

code, pre, kbd, samp { font-family: var(--font-mono); }
:not(pre) > code {
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.08em 0.36em;
  word-break: break-word;
}

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--accent); padding: 0.6rem 1rem; z-index: 20; border-radius: 0 0 var(--radius) 0; }
.skip-link:focus { left: 0; top: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.shell, .shell-wide { max-width: var(--shell); margin: 0 auto; padding: 0 1.25rem; }

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

/* ---- Header / nav ------------------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
}
.site-header .shell, .site-header .shell-wide { display: flex; align-items: center; gap: 1.25rem; padding-top: 0.85rem; padding-bottom: 0.85rem; }
.brand { font-family: var(--font-mono); font-weight: 700; font-size: 1.02rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand:hover { color: var(--accent); }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.site-nav a:not(.btn) {
  color: var(--muted); text-decoration: none; font-size: 0.92rem;
  padding: 0.4rem 0.6rem; border-radius: var(--radius);
  min-height: 40px; display: inline-flex; align-items: center;
}
.site-nav a:not(.btn):hover { color: var(--ink); background: var(--surface); }
.site-nav a.is-active { color: var(--ink); font-weight: 600; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius);
  background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--surface); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .moon { display: block; }

.user-menu { display: flex; align-items: center; gap: 0.6rem; padding-left: 0.5rem; margin-left: 0.25rem; border-left: 1px solid var(--rule); }
.user-menu-avatar { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--rule); }
.user-menu-name { font-size: 0.88rem; color: var(--muted); max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu form { margin: 0; }

@media (max-width: 40rem) {
  .site-nav { gap: 0.1rem; }
  .site-nav a:not(.btn) { padding: 0.4rem 0.45rem; }
  .user-menu-name { display: none; }
}

main { padding: 3rem 0 5rem; }

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

.site-footer { border-top: 1px solid var(--rule); padding: 2.5rem 0 3.5rem; color: var(--muted); font-size: 0.88rem; margin-top: 2rem; }
.site-footer .shell { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: baseline; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-left: auto; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ---- Buttons --------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 42px; padding: 0.5rem 1.15rem;
  border-radius: var(--radius); border: 1px solid var(--rule-strong);
  background: var(--bg); color: var(--ink);
  font: inherit; font-size: 0.92rem; font-weight: 600; text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-wash); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-block { width: 100%; }
.btn-danger { border-color: var(--rule-strong); color: var(--danger-ink); background: var(--bg); }
.btn-danger:hover { background: var(--danger-wash); border-color: var(--danger-ink); color: var(--danger-ink); }
.btn-sm { min-height: 34px; padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* ---- Forms ---------------------------------------------------------- */

label { font-weight: 600; display: block; margin-bottom: 0.4rem; font-size: 0.92rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--rule-strong);
  border-radius: var(--radius); padding: 0.55rem 0.8rem; min-height: 42px;
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
textarea { min-height: 7rem; resize: vertical; }
.form-field { margin: 1.25rem 0; }
.help-text { color: var(--muted); font-size: 0.88rem; margin: 0.4rem 0 0.9rem; }

/* ---- Cards & callouts --------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.5rem; }

.callout { border: 1px solid var(--rule); border-left-width: 3px; background: var(--surface); padding: 0.9rem 1.15rem; margin: 1.5rem 0; border-radius: var(--radius); }
.callout p:last-child { margin-bottom: 0; }
.callout-warn { border-color: var(--warn-ink); background: var(--warn-wash); color: var(--warn-ink); }
.callout-warn strong { color: var(--warn-ink); }
.callout-good { border-color: var(--good-ink); background: var(--good-wash); color: var(--good-ink); }
.callout-good strong { color: var(--good-ink); }

/* ---- Error pages -------------------------------------------------- */

.error-panel { text-align: center; padding: 0 0 4rem; max-width: 30rem; margin: 0 auto; }
.error-panel .status-code { font-family: var(--font-mono); font-size: 4rem; font-weight: 700; color: var(--rule-strong); margin-bottom: 0.25rem; letter-spacing: -0.03em; }

/* ---- Sign-in ---------------------------------------------------- */

.auth-panel { max-width: 23rem; margin: 0 auto; }
.auth-panel .btn, .oauth-btn { width: 100%; }
.oauth-list { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 0.6rem; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  min-height: 44px; padding: 0.55rem 1.05rem;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
  font: inherit; font-size: 0.94rem; font-weight: 600; cursor: pointer;
}
.oauth-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-wash); color: var(--accent); }
.oauth-btn svg { flex-shrink: 0; }
.oauth-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.oauth-btn-secondary { background: var(--surface); }
.oauth-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.oauth-btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }

.oauth-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--subtle); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.oauth-divider::before, .oauth-divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.email-auth-form { margin: 0; display: grid; gap: 0.9rem; }
.email-auth-form .field { display: grid; gap: 0.35rem; }
.email-auth-actions { display: flex; gap: 0.5rem; }
.email-auth-actions .oauth-btn { flex: 1; }
.linklike {
  justify-self: start; padding: 0; border: 0; background: none;
  color: var(--accent); font: inherit; font-size: 0.88rem; text-decoration: underline; cursor: pointer;
}
.linklike:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 26rem) { .email-auth-actions { flex-direction: column; } }

/* ---- Hero ------------------------------------------------------- */

.hero { padding: 0 0 0.5rem; }
.hero h1 { margin-bottom: 0.6rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.9rem; }
.hero-note { font-size: 0.92rem; color: var(--muted); margin-top: 1rem; }

/* ---- Feature grid --------------------------------------------- */

.feature-grid { list-style: none; padding: 0; margin: 2.5rem 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.feature-grid li { border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.5rem 1.4rem; background: var(--bg); }
.feature-grid li:hover { border-color: var(--rule-strong); }
.feature-grid h3 { margin: 0 0 0.4rem; }
.feature-grid p { color: var(--muted); font-size: 0.92rem; margin: 0; }
.feature-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem;
  background: var(--accent-wash); color: var(--accent);
  border-radius: var(--radius); margin-bottom: 1rem;
}

/* ---- Pricing -------------------------------------------------- */

.pricing-grid { list-style: none; padding: 0; margin: 2rem 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.pricing-card { border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.6rem; display: flex; flex-direction: column; background: var(--bg); }
.pricing-card h2, .pricing-card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.pricing-amount { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 700; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.pricing-tagline { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.2rem; }
.pricing-features { list-style: none; padding: 0; margin: 0 0 1.5rem; flex: 1; }
.pricing-features li { padding: 0.45rem 0; border-top: 1px solid var(--rule); font-size: 0.9rem; margin: 0; }
.pricing-features li:first-child { border-top: none; }
.pricing-card-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pricing-amount-planned { color: var(--muted); font-size: 1.2rem; }
.pricing-note { font-family: var(--font-sans); font-size: 0.78rem; font-weight: 400; color: var(--muted); display: block; margin-top: 0.2rem; }

/* ---- FAQ / definition lists --------------------------------- */

.faq-list { margin: 1.75rem 0; }
.faq-list dt { font-weight: 650; margin-top: 1.6rem; letter-spacing: -0.01em; }
.faq-list dt:first-child { margin-top: 0; }
.faq-list dd { margin: 0.4rem 0 0; color: var(--muted); }
.faq-list dd code, .faq-list dt code { font-size: 0.86em; }

/* ---- Steps ------------------------------------------------- */

.steps { list-style: none; counter-reset: step; padding: 0; margin: 1.75rem 0; display: grid; gap: 1.25rem; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: 0 1rem; margin: 0; }
.steps > li::before {
  content: counter(step);
  font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem;
  color: var(--accent); border: 1px solid var(--rule-strong); border-radius: 50%;
  width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center;
}
.steps strong { display: block; }
.steps p { margin: 0.15rem 0 0; font-size: 0.92rem; color: var(--muted); }
.steps .code-preview { grid-column: 1 / -1; margin: 0.9rem 0 0; }

/* ---- Code block (reads as a terminal in either theme) ------ */

.code-block { position: relative; }
.code-block .code-copy-btn { position: absolute; top: 0.7rem; right: 0.7rem; z-index: 1; }
.code-block .code-preview { margin: 2rem 0; }

.code-preview {
  background: var(--term-bg); color: var(--term-ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg); padding: 1.15rem 1.35rem;
  font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.65;
  overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch;
  margin: 2rem 0;
}

/* ---- Docs "on this page" rail ---------------------------- */

.docs-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; }
/* On wide viewports the "on this page" rail floats into the right gutter so
   the docs body keeps the same content width as every other page. */
@media (min-width: 72rem) {
  .docs-layout { grid-template-columns: 1fr 13rem; margin-right: -15rem; }
  .docs-toc { order: 2; }
  .docs-main { order: 1; min-width: 0; }
}
.docs-toc { position: sticky; top: 5rem; align-self: start; font-size: 0.86rem; }
.docs-toc p { font-weight: 600; color: var(--subtle); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; margin: 0 0 0.6rem; }
.docs-toc ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.15rem; }
.docs-toc a { display: block; padding: 0.25rem 0; color: var(--muted); text-decoration: none; }
.docs-toc a:hover { color: var(--accent); }
@media (max-width: 72rem) { .docs-toc { display: none; } }

/* ---- Key management ------------------------------------- */

.key-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--rule); border-radius: var(--radius-lg); }
.key-list li { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--rule); margin: 0; }
.key-list li:last-child { border-bottom: none; }
.key-list .label-link { font-weight: 600; text-decoration: none; }
.key-list .label-link:hover { text-decoration: underline; }
.key-list .help-text { margin: 0; }
.key-list .key-usage { margin-left: auto; white-space: nowrap; }
@media (max-width: 34rem) {
  .key-list li { flex-wrap: wrap; gap: 0.2rem 0.75rem; }
  .key-list .key-usage { margin-left: 0; flex-basis: 100%; }
}

.key-value { display: flex; align-items: flex-start; gap: 0.6rem; margin: 0.85rem 0 1rem; }
.key-value code, .key-value pre {
  flex: 1; min-width: 0; margin: 0; font-family: var(--font-mono); font-size: 0.86rem;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: 0.65rem 0.8rem; overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch;
}
.key-value .btn { flex-shrink: 0; }
.key-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 0.5rem; }
.key-actions form { margin: 0; }

.key-reveal code { display: block; }

@media (prefers-reduced-motion: no-preference) {
  a, .btn, .oauth-btn, .icon-btn, .site-nav a, .feature-grid li { transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease; }
}
