/* matter-engine.com: one stylesheet, no web fonts, no scripts. Motion only in transform/opacity/clip-path, and none
   under prefers-reduced-motion (everything is then shown in its final state). */
:root {
  --bg: #1b1d22;
  --bg-alt: #16181d;
  --surface: #23262d;
  --surface-2: #2b2f37;
  --text: #e8eaee;
  --muted: #a3a9b5;
  --accent: #7ea4ff;
  --accent-strong: #5e8cff;
  --on-accent: #0f1217;
  --good: #5fcf86;
  --bad: #ff8a80;
  --wait: #c49bff;
  --border: #343843;
  --radius: 14px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-alt: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --text: #16181d;
    --muted: #4f5664;
    --accent: #2f5fd0;
    --accent-strong: #2f5fd0;
    --on-accent: #ffffff;
    --good: #1e7a3c;
    --bad: #b42318;
    --wait: #7a3fb0;
    --border: #d8dbe1;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
}
img, svg { display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, pre { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5.2vw, 3.4rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

.skip { position: absolute; left: 16px; top: -48px; padding: 8px 14px; background: var(--accent-strong); color: var(--on-accent);
  border-radius: 8px; z-index: 10; }
.skip:focus { top: 12px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; }
.brand img { border-radius: 7px; }
.links { display: flex; align-items: center; gap: 22px; list-style: none; margin: 0; padding: 0; }
.links a:not(.btn) { color: var(--muted); text-decoration: none; }
.links a:not(.btn):hover { color: var(--text); }
@media (max-width: 720px) { .links li:not(:last-child) { display: none; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px;
  border-radius: 999px; background: var(--accent-strong); color: var(--on-accent); font-weight: 650; text-decoration: none;
  border: 1px solid transparent; transition: transform 0.18s ease, background-color 0.18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { min-height: 40px; padding: 0 16px; font-size: 0.95rem; }

/* hero */
.hero { padding: clamp(40px, 8vw, 96px) 0 clamp(48px, 8vw, 96px); position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: -20% -10% auto auto; width: 70vmax; height: 70vmax; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent-strong) 22%, transparent), transparent);
  opacity: 0.7; }
.hero-grid { position: relative; display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(28px, 5vw, 64px); align-items: center; }
.hero-grid > * { min-width: 0; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.eyebrow { color: var(--accent); font-weight: 650; font-size: 0.95rem; letter-spacing: 0.02em; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 38em; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* the demo: a terminal and a phone */
.demo { margin: 0; position: relative; padding-bottom: 168px; }
.demo figcaption { margin-top: 12px; }
.term { background: #111318; color: #e8eaee; border: 1px solid #343843; border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.55); overflow: hidden; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; background: #1b1d22; border-bottom: 1px solid #2b2f37; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: #3a3f4a; }
.term-title { margin-left: 8px; font: 0.8rem var(--mono); color: #a3a9b5; }
.term-body { padding: 16px 18px 20px; font: 0.86rem/1.75 var(--mono); min-height: 15.5em; }
.term-body p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term .pr { color: #7ea4ff; }
.term .ag { color: #7ea4ff; }
.term .tool { color: #d7dbe3; }
.term .tag { color: #a3a9b5; border: 1px solid #343843; border-radius: 5px; padding: 0 5px; font-size: 0.85em; }
.term .good { color: #5fcf86; }
.term .bad { color: #ff8a80; }
.term .ask { color: #c49bff; }
.term .wait { color: #c49bff; }
.term code { color: #e8eaee; font-size: 1em; }
.phone { position: absolute; right: 0; bottom: 0; width: 214px; padding: 18px 12px 14px;
  background: #0f1116; border: 1px solid #3a3f4a; border-radius: 28px; color: #e8eaee;
  box-shadow: 0 28px 60px -18px rgb(0 0 0 / 0.65); font-size: 0.8rem; }
.phone-notch { width: 64px; height: 6px; margin: 0 auto 12px; background: #2b2f37; border-radius: 99px; }
.phone-note { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 10px; padding: 9px 10px; background: #23262d;
  border-radius: 12px; line-height: 1.35; }
.phone-note img { border-radius: 4px; flex: none; margin-top: 1px; }
.phone-card { padding: 10px; background: #1b1d22; border: 1px solid #343843; border-radius: 12px; }
.phone-q { margin: 0 0 4px; color: #a3a9b5; }
.phone-cmd { margin: 0 0 10px; font: 0.78rem var(--mono); }
.phone-btns { display: flex; gap: 8px; margin: 0; }
.pbtn { flex: 1; text-align: center; padding: 6px 0; border-radius: 99px; border: 1px solid #3a3f4a; }
.pbtn-yes { background: #5e8cff; border-color: #5e8cff; color: #0f1217; font-weight: 650; }
/* narrow screens: the phone sits under the terminal, nothing covered, and long lines wrap instead of being cut */
@media (max-width: 600px) {
  .demo { display: flex; flex-direction: column; padding-bottom: 0; }
  .phone { position: static; align-self: flex-end; width: 220px; margin: -18px 8px 0 0; order: 2; }
  .demo figcaption { order: 3; }
  .term-body p { white-space: normal; overflow: visible; }
}

/* sections */
.band { padding: clamp(56px, 9vw, 104px) 0; }
.band-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; margin-top: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px;
  transition: transform 0.25s ease, border-color 0.25s ease; }
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card p { color: var(--muted); margin: 0; }
.ico { width: 30px; height: 30px; margin-bottom: 14px; fill: none; stroke: var(--accent); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
.steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.step { position: relative; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.step p { color: var(--muted); margin: 0; }
.num { display: inline-grid; place-items: center; width: 34px; height: 34px; margin-bottom: 12px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent-strong) 18%, transparent); color: var(--accent); font-weight: 700; }
.install > * { max-width: 760px; }
.shell { background: #111318; color: #e8eaee; border: 1px solid #343843; border-radius: var(--radius); padding: 8px 20px 18px; margin: 24px 0; }
.shell-label { margin: 14px 0 6px; color: #a3a9b5; font-size: 0.85rem; }
.shell pre { margin: 0; padding: 10px 12px; background: #1b1d22; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.shell code { font-size: 0.9rem; }

/* text pages */
.doc { padding: clamp(40px, 7vw, 80px) 0 clamp(56px, 8vw, 96px); }
.doc .wrap { max-width: 760px; }
.doc h2 { font-size: 1.45rem; margin-top: 1.8em; }
.doc li { margin-bottom: 0.4em; }
.doc table { width: 100%; border-collapse: collapse; margin: 0 0 1.4em; font-size: 0.95rem; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.doc th { color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.draft { padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--wait) 55%, var(--border)); border-radius: 10px;
  background: color-mix(in srgb, var(--wait) 10%, transparent); }

/* footer */
.foot { border-top: 1px solid var(--border); padding: 36px 0 48px; }
.foot-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; }
.foot-grid p { margin-top: 12px; max-width: 34em; }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 22px; list-style: none; margin: 0; padding: 0; }
.foot-links a { color: var(--muted); display: inline-block; padding: 6px 0; }

/* ---- motion: only when the visitor hasn't asked for less ---- */
@media (prefers-reduced-motion: no-preference) {
  /* the headline and text paint at once (they're the largest paint); the demo eases in beside them */
  .term { animation: rise 0.8s 0.1s cubic-bezier(.2, .7, .2, 1) both; }

  /* the session plays once: the task is typed, then each line appears */
  .typed { display: inline-block; vertical-align: bottom; clip-path: inset(0 100% 0 0);
    animation: type 1.5s 0.7s steps(36, end) forwards; }
  .l2, .l3, .l4, .l5, .l6, .l7 { opacity: 0; animation: line 0.35s ease-out forwards; }
  .l2 { animation-delay: 2.5s; }
  .l3 { animation-delay: 3.2s; }
  .l4 { animation-delay: 4.0s; }
  .l5 { animation-delay: 4.8s; }
  .l6 { animation-delay: 5.6s; }
  .l7 { animation-delay: 7.6s; }
  .phone { opacity: 0; animation: phone 0.6s 6.1s cubic-bezier(.2, .8, .2, 1) forwards; }
  .pbtn-yes { animation: tap 0.5s 7.1s ease-out both; }

  /* scroll-driven reveals where the browser has them; elsewhere the content is simply there */
  @supports (animation-timeline: view()) {
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% cover 28%; }
  }
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes type { to { clip-path: inset(0 0 0 0); } }
@keyframes line { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes phone { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes tap { 0%, 100% { transform: none; } 45% { transform: scale(0.92); } }

/* ---- docs: a side nav on wide screens, a menu at the top on phones; code scrolls inside its own box ---- */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); padding: clamp(28px, 5vw, 56px) 0 80px; }
.docs-nav { font-size: 0.95rem; }
.docs-side { position: sticky; top: 84px; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.docs-side a, .docs-menu a { display: block; padding: 7px 14px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; margin-left: -1px; }
.docs-side a:hover, .docs-menu a:hover { color: var(--text); }
.docs-side a[aria-current="page"], .docs-menu a[aria-current="page"] { color: var(--text); font-weight: 650; border-left-color: var(--accent); }
.docs-menu { display: none; }
.docs-body { min-width: 0; max-width: 820px; overflow-wrap: break-word; }
.docs-body h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.docs-body h2 { font-size: 1.4rem; margin-top: 1.9em; scroll-margin-top: 80px; }
.docs-body h3 { font-size: 1.1rem; margin-top: 1.6em; scroll-margin-top: 80px; }
.docs-body h4 { font-size: 1rem; margin-top: 1.4em; scroll-margin-top: 80px; }
.docs-body section { scroll-margin-top: 80px; }
.docs-body li { margin-bottom: 0.35em; }
.docs-body pre { margin: 0 0 1.2em; padding: 14px 16px; overflow-x: auto; background: #111318; color: #e8eaee;
  border: 1px solid #343843; border-radius: 10px; font-size: 0.86rem; line-height: 1.55; }
.docs-body pre code { font-size: 1em; }
.docs-body :not(pre) > code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); font-size: 0.88em; overflow-wrap: anywhere; }
.docs-body table { width: 100%; border-collapse: collapse; margin: 0 0 1.4em; font-size: 0.93rem; }
.docs-body th, .docs-body td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.docs-body th { color: var(--muted); font-weight: 600; }
.docs-body td:first-child { white-space: nowrap; }
.toc ul { display: flex; flex-wrap: wrap; gap: 6px 8px; list-style: none; margin: 0 0 1.6em; padding: 0; }
.toc a { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 99px; font-size: 0.88rem;
  text-decoration: none; color: var(--text); font-family: var(--mono); }
.toc a:hover { border-color: var(--accent); }
.doc-cards { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.doc-cards a { display: block; height: 100%; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; transition: border-color 0.2s ease, transform 0.2s ease; }
.doc-cards a:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); transform: translateY(-2px); }
.doc-cards strong { display: block; margin-bottom: 4px; }
.doc-cards span { color: var(--muted); font-size: 0.95rem; }
@media (max-width: 860px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .docs-side { display: none; }
  .docs-menu { display: block; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  .docs-menu summary { min-height: 48px; display: flex; align-items: center; padding: 0 16px; cursor: pointer; font-weight: 650; }
  .docs-menu ul { list-style: none; margin: 0; padding: 0 0 8px; border-top: 1px solid var(--border); }
  .docs-menu a { min-height: 44px; display: flex; align-items: center; }
}
