/* The site's own theme, layered over markset.css exactly as a theme stylesheet
 * is layered over a document (spec §6). Two jobs: the chrome (header, TOC, case
 * panes) and the handful of author classes the site's pages use, which are the
 * reserved ones from §5 plus .tick, .stats and .compare. */
@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&display=swap");

/* ---- identity ------------------------------------------------------------ */
body { --ms-font-heading: "Source Serif 4", Charter, Georgia, "Times New Roman", serif; }
.ms-document > h1 { font-size: clamp(2.1rem, 4.2vw, 2.9rem); line-height: 1.06; letter-spacing: -0.022em; text-wrap: balance; }
.ms-document > h2 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); letter-spacing: -0.015em; text-wrap: balance; }
.ms-document > h1 code { background: none; padding: 0; font-size: 0.82em; }
.ms-document > .lead { max-width: 60ch; color: var(--ms-fg-muted); }
.ms-document > .lead strong { color: var(--ms-fg); }
.eyebrow { font-family: var(--ms-font-body); color: var(--ms-accent); letter-spacing: 0.12em; }
.badge { font-family: var(--ms-font-body); }
/* A run of badges under the title reads as one status line, not four blocks. */
.ms-document > p > .ms-span.badge + .ms-span.badge { margin-left: 0.3rem; }

/* Ruler-edge divider between major sections: {.tick} on a thematic break. */
.ms-document > hr.tick {
  max-width: none;
  height: 13px;
  border-top: 1px solid var(--ms-border);
  background-image: repeating-linear-gradient(to right, var(--ms-border) 0 1px, transparent 1px 12px);
  background-size: 100% 5px;
  background-repeat: no-repeat;
  margin-top: calc(var(--ms-space) * 3);
}

/* A metrics block as a dense fact strip: {.stats}. */
.stats { gap: 1px; background: var(--ms-border); border: 1px solid var(--ms-border); border-radius: var(--ms-radius); overflow: hidden; }
.stats .ms-metric { border: 0; border-radius: 0; padding: 0.9rem 1.1rem; }
.stats .ms-metric-value { font-family: var(--ms-font-heading); }

/* A grid item that leads with a heading: the heading is a label, not a section. */
.ms-grid-item > h3:first-child { font-size: 1.02rem; letter-spacing: -0.01em; }
.ms-grid-item > h3:first-child + * { margin-top: 0.45rem !important; }

/* A comparison table: {.compare}. */
.compare { font-size: 0.9rem; border: 1px solid var(--ms-border); border-radius: var(--ms-radius); border-collapse: separate; border-spacing: 0; background: var(--ms-surface); }
.compare th { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ms-fg-muted); padding: 1rem 0.75rem 0.55rem; }
.compare td { padding: 0.7rem 0.75rem; vertical-align: middle; }
.compare tr:last-child td { border-bottom: 0; }
.compare td:first-child { font-weight: 600; white-space: nowrap; }
.compare tr:last-child { background: var(--ms-bg); }

/* ---- chrome -------------------------------------------------------------- */
/* The app bar follows the page. Its height is a token rather than a measured
 * value, because two other things have to line up under it: the sticky table of
 * contents, and the scroll position of any heading reached by an anchor. */
body { --site-header-h: 3.25rem; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ms-space);
  min-height: var(--site-header-h);
  padding: 0.75rem var(--ms-space);
  border-bottom: 1px solid var(--ms-border);
  background: var(--ms-surface);
}
/* An anchor target must clear the bar instead of hiding behind it. */
.ms-document :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: calc(var(--site-header-h) + 0.5rem); }
.site-brand { font-family: var(--ms-font-heading); font-weight: 700; font-size: 1.1rem; color: var(--ms-fg); text-decoration: none; letter-spacing: -0.01em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.site-brand { flex: none; }
.site-nav a { color: var(--ms-fg-muted); text-decoration: none; font-family: var(--ms-font-body); font-size: 0.9rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ms-accent); }
/* The reader's color scheme, with no script anywhere. The radio inputs hold the
 * state; body:has() reads it; markset.css resolves every color through
 * color-scheme, so forcing a scheme is one property. The inputs are clipped
 * rather than display:none, which would take them out of the tab order. */
