/*
 * pdatum.pearachute.com's one stylesheet, for every page the host serves
 * (PAGES in api/pdatum.py). A page carries no <style> of its own, so the pages
 * cannot drift apart.
 *
 * Pearachute's family tokens, as pkanban's frontend/src/theme.css has them:
 * the five --pear-* colors verbatim, warm neutrals keyed to --pear-dark,
 * AA-darkened cyan and green for text in light mode, code always dark.
 */
:root {
  --pear-primary: #63cdf5;
  --pear-dark: #231f20;
  --pear-accent: #42ba3b;
  --pear-light-green: #bfe47e;
  --pear-pale-blue: #def4fd;

  --bg: #f7f6f4;
  --card: #ffffff;
  --surface: #efedea;
  --border: #ddd9d4;
  --border-strong: #c4bfb8;
  --fg: var(--pear-dark);
  --fg-muted: #6b6560;
  --primary: #0b6c91;
  --primary-fg: #ffffff;
  --accent: #277322;
  --warning: #8a5408;
  --code-bg: var(--pear-dark);
  --code-fg: #f2efec;
  --code-border: transparent;
  --grid-line: rgb(35 31 32 / 0.07);

  --font-sans: "Ubuntu", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Ubuntu Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --tracking-tight: -0.02em;
  --tracking-wide: 0.06em;
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);

  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--pear-dark);
    --card: #2b2726;
    --surface: #332e2d;
    --border: #423c3b;
    --border-strong: #574f4d;
    --fg: #f2efec;
    --fg-muted: #a8a19c;
    --primary: var(--pear-primary);
    --primary-fg: var(--pear-dark);
    --accent: var(--pear-accent);
    --warning: #e0a03a;
    --code-bg: #1a1717;
    --code-border: #423c3b;
    --grid-line: rgb(242 239 236 / 0.05);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--pear-dark);
  --card: #2b2726;
  --surface: #332e2d;
  --border: #423c3b;
  --border-strong: #574f4d;
  --fg: #f2efec;
  --fg-muted: #a8a19c;
  --primary: var(--pear-primary);
  --primary-fg: var(--pear-dark);
  --accent: var(--pear-accent);
  --warning: #e0a03a;
  --code-bg: #1a1717;
  --code-border: #423c3b;
  --grid-line: rgb(242 239 236 / 0.05);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }
a { color: var(--primary); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
code, kbd, samp, pre { font-family: var(--font-mono); }
p code, li code {
  font-size: 0.95em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.25em;
}
h1, h2, h3 { margin: 0; letter-spacing: var(--tracking-tight); font-weight: 700; }
p { margin: 0 0 1rem; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

/* -- header ------------------------------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--fg); text-decoration: none;
  font-weight: 700; font-size: 1.25rem; letter-spacing: var(--tracking-tight);
}
.logo:hover { color: var(--fg); }
.mark { color: var(--primary); flex: none; }
.site-nav { display: none; gap: 20px; margin-left: 8px; }
.site-nav a { color: var(--fg-muted); text-decoration: none; font-size: 0.9375rem; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--fg); }
/* The header needs about 1140px with all eight links; narrower, they would
   push the key button off the page, so they hide, and the footer and the
   front page's cards still list every feed. */
@media (min-width: 1160px) { .site-nav { display: flex; } }
.header-end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; white-space: nowrap; }

.theme-toggle {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  background: none; color: var(--fg-muted);
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--border); }
.theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

/* -- buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  font: 500 0.9375rem/1.2 var(--font-sans);
  text-decoration: none; cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
.btn-sm { padding: 7px 12px; font-size: 0.875rem; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover {
  background: color-mix(in srgb, var(--primary) 86%, var(--fg));
  color: var(--primary-fg);
}
.btn-install {
  background: var(--card); color: var(--fg);
  border-color: var(--border-strong);
  font-family: var(--font-mono); font-size: 1rem;
}
.btn-install:hover { color: var(--fg); border-color: var(--primary); }
.btn-install .prompt { color: var(--accent); }
.btn-outline { background: var(--card); color: var(--fg); border-color: var(--border-strong); }
.btn-outline:hover { color: var(--fg); border-color: var(--primary); }
.chip {
  font: 700 0.6875rem/1 var(--font-mono);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px 5px; margin-left: 4px;
}

/* -- hero -------------------------------------------------------------- */
.hero { position: relative; padding: 56px 0 64px; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 30% 0%, #000 0%, transparent 75%);
          mask-image: radial-gradient(ellipse 80% 70% at 30% 0%, #000 0%, transparent 75%);
}
.hero .wrap { display: grid; gap: 48px; align-items: center; }
/* a terminal's long line scrolls inside it, never widening the page */
.hero .wrap > * { min-width: 0; }
@media (min-width: 1000px) {
  .hero { padding: 88px 0 96px; }
  .hero .wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 56px; }
}
.eyebrow {
  display: inline-flex; gap: 10px; flex-wrap: wrap;
  font: 700 0.75rem/1 var(--font-mono);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--fg-muted); margin: 0 0 20px;
}
.eyebrow span + span::before { content: "·"; margin-right: 10px; color: var(--border-strong); }
.hero h1 {
  font-size: clamp(2.25rem, 1.4rem + 3.2vw, 3.375rem);
  line-height: 1.08;
  text-wrap: balance;
  margin-bottom: 20px;
}
.lede { font-size: 1.1875rem; line-height: 1.6; color: var(--fg-muted); max-width: 34rem; }
.lede strong { color: var(--fg); font-weight: 500; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 20px; }
.proof { font-size: 0.9375rem; color: var(--fg-muted); margin: 0; }

