/* Critical CSS — applied before the Tailwind bundle arrives so the article
 * body is never rendered unstyled (the "splash" users saw on navigation).
 *
 * Keep this in sync with the prose / base / shiki rules in
 * `app/styles.css`. Tailwind utilities override these once the JS bundle
 * finishes loading; this file only needs to make the page look
 * presentable on the very first paint.
 *
 * If you change a value here, change the matching rule in styles.css.
 * If you only change a value in styles.css, also update this file.
 *
 * IMPORTANT: this file must reference the SAME CSS variable names as
 * `app/styles.css` (`--color-text`, `--color-bg`, `--color-code-bg`,
 * etc.). Earlier this file used a different prefix (`--c-text`) with
 * hardcoded light fallbacks, which broke dark mode — the fallbacks
 * fired and the prose rendered with the light-theme color in dark
 * mode. Now both files read from the same `--color-*` tokens.
 *
 * The prose font sizes read from `--prose-*` tokens defined in the
 * inlined THEME_TOKENS block (app/routes/_renderer.tsx). That block is
 * the single source of truth for the type scale, so the size values
 * here and in styles.css can never drift.
 */

html,
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Reserve the scrollbar gutter always. The site styles ::-webkit-scrollbar with
 * a fixed width, so the vertical scrollbar occupies layout width instead of
 * overlaying; without a stable gutter it appears on long pages and vanishes on
 * short ones, shifting the full-width topbar horizontally on every navigation. */
html {
  scrollbar-gutter: stable;
}

* {
  scrollbar-color: var(--color-border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 0.75rem;
  height: 0.75rem;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-faint);
}

header.topbar-critical {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}
header.topbar-critical .logo-mark {
  width: 24px;
  height: 24px;
  flex: none;
  display: block;
}

