@import url('https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@100..125,400..800&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;450;500;600&display=swap');

/* ============================================================
   OAuth for Agents — shared stylesheet
   Plain CSS, no build step.

   The palette encodes the three parties that appear in every
   flow on this site, and uses them consistently everywhere:

     --accent  magenta   the agent / the client
     --auth    violet    the authorization server
     --res     teal      the protected resource / API

   Neutrals carry a violet bias so they sit with the triad
   rather than against it. Swap the :root block to reskin.
   ============================================================ */

:root {
  --paper:        #f7f6fb;
  --paper-2:      #efedf7;
  --paper-3:      #e4e1f0;
  --ink:          #16131f;
  --ink-2:        #474262;
  --ink-3:        #726c8c;
  --rule:         #d9d5e8;

  --accent:       #c40f6c;
  --accent-soft:  #fce4f0;
  --accent-ink:   #9c0b56;
  --auth:         #5b34c7;
  --auth-soft:    #e9e3fb;
  --res:          #0d7480;
  --res-soft:     #d9f0f2;

  --code-bg:      #17131f;
  --code-ink:     #e7e3f2;

  --display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --measure: 34rem;
  --wide: 62rem;
  --radius: 4px;
}

:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:       #0d0b14;
    --paper-2:     #15121f;
    --paper-3:     #1e1a2b;
    --ink:         #f2effa;
    --ink-2:       #b6afcc;
    --ink-3:       #877fa3;
    --rule:        #2a2440;
    --accent:      #ff5ea3;
    --accent-soft: #2c0f22;
    --accent-ink:  #ff8dbe;
    --auth:        #a98cff;
    --auth-soft:   #1c1436;
    --res:         #3ecad6;
    --res-soft:    #0b2429;
    --code-bg:     #07050c;
    --code-ink:    #e7e3f2;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper:       #0d0b14;
  --paper-2:     #15121f;
  --paper-3:     #1e1a2b;
  --ink:         #f2effa;
  --ink-2:       #b6afcc;
  --ink-3:       #877fa3;
  --rule:        #2a2440;
  --accent:      #ff5ea3;
  --accent-soft: #2c0f22;
  --accent-ink:  #ff8dbe;
  --auth:        #a98cff;
  --auth-soft:   #1c1436;
  --res:         #3ecad6;
  --res-soft:    #0b2429;
  --code-bg:     #07050c;
  --code-ink:    #e7e3f2;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- layout ---------- */

.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: 1.5rem; }
.col  { max-width: var(--measure); }
/* .col-wide marks a text column: it releases the per-paragraph measure cap
   without changing the container width, so every page shares one left edge. */
.wrap.col-wide { max-width: var(--wide); }

section { padding-block: 5rem; }
section + section { border-top: 1px solid var(--rule); }

@media (max-width: 40rem) {
  section { padding-block: 3.25rem; }
  .wrap { padding-inline: 1.125rem; }
}

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

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 0.6em; text-wrap: balance; }
h1, h2 { font-variation-settings: 'wdth' 112; }

h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 600; }
h3 { font-size: clamp(1.25rem, 2.4vw, 1.6rem); }
h4 { font-size: 1.05rem; font-family: var(--body); font-weight: 700; letter-spacing: 0.01em; }

p { margin: 0 0 1.1em; max-width: var(--measure); }
.col-wide p, .col-wide li { max-width: none; }

.lede { font-size: clamp(1.15rem, 2.2vw, 1.4rem); line-height: 1.5; color: var(--ink-2); max-width: 38rem; }
.lede strong { color: var(--ink); font-weight: 600; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}
.eyebrow.cool { color: var(--auth); }

a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--accent); }

ul, ol { padding-left: 1.2em; }
li { margin-bottom: 0.5em; max-width: var(--measure); }

strong { font-weight: 600; }
em { font-style: italic; }

.small { font-size: 0.9rem; color: var(--ink-3); }

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

/* ---------- header / nav ---------- */

