/* Make AI Visible - reset, type scale, page and index rail, long-form text. */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background-color: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media (min-width: 48rem) {
  html { scrollbar-gutter: stable; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.06rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 160ms;
  }

  ::view-transition-group(site-header) {
    animation-duration: 0s;
  }

  ::view-transition-old(site-header),
  ::view-transition-new(site-header) {
    animation: none;
    mix-blend-mode: normal;
    height: 100%;
  }
}

/* ---------- Page and index rail ---------- */

.page {
  width: min(
    100% - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px),
    var(--page)
  );
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--s5) + env(safe-area-inset-top, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

main,
.article {
  flex: 1;
  min-width: 0;
  padding-bottom: var(--s7);
}

main { padding-top: var(--s6); }
.article { padding-top: var(--s6); }

.article { max-width: var(--measure); counter-reset: section figure; }

@media (min-width: 60rem) {
  main,
  .article,
  .pager { margin-left: var(--rail); }
}

/* ---------- Headings ---------- */

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.05rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 0 0 var(--s4);
  text-wrap: balance;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: var(--s7) 0 var(--s3);
}

h2[id],
.post-group {
  scroll-margin-top: var(--s6);
}

h3 {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: var(--s5) 0 var(--s1);
}

/* Section numbers live in the rail, no markup required. */
.article h2 {
  counter-increment: section;
  position: relative;
}

@media (min-width: 60rem) {
  .article h2::before {
    content: counter(section, decimal-leading-zero);
    position: absolute;
    left: calc(-1 * var(--rail));
    top: 0.5em;
    width: calc(var(--rail) - var(--s5));
    text-align: right;
    font: 500 0.72rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    color: var(--muted);
  }
}

/* ---------- Text ---------- */

p { margin: 0 0 var(--s4); }

a { color: var(--ink); }

.eyebrow,
.section-label,
.card-kicker,
.pager-label,
.mismatch-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  display: block;
  margin: 0 0 var(--s3);
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 1.1rem;
  height: 0.5rem;
  margin-right: var(--s2);
  vertical-align: 0.02em;
  background: var(--marker);
}

.lede {
  font-size: 1.19rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: var(--measure);
  margin: 0;
}

.page-intro {
  max-width: var(--measure);
  padding-bottom: var(--s5);
  margin-bottom: var(--s5);
  border-bottom: 1px solid var(--line);
}

.page-intro h1 {
  margin-bottom: var(--s4);
}

.page-intro .lede {
  margin: 0;
}

.page-intro + .tool-scope,
.page-intro + .glossary-find,
.page-intro + .term-index {
  margin-top: 0;
}

.crumb {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 var(--s5);
}

.crumb a,
.text-link,
.article em a {
  color: var(--ink);
  text-decoration-color: var(--marker-edge);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

.text-link {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.94rem;
}

.article > .lede { margin-bottom: var(--s3); }

.article-header {
  position: relative;
  padding-bottom: var(--s5);
  margin-bottom: var(--s6);
  border-bottom: 1px solid var(--line);
}

.article-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 3.5rem;
  height: 2px;
  background: var(--marker);
}

.article-header .crumb {
  margin-bottom: var(--s4);
}

.article-byline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s3) var(--s4);
  margin: var(--s4) 0 0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.article-byline time {
  margin: 0;
}

/* Direct children only — lists inside figures carry their own grammar. */
.article > ul,
.article > ol { padding-left: var(--s5); }

.article > ul > li,
.article > ol > li { margin-bottom: var(--s2); }

strong { font-weight: 600; }

blockquote {
  margin: var(--s5) 0;
  padding: var(--s3) 0 var(--s3) var(--s4);
  border-left: 2px solid var(--marker);
  font-size: 1.1rem;
  color: var(--ink-soft);
}

.pull {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.4vw, 1.45rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: var(--s6) 0;
  padding: var(--s4) 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: var(--s5) 0 var(--s6);
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-display);
  font-size: 0.92rem;
  line-height: 1.45;
  margin: var(--s5) 0 var(--s6);
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--s3) var(--s3) var(--s3) 0;
  border-bottom: 1px solid var(--line);
}

th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
}

/* ---------- Code ---------- */

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--sunken);
  padding: 0.08em 0.3em;
}

pre {
  overflow-x: auto;
  max-width: 100%;
  padding: var(--s4);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

@media (max-width: 48rem) {
  h2 { margin-top: var(--s6); }
}

@media (max-width: 30rem) {
  .table-wrap table thead,
  .term-table-wrap table thead {
    display: none;
  }

  .table-wrap table tbody tr,
  .term-table-wrap table tbody tr {
    display: block;
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--line);
  }

  .table-wrap table tbody tr:last-child,
  .term-table-wrap table tbody tr:last-child {
    border-bottom: 0;
  }

  .table-wrap table tbody td,
  .term-table-wrap table tbody td {
    display: block;
    border-bottom: none;
    padding: var(--s1) 0 var(--s3);
  }

  .table-wrap table tbody td:last-child,
  .term-table-wrap table tbody td:last-child {
    padding-bottom: 0;
  }

  .table-wrap table tbody td::before,
  .term-table-wrap table tbody td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: var(--s1);
  }

  .table-wrap table tbody td[data-label=""]::before,
  .term-table-wrap table tbody td[data-label=""]::before {
    content: none;
  }
}