/* ==========================================================
   base.css — Reset, typography and page layout
   Uses only the custom properties from tokens.css.

   CUSTOMIZE HERE:
   - Nothing needs changing here for colors, fonts or spacing:
     edit tokens.css instead.
   - Breakpoints (search for "@media"): 56rem = tablet,
     72rem = desktop with the "On this page" column.
   ========================================================== */

/* ---------- Reset ---------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + var(--space-md));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;

  /* Topic accent: layout.js sets --accent for topic pages */
  --accent: var(--color-accent);
}

img,
svg {
  display: block;
  max-width: 100%;
}

svg {
  flex-shrink: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* ---------- Focus ---------- */

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: 2px;
}

/* ---------- Typography ---------- */

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-variation-settings:
    "SOFT" var(--heading-soft),
    "WONK" var(--heading-wonk);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1);
  font-variation-settings:
    "SOFT" var(--heading-soft),
    "WONK" var(--heading-wonk),
    "opsz" 144;
}

h2 {
  font-size: var(--text-h2);
}

h3 {
  font-size: var(--text-h3);
}

h4 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0;
}

p,
li {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: var(--line);
  text-underline-offset: 0.2em;
  text-decoration-color: var(--color-muted);
  transition: text-decoration-color var(--duration) var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

strong {
  font-weight: 600;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: var(--text-code);
}

/* Inline code, not inside a code block */
:not(pre) > code {
  padding: 0.1em 0.3em;
  background: var(--color-surface);
  border-radius: var(--radius);
  font-size: 0.9em;
  overflow-wrap: break-word;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  border: var(--line) solid var(--color-line-soft);
  border-radius: var(--radius);
  font-size: var(--text-xs);
  line-height: 1.6;
  text-align: center;
  color: var(--color-muted);
}

mark {
  background: var(--color-mark);
  color: inherit;
  font-weight: 600;
}

hr {
  border: 0;
  border-top: var(--line) solid var(--color-line-soft);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.skip-link {
  position: absolute;
  top: var(--space-2xs);
  left: var(--space-2xs);
  z-index: 100;
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-ink);
  color: var(--color-bg);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

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

.frame {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Topic pages: thin accent rule along the top edge */
body[data-topic] .site-header {
  border-top: var(--rule-accent) solid var(--accent);
}

/* ---------- Documentation layout: sidebar | content | toc ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  padding-top: var(--space-lg);
  padding-bottom: var(--space-xl);
}

.layout > main {
  min-width: 0;
}

@media (min-width: 56rem) {
  .layout--doc {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }
}

@media (min-width: 72rem) {
  .layout--doc {
    grid-template-columns: var(--sidebar-width) minmax(0, var(--measure)) var(
        --toc-width
      );
    gap: var(--space-xl);
  }
}

/* Readable line length for all running text */
.content > * {
  max-width: var(--measure);
}

.content > * + * {
  margin-top: var(--space-sm);
}

.content h2 {
  margin-top: var(--space-xl);
}

.content h3 {
  margin-top: var(--space-lg);
}

.content h2 + *,
.content h3 + * {
  margin-top: var(--space-xs);
}

.content ul,
.content ol {
  padding-left: 1.4em;
}

.content li + li {
  margin-top: var(--space-3xs);
}

.content li > ul,
.content li > ol {
  margin-top: var(--space-3xs);
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Sections inside content (check yourself, related) follow the same rhythm */
.content section > * {
  max-width: var(--measure);
}

.content section > * + * {
  margin-top: var(--space-sm);
}

.content .check-yourself details + details {
  margin-top: 0;
}

/* Home page frame */
.home {
  padding-bottom: var(--space-xl);
}