.site-head {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
section[id], main [id] { scroll-margin-top: 5rem; }
.site-head .wrap { display: flex; align-items: center; gap: 1.5rem; height: 3.75rem; }
.brand { font-family: var(--display); font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.site-nav { margin-left: auto; display: flex; gap: 1.25rem; font-size: 0.9rem; overflow-x: auto; }
.site-nav a { text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--ink); }
.site-nav a[aria-current] { font-weight: 600; }

@media (max-width: 46rem) { .site-nav { gap: 0.9rem; font-size: 0.82rem; } }

/* On narrow screens the header stacks: brand on top, nav beneath. */
@media (max-width: 34rem) {
  .site-head .wrap { height: auto; flex-wrap: wrap; gap: 0.35rem; padding-block: 0.6rem; }
  .site-nav { margin-left: 0; width: 100%; gap: 1rem; font-size: 0.8rem; }
  section[id], main [id] { scroll-margin-top: 6.5rem; }
}

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

.hero { padding-block: clamp(4rem, 11vw, 8.5rem) 4.5rem; }
.hero h1 { max-width: 21ch; }
.hero h1 .mark { color: var(--accent); }
.hero .lede { margin-top: 1.75rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.25rem; }

.btn {
  display: inline-block; padding: 0.72rem 1.3rem; border-radius: var(--radius);
  font-size: 0.94rem; font-weight: 600; text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); }

/* ---------- the "what broke" list ---------- */

.breaks { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin-top: 2.5rem; }
.break { background: var(--paper); padding: 1.6rem 1.5rem; display: grid; grid-template-columns: 2.2rem 1fr; gap: 0 1rem; }
.break .n { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; color: var(--accent); padding-top: 0.32rem; }
.break h3 { margin: 0 0 0.35em; font-size: 1.15rem; }
.break p { margin: 0; color: var(--ink-2); font-size: 0.97rem; max-width: 48rem; }
.break .fix { margin-top: 0.6rem; font-size: 0.88rem; color: var(--ink-3); grid-column: 2; }
.break .fix b { color: var(--auth); font-weight: 600; }

@media (min-width: 56rem) { .breaks { grid-template-columns: 1fr 1fr; } }

/* ---------- the ladder ---------- */

.ladder { display: grid; gap: 1.25rem; margin-top: 3rem; counter-reset: rung -1; }