body:has(#ms-scheme-light:checked) { color-scheme: light; }
body:has(#ms-scheme-dark:checked) { color-scheme: dark; }
.site-scheme { flex: none; display: flex; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--ms-border); border-radius: 999px; background: var(--ms-bg); }
.site-scheme-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.site-scheme-option { padding: 0.2rem 0.55rem; border-radius: 999px; font-family: var(--ms-font-body); font-size: 0.7rem; line-height: 1.4; color: var(--ms-fg-muted); cursor: pointer; }
.site-scheme-option:hover { color: var(--ms-fg); }
.site-scheme-input:checked + .site-scheme-option { background: var(--ms-surface); color: var(--ms-fg); }
/* Keyboard focus has to be visible on the label, because the input it belongs
 * to is clipped out of sight. */
.site-scheme-input:focus-visible + .site-scheme-option { outline: 2px solid var(--ms-accent); outline-offset: 1px; }

.site-layout { max-width: 75rem; margin: 0 auto; }
.site-layout.has-toc { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: var(--ms-space); }
.site-layout.has-toc > * { min-width: 0; } /* or a wide block inside main widens the whole grid */
.site-toc { position: sticky; top: var(--site-header-h); align-self: start; max-height: calc(100vh - var(--site-header-h)); overflow-y: auto; padding: calc(var(--ms-space) * 2) var(--ms-space); font-size: 0.875rem; border-right: 1px solid var(--ms-border); }
.site-toc ul { list-style: none; margin: 0; padding: 0; }
.site-toc li { margin: 0.25rem 0; }
.site-toc .toc-3 { padding-left: 1rem; }
.site-toc a { color: var(--ms-fg-muted); text-decoration: none; }
.site-toc a:hover { color: var(--ms-accent); }
.site-footer { max-width: var(--ms-measure-wide); margin: 0 auto; padding: calc(var(--ms-space) * 2) var(--ms-space); color: var(--ms-fg-muted); font-size: 0.875rem; border-top: 1px solid var(--ms-border); }
.site-status { color: var(--ms-fg-muted); }
.site-list li + li { margin-top: 0.4rem; }
.site-table td, .site-table th { padding-right: 1.5rem; }
.site-more { color: var(--ms-fg-muted); font-size: 0.875rem; margin-top: calc(var(--ms-space) * 2) !important; padding-top: var(--ms-space); border-top: 1px solid var(--ms-border); }

/* A line above a guide example saying what to look at. */
.site-note { color: var(--ms-fg-muted); max-width: 70ch; }
.ms-document > .site-note { margin-top: calc(var(--ms-space) * 1.5) !important; }
.ms-document > .site-note + .site-case { margin-top: 0.5rem !important; }

/* conformance and guide case cards */
.site-case { border: 1px solid var(--ms-border); border-radius: var(--ms-radius); padding: var(--ms-space); }
.site-case + .site-case { margin-top: var(--ms-space); }
.site-case-title { font-size: 1rem; margin: 0 0 0.75rem; }
.site-case-index { color: var(--ms-fg-muted); font-weight: 400; }
.site-panes { display: grid; gap: var(--ms-space); grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.site-pane > h4 { margin: 0 0 0.4rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ms-fg-muted); }
.site-pane pre { margin: 0; font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }
.site-preview { border: 1px dashed var(--ms-border); border-radius: var(--ms-radius); padding: var(--ms-space); background: var(--ms-bg); }
.site-preview > * + * { margin-top: var(--ms-space); }
.site-preview > *:first-child { margin-top: 0; }
.site-diagnostics { margin-top: 0.75rem; font-size: 0.875rem; color: var(--ms-fg-muted); }
@media (max-width: 60rem) {
  .site-layout.has-toc { grid-template-columns: 1fr; }
  .site-toc { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--ms-border); }
}

/* Narrow: the links would wrap to three rows and the sticky bar would eat a
 * third of the screen, so they become one scrolling row instead. The fade on
 * the right edge is what says there is more of it. */
@media (max-width: 40rem) {
  /* Brand and scheme control on the first row, links on their own below. Three
   * things on one row left the links about 140px of it. The height token moves
   * with the layout, because scroll-margin still reads it. */
  body { --site-header-h: 5rem; }
  .site-header { flex-wrap: wrap; row-gap: 0.4rem; padding-block: 0.5rem; }
  .site-nav {
    order: 3;
    flex-basis: 100%;
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 1.25rem;
    mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { white-space: nowrap; }
}

@media print {
  .site-header { position: static; }
  .site-scheme { display: none; }
}
