/* Anyi's public pages (home and docs), on the shared KeaiUI public-web
   pattern: the same reading scale and rhythm as Ingrid's site, with Anyi's
   own evidence, a pivot table as static HTML in the grid's own look. */
@import url('./tokens.css');
@import url('./public-web.css');

:root {
  color-scheme: light;
}

html {
  min-width: 300px;
  background: var(--color-surface-page);
}

.landing-page {
  --keaiui-web-page-font-size: var(--text-size-web-subheading);
}

.site-shell {
  --keaiui-web-shell-width: 720px;
  min-height: 100vh;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1 {
  max-width: 24ch;
  margin: 0;
  font-size: var(--text-size-web-display);
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: var(--text-size-web-heading);
  line-height: 1.3;
}

h3 {
  margin: 0;
  font-size: var(--text-size-web-subheading);
  line-height: 1.3;
}

.intro {
  padding: var(--space-8) 0 var(--space-7);
}

.hero-lede {
  max-width: 60ch;
  margin: var(--space-6) 0 0;
  font-size: var(--text-size-web-subheading);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  margin-top: var(--space-6);
  font-size: var(--text-size-web-body);
}

.fine-print {
  margin: var(--space-5) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-size-web-body);
}

.section {
  padding: var(--space-7) 0;
  border-top: 1px solid var(--color-border);
}

.section > p,
.section > ul {
  max-width: 60ch;
  margin: var(--space-5) 0 0;
}

.section > ul {
  padding-left: 1.2em;
}

.section li + li {
  margin-top: var(--space-2);
}

/* The pivot example: a real result, drawn as the grid draws it. */
.pivot-example {
  margin: 0 0 var(--space-8);
}

.pivot-example figcaption {
  margin: var(--space-5) 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-size-web-body);
  line-height: 1.5;
}

.pivot-table {
  /* Anyi's grid, drawn as data-grid's grid.css draws it: KeaiUI body text,
     22px rows, a raised header band one control tall, fine rules, and the
     fold caret on a group. */
  --rule: color-mix(in srgb, var(--color-border) 60%, var(--color-surface-page));
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface-page);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-size-body);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pivot-table th,
.pivot-table td {
  box-sizing: border-box;
  height: 22px;
  padding: 0 6px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  text-align: right;
  font-weight: 400;
}

.pivot-table thead th {
  height: var(--size-ctrl-md, 24px);
  background: var(--color-surface-raised);
  border-right-color: var(--color-border);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

.pivot-table thead th:first-child,
.pivot-table tbody th {
  min-width: 9em;
  text-align: left;
}

.pivot-table tbody th[data-tree='leaf'] {
  padding-left: calc(6px + 14px);
}

.pivot-table tbody th[data-tree='open']::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  vertical-align: -1px;
  background: var(--color-text-muted);
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'><polyline points='96 48 176 128 96 208' fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='24'/></svg>") center / contain no-repeat;
  transform: rotate(90deg);
}

.dataset-list {
  display: grid;
  gap: var(--space-3);
  max-width: 60ch;
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
}

.dataset-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: baseline;
}

.dataset-list .count {
  color: var(--color-text-muted);
  font-size: var(--text-size-web-body);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The footer: maker credit beside the mark, then the destinations, as on
   Ingrid's pages. */
.site-footer {
  padding: var(--space-6) 0;
  border-top: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-size: var(--text-size-web-body);
}

.site-footer a {
  font-weight: 600;
}

.site-footer p {
  margin: 0;
}

.site-footer p > span {
  display: inline-block;
  width: 0.77em;
  height: 0.77em;
  margin-right: 4px;
  color: var(--color-accent);
}

/* Docs, as Ingrid's (apps/ingrid/frontend/site/site.css): the page title,
   then "On this page", then task sections with stable anchors. Every page
   keeps one shell width so moving between them never shifts the layout. */
.docs-layout {
  display: block;
  padding: 18px 0 24px;
}

.docs-title {
  padding-bottom: 16px;
}

.docs-title > p:last-child {
  margin: 7px 0 0;
  color: var(--color-text-muted);
}

.docs-toc {
  columns: 2;
  padding: 0 0 15px;
  border-bottom: 1px solid var(--color-border-strong);
}

.docs-toc a {
  display: block;
  padding: 3px 0;
  color: var(--color-accent);
}

.toc-title {
  column-span: all;
  margin: 0 0 5px;
  color: var(--color-text-strong);
  font-size: var(--text-size-web-meta);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.docs-content {
  padding-top: 16px;
}

.docs-content section {
  padding-top: 16px;
  scroll-margin-top: var(--space-4);
}

.docs-content section + section {
  margin-top: 16px;
  border-top: 1px solid var(--color-border);
}

.docs-content h2 {
  margin-bottom: 6px;
}

.docs-content h3 {
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}

.docs-content p,
.docs-content ul,
.docs-content ol,
.docs-content dl {
  margin-top: 8px;
  margin-bottom: 0;
}

.docs-content li + li {
  margin-top: 5px;
}

.docs-content dt {
  margin-top: 10px;
  color: var(--color-text-strong);
  font-weight: 600;
}

.docs-content dd {
  margin: 2px 0 0;
  color: var(--color-text-muted);
}

.note {
  margin-top: 10px;
  padding: 9px 12px;
  border-left: 2px solid var(--color-accent-soft-border);
  background: var(--color-accent-soft);
}

kbd {
  display: inline-block;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 22px;
  padding: 1px 5px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  background: var(--color-button-face);
  font-family: var(--font-sans);
  font-size: var(--text-size-web-ui);
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  box-shadow: var(--bevel-raised);
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 639px) {
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-3);
  }

  .hero-actions {
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  .docs-toc {
    columns: 1;
  }

  .docs-toc a {
    display: flex;
    align-items: center;
    min-height: var(--size-touch);
  }

  .docs-content ul,
  .docs-content ol {
    padding-left: 22px;
  }

  .dataset-list li {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* A results table in a reading page (How it works): the home table's rules
   and header band, numbers right-aligned in tabular figures; on a narrow
   screen it scrolls sideways in its own box, never the page. */
.table-scroll {
  overflow-x: auto;
  margin-block: var(--space-3);
}
.docs-content table {
  --rule: color-mix(in srgb, var(--color-border) 60%, var(--color-surface-page));
  border-collapse: collapse;
  border: 1px solid var(--color-border);
  font-size: var(--text-size-ui);
  min-width: 100%;
}
.docs-content th,
.docs-content td {
  padding: 4px 8px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  text-align: right;
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}
.docs-content thead th {
  background: var(--color-surface-raised);
  border-bottom-color: var(--color-border);
  font-weight: 600;
  white-space: nowrap;
}
.docs-content th:first-child,
.docs-content td:first-child {
  text-align: left;
  min-width: 16em;
}
