/* Documentation site chrome. Everything below the `.gl-doc-` prefix belongs
   to this site rather than to the design system it documents — including the
   width/height constants used directly below. The source design system
   defines no container-width tokens at all, so there is nothing under
   `--gl-*` for a doc shell to reach for; the Space foundation page's own
   notes say to omit that group entirely rather than invent one. */

.gl-doc-skip {
  position: absolute;
  inset-inline-start: var(--gl-space-xs);
  inset-block-start: -4rem;
  z-index: 40;
  padding: var(--gl-space-2xs) var(--gl-space-xs);
  background: var(--gl-color-surface-card);
  border: 1px solid var(--gl-color-border-default);
  border-radius: var(--gl-radius-sm);
  box-shadow: var(--gl-shadow-float);
  transition: inset-block-start var(--gl-dur-fast) var(--gl-ease);
}
.gl-doc-skip:focus { inset-block-start: var(--gl-space-2xs); }

.gl-doc-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  height: 3.5rem;
  background: color-mix(in srgb, var(--gl-color-surface-page) 92%, transparent);
  border-bottom: 1px solid var(--gl-color-border-hairline);
}
.gl-doc-header__inner {
  display: flex;
  align-items: center;
  gap: var(--gl-space-xs);
  height: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: var(--gl-space-xs);
}

.gl-doc-wordmark {
  display: flex;
  align-items: baseline;
  gap: var(--gl-space-2xs);
  color: var(--gl-color-text-primary);
  text-decoration: none;
  font-family: var(--gl-font-sans);
  font-size: var(--gl-step-0);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.gl-doc-wordmark:hover { color: var(--gl-color-text-primary); }
.gl-doc-wordmark__mark {
  width: 1.375rem;
  height: 1.375rem;
  flex: none;
  align-self: center;
  color: var(--gl-color-accent);
}
.gl-doc-wordmark__version {
  font-family: var(--gl-font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--gl-color-text-tertiary);
}

.gl-doc-header__actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--gl-space-2xs); }

.gl-doc-layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: var(--gl-space-l);
  max-width: 72rem;
  margin-inline: auto;
  padding: var(--gl-space-m) var(--gl-space-xs) var(--gl-space-2xl);
}

.gl-doc-sidebar {
  position: sticky;
  inset-block-start: calc(3.5rem + var(--gl-space-m));
  align-self: start;
  max-height: calc(100vh - 3.5rem - var(--gl-space-l));
  overflow-y: auto;
  padding-inline-end: var(--gl-space-2xs);
}
.gl-doc-nav__group + .gl-doc-nav__group { margin-top: var(--gl-space-s); }
.gl-doc-nav__heading {
  margin-bottom: var(--gl-space-2xs);
  font-family: var(--gl-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gl-color-text-tertiary);
}
.gl-doc-nav__link {
  display: block;
  padding: var(--gl-space-3xs) var(--gl-space-xs);
  margin-inline-start: calc(var(--gl-space-xs) * -1);
  border-inline-start: 2px solid transparent;
  border-radius: 0 var(--gl-radius-sm) var(--gl-radius-sm) 0;
  color: var(--gl-color-text-secondary);
  font-size: var(--gl-step--1);
  text-decoration: none;
  transition: color var(--gl-dur-fast) var(--gl-ease),
              background-color var(--gl-dur-fast) var(--gl-ease);
}
.gl-doc-nav__link:hover { color: var(--gl-color-text-primary); background: var(--gl-color-surface-fill); }
.gl-doc-nav__link[aria-current="page"] {
  color: var(--gl-color-accent-ink);
  border-inline-start-color: var(--gl-color-accent);
  background: var(--gl-color-accent-soft);
  font-weight: 500;
}

.gl-doc-main {
  min-width: 0;
  /* The design system's own body-text token (--gl-step-0, 18–20px) is right
     for a product screen but too large for long-form documentation prose.
     This site's own copy gets a plain, fixed 16px instead — the token above
     is unchanged, and specimen tables/demos below still show its real
     value. */
  font-size: 1rem;
}
.gl-doc-main > * { max-width: 50rem; }

.gl-doc-title { margin-bottom: var(--gl-space-xs); }
.gl-doc-title__section {
  display: block;
  margin-bottom: var(--gl-space-2xs);
  font-family: var(--gl-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gl-color-accent);
}

