mdpreviewer 0.1.0

Live-reloading browser preview for a single Markdown file, with mermaid diagrams and cursor sync for Helix.
:root {
  color-scheme: dark;
}

body {
  margin: 0;
  background: #0d1117;
}

/*
 * github-markdown.css styles the .markdown-body element itself; here we only
 * constrain its width and give it breathing room within the page.
 */
.markdown-body {
  box-sizing: border-box;
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6rem;
}

/* Rendered mermaid diagrams: centered, transparent, and scaled to fit. */
pre.mermaid,
.mermaid {
  background: transparent;
  text-align: center;
  overflow: visible;
}

pre.mermaid svg,
.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Diagrams and images are click-to-zoom; hint that with the cursor. */
.markdown-body pre.mermaid,
.markdown-body img {
  cursor: zoom-in;
}

/* A linked image follows its link instead of zooming, so it keeps the
 * pointer cursor. */
.markdown-body a img {
  cursor: pointer;
}

/*
 * Zoom overlay: a full-window view of one diagram, image, table or code block.
 * The figure is centered by `left/top: 50%` plus a `translate(-50%, -50%)` in
 * the transform, so pan and zoom are a single matrix on one element.
 */
.mdpreviewer-zoom {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(1, 4, 9, 0.94);
  overflow: hidden;
  cursor: grab;
  /* Keep touch gestures from scrolling the page behind the overlay. */
  touch-action: none;
  overscroll-behavior: contain;
}

.mdpreviewer-zoom[hidden] {
  display: none;
}

/* While panning, text must not select: the drag is a pan, not a selection.
 * The rule is scoped to the drag, so selection is untouched at rest. */
.mdpreviewer-zoom.is-panning {
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

.mdpreviewer-zoom-figure {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* The figure carries .markdown-body so cloned tables and code keep their
 * theme, but none of the page layout that class normally applies. */
.mdpreviewer-zoom .markdown-body {
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
}

.mdpreviewer-zoom-hint,
.mdpreviewer-zoom-close {
  position: absolute;
  color: #9198a1;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid #3d444d;
  border-radius: 6px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
}

.mdpreviewer-zoom-hint {
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  padding: 0.35rem 0.75rem;
  pointer-events: none;
  white-space: nowrap;
}

.mdpreviewer-zoom-close {
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.mdpreviewer-zoom-close:hover {
  color: #f0f6fc;
}

/* Front matter: a muted, collapsed YAML block above the document body. */
.markdown-body details.frontmatter {
  margin-bottom: 1.5rem;
  /* Same muted grey the vendored theme uses for blockquotes. */
  color: #9198a1;
  font-size: 85%;
}

.markdown-body details.frontmatter summary {
  cursor: pointer;
}

.markdown-body details.frontmatter pre {
  margin: 0.5rem 0 0;
}

/* Scroll target: a brief outline around the block under the editor's cursor. */
.markdown-body .mdpreviewer-target {
  /* The vendored dark theme's accent blue. */
  outline: 2px solid #4493f8;
  outline-offset: 4px;
  animation: mdpreviewer-target-fade 1.2s ease-out forwards;
}

@keyframes mdpreviewer-target-fade {
  from {
    outline-color: #4493f8;
  }
  to {
    outline-color: transparent;
  }
}