/* =========================================================
   smabo — documentation (Markdown → HTML) styles
   Loaded in addition to style.css on pages under /docs.
   Styles a `.doc-content` article rendered from Markdown,
   plus a sticky table-of-contents sidebar and Mermaid blocks.
   ========================================================= */

/* layout: sticky TOC + content */
.doc-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 40px;
  align-items: start;
  padding-block: 56px;
}

.doc-toc {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  font-size: 0.86rem;
  border-left: 2px solid var(--line);
  padding-left: 16px;
  order: 2;
}
.doc-toc__title {
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.doc-toc ul { list-style: none; margin: 0; padding: 0; }
.doc-toc li { margin: 2px 0; }
.doc-toc a {
  color: var(--ink-soft);
  display: block;
  padding: 3px 0;
  line-height: 1.4;
}
.doc-toc a:hover { color: var(--indigo); text-decoration: none; }
.doc-toc a.is-active { color: var(--indigo); font-weight: 700; }
.doc-toc .toc-h3 a { padding-left: 14px; font-size: 0.95em; color: var(--muted); }

/* inline TOC embedded in article body — hidden on wide screens (sidebar handles it) */
.doc-toc--inline {
  display: none;
  position: static;
  max-height: none;
  overflow-y: visible;
  order: unset;
  margin-bottom: 40px;
}

/* content column */
.doc-content { min-width: 0; max-width: 820px; }
.doc-content > *:first-child { margin-top: 0; }

.doc-content h2 {
  font-size: 1.5rem;
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 80px;
}
.doc-content h3 {
  font-size: 1.15rem;
  margin: 30px 0 12px;
  display: flex; align-items: center; gap: 8px;
  scroll-margin-top: 80px;
}
.doc-content h3::before {
  content: ""; width: 4px; height: 1.05em; flex: none;
  background: linear-gradient(var(--indigo), var(--cyan));
  border-radius: 2px;
}
.doc-content h4 { font-size: 1rem; margin: 22px 0 10px; scroll-margin-top: 80px; }

.doc-content p { margin: 0 0 16px; }
.doc-content ul, .doc-content ol { margin: 0 0 16px; padding-left: 1.4em; }
.doc-content li { margin: 4px 0; }
.doc-content li > ul, .doc-content li > ol { margin: 4px 0; }

.doc-content a { font-weight: 600; }

/* heading anchor link (added by the generator) */
.doc-content .headerlink {
  opacity: 0; margin-left: 8px; font-weight: 400;
  color: var(--muted); text-decoration: none;
}
.doc-content h2:hover .headerlink,
.doc-content h3:hover .headerlink,
.doc-content h4:hover .headerlink { opacity: 1; }

/* tables — match the site's table.spec look.
   display:block (formerly used to enable horizontal scroll) broke the table's
   own column-width auto-layout: short tables would render their bordered
   white box at full width while the actual header/cell backgrounds only
   spanned the narrower auto-sized columns, leaving a blank strip on the
   right. Keep display:table (the default) so column sizing/backgrounds
   behave correctly; overflow-x:auto still scrolls genuinely wide tables. */
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.doc-content th, .doc-content td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.doc-content th { white-space: nowrap; }
.doc-content td { white-space: normal; word-break: break-word; }
.doc-content thead th { background: var(--bg-soft); font-weight: 700; color: var(--ink); }
.doc-content tbody tr:last-child td { border-bottom: none; }
.doc-content table code { white-space: normal; }

/* blockquotes → callout style */
.doc-content blockquote {
  margin: 22px 0;
  background: var(--bg-tint);
  border: 1px solid var(--line);
  border-left: 4px solid var(--indigo);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.doc-content blockquote > *:first-child { margin-top: 0; }
.doc-content blockquote > *:last-child { margin-bottom: 0; }

.doc-content hr { border: none; border-top: 1px solid var(--line); margin: 40px 0; }

/* Mermaid diagrams */
.doc-content .mermaid {
  margin: 22px 0;
  padding: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
  overflow-x: auto;
  /* hide the raw text until Mermaid has rendered it */
  font-size: 0; color: transparent;
}
.doc-content .mermaid svg { max-width: 100%; height: auto; font-size: 1rem; }

/* back link */
.doc-back { margin-top: 48px; }

/* index page hero — fixed size from ~600px viewport width upward (phones
   below that shrink proportionally to fit, everything else stays constant). */
.doc-hero--cover {
  background: none;
  padding-block: 0;
}
.doc-hero--cover img {
  display: block;
  width: 600px;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

/* video/image caption embedded directly on the media, same scrim treatment as the hero.
   Fixed size from ~600px viewport width upward, like the hero image — phones
   below that shrink proportionally to fit, everything else stays constant. */
.media-cover {
  position: relative;
  display: inline-block;
  width: 600px;
  max-width: 100%;
  line-height: 0;
}
.media-cover video {
  display: block;
  width: 100%;
}
.media-cover__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
  padding: 16px 16px 6%;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0) 55%);
}
.media-cover__overlay p {
  margin: 0;
  color: #fff;
  font-weight: 700;
  font-size: clamp(0.85rem, 0.7rem + 0.6vw, 1.05rem);
  line-height: 1.5;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}

/* index page CTA button ("Start building smabo") — extra breathing room.
   Fixed size at every width, same as the hero image/videos — it never grows
   or shrinks with the viewport. On very narrow screens the label wraps
   instead of overflowing, so it never clips. */
.cta-block { margin-block: 0 28px; }
.cta-block .btn {
  font-size: 1rem;
  padding: 13px 26px;
  max-width: calc(100vw - 40px);
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}

/* scroll reveal: index page content blocks fade + rise into view (docs.js) */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .7s ease, transform .7s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* responsive: drop the TOC sidebar */
@media (max-width: 860px) {
  .doc-wrap { grid-template-columns: 1fr; padding-block: 36px; }
  .doc-toc { display: none; }
  .doc-toc--inline { display: block; }
}

/* startup-procedure popup (docs.js) */
.startup-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  overflow-y: auto;
}
.startup-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 760px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  padding: 28px 28px 32px;
}
.startup-modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  color: #666;
}
.startup-modal__close:hover { color: #000; }
.startup-modal__body { margin-top: 6px; }
.startup-modal__loading { color: #888; }