.gl-doc-main h2 {
  margin-block: var(--gl-space-2xl) var(--gl-space-xs);
  padding-bottom: var(--gl-space-2xs);
  border-bottom: 1px solid var(--gl-color-border-hairline);
}
.gl-doc-main h3 { margin-block: var(--gl-space-l) var(--gl-space-2xs); }
.gl-doc-main h4 { margin-block: var(--gl-space-s) var(--gl-space-2xs); }
.gl-doc-main p,
.gl-doc-main ul,
.gl-doc-main ol { max-width: 68ch; }
.gl-doc-main ul:not([class]),
.gl-doc-main ol:not([class]) { padding-inline-start: var(--gl-space-s); }

.gl-doc-footer {
  max-width: 72rem;
  margin-inline: auto;
  padding: var(--gl-space-s) var(--gl-space-xs) var(--gl-space-l);
  border-top: 1px solid var(--gl-color-border-hairline);
  color: var(--gl-color-text-tertiary);
  font-size: var(--gl-step--1);
}
.gl-doc-footer__inner { display: flex; flex-wrap: wrap; gap: var(--gl-space-xs); justify-content: space-between; }

/* `button.gl-doc-nav-toggle` (element + class) rather than a bare class:
   button.css's own base rule is `button:not(.icon-button)`, which is also
   one element + one class in specificity and sets `display: inline-flex` —
   a bare `.gl-doc-nav-toggle { display: none }` loses that fight and the
   toggle stays visible at every width. Matching its specificity here (and
   coming later in the concatenated stylesheet) settles it in source order. */
button.gl-doc-nav-toggle { display: none; }

@media (max-width: 60rem) {
  .gl-doc-layout { grid-template-columns: minmax(0, 1fr); gap: var(--gl-space-s); }
  .gl-doc-sidebar {
    position: static;
    max-height: none;
  }
  /* The toggle is a normal Button; the panel it opens gets its own card
     treatment. Putting the same card styling on the <aside> wrapper too
     nested a button-shaped box inside an outer box for no reason. */
  .gl-doc-nav {
    margin-top: var(--gl-space-xs);
    padding: var(--gl-space-xs);
    background: var(--gl-color-surface-card);
    border: 1px solid var(--gl-color-border-default);
    border-radius: var(--gl-radius-md);
  }
  .gl-doc-sidebar[data-collapsed="true"] > .gl-doc-nav { display: none; }
  button.gl-doc-nav-toggle {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 34rem) {
  .gl-doc-wordmark__version { display: none; }
  .gl-doc-layout { padding-inline: var(--gl-space-2xs); }
}

/* The live-example figure used throughout the docs — see the "How the
   example demos work" section on the Using the CSS page. One class on the
   outer <figure>; everything inside is styled by plain element selectors,
   since figcaption/div/details/summary/pre already say what they are.
   `data-layout` and `data-surface` on the preview <div> distinguish the
   handful of demos that need a non-default arrangement. */

.example {
  margin: var(--gl-space-s) 0 var(--gl-space-l);
  border: 1px solid var(--gl-color-border-default);
  border-radius: var(--gl-radius-lg);
  background: var(--gl-color-surface-card);
  overflow: hidden;
}

.example figcaption {
  padding: var(--gl-space-2xs) var(--gl-space-xs);
  border-bottom: 1px solid var(--gl-color-border-hairline);
  background: var(--gl-color-surface-fill);
  font-family: var(--gl-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gl-color-text-secondary);
}

.example > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gl-space-xs);
  padding: var(--gl-space-s);
}
/* nowrap is load-bearing: a column-direction flex container with wrap enabled
   sizes its single line against the container rather than the content, which
   left every stacked example with a few hundred pixels of dead space. */
.example > div[data-layout="stack"] { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
.example > div[data-layout="grid"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  align-items: start;
}
.example > div[data-surface="sunken"] { background: var(--gl-color-surface-fill); }
.example > div > * { min-width: 0; }

.example details {
  border-top: 1px solid var(--gl-color-border-hairline);
  background: var(--gl-color-surface-fill);
}
.example summary {
  padding: var(--gl-space-2xs) var(--gl-space-xs);
  font-size: var(--gl-step--2);
  font-weight: 500;
  color: var(--gl-color-text-secondary);
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--gl-space-2xs);
}
.example summary::-webkit-details-marker { display: none; }
.example summary::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
  rotate: -45deg;
  transition: rotate var(--gl-dur-fast) var(--gl-ease);
}
.example details[open] > summary::before { rotate: 45deg; }
.example summary:hover { color: var(--gl-color-text-primary); }