.topic-scroll-frame {
  position: relative;
}
.topic-scroll-frame::before,
.topic-scroll-frame::after {
  content: "";
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.topic-scroll-frame::before {
  left: -0.55rem;
  border-top: 0.28rem solid transparent;
  border-right: 0.38rem solid var(--color-text-faint);
  border-bottom: 0.28rem solid transparent;
  transform: translateY(-50%);
}
.topic-scroll-frame::after {
  right: -0.55rem;
  border-top: 0.28rem solid transparent;
  border-bottom: 0.28rem solid transparent;
  border-left: 0.38rem solid var(--color-text-faint);
  transform: translateY(-50%);
}
@media (max-width: 1023.98px) {
  .topic-scroll-frame[data-scroll-left]::before,
  .topic-scroll-frame[data-scroll-right]::after {
    opacity: 0.45;
  }
  /* A paragraph with an atomic non-wrapping run (long inline-code token, URL,
     hash, or `nowrap` signature) scrolls on its own X axis on narrow screens
     instead of widening the page. `auto` only shows a scrollbar on real
     overflow; line-height 1.7 keeps the forced `overflow-y: auto` from clipping
     descenders. Mirrors styles.css. */
  .prose p {
    overflow-x: auto;
  }
}

.prose {
  color: var(--color-text);
  font-size: var(--prose-text-size);
  line-height: 1.7;
}
.prose > * + * {
  margin-top: 1.1em;
}
.prose p + p {
  margin-top: 1.1em;
}
/* A paragraph after a list: `.prose p { margin: 0 }` zeroes its top margin and
   `.prose p + p` only matches a paragraph after a paragraph, so a paragraph
   following a list (which carries `margin: 0`) would butt against the last
   bullet. Restore the rhythm. */
.prose ul + p,
.prose ol + p {
  margin-top: 1.1em;
}
.prose h1 {
  --heading-anchor-line: 1.2;
  position: relative;
  font-size: var(--prose-h1-size);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
  color: var(--color-text);
  scroll-margin-top: calc(var(--topbar-height, 3.5rem) + 1.5rem);
}
.prose h2 {
  --heading-anchor-line: 1.3;
  position: relative;
  font-size: var(--prose-h2-size);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 2em 0 0.6em;
  padding-top: 0.4em;
  color: var(--color-text);
  scroll-margin-top: calc(var(--topbar-height, 3.5rem) + 1.5rem);
}
.prose h3 {
  --heading-anchor-line: 1.4;
  position: relative;
  font-size: var(--prose-h3-size);
  line-height: 1.4;
  font-weight: 600;
  margin: 1.6em 0 0.4em;
  color: var(--color-text);
  scroll-margin-top: calc(var(--topbar-height, 3.5rem) + 1.5rem);
}
.prose h4 {
  --heading-anchor-line: 1.4;
  position: relative;
  font-size: var(--prose-h4-size);
  line-height: 1.4;
  font-weight: 600;
  margin: 1.4em 0 0.4em;
  color: var(--color-text);
  scroll-margin-top: calc(var(--topbar-height, 3.5rem) + 1.5rem);
}
/* A signature row nested under a shape or receiver heading sits at `h4` for
   the outline only; it reads at the same size as every other signature row.
   Mirrors app/styles.css. */
.prose h4:has(.api-signature) {
  font-size: var(--prose-h3-size);
  margin-top: 1.6em;
}
.prose :is(h1, h2, h3, h4, h5, h6) {
  font-family: var(--font-heading);
}
.prose p {
  margin: 0;
}
.prose a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid
    color-mix(in srgb, var(--color-accent) 30%, transparent);
  transition: border-color 0.15s ease;
}
.prose a:hover {
  border-bottom-color: var(--color-accent);
}
/* A linked badge draws no underline. Mirrors app/styles.css. */
.prose a:has(> img[src*="shields.io"]) {
  border-bottom: none;
}
.prose a.heading-anchor {
  position: relative;
  color: inherit;
  font-weight: inherit;
  border-bottom: none;
}
.prose a.heading-anchor:hover {
  color: var(--color-accent);
}
/* Hang the permalink icon in the left margin, centered on the heading's FIRST
   line. The box is one line-height tall (--heading-anchor-line) anchored at
   top: 0, so a signature heading that wraps to several lines keeps the icon on
   the top line instead of dropping to the last. left/width and the glyph size
   are pinned to --prose-h3-size so horizontal placement and icon size stay
   uniform across h1-h4 regardless of heading font-size. */
.heading-anchor-icon {
  position: absolute;
  top: 0;
  left: calc(-1.15 * var(--prose-h3-size));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--prose-h3-size);
  height: calc(var(--heading-anchor-line, 1.4) * 1em);
  opacity: 0;
  color: var(--color-text-faint);
  transition: opacity 0.2s ease-in-out, color 0.2s ease-in-out;
}
.heading-anchor-icon svg {
  width: calc(0.85 * var(--prose-h3-size));
  height: calc(0.85 * var(--prose-h3-size));
}
.prose :is(h1, h2, h3, h4):hover .heading-anchor-icon,
.heading-anchor:focus-visible .heading-anchor-icon {
  opacity: 1;
  color: var(--color-accent);
}
.prose strong {
  font-weight: 600;
  color: var(--color-text);
}
/* Bold in API doc text renders at the surrounding weight; only a slot name
   (`.api-name`) stays bold. Mirrors app/styles.css; unlayered here so it beats
   the unlayered `.prose strong` rule above by specificity. */
.prose .api-symbol-body strong:not(.api-name) {
  font-weight: inherit;
}
/* A signature reads at normal weight inside its `h3`/`h4` from the first paint; its
   names carry their own inline weight. Mirrors app/styles.css. */
.prose .api-signature {
  font-weight: 400;
}
.prose code {
  font-family: var(--font-mono);
  font-size: var(--prose-code-size);
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: var(--color-text);
  /* Break space-less tokens so they can't force page-wide horizontal scroll on
     narrow screens. Mirrors app/styles.css. */
  overflow-wrap: anywhere;
}
/* If a signature code span is wrapped in a plain `.prose a`, the link underline
   already marks it: drop the inline-code border and padding so the chip chrome
   doesn't fight the underline. Excludes `a.heading-anchor` (the detail-heading
   permalink), which keeps its pill. Mirrors app/styles.css; unlayered here so
   it beats the unlayered `.prose code` rule above by specificity. */
