/* Base styles of the multiview playground: reset, body, type scale, links, focus ring,
   visually hidden, skip link, reduced motion. Values come from tokens.css only.
   Spec: docs/design-system.md sections 3, 9. */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + var(--space-4));
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  font-weight: var(--text-body-weight);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { margin: 0; cursor: pointer; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

/* ---- type scale: one class per step (spec 3.2) ---- */
.mv-text-display, h1 {
  font-family: var(--text-display-font);
  font-size: var(--text-display-size);
  line-height: var(--text-display-lh);
  font-weight: var(--text-display-weight);
  letter-spacing: var(--text-display-tracking);
  text-wrap: balance;
}
.mv-text-title, h2 {
  font-size: var(--text-title-size);
  line-height: var(--text-title-lh);
  font-weight: var(--text-title-weight);
  letter-spacing: var(--text-title-tracking);
  text-wrap: balance;
}
.mv-text-heading, h3 {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-lh);
  font-weight: var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking);
}
.mv-text-lead {
  font-size: var(--text-lead-size);
  line-height: var(--text-lead-lh);
  font-weight: var(--text-lead-weight);
  letter-spacing: var(--text-lead-tracking);
}
.mv-text-body {
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  font-weight: var(--text-body-weight);
  letter-spacing: var(--text-body-tracking);
}
.mv-text-small {
  font-size: var(--text-small-size);
  line-height: var(--text-small-lh);
  font-weight: var(--text-small-weight);
  letter-spacing: var(--text-small-tracking);
}
.mv-text-label {
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  font-weight: var(--text-label-weight);
  letter-spacing: var(--text-label-tracking);
}
.mv-text-overline {
  font-size: var(--text-overline-size);
  line-height: var(--text-overline-lh);
  font-weight: var(--text-overline-weight);
  letter-spacing: var(--text-overline-tracking);
  text-transform: uppercase;
}
.mv-text-code {
  font-family: var(--font-mono);
  font-size: var(--text-code-size);
  line-height: var(--text-code-lh);
  font-weight: var(--text-code-weight);
  letter-spacing: var(--text-code-tracking);
  font-variant-ligatures: none;
}
.mv-text-code-sm {
  font-family: var(--font-mono);
  font-size: var(--text-code-sm-size);
  line-height: var(--text-code-sm-lh);
  font-weight: var(--text-code-sm-weight);
  letter-spacing: var(--text-code-sm-tracking);
  font-variant-numeric: tabular-nums;
}
.mv-text-stat {
  font-family: var(--text-stat-font);
  font-size: var(--text-stat-size);
  line-height: var(--text-stat-lh);
  font-weight: var(--text-stat-weight);
  letter-spacing: var(--text-stat-tracking);
  font-variant-numeric: tabular-nums;
}

.mv-text-hand {
  font-family: var(--text-hand-font);
  font-size: var(--text-hand-size);
  line-height: var(--text-hand-lh);
  font-weight: var(--text-hand-weight);
  letter-spacing: var(--text-hand-tracking);
}
.mv-text-hand-sm {
  font-family: var(--text-hand-sm-font);
  font-size: var(--text-hand-sm-size);
  line-height: var(--text-hand-sm-lh);
  font-weight: var(--text-hand-sm-weight);
  letter-spacing: var(--text-hand-sm-tracking);
}

/* Graph paper (spec 12.3): on body or .mv-page only. Cards have solid backgrounds, so the grid stops at their edge. */
.mv-paper {
  background-color: var(--color-bg);
  background-image: var(--paper-grid);
}

/* Colour helpers for the text roles. */
.mv-text-secondary { color: var(--color-text-secondary); }
.mv-text-muted { color: var(--color-text-muted); }

/* Numbers that are measured: mono, tabular. */
.mv-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Space around headings: twice as much above as below; the first child has none (spec 3.4). */
h2 { margin-block: var(--space-8) var(--space-3); }
h3 { margin-block: var(--space-6) var(--space-2); }
:is(h1, h2, h3):first-child { margin-top: 0; }

p + p { margin-top: var(--space-4); }
strong, b { font-weight: var(--font-weight-semibold); }

/* Inline code: mono face, no box (spec 3.2). */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-variant-ligatures: none;
}
code { color: var(--color-text); padding: 0; background: none; }
pre code { font-size: inherit; }

/* ---- links (spec 3.4) ---- */
a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color var(--dur-instant) var(--ease-out);
}
a:hover {
  color: var(--color-accent-hover);
  text-decoration-thickness: 2px;
}

/* ---- focus ring (spec 9.2): style :focus-visible only ---- */
:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}
:focus:not(:focus-visible) { outline: none; }
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: var(--focus-width) solid var(--color-focus); outline-offset: var(--focus-offset); }

::selection { background: var(--color-accent-subtle); color: var(--color-text); }

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

/* ---- skip link (spec 6.15): hidden above the viewport, shown on focus ---- */
.mv-skip-link {
  position: fixed;
  top: 0;
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transform: translateY(-200%);
}
.mv-skip-link:focus,
.mv-skip-link:focus-visible {
  top: var(--space-2);
  transform: none;
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
  color: var(--color-on-accent);
}

/* ---- keyframes shared by the components (durations come from tokens) ---- */
@keyframes mv-reveal {
  from { opacity: 0; translate: 0 var(--motion-distance); }
  to { opacity: 1; translate: 0 0; }
}
@keyframes mv-step-in {
  from { opacity: 0; translate: 0 var(--motion-distance-lg); }
  to { opacity: 1; translate: 0 0; }
}
@keyframes mv-progress {
  from { transform: translateX(-100%); }
  to { transform: translateX(333.34%); }
}
@keyframes mv-bar-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes mv-bar-grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes mv-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- reduced motion (spec 9.1): tokens are already zero; this guards everything else ---- */
@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;
  }
}
