/* ============================================================
   Six Primitives — a Cloudflare field guide
   Plain CSS · no frameworks · solid colors, no gradients
   ============================================================ */

/* ---------- design tokens ---------- */
:root {
  --paper: #fbfaf7;
  --card: #ffffff;
  --surface: #f4f2ed;
  --ink: #15171c;
  --ink-soft: #333a44;
  --muted: #5b6470;
  --faint: #8b93a0;
  --line: #e7e3db;
  --line-2: #d9d4ca;

  --orange: #f6821f;  --orange-ink: #a24d08;  --orange-tint: #fdf2e4;
  --teal:    #0d9488; --teal-ink:    #0b6a62; --teal-tint:    #e7f5f3;
  --blue:    #2563eb; --blue-ink:    #1e46b8; --blue-tint:    #eaeffd;
  --purple:  #7c3aed; --purple-ink:  #6629d0; --purple-tint:  #f3edfe;
  --green:   #16a34a; --green-ink:   #116b37; --green-tint:   #e9f7ee;
  --rose:    #e11d48; --rose-ink:    #ac0e40; --rose-tint:    #fceef1;

  --ok:       #15803d; --ok-tint:    #f2f9f3; --ok-line:    #d3e8d8;
  --warn:     #b45309; --warn-tint:  #fdf7ec; --warn-line:  #eadbc0;

  --code-bg: #171a20; --code-head: #1e222a; --code-line: #262b34;
  --code-ink: #e3e7f0;
  --syn-cm: #7d8798;  --syn-kw: #f6944b;  --syn-str: #7ec99f;
  --syn-fn: #7fb2ff;  --syn-num: #dcae63; --syn-tag: #66c4bd;
  --syn-attr: #b48ead; --syn-key: #9fc2ec;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", monospace;

  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(21,23,28,.05), 0 10px 30px rgba(21,23,28,.07);
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16.5px/1.7 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #fde3c8; }
a { color: inherit; }
:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 0 0 10px 0; font-weight: 600; text-decoration: none;
}
.skip:focus { left: 0; }

.shell {
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 40px);
}
.shell.narrow { max-width: 880px; }

