/* ============================================================
 * Axismundi Style Guide — site chrome
 *
 * Decoration and typesetting for the documentation site itself. Nothing here
 * decides a value: type comes from the typescale, colour from the theme's
 * palette, spacing from the measurement scale, and the shell's geometry from
 * the layout tokens. This site is the first implementation of its own
 * Foundations pages, so a number invented here would be a number those pages
 * do not describe.
 *
 * Two `--sg-` names survive, and both name a surface role rather than a value:
 * where this site puts its raised and its quiet surfaces is a documentation
 * decision, not a colour one.
 * ============================================================ */

:root {
  /* Which surface role each part of the chrome sits on. The roles come from
   * the theme; these two say where this site puts its raised surfaces, which
   * is a documentation-layout decision rather than a colour one. */
  --sg-surface-raised: var(--md-sys-color-surface-container-low);
  --sg-surface-quiet: var(--md-sys-color-surface-container-high);

}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.sg-body {
  margin: 0;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-body-large-font);
  font-size: var(--md-sys-typescale-body-large-size);
  font-weight: var(--md-sys-typescale-body-large-weight);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  line-height: var(--md-sys-typescale-body-large-line-height);
  /* The spec gives every role an opsz equal to its font size; on a variable
   * font this does exactly that, so no role emits font-variation-settings. */
  font-optical-sizing: auto;
}

/* --- Skip link ------------------------------------------------ */

.sg-skip {
  position: absolute;
  inset-inline-start: -9999px;
  z-index: 10;
}

.sg-skip:focus {
  inset-inline-start: var(--md-sys-measurement-space200);
  inset-block-start: var(--md-sys-measurement-space200);
  padding: 0.5rem 0.75rem;
  background: var(--sg-surface-raised);
  border-radius: var(--md-sys-shape-corner-value-medium);
  outline: 3px solid var(--md-sys-color-primary);
}

/* --- Navigation ----------------------------------------------- */

.sg-nav {
  padding: var(--md-sys-measurement-space400) var(--md-sys-measurement-space200);
  border-inline-end: 1px solid var(--md-sys-color-outline-variant);
  position: sticky;
  inset-block-start: 0;
  max-block-size: 100dvh;
  overflow-y: auto;
}

/* Below expanded the rail is not beside the pane, so it stops being sticky and
 * its edge moves from the side to the bottom. The breakpoint is M3's: a
 * standard expanded navigation rail is what expanded and up gets, and compact
 * and medium get a navigation bar or a modal rail instead. */
@media (max-width: 839px) {
  .sg-nav {
    position: static;
    max-block-size: none;
    border-inline-end: 0;
    border-block-end: 1px solid var(--md-sys-color-outline-variant);
  }
}

.sg-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space200);
  margin-block-end: var(--md-sys-measurement-space400);
}

.sg-nav__home {
  display: block;
  font-family: var(--md-sys-typescale-title-medium-font);
  font-size: var(--md-sys-typescale-title-medium-size);
  font-weight: var(--md-sys-typescale-title-medium-emphasized-weight);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  color: inherit;
  text-decoration: none;
}

.sg-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--md-sys-measurement-space200);
}

.sg-nav__link {
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  line-height: var(--md-sys-typescale-label-large-line-height);
  color: inherit;
  text-decoration: none;
}

.sg-nav__link:hover,
.sg-nav__link:focus-visible {
  text-decoration: underline;
}

.sg-nav__link.is-current {
  color: var(--md-sys-color-primary);
}

.sg-nav__summary {
  display: block;
  font-family: var(--md-sys-typescale-body-small-font);
  font-size: var(--md-sys-typescale-body-small-size);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  line-height: var(--md-sys-typescale-body-small-line-height);
  color: var(--md-sys-color-on-surface-variant);
}

/* --- Page ----------------------------------------------------- */

.sg-main {
  padding-block: var(--md-sys-measurement-space400) 0;
}

.sg-page-title {
  font-family: var(--md-sys-typescale-headline-large-font);
  font-size: var(--md-sys-typescale-headline-large-size);
  font-weight: var(--md-sys-typescale-headline-large-weight);
  letter-spacing: var(--md-sys-typescale-headline-large-tracking);
  line-height: var(--md-sys-typescale-headline-large-line-height);
  margin: 0;
}

.sg-page-description {
  font-size: var(--md-sys-typescale-body-large-size);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  line-height: var(--md-sys-typescale-body-large-line-height);
  color: var(--md-sys-color-on-surface-variant);
  margin-block: 0.5rem 0;
}

.sg-page-head {
  margin-block-end: var(--md-sys-measurement-space400);
  padding-block-end: var(--md-sys-measurement-space200);
  border-block-end: 1px solid var(--md-sys-color-outline-variant);
}