.example pre {
  margin: 0;
  padding: var(--gl-space-xs);
  border-top: 1px solid var(--gl-color-border-hairline);
  overflow-x: auto;
  font-size: var(--gl-step--2);
  line-height: 1.5;
  tab-size: 2;
}
.example pre code { background: none; border: 0; padding: 0; white-space: pre; }

/* Standalone fenced code blocks in the prose (unhighlighted — there is no
   syntax highlighter in this build any more, just Kramdown's plain
   <pre><code class="language-*">). */
.gl-doc-main > pre {
  margin-block: var(--gl-space-xs);
  padding: var(--gl-space-xs);
  border: 1px solid var(--gl-color-border-default);
  border-radius: var(--gl-radius-md);
  background: var(--gl-color-surface-fill);
  overflow-x: auto;
  font-size: var(--gl-step--2);
  line-height: 1.5;
}
.gl-doc-main > pre code { background: none; border: 0; padding: 0; white-space: pre; }

/* Presentation for the token reference tables and swatch grids, plus a
   generic data-table utility. All of this is documentation chrome — the
   design system itself has no Table component (see the note on the removed
   `table`/`progress`/`callout` pages in git history). */

.gl-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: var(--gl-space-xs);
  margin-block: var(--gl-space-xs) var(--gl-space-s);
  padding: 0;
  list-style: none;
}
.gl-swatch {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gl-color-border-default);
  border-radius: var(--gl-radius-sm);
  overflow: hidden;
  background: var(--gl-color-surface-card);
}
.gl-swatch__chip {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  height: 4rem;
  padding: var(--gl-space-2xs);
  font-family: var(--gl-font-mono);
  font-size: 11px;
  font-weight: 600;
}
.gl-swatch__meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: var(--gl-space-2xs);
  border-top: 1px solid var(--gl-color-border-hairline);
  font-family: var(--gl-font-mono);
  font-size: 11px;
}
.gl-swatch__hex { color: var(--gl-color-text-primary); text-transform: uppercase; }
.gl-swatch__ratio { color: var(--gl-color-text-tertiary); }

.gl-alias-row { display: flex; align-items: center; gap: var(--gl-space-2xs); }
.gl-alias-chip {
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  border: 1px solid var(--gl-color-border-default);
  border-radius: var(--gl-radius-sm);
}
.gl-alias-chip--pair { display: flex; }
.gl-alias-chip--pair > span { flex: 1; }

/* Type specimen rows. */
.gl-specimen {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gl-space-3xs);
  padding-block: var(--gl-space-xs);
  border-bottom: 1px solid var(--gl-color-border-hairline);
}
.gl-specimen__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gl-space-xs);
  font-family: var(--gl-font-mono);
  font-size: 11px;
  color: var(--gl-color-text-tertiary);
}
.gl-specimen__sample {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gl-color-text-primary);
}

/* Space and radius rulers. */
.gl-ruler { display: flex; flex-direction: column; gap: var(--gl-space-2xs); }
.gl-ruler__row { display: grid; grid-template-columns: 6.5rem 4.5rem 1fr; align-items: center; gap: var(--gl-space-xs); font-family: var(--gl-font-mono); font-size: 11px; }
.gl-ruler__bar { height: 0.75rem; background: var(--gl-color-accent); border-radius: var(--gl-radius-sm); }
.gl-ruler__num { color: var(--gl-color-text-tertiary); text-align: right; }

.gl-radius-grid, .gl-elevation-grid, .gl-motion-grid, .gl-accent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--gl-space-xs);
  margin-block: var(--gl-space-xs);
  padding: 0;
  list-style: none;
}
.gl-radius-demo {
  height: 4.5rem;
  background: var(--gl-color-accent-soft);
  border: 1px solid var(--gl-color-accent);
  margin-bottom: var(--gl-space-2xs);
}
.gl-elevation-demo {
  height: 4.5rem;
  background: var(--gl-color-surface-card);
  border: 1px solid var(--gl-color-border-hairline);
  border-radius: var(--gl-radius-lg);
  margin-bottom: var(--gl-space-2xs);
}
.gl-motion-demo {
  height: 4.5rem;
  display: grid;
  place-items: center;
  background: var(--gl-color-surface-fill);
  border: 1px solid var(--gl-color-border-hairline);
  border-radius: var(--gl-radius-md);
  margin-bottom: var(--gl-space-2xs);
  cursor: pointer;
  overflow: hidden;
}
.gl-motion-demo__dot {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--gl-radius-full);
  background: var(--gl-color-accent);
  translate: -3rem 0;
  transition-property: translate;
  transition-duration: var(--gl-dur-base);
  transition-timing-function: var(--gl-ease);
}
.gl-motion-demo:hover .gl-motion-demo__dot,
.gl-motion-demo:focus-visible .gl-motion-demo__dot { translate: 3rem 0; }

