/* =========================================================================
   Base layer: reset, typography defaults, accessibility
   -------------------------------------------------------------------------
   Consumes the tokens. Adds no colour values of its own.
   ========================================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-base);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* The brief forbids horizontal scroll at any width. This is the backstop;
     the real guarantee is that no component is allowed to overflow. */
  overflow-x: hidden;
}

body > main { flex: 1; min-width: 0; }

/* The signature dot grid. Applied to a page region rather than the body so
   it can sit behind specific sections without affecting readability. */
.dot-field {
  background-color: var(--surface-base);
  background-image: var(--dot-grid);
  background-size: var(--dot-grid-size);
}

h1,
h2,
h3,
h4 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-3);
  color: var(--text-strong);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-2xl);
  line-height: 40px;
}
h2 {
  font-size: var(--text-xl);
  line-height: 34px;
  font-weight: var(--weight-semibold);
}
h3 {
  font-size: var(--text-lg);
  line-height: 28px;
  font-weight: var(--weight-semibold);
}
h4 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

p {
  margin: 0 0 var(--space-4);
  text-wrap: pretty;
}

a {
  color: var(--text-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  /* Text accent, never the raw accent: amber is fill-only on light. */
  color: var(--text-accent);
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

ul,
ol {
  margin: 0 0 var(--space-4);
  padding-left: 1.25em;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* =========================================================================
   Accessibility
   ========================================================================= */

/* Visible focus everywhere. The ring colour flips with the theme so it stays
   visible on both fields: cream on dark, Depth on light. */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus-ring) 50%, transparent);
  outline-offset: 0;
  border-color: var(--focus-ring);
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  /* Inverted against the page, so it stands out on either theme. */
  background: var(--text-strong);
  color: var(--surface-base);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-md);
  transform: translateY(-150%);
  transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Reduced motion: non-essential motion off, state changes instant. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================================
   Layout primitives
   ========================================================================= */

.wrap {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.wrap--reading {
  max-width: var(--reading-width);
}

@media (min-width: 48rem) {
  .wrap {
    padding-inline: var(--space-6);
  }
}

.section {
  padding-block: var(--space-7);
}

@media (min-width: 48rem) {
  .section {
    padding-block: var(--space-8);
  }
}

/* The eyebrow label: uppercase Inter, tracked. Used for section labels and
   the studio mark, per the source system's label convention. */
.eyebrow {
  line-height: 1.2;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}

/* Technical scaffolding text: versions, IDs, dates-as-meta. */
.label-mono {
  line-height: 1.4;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--text-muted);
}

.prose {
  max-width: var(--reading-width);
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2 {
  font-size: var(--text-xl);
  margin-top: var(--space-7);
}

.prose h3 {
  font-size: var(--text-lg);
  margin-top: var(--space-5);
}

.prose a {
  color: var(--text-accent);
  text-decoration: underline;
}

.prose a:hover {
  color: var(--text-strong);
}

/* Structure-purple divider: a core motif of the system. */
.divider-structure {
  border: 0;
  border-top: var(--border-struct, 2px solid var(--color-structure));
  margin-block: var(--space-5);
}