.prose a:not(.heading-anchor) .api-signature {
  border-color: transparent;
  padding: 0;
}
/* A prose code span that is itself the link text (`[`resolve`](./resolve.md)`)
   reads as inert chrome at a glance, because the pill looks the same whether or
   not it navigates. Tint it with the accent so the affordance is legible without
   hovering. Excludes `.api-signature` (the rule above deliberately strips its
   chrome) and `a.heading-anchor`. The border goes transparent rather than
   keeping `--color-border`: a tinted chip inside a neutral grey outline reads as
   a mistake, and the accent text plus the link underline already carry the
   affordance. Mirrors app/styles.css; unlayered here so it beats the unlayered
   `.prose code` rule above by specificity. */
.prose a:not(.heading-anchor) > code:not(.api-signature) {
  background: var(--color-accent-soft);
  border-color: transparent;
  color: var(--color-accent);
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}
/* The glow is the hover state, not the resting one: at rest the tint plus the
   accent text is enough, and the ring arrives only once the pointer (or the
   keyboard focus ring) is actually on the target. */
.prose a:not(.heading-anchor):hover > code:not(.api-signature),
.prose a:not(.heading-anchor):focus-visible > code:not(.api-signature) {
  background: color-mix(in srgb, var(--color-accent) 18%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}
/* The `<pre>` sits inside Fumadocs' code block figure, which draws the frame;
   the figure's card and secondary colors point at the code background. Mirror
   of the layered rules in styles.css. */
.prose pre {
  font-family: var(--font-mono);
  font-size: var(--prose-pre-size);
  line-height: 1.55;
}
.prose figure.shiki {
  --color-fd-card: var(--color-code-bg);
  --color-fd-secondary: var(--color-code-bg);
}
.prose pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}
/* Platform marker badge (`ui/badge` in a `ui/tooltip` trigger): a square,
   icon-only chip sitting on the text baseline. Mirror of the layered rules in
   styles.css. */
.prose .platform-badge {
  display: inline-flex;
  vertical-align: text-bottom;
  border-radius: 6px;
}
.prose .platform-badge-icon {
  padding-inline: 0.25rem;
}
.prose .platform-badge-glyph {
  width: 100%;
  height: 100%;
}
.prose ul,
.prose ol {
  padding-left: 1.4em;
  margin: 0;
}
.prose ul {
  list-style: disc;
}
.prose ol {
  list-style: decimal;
}
.prose li {
  margin-top: 0.35em;
}
.prose li::marker {
  color: var(--color-text-faint);
}
.prose ul.not-prose {
  list-style: none;
  padding-left: 0;
}
/* The /api availability list and signature history list lead each item with a
   category chip instead of a bullet. Must live here (unlayered): the styles.css
   mirror is in @layer components and loses to the `.prose ul` rule above. */
.prose .api-availability ul,
.prose .api-revisions {
  list-style: none;
  padding-left: 0;
}
/* Symmetric block margin like hr / admonition; a zero top would leave the
   blockquote butted against the element above it, because `.prose blockquote`
   out-specifies the `.prose > * + *` owl. Mirror of the layered rule. */
.prose blockquote {
  margin: 1.4em 0;
  padding: 0.8em 1em;
  border-left: 3px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
.prose blockquote > :first-child {
  margin-top: 0;
}
.prose blockquote > :last-child {
  margin-bottom: 0;
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 2em 0;
}
.prose table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  font-size: var(--prose-table-size);
  margin: 1.2em 0;
}
.prose th,
.prose td {
  text-align: left;
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border);
}
.prose th {
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
}
/* Mirrors app/styles.css. The code rule must live here: the unlayered
   `.prose code { overflow-wrap: anywhere }` above beats any layered override. */