.sg-prose h2 {
  margin-block-start: var(--md-sys-measurement-space400);
  font-family: var(--md-sys-typescale-headline-small-font);
  font-size: var(--md-sys-typescale-headline-small-size);
  font-weight: var(--md-sys-typescale-headline-small-weight);
  letter-spacing: var(--md-sys-typescale-headline-small-tracking);
  line-height: var(--md-sys-typescale-headline-small-line-height);
}

.sg-prose h3 {
  margin-block-start: var(--md-sys-measurement-space400);
  font-family: var(--md-sys-typescale-title-large-font);
  font-size: var(--md-sys-typescale-title-large-size);
  font-weight: var(--md-sys-typescale-title-large-weight);
  letter-spacing: var(--md-sys-typescale-title-large-tracking);
  line-height: var(--md-sys-typescale-title-large-line-height);
}

.sg-prose a {
  color: var(--md-sys-color-primary);
}

.sg-prose code {
  font-family: var(--md-ref-typeface-mono);
  font-size: 0.9em;
  background: var(--sg-surface-quiet);
  padding: 0.1em 0.35em;
  border-radius: 4px;
	/* Paths and token names are meaningful inline documentation, not code
	 * samples. Let an unbroken one wrap on a narrow window; preformatted
	 * examples below retain their deliberate horizontal scroll. */
	overflow-wrap: anywhere;
}

.sg-prose pre {
  background: var(--sg-surface-raised);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-value-medium);
  padding: var(--md-sys-measurement-space200);
  overflow-x: auto;
  /* The one place this site raises a surface. In light the theme's formula
   * draws a shadow; in dark it resolves to none, because M3 reads elevation
   * from tonal surface difference there instead. Both come from the theme, so
   * the behaviour on this page is the behaviour a WordPress page would get. */
  box-shadow: var(--md-sys-elevation-shadow-level1);
}

.sg-prose pre code {
  background: none;
  padding: 0;
}

.sg-prose table {
  inline-size: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.sg-prose th {
  font-size: var(--md-sys-typescale-title-small-size);
  font-weight: var(--md-sys-typescale-title-small-weight);
  letter-spacing: var(--md-sys-typescale-title-small-tracking);
  line-height: var(--md-sys-typescale-title-small-line-height);
}

.sg-prose td {
  font-size: var(--md-sys-typescale-body-medium-size);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}

.sg-prose th,
.sg-prose td {
  text-align: start;
  padding: 0.5rem 0.75rem;
  border-block-end: 1px solid var(--md-sys-color-outline-variant);
  vertical-align: top;
}

.sg-prose blockquote {
  margin-inline: 0;
  padding-inline-start: var(--md-sys-measurement-space200);
  border-inline-start: 3px solid var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface-variant);
}

/* --- Footer --------------------------------------------------- */

.sg-footer {
  padding-block: var(--md-sys-measurement-space400);
  margin-block-start: var(--md-sys-measurement-space400);
  border-block-start: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  
}

.sg-footer__line {
  margin-block: 0 0.5rem;
}

.sg-footer__meta {
  margin-block: var(--md-sys-measurement-space200) 0;
}

.sg-footer a {
  color: var(--md-sys-color-primary);
}

/* --- Documentation figures ------------------------------------
 *
 * Swatches read their colour from the token they are documenting, so a figure
 * on this site shows the live value in the live scheme rather than a
 * screenshot of what it was. Switching the theme repaints them.
 * -------------------------------------------------------------- */

.sg-tones {
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(auto-fit, minmax(2.5rem, 1fr));
  margin-block: 0.5rem 1.5rem;
}

.sg-tone {
  display: grid;
  place-items: center;
  min-block-size: 3rem;
  border-radius: 4px;
  font-size: var(--md-sys-typescale-label-small-size);
  line-height: var(--md-sys-typescale-label-small-line-height);
  /* The tone number has to stay readable on its own tone. `contrast-color()`
   * would answer this exactly, but it is new enough that most readers would
   * get no label at all, and on a reference page the number is the point. A
   * tonal ramp is ordered by lightness by definition, so the template picks
   * the label colour from the tone itself - dark up to 50, light from 60 -
   * which needs no browser support and cannot be wrong on these ramps. */
  color: var(--sg-tone-ink);
}

.sg-roles {
  display: grid;
  gap: var(--md-sys-measurement-space200);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin-block: 0.5rem 1.5rem;
  padding: 0;
  list-style: none;
}

.sg-role {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium, 12px);
  overflow: hidden;
}

.sg-role__swatch {
  display: block;
  block-size: 3.5rem;
}

.sg-role__meta {
  padding: 0.5rem 0.75rem;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
}

.sg-role__name {
  display: block;
  font-family: var(--md-ref-typeface-mono);
  color: var(--md-sys-color-on-surface);
  word-break: break-all;
}

.sg-role__map {
  display: block;
  color: var(--md-sys-color-on-surface-variant);
}