/* -- terminal ---------------------------------------------------------- */
.term {
  background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--code-border); border-radius: var(--radius-xl);
  overflow: hidden; min-width: 0;
}
.term-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgb(242 239 236 / 0.08);
  font: 0.75rem/1 var(--font-mono); color: #a8a19c;
}
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #574f4d; flex: none; }
.term-bar i:nth-child(1) { background: #f07171; }
.term-bar i:nth-child(2) { background: #e0c04a; }
.term-bar i:nth-child(3) { background: var(--pear-accent); }
.term-bar span { margin-left: 6px; }
.term pre {
  margin: 0; padding: 16px 18px 18px;
  font-size: 0.8125rem; line-height: 1.55;
  overflow-x: auto; tab-size: 4;
}
@media (min-width: 640px) { .term pre { font-size: 0.875rem; } }
.term .p { color: var(--pear-accent); user-select: none; }
.term .c { color: #9a928c; }
.term .o { color: #cfc8c2; }
.term .e { color: #e0c04a; }
.term .s { color: var(--pear-light-green); }
.term .k { color: var(--pear-primary); }

/* -- sections ---------------------------------------------------------- */
section.band { padding: 72px 0; border-top: 1px solid var(--border); }
@media (min-width: 1000px) { section.band { padding: 96px 0; } }
section.alt { background: var(--surface); }
.section-head { max-width: 44rem; margin-bottom: 40px; }
.section-head h2, .split h2 { font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.125rem); line-height: 1.15; margin-bottom: 14px; }
.section-head p, .split .text p { color: var(--fg-muted); font-size: 1.0625rem; }
.section-head p:last-child { margin-bottom: 0; }

/* -- what's in it ------------------------------------------------------ */
/* Seven feeds, one card each. The front page lists all seven: three over
   two over two, the last four wider, or on two columns the last one across
   both, so no card sits alone. A feed's page lists the other six, three by
   two. */
.datasets { display: grid; gap: 16px; }
@media (min-width: 700px) { .datasets { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 700px) and (max-width: 899.98px) {
  .datasets.seven > :last-child { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  .datasets { grid-template-columns: repeat(3, 1fr); }
  .datasets.seven { grid-template-columns: repeat(6, 1fr); }
  .datasets.seven > * { grid-column: span 2; }
  .datasets.seven > :nth-child(n+4) { grid-column: span 3; }
}
.dataset {
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 22px 22px 20px;
  display: flex; flex-direction: column;
}
.dataset header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dataset h3 { font-size: 1.1875rem; }
.dataset p { color: var(--fg-muted); margin-bottom: 14px; }
.dataset .endpoint { margin-top: auto; font: 0.875rem/1.4 var(--font-mono); color: var(--fg); }
.dataset .endpoint b { color: var(--accent); font-weight: 700; margin-right: 6px; }
.dataset .endpoint + .endpoint { margin-top: 4px; }
.dataset h3 a { color: inherit; text-decoration: none; }
.dataset h3 a:hover { color: var(--primary); }
.dataset .more { margin: 16px 0 0; font-size: 0.9375rem; }

/* -- text beside a panel ----------------------------------------------- */
.split { display: grid; gap: 40px; align-items: start; }
@media (min-width: 1000px) { .split { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 64px; } }
.split .text { max-width: 36rem; }

/* -- rules ------------------------------------------------------------- */
/* minmax(0, ...): an .eg line does not wrap, and would otherwise widen its
   column past the screen, where overflow: hidden clips it without a word */
.rules {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-xl);
  overflow: hidden;
}
@media (min-width: 700px) { .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rule { background: var(--card); padding: 24px; display: flex; flex-direction: column; }
.rule h3 { font-size: 1.1875rem; margin-bottom: 8px; }
.rule p { color: var(--fg-muted); margin-bottom: 16px; }
.rule .eg {
  margin-top: auto;
  font: 0.875rem/1.5 var(--font-mono);
  background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--code-border); border-radius: var(--radius-md);
  padding: 8px 12px; overflow-x: auto; white-space: pre;
}
.rule .eg .k { color: var(--pear-primary); }
.rule .eg .s { color: var(--pear-light-green); }
.rule .eg .m { color: #e0a03a; }
.rule .eg .c { color: #9a928c; }

/* -- agents ------------------------------------------------------------ */
.facts { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 14px; }
.facts li { padding-left: 22px; position: relative; color: var(--fg-muted); }
.facts li::before {
  content: ""; position: absolute; left: 2px; top: 0.55em;
  width: 8px; height: 8px; border: 1.5px solid var(--primary); border-radius: 1px;
}
.facts li strong { color: var(--fg); font-weight: 500; }

/* -- sources ----------------------------------------------------------- */
.cols { display: grid; gap: 40px; }
@media (min-width: 860px) { .cols { grid-template-columns: 1fr 1fr; gap: 64px; } }
.cols h3 { font-size: 1.1875rem; margin-bottom: 16px; }
.ledger { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.ledger li { padding: 14px 0; border-bottom: 1px solid var(--border); color: var(--fg-muted); }
.ledger li strong { display: block; color: var(--fg); font-weight: 500; margin-bottom: 2px; }
/* A source named in a ledger links its public record; quiet like a
   dataset's title link, so a list of them doesn't read as a row of buttons. */
.ledger li strong a { color: inherit; text-decoration-color: var(--border-strong); }
.ledger li strong a:hover { color: var(--primary); }
/* The feed pages a source fills, under its entry on the home page. */
.ledger .read-in { display: block; margin-top: 4px; font-size: 0.9375rem; }
.pledge {
  margin: 40px 0 0; max-width: 44rem;
  font-size: 1.125rem; line-height: 1.6;
}

/* -- a feed's page ------------------------------------------------------- */
/* what one record holds: a field, then what it means */
.fields {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
}
.fields > div { display: grid; gap: 4px 24px; padding: 14px 22px; }
.fields > div + div { border-top: 1px solid var(--border); }
@media (min-width: 700px) { .fields > div { grid-template-columns: 15rem minmax(0, 1fr); } }
.fields dt { font: 0.9375rem/1.5 var(--font-mono); color: var(--fg); overflow-wrap: anywhere; }
.fields dd { margin: 0; color: var(--fg-muted); }
.callout {
  border-left: 3px solid var(--primary);
  padding: 4px 0 4px 16px; margin: 24px 0 0;
}
.callout p { color: var(--fg); margin: 0; }
.illustrative { font-size: 0.875rem; color: var(--fg-muted); margin: 16px 0 0; }
/* a feed's limits stand alone, a column of their own: keep the lines short */
.section-head + .ledger { max-width: 48rem; }

/* -- access ------------------------------------------------------------ */
.access { text-align: left; }
.access .wrap { display: grid; gap: 28px; align-items: center; }
@media (min-width: 900px) { .access .wrap { grid-template-columns: 1fr auto; gap: 48px; } }
.access h2 { font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.125rem); margin-bottom: 12px; }
.access p { color: var(--fg-muted); font-size: 1.0625rem; max-width: 40rem; margin: 0; }
.access .cta { margin: 0; }

/* -- footer ------------------------------------------------------------ */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0 40px; font-size: 0.9375rem; color: var(--fg-muted); }
.site-footer .wrap { display: grid; gap: 20px; }
@media (min-width: 860px) { .site-footer .wrap { grid-template-columns: 1fr auto; align-items: center; } }
.site-footer .logo { font-size: 1.0625rem; }
.site-footer p { margin: 8px 0 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer nav a { color: var(--fg-muted); }
.site-footer nav a:hover { color: var(--fg); }

/* -- sign-in ------------------------------------------------------------ */
/* The page an AI app sends a person to, to connect with their key
   (api/oauth.py). No header, footer or nav: nothing to wander off to. */
.consent { max-width: 34rem; margin: 0 auto; padding: 64px 16px; }
.consent h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem); line-height: 1.2; margin-bottom: 16px; }
.consent p { color: var(--fg-muted); }
.consent strong { color: var(--fg); font-weight: 500; word-break: break-word; }
.consent-label { display: block; font-weight: 500; margin: 24px 0 8px; }
.consent-field {
  display: block; width: 100%;
  padding: 10px 12px;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font: 400 1rem/1.4 var(--font-mono);
}
.consent-field:focus-visible { border-color: var(--primary); }
.consent-problem { color: var(--warning); margin: 8px 0 0; }
.consent-note { font-size: 0.9375rem; margin: 16px 0 0; }
.consent-actions { display: flex; gap: 12px; margin-top: 24px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
