birta 0.2.1

Preview markdown files in the browser with GitHub-style rendering
Documentation
/*
 * Page-level styles for birta viewer.
 * Theme colors are inherited from github-markdown-css which defines
 * --bgColor-default, --fgColor-default, etc. via [data-theme] and
 * @media (prefers-color-scheme) selectors on .markdown-body.
 *
 * For the header and status bar (outside .markdown-body), we define
 * our own variables that mirror the github-markdown-css palette.
 */

:root {
  --birta-fg: #1f2328;
  --birta-bg: #ffffff;
  --birta-bg-secondary: #f6f8fa;
  --birta-border: #d1d9e0;
}

[data-theme="dark"] {
  --birta-fg: #e6edf3;
  --birta-bg: #0d1117;
  --birta-bg-secondary: #161b22;
  --birta-border: #30363d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --birta-fg: #e6edf3;
    --birta-bg: #0d1117;
    --birta-bg-secondary: #161b22;
    --birta-border: #30363d;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--birta-bg);
  color: var(--birta-fg);
  transition: background-color 0.2s, color 0.2s;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background-color: var(--birta-bg-secondary);
  border-bottom: 1px solid var(--birta-border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--birta-fg);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.header.header-hidden {
  display: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.filename {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-select {
  background: var(--birta-bg-secondary);
  border: 1px solid var(--birta-border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--birta-fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color 0.2s;
  appearance: auto;
}

.theme-select:hover {
  border-color: var(--birta-fg);
}

.theme-select option {
  background: var(--birta-bg);
  color: var(--birta-fg);
}

.reading-toggle,
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--birta-border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--birta-fg);
  font-size: 14px;
  line-height: 1;
  transition: border-color 0.2s;
}

.reading-toggle:hover,
.theme-toggle:hover {
  border-color: var(--birta-fg);
}

.theme-toggle.disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.theme-toggle svg {
  display: none;
}

.container {
  max-width: 1012px;
  margin: 24px auto;
  padding: 0;
  border: 1px solid var(--birta-border);
  border-radius: 6px;
}

.container .markdown-body {
  padding: 40px;
}

/* File header bar — GitHub-style */
.file-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--birta-bg-secondary);
  border-bottom: 1px solid var(--birta-border);
  border-radius: 6px 6px 0 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 32px;
}

.file-header-icon {
  flex-shrink: 0;
  opacity: 0.6;
}

.file-header-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 767px) {
  .container .markdown-body {
    padding: 16px;
  }

  .header {
    padding: 8px 16px;
  }
}

.status {
  position: fixed;
  bottom: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  background-color: var(--birta-bg-secondary);
  border: 1px solid var(--birta-border);
  color: var(--birta-fg);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.status.visible {
  opacity: 1;
}

/* --- Reading mode --- */
body.reading-mode .header {
  transform: translateY(-100%);
  pointer-events: none;
  opacity: 0;
}

body.reading-mode .file-header {
  display: none;
}

body.reading-mode .container {
  border-color: transparent;
  margin-top: 0;
}

.reading-progress {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background-color: var(--birta-fg);
  opacity: 0.25;
  z-index: 200;
  pointer-events: none;
  transition: width 80ms linear;
}

.reading-exit-zone {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  z-index: 300;
}

.reading-exit-bar {
  position: fixed;
  top: 8px;
  right: 16px;
  z-index: 301;
  transform: translateY(-48px);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.reading-exit-zone:hover ~ .reading-exit-bar,
.reading-exit-bar:hover {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.reading-exit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: var(--birta-bg-secondary);
  border: 1px solid var(--birta-border);
  border-radius: 6px;
  color: var(--birta-fg);
  cursor: pointer;
  transition: border-color 0.2s;
}

.reading-exit-btn:hover {
  border-color: var(--birta-fg);
}

/* Override inline background-color from syntect on themed code blocks */
.markdown-body .highlight pre[style],
.markdown-body pre[style] {
  background-color: var(--bgColor-muted) !important;
}

/* Heading anchor links — GitHub-style hover-reveal */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  position: relative;
}

.markdown-body .anchor {
  float: left;
  padding-right: 4px;
  margin-left: -20px;
  line-height: 1;
}

.markdown-body .anchor::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  background-color: var(--birta-fg);
  opacity: 0;
  transition: opacity 0.15s;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a2.002 2.002 0 0 0 0 2.83Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a2.002 2.002 0 0 0 0 2.83Z'/%3E%3C/svg%3E");
  -webkit-mask-size: 16px 16px;
  mask-size: 16px 16px;
}

.markdown-body h1:hover .anchor::before,
.markdown-body h2:hover .anchor::before,
.markdown-body h3:hover .anchor::before,
.markdown-body h4:hover .anchor::before,
.markdown-body h5:hover .anchor::before,
.markdown-body h6:hover .anchor::before,
.markdown-body .anchor:focus::before {
  opacity: 0.5;
}

.markdown-body h1:hover .anchor::before:hover,
.markdown-body .anchor:focus::before {
  opacity: 1;
}