.gl-accent-demo {
  height: 4.5rem;
  display: flex;
  align-items: flex-end;
  padding: var(--gl-space-2xs);
  border-radius: var(--gl-radius-md);
  color: #fff;
  font-family: var(--gl-font-mono);
  font-size: 11px;
  margin-bottom: var(--gl-space-2xs);
}

/* Token names read `<code>` sitewide, which already carries a mono chip
   look for running prose (see :not(pre) > code in base/typography.css).
   Inside these specimen/swatch/ruler rows the old `.gl-token-name` class was
   plain mono text with no chip, so `<code>` is flattened back to that look
   here the same way table cells are. */
.gl-swatch code, .gl-specimen code, .gl-ruler code, .gl-alias-row code {
  background: none;
  border: 0;
  padding: 0;
  font-size: var(--gl-step--2);
  color: var(--gl-color-text-primary);
  white-space: nowrap;
}

/* A documentation aside. Like `<table>`, this is site chrome for the prose
   itself, not a system component — the real system has no Callout. */
.gl-callout {
  margin-block: var(--gl-space-s);
  padding: var(--gl-space-xs) var(--gl-space-s);
  border: 1px solid var(--gl-color-border-hairline);
  border-left: 3px solid var(--gl-color-accent);
  border-radius: var(--gl-radius-md);
  background: var(--gl-color-surface-fill);
}
.gl-callout p { margin: 0; font-size: var(--gl-step--1); }
.gl-callout .type-label { display: block; margin-bottom: var(--gl-space-2xs); }
/* Generic reference tables (component APIs, alias tables, the contrast
   contract). `<table>` IS a table — no class needed to say so. Every table
   on this site uses the one compact density, so there is no separate
   modifier for it. `display: block` plus `overflow-x: auto` gives the table
   its own horizontal scrollbar on narrow viewports without a wrapper div;
   the anonymous table box the browser generates around `<thead>`/`<tbody>`
   still does the row/column layout. `<code>` replaces the old
   `.gl-token-name` / `.gl-table__code` cells — it is already styled
   sitewide, just re-flattened here to a plain mono run instead of the
   chip-with-border look prose code gets, to match this table's original
   look. `.num` is the one sanctioned class left, for right-aligned numeric
   columns — there is no attribute that means "this column is a number". */
table { width: 100%; border-collapse: collapse; font-size: var(--gl-step--1); display: block; overflow-x: auto; }
table th, table td {
  padding: var(--gl-space-3xs) var(--gl-space-xs);
  border-bottom: 1px solid var(--gl-color-border-hairline);
  text-align: left;
  vertical-align: top;
}
table th { font-family: var(--gl-font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gl-color-text-secondary); font-weight: 500; }
table code { background: none; border: 0; padding: 0; font-size: var(--gl-step--2); white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Home page. */
.gl-hero { padding-block: var(--gl-space-m) var(--gl-space-l); }
.gl-hero__title {
  font-size: var(--gl-step-4);
  margin-bottom: var(--gl-space-xs);
}
.gl-hero__actions { display: flex; flex-wrap: wrap; gap: var(--gl-space-xs); margin-top: var(--gl-space-s); }
.gl-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: var(--gl-space-xs);
  margin-block: var(--gl-space-l);
  padding: var(--gl-space-xs);
  background: var(--gl-color-surface-card);
  border: 1px solid var(--gl-color-border-default);
  border-radius: var(--gl-radius-lg);
}
.gl-stat__value {
  display: block;
  font-family: var(--gl-font-sans);
  font-size: var(--gl-step-2);
  font-weight: 600;
  line-height: 1.16;
  font-variant-numeric: tabular-nums;
}
.gl-stat__label {
  font-family: var(--gl-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gl-color-text-tertiary);
}