section[id] { scroll-margin-top: 82px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(251, 250, 247, .88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-row { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand {
  display: flex; align-items: center; gap: 11px;
  text-decoration: none; font-weight: 750; font-size: 15.5px;
  letter-spacing: -.01em; margin-right: auto; flex: none;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: var(--orange); display: grid; place-items: center;
}
.brand-mark svg { width: 15px; height: 15px; display: block; }
.brand-tag {
  font-weight: 500; font-size: 12.5px; color: var(--faint);
  border-left: 1px solid var(--line); padding-left: 11px; letter-spacing: .02em;
}
.site-nav {
  display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  text-decoration: none; font-size: 13px; font-weight: 600;
  color: var(--muted); padding: 8px 10px; border-radius: 8px;
  white-space: nowrap; transition: color .15s ease, background .15s ease;
}
.site-nav a:hover { color: var(--ink); background: rgba(21,23,28,.05); }
.site-nav a.active { color: var(--orange-ink); background: var(--orange-tint); }
.site-nav .nav-cta {
  background: var(--ink); color: #fff; padding: 9px 15px; margin-left: 6px;
}
.site-nav .nav-cta:hover { background: #2a2e37; color: #fff; }
.site-nav .nav-cta.active { background: var(--ink); color: #fff; }

/* ---------- hero ---------- */
.hero { position: relative; padding: clamp(64px, 9vh, 108px) 0 72px; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; opacity: .55; pointer-events: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26"><circle cx="1.5" cy="1.5" r="1.5" fill="%23e7e3db"/></svg>');
  background-size: 26px 26px;
}
.hero-inner { position: relative; }

.eyebrow {
  font-size: 12px; font-weight: 750; letter-spacing: .15em;
  text-transform: uppercase; color: var(--orange-ink); margin: 0 0 16px;
}
h1 {
  font-size: clamp(2.35rem, 5.2vw, 3.55rem);
  line-height: 1.06; letter-spacing: -.035em; font-weight: 800;
  margin: 0 0 .45em; max-width: 17ch;
}
h1 em { font-style: normal; color: var(--orange-ink); }

.section-lede, .lede { font-size: 18.5px; color: var(--muted); margin: 0; max-width: 66ch; }
.hero .lede { margin-bottom: 30px; }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 34px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 11px; font-weight: 650; font-size: 15px;
  text-decoration: none; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a2e37; }
.btn.ghost { border-color: var(--line-2); color: var(--ink); background: var(--card); }
.btn.ghost:hover { border-color: var(--faint); }

.pills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 42px; }
.pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 15px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; font-size: 13.5px; font-weight: 600;
  text-decoration: none; color: var(--ink-soft);
  transition: border-color .15s ease, transform .15s ease;
}
.pill:hover { border-color: var(--pc, var(--line-2)); transform: translateY(-1px); }
.pill i { width: 9px; height: 9px; border-radius: 3px; background: var(--pc); flex: none; }

.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 1000px;
}
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 18px;
}
.stat b {
  display: block; font-size: 30px; letter-spacing: -.03em;
  font-weight: 780; line-height: 1.1;
}
.stat span { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------- section scaffolding ---------- */
.section { padding: clamp(64px, 9vw, 104px) 0; }
.section-head { max-width: 820px; margin-bottom: 44px; }
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 750; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent-ink, var(--orange-ink));
  margin: 0 0 14px;
}
.kicker::before {
  content: ""; width: 22px; height: 2px;
  background: var(--accent, var(--orange)); border-radius: 2px;
}
h2 {
  font-size: clamp(1.65rem, 3vw, 2.15rem); line-height: 1.14;
  letter-spacing: -.028em; font-weight: 780; margin: 0 0 14px;
}

