/* ==========================================================================
   rapportsoftware.com layout. Tokens only (tokens.css + brand.css); component
   recipes from components.css. No raw colours, no borders except table grid.
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--ds-bg);
  color: var(--ds-ink);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-md);
  line-height: var(--ds-text-md-lh);
  font-weight: var(--ds-fw-regular);
  letter-spacing: var(--ds-tracking-tight);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration-color: var(--ds-line-strong); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }
a:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); border-radius: var(--ds-radius-sm); }
a.ds-btn { text-decoration: none; }
a.ds-btn:focus-visible { border-radius: var(--ds-radius-control); }

h1, h2, h3, p, ul, ol, dl, table { margin: 0; }

.skip-link {
  position: absolute; left: var(--ds-space-4); top: calc(-1 * var(--ds-control-lg) * 2);
  z-index: var(--ds-z-sticky);
  height: var(--ds-control); padding: 0 var(--ds-space-3);
  display: inline-flex; align-items: center;
  background: var(--ds-surface-inverse); color: var(--ds-ink-inverse);
  border-radius: var(--ds-radius-control); font-size: var(--ds-text-base); font-weight: var(--ds-fw-medium);
  text-decoration: none;
}
.skip-link:focus-visible { top: var(--ds-space-4); }

/* ---- Layout containers ---- */
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--ds-space-6); }
.measure { max-width: 680px; }

/* ---- Header ---- */
.site-header { background: var(--ds-surface); box-shadow: 0 1px 0 var(--ds-line); }
.site-header__inner { min-height: calc(var(--ds-control-lg) + var(--ds-space-6)); display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-6); }

.brand { display: inline-flex; align-items: center; gap: var(--ds-space-2); text-decoration: none; }
.brand__mark {
  width: var(--ds-icon-lg); height: var(--ds-icon-lg); flex: none;
  background: var(--ds-accent);
  -webkit-mask: url("mark.svg") center / contain no-repeat;
  mask: url("mark.svg") center / contain no-repeat;
}
.brand__name { font-weight: var(--ds-fw-semibold); font-size: var(--ds-text-md); line-height: var(--ds-text-md-lh); letter-spacing: var(--ds-tracking-tight); }

.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--ds-space-1); }
.site-nav a:not(.ds-btn) {
  display: inline-flex; align-items: center; height: var(--ds-control); padding: 0 var(--ds-space-3);
  border-radius: var(--ds-radius-control);
  font-size: var(--ds-text-base); font-weight: var(--ds-fw-medium); color: var(--ds-ink-2);
  text-decoration: none;
  transition: background-color var(--ds-duration-fast) var(--ds-ease-out), color var(--ds-duration-fast) var(--ds-ease-out);
}
.site-nav a:not(.ds-btn):hover { background: var(--ds-hover); color: var(--ds-ink); }
.site-nav .ds-btn { margin-left: var(--ds-space-2); }

/* ---- Hero: copy on the left, an abstract message thread on the right ---- */
.hero { padding: var(--ds-space-16) 0; }
.hero__inner { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--ds-space-12); align-items: center; }
.eyebrow {
  font-family: var(--ds-font-mono); font-size: var(--ds-text-sm); line-height: var(--ds-text-sm-lh); font-weight: var(--ds-fw-medium);
  color: var(--ds-accent); letter-spacing: 0.04em; text-transform: uppercase;
  margin-bottom: var(--ds-space-5);
}
.hero .ds-display { text-wrap: balance; }
.lede { margin-top: var(--ds-space-5); max-width: 560px; font-size: var(--ds-text-lg); line-height: var(--ds-text-lg-lh); color: var(--ds-ink-2); }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-3); margin-top: var(--ds-space-8); }

.thread { display: flex; flex-direction: column; gap: var(--ds-space-3); padding: var(--ds-space-5); }
.thread__msg {
  display: flex; flex-direction: column; gap: var(--ds-space-2);
  max-width: 78%; padding: var(--ds-space-3) var(--ds-space-4);
  background: var(--ds-surface-2); border-radius: var(--ds-radius-card); border-bottom-left-radius: var(--ds-radius-sm);
}
.thread__msg--out { align-self: flex-end; background: var(--ds-accent-soft); border-radius: var(--ds-radius-card); border-bottom-right-radius: var(--ds-radius-sm); }
.thread__line { height: var(--ds-space-2); border-radius: var(--ds-radius-full); background: var(--ds-line-strong); width: 100%; }
.thread__line--short { width: 55%; }
.thread__line--mid { width: 80%; }
.thread__msg--out .thread__line { background: var(--ds-accent); opacity: 0.45; }
.thread__status { display: flex; gap: var(--ds-space-2); align-self: flex-end; }
.thread__typing { display: flex; gap: var(--ds-space-1); align-self: flex-start; padding: var(--ds-space-3) var(--ds-space-4); background: var(--ds-surface-2); border-radius: var(--ds-radius-full); }
.thread__typing span { width: var(--ds-space-2); height: var(--ds-space-2); border-radius: var(--ds-radius-full); background: var(--ds-ink-3); }

