/* Motion Basics — tokens follow www-motion/shared/studio.css */
:root {
  --paper: #f7f6f2; --stage: #fbfaf7; --ink: #171717; --muted: #57554f; --soft: #6b6962;
  --line: #dedbd2; --red: #c81b1c; --blue: #2f5fb3; --green: #2f7d4f; --code: #f0eee8;
  --serif: "Noto Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121211; --stage: #181816; --ink: #ecebe6; --muted: #a8a59c; --soft: #8f8c84;
    --line: #2e2d29; --red: #ec4d42; --blue: #7aa2ec; --green: #6cc08f; --code: #1d1c1a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121211; --stage: #181816; --ink: #ecebe6; --muted: #a8a59c; --soft: #8f8c84;
  --line: #2e2d29; --red: #ec4d42; --blue: #7aa2ec; --green: #6cc08f; --code: #1d1c1a; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
html[lang="en"] body { font-family: Georgia, var(--sans); }
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
code, pre { font-family: var(--mono); }
.mono, .eyebrow, .layer-tag, .control-name, .control-value, .meta-label, .card-number, .card-count, .header-count {
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
}
.eyebrow { color: var(--red); font-weight: 700; letter-spacing: .12em; }
.shell { width: min(100% - 96px, 1360px); margin-inline: auto; }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 18px; min-height: 58px; width: min(100% - 96px, 1360px); margin-inline: auto; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; font-weight: 700; letter-spacing: -.01em; }
.brand i { font-style: normal; color: var(--red); }
.brand-badge { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; border: 1px solid var(--line); padding: 1px 6px; border-radius: 3px; color: var(--muted); }
.header-sep { width: 1px; height: 18px; background: var(--line); }
.header-link { color: var(--muted); font-size: 14px; white-space: nowrap; }
.header-link:hover { color: var(--ink); }
.header-spacer { flex: 1; }
.header-count { color: var(--muted); }
.icon-button { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 999px; background: transparent; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; white-space: nowrap; }
.icon-button:hover { border-color: var(--ink); }

/* index */
.hero { padding: 88px 0 56px; border-bottom: 1px solid var(--line); }
.hero h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(44px, 7vw, 92px); line-height: 1.02; letter-spacing: -.02em; margin: 14px 0 22px; }
.hero h1 span { color: var(--red); }
.hero-lede { max-width: 720px; font-size: 18px; color: var(--muted); margin: 0; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 36px; margin-top: 36px; }
.hero-stats b { display: block; font-family: var(--serif); font-size: 34px; font-weight: 900; line-height: 1; }
.hero-stats span { font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.layer { padding: 56px 0 8px; }
.layer-head { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: baseline; margin-bottom: 22px; }
.layer-head h2 { font-family: var(--serif); font-size: 28px; margin: 0; }
.layer-head p { margin: 0; color: var(--muted); max-width: 720px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.card { display: flex; flex-direction: column; gap: 10px; min-height: 178px; padding: 20px 20px 18px; background: var(--paper); transition: background .2s; }
.card:hover { background: var(--stage); }
.card-top { display: flex; justify-content: space-between; color: var(--muted); }
.card h3 { font-family: var(--serif); font-size: 21px; line-height: 1.25; margin: 0; }
.card h3 small { display: block; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .04em; color: var(--muted); margin-top: 4px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.usage { display: flex; align-items: center; gap: 10px; }
.usage-bar { flex: 1; height: 3px; background: var(--line); position: relative; }
.usage-bar i { position: absolute; inset: 0 auto 0 0; background: var(--red); }
.card-count { color: var(--muted); white-space: nowrap; }

/* primitive page */
.page { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 48px; padding: 36px 0 80px; align-items: start; }
.demo-column { position: sticky; top: 82px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.stage { position: relative; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 10px; background: var(--stage); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage[data-error]::after { content: attr(data-error); position: absolute; inset: auto 12px 12px; font: 12px var(--mono); color: var(--red); }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; margin-bottom: -6px; }
.stage-badge { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-badge::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.replay { flex: none; }
.readout { min-height: 20px; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 22px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; }
.controls:empty { display: none; }
.control { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.control-name { color: var(--muted); }
.control-value { color: var(--ink); text-transform: none; letter-spacing: 0; }
.control input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--red); }
.control select { grid-column: 1 / -1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.control-toggle { grid-template-columns: auto 1fr; justify-content: start; }
.control-toggle input { accent-color: var(--red); width: 16px; height: 16px; margin: 0; }
.control-button-row { display: block; }
.control-button { width: 100%; padding: 8px 12px; border: 1px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.reduced-note { margin: 0; font-size: 13px; color: var(--muted); }

.sidebar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; min-width: 0; }
.title-block h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(34px, 4vw, 54px); line-height: 1.05; letter-spacing: -.015em; margin: 10px 0 6px; }
.title-block .alt { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.summary { font-size: 18px; margin: 14px 0 0; }
.why { color: var(--muted); margin: 10px 0 0; }
.section h2 { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--red); margin: 0 0 12px; font-weight: 700; }
.section p { margin: 0 0 10px; }
.formula { margin: 0; padding: 14px 16px; background: var(--code); border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.params { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.params th { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 400; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line); }
.params td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.params td:first-child { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.params td small { display: block; color: var(--muted); }
.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.bullets li { padding-left: 18px; position: relative; }
.bullets li::before { content: ""; position: absolute; left: 0; top: .72em; width: 8px; height: 1px; background: var(--red); }
.source { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; }
.chip:hover { border-color: var(--ink); }
.chip small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.chip-more { color: var(--muted); }
.stat-line { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.stat-line b { color: var(--ink); font-weight: 600; }
.code-block { position: relative; }
.code-block pre { margin: 0; padding: 16px; background: var(--code); border-radius: 8px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; max-height: 520px; }
.copy { position: absolute; top: 8px; right: 8px; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.pager { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; }
.pager a { display: grid; gap: 2px; max-width: 48%; }
.pager a:last-child { text-align: right; margin-left: auto; }
.pager small { font-family: var(--mono); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
:not(pre) > code { font-size: .88em; padding: 1px 5px; border-radius: 4px; background: var(--code); }

.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 13px; }

@media (max-width: 960px) {
  .page { grid-template-columns: 1fr; gap: 32px; }
  .demo-column { position: static; }
  .layer-head { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 640px) {
  .shell, .header-inner { width: calc(100% - 32px); }
  .header-inner { gap: 10px; }
  .header-count, .header-sep, .brand-badge, .header-studies { display: none; }
  .hero { padding: 56px 0 40px; }
  .stage { aspect-ratio: 1 / 1; }
  .controls { grid-template-columns: 1fr; }
  .params td:first-child { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}