.rung {
  position: relative;
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0 1.5rem;
  padding: 1.75rem 1.75rem 1.75rem 1.5rem;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.rung:hover { border-color: var(--accent); transform: translateY(-2px); }
.rung .num {
  counter-increment: rung;
  font-family: var(--mono); font-weight: 600; font-size: 0.78rem;
  color: var(--ink-3); padding-top: 0.4rem;
}
.rung .num::before { content: counter(rung, decimal-leading-zero); }
.rung h3 { margin-bottom: 0.4em; }
.rung p { margin: 0; color: var(--ink-2); font-size: 0.99rem; max-width: 46rem; }
.rung .adds { margin-top: 0.9rem; font-size: 0.86rem; color: var(--ink-3); }
.rung .adds b { color: var(--ink-2); font-weight: 600; }
.rung .go { margin-top: 1rem; font-size: 0.86rem; font-weight: 600; color: var(--accent); }
.rung .go::after { content: ' →'; }

@media (max-width: 40rem) {
  .rung { grid-template-columns: 1fr; padding: 1.4rem; gap: 0.4rem; }
  .rung .num { padding-top: 0; }
}

/* ---------- flow diagrams ---------- */

.flow {
  margin: 2.25rem 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-2);
  overflow: hidden;
}
.flow figcaption {
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3);
}
.flow ol { list-style: none; margin: 0; padding: 0.5rem 0; counter-reset: step; }
.flow li {
  counter-increment: step;
  position: relative;
  margin: 0;
  max-width: none;
  padding: 0.95rem 1.4rem 0.95rem 3.5rem;
}
.flow li::before {
  content: counter(step);
  position: absolute; left: 1.4rem; top: 1.05rem;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper-3); color: var(--ink-2);
  font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
}
.flow li + li { border-top: 1px dashed var(--rule); }
.flow li.hi::before { background: var(--accent); color: #fff; }
.flow li.hi { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }

.hop { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; font-size: 0.8rem; margin-bottom: 0.3rem; }
.hop .who {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 4px;
  background: var(--paper-3); color: var(--ink-2); white-space: nowrap;
}
.hop .who.agent { background: var(--accent-soft); color: var(--accent-ink); }
.hop .who.as    { background: var(--auth-soft); color: var(--auth); }
.hop .who.api   { background: var(--res-soft); color: var(--res); }
.hop .arr { color: var(--ink-3); font-weight: 700; }
.flow li p { margin: 0; font-size: 0.96rem; color: var(--ink-2); max-width: none; }
.flow li p + p { margin-top: 0.5rem; }
.flow li code { font-size: 0.86em; }

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

pre {
  background: var(--code-bg); color: var(--code-ink);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 1.5rem 0;
  border: 1px solid var(--rule);
}
pre .c { color: #6f6690; }
pre .k { color: #ff8dbe; }
pre .s { color: #4fd3de; }
pre .n { color: #b39cff; }
code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--paper-3); padding: 0.12em 0.36em; border-radius: 4px;
}
pre code { background: none; padding: 0; font-size: inherit; }

/* ---------- spec chips & cards ---------- */

.badge {
  display: inline-block; font-family: var(--mono); font-size: 0.64rem; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
  padding: 0.2rem 0.45rem; border-radius: 4px; vertical-align: 0.12em;
}
.badge.rfc     { background: var(--res-soft); color: var(--res); }
.badge.wg      { background: var(--auth-soft); color: var(--auth); }
.badge.ind     { background: var(--paper-3); color: var(--ink-3); }
.badge.queue   { background: var(--accent-soft); color: var(--accent-ink); }

.specs { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin: 2rem 0; }
@media (min-width: 52rem) { .specs { grid-template-columns: 1fr 1fr; } }

.spec { background: var(--paper); padding: 1.35rem 1.4rem; }
.spec h4 { margin: 0 0 0.35em; display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
.spec h4 a { text-decoration: none; }
.spec h4 a:hover { text-decoration: underline; }
.spec .id { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3); font-weight: 400; }
.spec p { margin: 0; font-size: 0.93rem; color: var(--ink-2); max-width: none; }

/* ---------- callouts ---------- */

.note {
  border: 1px solid var(--auth);
  background: var(--auth-soft);
  padding: 1.2rem 1.35rem 1.25rem;
  border-radius: var(--radius);
  margin: 2rem 0;
}
.note p { margin: 0; max-width: none; font-size: 0.96rem; }
.note p + p { margin-top: 0.7rem; }
.note .label {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--paper); background: var(--auth); font-weight: 600;
  display: inline-block; padding: 0.16rem 0.5rem; border-radius: 3px; margin-bottom: 0.7rem;
}

.note.warn { border-color: var(--accent); background: var(--accent-soft); }
.note.warn .label { background: var(--accent); color: var(--paper); }

/* ---------- assumption vs reality ---------- */

.versus { display: grid; gap: 1rem; margin: 2.25rem 0; }
@media (min-width: 48rem) { .versus { grid-template-columns: 1fr 1fr; gap: 1.25rem; } }
.versus > div { padding: 1.3rem 1.4rem; border-radius: var(--radius); border: 1px solid var(--rule); }
.versus .then { background: var(--paper-2); }
.versus .now  { background: var(--paper); border-color: var(--accent); }
.versus h4 { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.8em; }
.versus .now h4 { color: var(--accent); }
.versus p { margin: 0; font-size: 0.97rem; max-width: none; }

/* ---------- gaps list ---------- */

.gaps { list-style: none; padding: 0; margin: 2.5rem 0 0; }
.gaps li { border-top: 1px solid var(--rule); padding: 1.5rem 0; max-width: none; margin: 0; }
.gaps li:last-child { border-bottom: 1px solid var(--rule); }
.gaps h3 { font-size: 1.15rem; margin-bottom: 0.4em; }
.gaps p { max-width: 46rem; margin: 0; color: var(--ink-2); font-size: 0.97rem; }
.gaps .closest { margin-top: 0.6rem; font-size: 0.87rem; color: var(--ink-3); }
.gaps .closest b { color: var(--ink-2); font-weight: 600; }

/* ---------- prev/next ---------- */

.pager { display: grid; gap: 1rem; margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--rule); }
@media (min-width: 44rem) { .pager { grid-template-columns: 1fr 1fr; } }
.pager a { display: block; padding: 1.1rem 1.3rem; border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; }
.pager a:hover { border-color: var(--accent); }
.pager .dir { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: 0.3rem; }
.pager .t { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.pager .next { text-align: right; }

/* ---------- page header for interior pages ---------- */

.page-head { padding-block: clamp(3rem, 8vw, 5rem) 2.5rem; border-bottom: 1px solid var(--rule); }
.page-head .step-of { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 1rem; }
.page-head h1 { font-size: clamp(2.1rem, 5.2vw, 3.4rem); max-width: 18ch; }
.page-head .lede { margin-top: 1.25rem; }

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

.site-foot { border-top: 1px solid var(--rule); padding-block: 3rem; color: var(--ink-3); font-size: 0.9rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; }
.site-foot a { color: var(--ink-2); }

/* ---------- utilities ---------- */

.stack > * + * { margin-top: 1.1rem; }
.mt-0 { margin-top: 0; }
table.plain { width: 100%; border-collapse: collapse; margin: 2rem 0; font-size: 0.93rem; }
table.plain th, table.plain td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.plain th { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.scroll-x { overflow-x: auto; }


/* ---------- accessibility ---------- */

:where(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .rung:hover { transform: none; }
}
