/* StateFlow documentation. Builds on style.css and stateflow.css: same fonts, brand colours, screenshot
   frames (.shot) and code cards (.code), laid out as a sidebar + article. */

.docs {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 48px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 24px 96px;
}

/* ---------- Sidebar ---------- */
.docs-nav {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 6px;
}

.docs-nav summary { display: none; }

.docs-nav .nav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 18px;
}

.docs-nav .nav-title span {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-dark);
  background: var(--ring);
  padding: 2px 8px;
  border-radius: 999px;
}

.docs-nav h4 {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 20px 0 6px;
}

.docs-nav ul { list-style: none; }

.docs-nav a.link {
  display: block;
  padding: 5px 10px;
  margin-left: -10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.93rem;
}

.docs-nav a.link:hover { background: var(--ring); color: var(--brand-dark); }

.docs-nav a.link.active {
  background: var(--brand);
  color: #fff;
}

/* ---------- Article ---------- */
.docs-main { min-width: 0; }

.crumbs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--brand-dark); }

.docs-main h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.12;
}

.docs-main .lede {
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 12px 0 28px;
  max-width: 720px;
}

.docs-main h2 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  margin: 48px 0 12px;
  scroll-margin-top: 90px;
}

.docs-main h3 {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 28px 0 8px;
  scroll-margin-top: 90px;
}

.docs-main p,
.docs-main li { color: #3a4456; }

.docs-main p { margin-bottom: 14px; max-width: 760px; }

.docs-main ul,
.docs-main ol { margin: 6px 0 16px 22px; max-width: 740px; }

.docs-main li { margin-bottom: 6px; }

.docs-main li strong,
.docs-main p strong { color: var(--ink); }

.docs-main code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(28, 36, 51, 0.07);
  color: var(--brand-dark);
  overflow-wrap: break-word;
}

.docs-main .code code,
.docs-main .shot code { background: none; padding: 0; color: inherit; }

.docs-main .shot,
.docs-main .code { margin: 22px 0 26px; }

.docs-main .shot { box-shadow: 0 18px 50px rgba(28, 36, 51, 0.22); }

.docs-main .shot.narrow { max-width: 420px; }
.docs-main .shot.medium { max-width: 620px; }

.docs-main .shots-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 22px 0 26px;
  align-items: start;
}

.docs-main .shots-row .shot { margin: 0; }

.code .chrome .copy {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--sf-ink-soft);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--sf-line);
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}

.code .chrome .copy:hover { color: #fff; }

/* ---------- Callouts ---------- */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid rgba(28, 36, 51, 0.08);
  border-left: 4px solid var(--brand);
  margin: 20px 0;
  max-width: 760px;
}

.callout p { margin: 0; }
.callout p + p { margin-top: 8px; }
.callout .label { font-weight: 900; color: var(--brand-dark); white-space: nowrap; }
.callout.warn { border-left-color: var(--accent); }
.callout.warn .label { color: #a8650d; }
.callout.sample { border-left-color: var(--sf-screen); }
.callout.sample .label { color: #3a6cc4; }

/* ---------- Tables ---------- */
.docs-main table {
  width: 100%;
  max-width: 820px;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 0.93rem;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.docs-main th,
.docs-main td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(28, 36, 51, 0.07);
  vertical-align: top;
}

.docs-main th {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #f1f4f9;
}

.docs-main tr:last-child td { border-bottom: none; }

/* Layer and node colour chips reuse .chip from stateflow.css on a light background. */
.docs-main .chip { background: var(--surface); color: var(--ink); border-color: rgba(28, 36, 51, 0.1); }

/* ---------- Index cards ---------- */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin: 18px 0 32px;
}

.doc-card {
  display: block;
  background: var(--surface);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s, border-color 0.2s;
}

.doc-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.doc-card strong { display: block; color: var(--ink); font-weight: 800; margin-bottom: 4px; }
.doc-card span { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Prev / next ---------- */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid rgba(28, 36, 51, 0.1);
}

.pager a {
  flex: 1;
  max-width: 48%;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
}

.pager a small { display: block; color: var(--ink-soft); font-weight: 700; font-size: 0.78rem; }
.pager a.next { text-align: right; margin-left: auto; }
.pager a:hover { color: var(--brand-dark); }

/* ---------- On this page ---------- */
.docs-toc {
  position: sticky;
  top: 88px;
  align-self: start;
  font-size: 0.86rem;
}

.docs-toc h4 {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.docs-toc ul { list-style: none; border-left: 2px solid rgba(28, 36, 51, 0.08); }
.docs-toc a { display: block; padding: 4px 0 4px 12px; color: var(--ink-soft); text-decoration: none; font-weight: 700; }
.docs-toc a:hover { color: var(--brand-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .docs { grid-template-columns: 220px minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 860px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 20px 16px 72px; }

  .docs-nav { position: static; max-height: none; margin-bottom: 20px; }
  .docs-nav summary {
    display: block;
    cursor: pointer;
    font-weight: 800;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .docs-nav details:not([open]) .nav-body { display: none; }
  .docs-nav .nav-body { padding: 8px 6px 0; }
  .docs-main .shots-row { grid-template-columns: minmax(0, 1fr); }
  .docs-main table { display: block; overflow-x: auto; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .site-nav a { padding: 8px 8px; font-size: 0.88rem; }
}

@media (min-width: 861px) {
  .docs-nav details > summary { display: none; }
}

/* Token colours not covered by stateflow.css. */
.code .s { color: #f2a679; }
.code .m { color: #f78c6c; }