.prose .cell-nowrap {
  white-space: nowrap;
}
.prose :is(td, th) code {
  overflow-wrap: normal;
}
.prose .table-scroll {
  overflow-x: auto;
  max-width: 100%;
  margin: 1.2em 0;
}
.prose .table-scroll > table {
  margin: 0;
  max-width: none;
}
/* Mirrors app/styles.css: a hand-written HTML table whose last column holds
   fenced code. The unlayered `.prose table` rule above beats any layered
   override, so the fixed columns live here. */
.prose .code-table > table {
  table-layout: fixed;
  width: 100%;
  min-width: 53rem;
}
.prose .code-table th:nth-child(1) {
  width: 17%;
}
.prose .code-table th:nth-child(2) {
  width: 24%;
}
.prose .code-table td {
  vertical-align: top;
}
.prose .code-table td > :first-child {
  margin-top: 0;
}
.prose .code-table td > :last-child {
  margin-bottom: 0;
}
.prose .api-overview {
  margin: 1.2em 0;
}
.prose .api-overview ul {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
  padding-left: 1.35rem;
}
.prose .api-overview li {
  margin: 0;
  padding-left: 0.1rem;
}
.prose .api-overview a {
  border-bottom: 0;
  text-decoration: none;
}
.prose .api-overview a:hover,
.prose .api-overview a:focus-visible {
  border-bottom: 0;
  text-decoration: none;
}
.prose .api-overview a .api-signature {
  padding: 0.04em 0.2em;
  border-color: transparent;
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-code-bg));
  font-size: 0.82em;
  line-height: 1.55;
}
.prose .api-overview a:hover .api-signature,
.prose .api-overview a:focus-visible .api-signature {
  background: var(--color-accent-soft);
}
/* Unlayered mirror of the `.signature-split` / `.signature-symbol-link` rules in
   app/styles.css: its unlayered `.prose a` / `.prose .api-overview a` outrank the
   layered copy regardless of specificity, so the split-signature seam flattening,
   the permalink-icon positioning context, and the brand deep-link's dotted
   underline are duplicated here (as with `a.heading-anchor`). Placed after the
   overview rules to win at equal specificity. */
.prose .signature-split {
  position: relative;
}
.prose .signature-split a.heading-anchor {
  position: static;
}
.prose .signature-split a .api-signature {
  border-color: transparent;
  border-radius: 0;
  /* Uniform vertical padding (matching `.prose code`), zero horizontal, so the
     fragments' shared background aligns top-to-bottom and abuts seamlessly. */
  padding: 0.1em 0;
}
.prose a.signature-symbol-link {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--color-accent);
  text-underline-offset: 0.15em;
}
/* Sidebar namespace count pills (Combined-only) — kept in sync with the
 * `nav-badge-*` rules in `app/styles.css`. Sidebar sits outside `.prose`. */
.nav-badge-counts {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}
.nav-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25em;
  height: 1.25em;
  padding: 0 0.35em;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1;
  color: #fff;
}
.nav-badge-count--new {
  background: var(--color-badge-new);
}
.nav-badge-count--changed {
  background: var(--color-badge-changed);
}
.nav-badge-count--deprecated {
  background: var(--color-badge-deprecated);
}
.prose img {
  max-width: 100%;
  margin-top: 0.75rem;
  border-radius: 8px;
}

/* Shiki token spans pinned to the per-theme variable pair, with the per-line
 * `<span class="line">` background forced transparent so the code block
 * figure's background shows through — keep in sync with `app/styles.css`.
 */
.shiki span:not(.line):not(.api-overload-count) {
  color: var(--shiki-light, currentColor);
  background-color: transparent;
}
html[data-theme="dark"] .shiki span:not(.line):not(.api-overload-count) {
  color: var(--shiki-dark, currentColor);
  background-color: transparent;
}