.sg-specimens {
  margin-block: 0.5rem 1.5rem;
  padding: 0;
  list-style: none;
}

.sg-specimen {
  padding-block: 0.75rem;
  border-block-start: 1px solid var(--md-sys-color-outline-variant);
}

.sg-specimen:last-child {
  border-block-end: 1px solid var(--md-sys-color-outline-variant);
}

/* The sample is set in the role it documents, so what a reader sees is what
 * the token does - including the line height, which is why each sample is long
 * enough to wrap. */
.sg-specimen__sample {
  display: block;
  color: var(--md-sys-color-on-surface);
  margin-block-end: 0.25rem;
}

.sg-specimen__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  color: var(--md-sys-color-on-surface-variant);
}

.sg-specimen__token {
  font-family: var(--md-ref-typeface-mono);
}

.sg-emphasis {
  font-weight: var(--md-sys-typescale-body-large-emphasized-weight);
}

/* Motion figures.
 *
 * The dot travels on the very tokens the row documents, so a curve that is
 * retuned in the theme is retuned here. That rules out SMIL, which cannot read
 * a custom property, and rules out an animation that loops: a reference page
 * should move when the reader asks, not forever. */

.sg-motion {
  margin-block: 0.5rem 1rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.sg-motion__row {
  display: grid;
  gap: 0.25rem;
}

.sg-motion__track {
  position: relative;
  display: block;
  block-size: 1.5rem;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container);
}

.sg-motion__dot {
  position: absolute;
  inset-block-start: 0.25rem;
  inset-inline-start: 0.25rem;
  inline-size: 1rem;
  block-size: 1rem;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  transition: translate var(--sg-motion-duration) var(--sg-motion-curve);
}

/* Travel is set on the track so the distance follows the figure's width. */
.sg-motion.is-playing .sg-motion__dot {
  translate: calc(100cqi - 1.5rem) 0;
}

.sg-motion__track {
  container-type: inline-size;
}

@media (prefers-reduced-motion: reduce) {
  .sg-motion__dot {
    transition: none;
  }
}

.sg-play {
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  block-size: 40px;
  padding-inline: 1rem;
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  cursor: pointer;
}

.sg-play:focus-visible {
  outline: var(--md-focus-ring-width) solid var(--md-sys-color-secondary);
  outline-offset: var(--md-focus-ring-outward-offset);
}

/* Shape figures. */

.sg-shapes {
  display: grid;
  gap: var(--md-sys-measurement-space200);
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  margin-block: 0.5rem 1.5rem;
  padding: 0;
  list-style: none;
}

.sg-shape__box {
  display: grid;
  place-items: center;
  block-size: 5rem;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: var(--md-sys-typescale-label-medium-size);
}

.sg-shape__name {
  display: block;
  margin-block-start: 0.25rem;
  font-family: var(--md-ref-typeface-mono);
  font-size: var(--md-sys-typescale-body-small-size);
  color: var(--md-sys-color-on-surface-variant);
  word-break: break-all;
}

/* State-layer figures. */

.sg-states {
  display: grid;
  gap: var(--md-sys-measurement-space200);
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  margin-block: 0.5rem 1.5rem;
  padding: 0;
  list-style: none;
}

.sg-state__swatch {
  display: grid;
  place-items: center;
  block-size: 4rem;
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--sg-state-opacity) * 100%), var(--md-sys-color-surface-container));
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-label-medium-size);
}

/* Elevation figures. */

.sg-elevations {
  display: grid;
  gap: var(--md-sys-measurement-space400);
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  margin-block: 1rem 2rem;
  padding: 0;
  list-style: none;
}

.sg-elevation__box {
  display: grid;
  place-items: center;
  block-size: 4.5rem;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-label-medium-size);
  box-shadow: var(--sg-elevation-shadow);
}

/* Spacing figures. The bar's length is the token it names. */

.sg-spacings {
  margin-block: 0.5rem 1.5rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--md-sys-measurement-space50);
}

.sg-spacing {
  display: grid;
  grid-template-columns: minmax(0, 5rem) minmax(0, 1fr);
  align-items: center;
  gap: var(--md-sys-measurement-space200);
}

.sg-spacing__bar {
  block-size: var(--md-sys-measurement-space150);
  min-inline-size: 1px;
  border-radius: var(--md-sys-shape-corner-value-extra-small);
  background: var(--md-sys-color-primary);
}

.sg-spacing__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  color: var(--md-sys-color-on-surface-variant);
}

/* Grid figure. Reads the same --ax-sys-layout-columns the site's own grid
 * does, so narrowing the window reflows it exactly as the table says. */

.sg-gridprobe {
  margin-block: 0.5rem 1.5rem;
}

.sg-gridprobe__col {
  display: grid;
  place-items: center;
  min-block-size: 3rem;
  border-radius: var(--md-sys-shape-corner-value-extra-small);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: var(--md-sys-typescale-label-medium-size);
}