/* ---- Sections ---- */
.section { padding: var(--ds-space-16) 0; }
.section--alt { background: var(--ds-surface); box-shadow: 0 1px 0 var(--ds-line), 0 -1px 0 var(--ds-line); }
.section__title {
  font-family: var(--ds-font-display); font-weight: var(--ds-fw-semibold);
  font-size: var(--ds-text-2xl); line-height: var(--ds-text-2xl-lh); letter-spacing: var(--ds-tracking-display);
  text-wrap: balance; max-width: 760px;
}
.section__intro { max-width: 680px; margin-top: var(--ds-space-4); color: var(--ds-ink-2); font-size: var(--ds-text-lg); line-height: var(--ds-text-lg-lh); }

/* Capabilities: card grid */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ds-space-4); margin-top: var(--ds-space-10); }
.cards .ds-card { padding: var(--ds-space-5); }
.cards .ds-card h3 { font-weight: var(--ds-fw-semibold); font-size: var(--ds-text-md); line-height: var(--ds-text-md-lh); letter-spacing: var(--ds-tracking-tight); margin-bottom: var(--ds-space-2); }
.cards .ds-card h3::before { content: ""; display: block; width: var(--ds-space-6); height: var(--ds-space-1); background: var(--ds-accent); border-radius: var(--ds-radius-sm); margin-bottom: var(--ds-space-4); }
.cards .ds-card p { color: var(--ds-ink-2); font-size: var(--ds-text-base); line-height: var(--ds-text-base-lh); }

/* How it works: numbered steps */
.steps { list-style: none; padding: 0; counter-reset: step; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--ds-space-8); margin-top: var(--ds-space-10); }
.steps li { counter-increment: step; padding-top: var(--ds-space-5); box-shadow: 0 -1px 0 var(--ds-line-strong); }
.steps li::before {
  content: "0" counter(step); display: block; font-family: var(--ds-font-mono); font-size: var(--ds-text-sm); line-height: var(--ds-text-sm-lh);
  font-weight: var(--ds-fw-medium); color: var(--ds-accent); margin-bottom: var(--ds-space-3);
}
.steps h3 { font-weight: var(--ds-fw-semibold); font-size: var(--ds-text-md); line-height: var(--ds-text-md-lh); letter-spacing: var(--ds-tracking-tight); margin-bottom: var(--ds-space-2); }
.steps p { color: var(--ds-ink-2); font-size: var(--ds-text-base); line-height: var(--ds-text-base-lh); }

/* Two-column feature: title left, points right */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--ds-space-8) var(--ds-space-16); align-items: start; }
.split .prose { font-size: var(--ds-text-lg); line-height: var(--ds-text-lg-lh); }

/* Closing call to action on an inverse surface */
.cta-band { background: var(--ds-surface-inverse); color: var(--ds-ink-inverse); padding: var(--ds-space-16) 0; }
.cta-band__inner { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--ds-space-8); align-items: center; }
.cta-band .section__title { color: inherit; }
.cta-band p { margin-top: var(--ds-space-3); color: inherit; opacity: 0.75; font-size: var(--ds-text-lg); line-height: var(--ds-text-lg-lh); }
.cta-band__action { display: flex; flex-direction: column; align-items: flex-start; gap: var(--ds-space-3); justify-self: end; }
.cta-band__email { font-size: var(--ds-text-base); line-height: var(--ds-text-base-lh); opacity: 0.75; }
.cta-band .ds-btn--primary:focus-visible { box-shadow: 0 0 0 2px var(--ds-surface-inverse), 0 0 0 4px var(--ds-focus); }