/* ---------- architecture diagram ---------- */
.diagram {
  margin: 6px 0 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(14px, 3vw, 30px); overflow-x: auto;
}
.arch {
  min-width: 720px; max-width: 940px; margin: auto; display: block;
  font-family: var(--font-sans); height: auto;
}
.arch text { font-family: var(--font-sans); }
.arch .colo {
  fill: #faf9f6; stroke: #ddd8cf; stroke-width: 1.5;
  stroke-dasharray: 6 7;
}
.arch .colo-label {
  font-size: 12.5px; font-weight: 600; fill: #9aa1ad; letter-spacing: .04em;
}
.arch .dcard rect { fill: #fff; stroke: #e3dfd6; stroke-width: 1.5; }
.arch .dt { font-size: 15px; font-weight: 700; fill: var(--ink); }
.arch .ds { font-size: 11.5px; fill: #6f7887; }
.arch .dm { font-size: 11.5px; fill: #4a5160; font-family: var(--font-mono); }
.arch .ln { fill: none; stroke-width: 2; }
.arch .dash { stroke-dasharray: 5 6; }
.arch .nb { fill: #fff; font-size: 11px; font-weight: 800; font-family: var(--font-sans); }
.arch .chip-t { font-size: 10px; font-weight: 750; font-family: var(--font-mono); }

.legend {
  list-style: none; margin: 18px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 28px;
}
.legend li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.lg-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: 11.5px; font-weight: 750;
  display: grid; place-items: center; margin-top: 2px;
}
.diagram-note { margin: 16px 2px 0; font-size: 13.5px; color: var(--faint); }

/* ---------- primitive grid ---------- */
.primitive-grid {
  list-style: none; margin: 44px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.primitive-grid a {
  display: block; height: 100%; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 18px; text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.primitive-grid a:hover {
  transform: translateY(-2px); border-color: var(--line-2);
  box-shadow: 0 10px 24px rgba(21,23,28,.07);
}
.pr-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.pr-top i { width: 9px; height: 9px; border-radius: 3px; background: var(--pc); flex: none; }
.pr-top b { font-size: 15.5px; letter-spacing: -.01em; }
.pr-cat {
  margin-left: auto; font-size: 10px; font-weight: 750;
  letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
}
.pr-desc { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.pr-code { font-family: var(--font-mono); font-size: 12.5px; color: var(--pc-ink, var(--orange-ink)); }

/* ---------- concept note ---------- */
.note {
  margin-top: 40px; background: var(--surface);
  border-left: 3px solid var(--accent, var(--orange));
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 22px 26px;
}
.note h3 {
  font-size: 12px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--accent-ink, var(--orange-ink)); font-weight: 750; margin: 0 0 8px;
}
.note p { margin: 0; font-size: 15px; color: var(--ink-soft); max-width: 78ch; }

/* ---------- service sections ---------- */
.service-cols {
  display: grid; grid-template-columns: minmax(0, 6.2fr) minmax(0, 5.8fr);
  gap: clamp(28px, 4.5vw, 56px); align-items: start;
}
.prose .mini {
  font-size: 12px; font-weight: 750; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted); margin: 26px 0 12px;
}
.prose .mini:first-child { margin-top: 0; }
.prose ul { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 11px; }
.prose ul li { position: relative; padding-left: 22px; font-size: 15.5px; color: var(--ink-soft); }
.prose ul li::before {
  content: ""; position: absolute; left: 2px; top: 10px;
  width: 8px; height: 8px; border-radius: 2.5px; background: var(--accent, var(--orange));
}
.prose p { font-size: 15.5px; color: var(--ink-soft); margin: 0 0 14px; max-width: 66ch; }
strong { font-weight: 650; color: var(--ink); }

code {
  font-family: var(--font-mono); font-size: .85em;
  background: #f0ede6; border: 1px solid var(--line);
  padding: 1.5px 6px; border-radius: 6px; color: var(--ink);
  white-space: nowrap;
}
h2 code { white-space: normal; }

/* ---------- callouts ---------- */
.callout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 28px; }
.callout { border-radius: var(--radius-sm); padding: 16px 18px; border: 1px solid; }
.callout.good { background: var(--ok-tint); border-color: var(--ok-line); }
.callout.caution { background: var(--warn-tint); border-color: var(--warn-line); }
.callout h4 {
  margin: 0 0 10px; font-size: 11.5px; letter-spacing: .12em;
  text-transform: uppercase; font-weight: 750;
}
.callout.good h4 { color: var(--ok); }
.callout.caution h4 { color: var(--warn); }
.callout ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.callout li { position: relative; padding-left: 20px; font-size: 13.8px; line-height: 1.55; color: var(--ink-soft); }
.callout.good li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }
.callout.caution li::before { content: "!"; position: absolute; left: 2px; color: var(--warn); font-weight: 800; }

/* ---------- code cards ---------- */
.code-rail { position: sticky; top: 88px; }
.code-card {
  margin: 0 0 12px; border-radius: 12px; overflow: hidden;
  background: var(--code-bg); box-shadow: 0 8px 26px rgba(23,26,32,.16);
}
.code-card figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--code-head); border-bottom: 1px solid var(--code-line);
  padding: 8px 10px 8px 14px;
}
.code-file { font-family: var(--font-mono); font-size: 12px; color: #9aa3b2; }
.copy {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 650;
  color: #aab3c2; background: #242832; border: 1px solid #2e3340;
  border-radius: 7px; padding: 4px 10px; cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.copy:hover { color: #e3e7f0; border-color: #3a4150; }
.copy.done { color: #7ec99f; border-color: #3a5c47; }
.code-card pre {
  margin: 0; padding: 15px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.68;
  color: var(--code-ink); tab-size: 2;
}
pre code {
  background: none; border: none; padding: 0; border-radius: 0;
  color: var(--code-ink);
  white-space: pre; font-size: inherit;
}
.code-caption { margin: 0 2px 14px; font-size: 13.5px; color: var(--faint); }
.code-rail .code-card:last-child { margin-bottom: 0; }

.cm  { color: var(--syn-cm); font-style: italic; }
.kw  { color: var(--syn-kw); }
.str { color: var(--syn-str); }
.fn  { color: var(--syn-fn); }
.num { color: var(--syn-num); }
.tg  { color: var(--syn-tag); }
.at  { color: var(--syn-attr); }
.ky  { color: var(--syn-key); }
.tp  { color: #7ec99f; }   /* terminal prompt */
.to  { color: #9aa3b2; }   /* terminal output */

/* ---------- lifecycle timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 34px 62px; }
.timeline li::before {
  content: ""; position: absolute; left: 19px; top: 44px; bottom: 2px;
  width: 2px; background: var(--line-2);
}
.timeline li:last-child::before { display: none; }
.t-dot {
  position: absolute; left: 0; top: 0; width: 40px; height: 40px;
  border-radius: 50%; background: var(--t-tint); color: var(--t-ink);
  border: 1.5px solid var(--t); display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
}
.timeline h3 { margin: 6px 0; font-size: 17px; letter-spacing: -.01em; }
.timeline p { margin: 0; font-size: 15px; color: var(--muted); max-width: 64ch; }

/* ---------- comparison table ---------- */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card);
}
.compare { width: 100%; border-collapse: collapse; min-width: 660px; font-size: 14.5px; }
.compare th, .compare td {
  padding: 14px 18px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.compare thead th {
  font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 750; background: var(--surface);
}
.compare tbody th {
  font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); font-weight: 700; width: 190px;
}
.compare tbody tr:last-child th, .compare tbody tr:last-child td { border-bottom: none; }
.compare td { color: var(--ink-soft); }
.c-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: baseline; }
.table-note { margin: 18px 2px 0; font-size: 14.5px; color: var(--muted); max-width: 74ch; }

/* ---------- deploy steps ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.steps li {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
  display: grid; grid-template-columns: 60px 1fr; gap: 18px; align-items: start;
}
.s-n {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--orange-tint); color: var(--orange-ink);
  font-weight: 800; font-size: 16px; display: grid; place-items: center;
}
.steps h3 { margin: 2px 0 8px; font-size: 17px; letter-spacing: -.01em; }
.steps p { margin: 0 0 12px; font-size: 15px; color: var(--muted); max-width: 68ch; }
.deploy-note { margin-top: 26px; font-size: 15px; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 56px 0 28px; }
.foot-flex {
  display: flex; flex-wrap: wrap; gap: 36px; justify-content: space-between;
  align-items: flex-start;
}
.site-footer h2 { font-size: 22px; margin: 0 0 10px; }
.foot-copy { margin: 0 0 10px; font-size: 15px; color: var(--muted); max-width: 58ch; }
.foot-meta { margin: 0; font-size: 13.5px; color: var(--faint); }
.palette { display: flex; gap: 14px; flex-wrap: wrap; }
.pal {
  display: grid; justify-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  color: var(--faint); text-transform: uppercase;
}
.pal i { width: 32px; height: 32px; border-radius: 9px; display: block; }
.foot-legal {
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--faint);
}

/* ---------- reveal-on-scroll (progressive enhancement) ---------- */
html.js [data-reveal] {
  opacity: 0; transform: translateY(16px);
  transition: opacity .6s ease, transform .6s ease;
}
html.js [data-reveal].revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .service-cols { grid-template-columns: 1fr; }
  .code-rail { position: static; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .primitive-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .brand-tag { display: none; }
  .legend { grid-template-columns: 1fr; }
  .callout-grid { grid-template-columns: 1fr; }
  .primitive-grid { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .steps li { grid-template-columns: 1fr; }
  .compare th, .compare td { padding: 12px 14px; }
}