/* ---- Reading copy ---- */
.prose { color: var(--ds-ink-2); }
.prose > * + * { margin-top: var(--ds-space-4); }
.prose strong { color: var(--ds-ink); font-weight: var(--ds-fw-semibold); }
.prose h2 {
  color: var(--ds-ink); font-weight: var(--ds-fw-semibold); letter-spacing: var(--ds-tracking-tight);
  font-size: var(--ds-text-lg); line-height: var(--ds-text-lg-lh); margin-top: var(--ds-space-10);
}
.prose ul { list-style: none; padding-left: 0; }
.prose li + li { margin-top: var(--ds-space-2); }
.prose ul li { position: relative; padding-left: var(--ds-space-5); }
.prose ul li::before {
  content: ""; position: absolute; left: 0; top: calc(var(--ds-text-md-lh) / 2 - var(--ds-space-1));
  width: var(--ds-space-2); height: var(--ds-space-2); background: var(--ds-accent); border-radius: var(--ds-radius-full);
}
.prose .ds-table { margin-top: var(--ds-space-5); }
.prose a { color: var(--ds-ink); }

/* Tables: multi-line cells get vertical padding */
.ds-table th { white-space: nowrap; }
.ds-table td { vertical-align: top; padding-top: var(--ds-space-3); padding-bottom: var(--ds-space-3); line-height: var(--ds-text-base-lh); }
.kv-table th[scope="row"] { width: 36%; color: var(--ds-ink-2); font-size: var(--ds-text-base); line-height: var(--ds-text-base-lh); font-weight: var(--ds-fw-medium); vertical-align: top; height: auto; padding-top: var(--ds-space-3); padding-bottom: var(--ds-space-3); white-space: normal; }
.kv-table td { height: auto; color: var(--ds-ink); }
.ds-table td a { overflow-wrap: anywhere; }

/* ---- Document pages ---- */
.page { padding: var(--ds-space-12) 0 var(--ds-space-16); }
.page__header { margin-bottom: var(--ds-space-10); }
.page__header .ds-display { font-size: var(--ds-text-2xl); line-height: var(--ds-text-2xl-lh); }
.page__header .lede { margin-top: var(--ds-space-3); font-size: var(--ds-text-md); line-height: var(--ds-text-md-lh); }
.page__meta { margin-top: var(--ds-space-3); font-family: var(--ds-font-mono); font-size: var(--ds-text-sm); line-height: var(--ds-text-sm-lh); color: var(--ds-ink-2); font-weight: var(--ds-fw-medium); }

/* ---- Footer ---- */
.site-footer { margin-top: auto; padding: var(--ds-space-10) 0; box-shadow: 0 -1px 0 var(--ds-line); background: var(--ds-surface); }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--ds-space-4) var(--ds-space-8); }
.site-footer__copy { font-size: var(--ds-text-base); line-height: var(--ds-text-base-lh); color: var(--ds-ink-2); }
.site-footer ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--ds-space-1) var(--ds-space-5); }
.site-footer li a { font-size: var(--ds-text-base); line-height: var(--ds-text-base-lh); color: var(--ds-ink-2); text-decoration: none; }
.site-footer li a:hover { color: var(--ds-ink); text-decoration: underline; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .hero__inner { grid-template-columns: minmax(0, 1fr); gap: var(--ds-space-8); }
  .thread { max-width: 480px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .cta-band__inner { grid-template-columns: minmax(0, 1fr); }
  .cta-band__action { justify-self: start; }
}

@media (max-width: 600px) {
  .container { padding: 0 var(--ds-space-4); }
  .site-header__inner { min-height: 0; padding: var(--ds-space-3) 0; flex-wrap: wrap; gap: var(--ds-space-2); }
  .site-nav { margin-left: calc(-1 * var(--ds-space-3)); }
  .hero { padding: var(--ds-space-10) 0; }
  .hero .ds-display { font-size: var(--ds-text-2xl); line-height: var(--ds-text-2xl-lh); }
  .lede { font-size: var(--ds-text-md); line-height: var(--ds-text-md-lh); }
  .section, .cta-band { padding: var(--ds-space-10) 0; }
  .section__title { font-size: var(--ds-text-xl); line-height: var(--ds-text-xl-lh); }
  .section__intro, .split .prose, .cta-band p { font-size: var(--ds-text-md); line-height: var(--ds-text-md-lh); }
  .cards, .steps { margin-top: var(--ds-space-6); }
  .steps { grid-template-columns: minmax(0, 1fr); gap: var(--ds-space-5); }
  .page { padding: var(--ds-space-8) 0 var(--ds-space-12); }
  .page__header .ds-display { font-size: var(--ds-text-xl); line-height: var(--ds-text-xl-lh); }
  .kv-table th[scope="row"], .kv-table td { display: block; width: auto; }
  .kv-table th[scope="row"] { padding-bottom: 0; border-bottom: 0; }
  .kv-table td { padding-top: var(--ds-space-1); }
  .site-footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-nav a { transition: none; }
}
