/* BioStat Prime Help — plain CSS, no frameworks */

:root {
  --primary: #307fff;
  --primary-hover: #1a6ef0;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-hover: #eef1f5;
  --header-bg: #ffffff;
  --text: #19191c;
  --text-soft: #5b5b66;
  --text-faint: #8c8c96;
  --border: #e3e5ea;
  --code-bg: #f1f3f6;
  --selected-bg: #e6efff;
  --tip: #307fff;
  --tip-bg: #eef4ff;
  --note: #7a5af8;
  --note-bg: #f3f0ff;
  --warning: #e07a00;
  --warning-bg: #fff5e6;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --header-h: 64px;
  --sidebar-w: 300px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

html.dark {
  --bg: #19191c;
  --bg-soft: #222226;
  --bg-hover: #2b2b30;
  --header-bg: #27282c;
  --text: #ffffffd9;
  --text-soft: #ffffffa6;
  --text-faint: #ffffff70;
  --border: #ffffff1f;
  --code-bg: #2b2b30;
  --selected-bg: #307fff2e;
  --tip-bg: #307fff1f;
  --note-bg: #7a5af81f;
  --warning-bg: #e07a001f;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--header-h) + 16px); scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.7 var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Animations ---------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.main > .breadcrumbs, .main > .article { animation: fade-up 0.5s var(--ease) both; }
.main > .article { animation-delay: 0.05s; }

/* Images and videos fade in as they scroll into view (class added by app.js) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal.revealed { opacity: 1; transform: none; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--header-bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.25s ease, background-color 0.3s ease;
}
.site-header.scrolled { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); }
html.dark .site-header.scrolled { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 16.5px; letter-spacing: -0.015em; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; flex-shrink: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px;
  border: 0; background: transparent; color: var(--text-soft); cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.theme-btn svg { transition: transform 0.5s var(--ease); }
.theme-btn:hover svg { transform: rotate(25deg); }
.menu-btn { display: none; }

.theme-btn .icon-moon { display: none; }
html.dark .theme-btn .icon-sun { display: none; }
html.dark .theme-btn .icon-moon { display: block; }

.search-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 10px 0 12px; min-width: 220px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft); color: var(--text-faint); font: inherit; font-size: 14px; cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.search-btn:hover { border-color: var(--primary); color: var(--text-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.search-btn kbd { margin-left: auto; font: 12px var(--font); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }

.trial-btn {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px;
  border-radius: 8px; background: var(--primary); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background-color 0.2s ease, transform 0.2s var(--ease), box-shadow 0.2s ease;
}
.trial-btn:hover { background: var(--primary-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent); }
.trial-btn:active { transform: none; }

/* ---------- Layout ---------- */
.layout { display: flex; }

.sidebar {
  position: sticky; top: var(--header-h);
  width: var(--sidebar-w); flex-shrink: 0;
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 8px 40px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.main { flex: 1; min-width: 0; padding: 32px 48px 0; max-width: 1040px; }

/* ---------- Sidebar tree ---------- */
.toc, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul { display: none; }
.toc li.open > ul { display: block; animation: slide-down 0.25s var(--ease); }
.toc-row { display: flex; align-items: flex-start; border-radius: 6px; transition: background-color 0.15s ease; }
.toc-row:hover { background: var(--bg-hover); }
.toc-row a {
  flex: 1; min-width: 0; display: block; padding: 6px 8px; font-size: 14px; font-weight: 450; line-height: 1.45;
  color: var(--text-soft); border-radius: 6px; transition: color 0.15s ease, transform 0.2s var(--ease);
}
.toc-row a:hover { text-decoration: none; color: var(--text); transform: translateX(2px); }
.toc-row.current { background: var(--selected-bg); box-shadow: inset 3px 0 0 var(--primary); }
.toc-row.current a { color: var(--primary); font-weight: 600; }
.toc > li > .toc-row a { font-weight: 500; color: var(--text); }
.toc > li > .toc-row.current a { color: var(--primary); }
.toc-toggle {
  flex-shrink: 0; width: 26px; height: 32px; padding: 0; border: 0; background: none;
  color: var(--text-faint); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.toc-toggle svg { width: 14px; height: 14px; transition: transform 0.25s var(--ease); }
.toc li.open > .toc-row .toc-toggle svg { transform: rotate(90deg); }
.toc-toggle-spacer { width: 26px; flex-shrink: 0; }
.toc ul .toc-row { padding-left: calc(var(--depth, 1) * 14px); }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 8px; color: var(--text-faint); }
.breadcrumbs a { color: var(--text-soft); }
.breadcrumbs__sep { color: var(--text-faint); }

/* ---------- Article ---------- */
.article { max-width: 820px; }
.article { color: var(--text); }
.article h1, .article h2, .article h3, .article h4 { font-weight: 700; color: var(--text); text-wrap: balance; }
.article h1 { font-size: 38px; line-height: 1.15; margin: 0 0 24px; letter-spacing: -0.03em; }
.article h2 { font-size: 26px; line-height: 1.3; margin: 44px 0 14px; letter-spacing: -0.022em; font-weight: 650; }
.article h3 { font-size: 20px; line-height: 1.35; margin: 30px 0 10px; letter-spacing: -0.015em; font-weight: 600; }
.article h4 { font-size: 17px; margin: 22px 0 8px; font-weight: 600; }
.article p { margin: 0 0 16px; color: var(--text-soft); }
html:not(.dark) .article p { color: #3b3b45; }
.article strong, .article b { font-weight: 600; color: var(--text); }
.article h1 a.anchor, .article h2 a.anchor, .article h3 a.anchor { opacity: 0; margin-left: 8px; font-weight: 400; color: var(--text-faint); }
.article h2:hover a.anchor, .article h3:hover a.anchor { opacity: 1; }

.article .control { font-weight: 600; color: var(--text); }
.article .emphasis { font-style: italic; }
.article .superscript { vertical-align: super; font-size: 0.8em; }

.article code, .article .code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--code-bg); padding: 2px 6px; border-radius: 4px;
}

.article .list { margin: 0 0 16px; padding-left: 26px; }
.article .list__item { margin-bottom: 6px; }
.article .list__item > p { margin-bottom: 6px; }

/* Images */
.article figure { margin: 0 0 20px; }
.article figure img {
  max-width: 100%; height: auto; display: block;
  border: 1px solid var(--border); border-radius: 10px; cursor: zoom-in; background: #fff;
  transition: transform 0.3s var(--ease), box-shadow 0.3s ease;
}
.article figure img:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12); }

/* Videos */
.article .video-player { margin: 0 0 20px; }
.article .video-player video {
  max-width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--border); background: #000;
}

/* Definition lists (Writerside "title-top") */
.article dl { margin: 0 0 18px; }
.article dt { font-weight: 700; margin: 0 0 4px; }
.article dd { margin: 0 0 12px; padding-left: 16px; border-left: 2px solid var(--border); }
.article dd > :last-child { margin-bottom: 0; }
.article dt[data-expandable="true"] { cursor: pointer; display: flex; align-items: center; gap: 6px; }
.article dt[data-expandable="true"]::before { content: "▸"; color: var(--text-faint); transition: transform 0.15s; }
.article dt[data-expandable="true"].expanded::before { transform: rotate(90deg); }

/* Notes, tips, warnings */
.article aside.prompt {
  margin: 0 0 18px; padding: 12px 16px 12px 44px; position: relative;
  border-radius: 8px; background: var(--tip-bg); border-left: 4px solid var(--tip);
}
.article aside.prompt > :last-child { margin-bottom: 0; }
.article aside.prompt::before {
  content: "i"; position: absolute; left: 14px; top: 13px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--tip); color: #fff;
  font: 700 13px/20px var(--font); text-align: center;
}
.article aside.prompt[data-type="note"] { background: var(--note-bg); border-color: var(--note); }
.article aside.prompt[data-type="note"]::before { background: var(--note); }
.article aside.prompt[data-type="warning"] { background: var(--warning-bg); border-color: var(--warning); }
.article aside.prompt[data-type="warning"]::before { content: "!"; background: var(--warning); }

/* Tabs */
.article .tabs { margin: 0 0 20px; border: 1px solid var(--border); border-radius: 8px; }
.tabs__nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 8px; overflow-x: auto; }
.tabs__btn {
  border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-soft);
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color 0.2s ease, border-color 0.25s var(--ease);
}
.tabs__btn:hover { color: var(--text); }
.tabs__btn[aria-selected="true"] { color: var(--primary); border-color: var(--primary); }
.article .tabs__content { padding: 16px; animation: fade-in 0.3s ease; }
.article .tabs__content[hidden] { display: none; }

/* Math (pre-rendered SVG) */
.article .MathJax svg { width: auto; height: auto; fill: currentColor; stroke: none; vertical-align: middle; }

/* Last modified + prev/next */
.article .last-modified { margin-top: 36px; font-size: 14px; color: var(--text-faint); }
.article .navigation-links { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.article .navigation-links a {
  display: block; padding: 14px 18px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 600;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.25s var(--ease), box-shadow 0.25s ease;
}
.article .navigation-links a:hover {
  border-color: var(--primary); text-decoration: none; color: var(--primary);
  transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}
.article .navigation-links__prev::before { content: "← Previous"; display: block; font-size: 13px; font-weight: 400; color: var(--text-faint); }
.article .navigation-links__next { grid-column: 2; text-align: right; }
.article .navigation-links__next::before { content: "Next →"; display: block; font-size: 13px; font-weight: 400; color: var(--text-faint); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 56px; padding: 24px 0 32px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 14px; }
.site-footer__social { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.site-footer__social a { color: var(--text-soft); display: inline-flex; }
.site-footer__social a:hover { color: var(--primary); text-decoration: none; }
.site-footer__social svg { fill: currentColor; stroke: none; }
.site-footer__link { font-weight: 600; }
.site-footer__copy { margin: 0; }

/* ---------- Search dialog ---------- */
.search-dialog {
  width: min(680px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 80px));
  margin: 60px auto auto; padding: 0; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow); overflow: hidden;
}
.search-dialog[open] { display: flex; flex-direction: column; animation: pop-in 0.22s var(--ease); }
.search-dialog::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(2px); animation: fade-in 0.2s ease; }
.search-results li { animation: fade-up 0.25s var(--ease) both; }
.search-results li:nth-child(2) { animation-delay: 0.02s; }
.search-results li:nth-child(3) { animation-delay: 0.04s; }
.search-results li:nth-child(4) { animation-delay: 0.06s; }
.search-results li:nth-child(n + 5) { animation-delay: 0.08s; }
.search-results li a { transition: background-color 0.12s ease; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-faint); }
.search-box input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 17px; }
.search-box kbd { font: 12px var(--font); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; cursor: pointer; }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results li a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.search-results li a:hover, .search-results li a.active { background: var(--selected-bg); text-decoration: none; }
.search-results .r-title { font-weight: 600; }
.search-results .r-path { font-size: 12.5px; color: var(--text-faint); }
.search-results .r-snippet { font-size: 14px; color: var(--text-soft); margin-top: 2px; }
.search-results mark { background: #ffe16b; color: #19191c; border-radius: 2px; padding: 0 1px; }
.search-empty { padding: 28px 16px; text-align: center; color: var(--text-faint); }

/* ---------- Image zoom ---------- */
.lightbox { padding: 0; border: 0; background: transparent; max-width: 95vw; max-height: 95vh; }
.lightbox[open] { animation: pop-in 0.25s var(--ease); }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.8); animation: fade-in 0.25s ease; }
.lightbox img { max-width: 95vw; max-height: 92vh; display: block; border-radius: 8px; background: #fff; cursor: zoom-out; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 25; height: auto;
    transform: translateX(-100%); transition: transform 0.3s var(--ease); box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-backdrop { position: fixed; inset: var(--header-h) 0 0; z-index: 24; background: rgba(0, 0, 0, 0.4); animation: fade-in 0.25s ease; }
  .main { padding: 24px 20px 0; }
}

@media (max-width: 640px) {
  .site-header { padding: 0 10px; gap: 6px; }
  .brand span { font-size: 15px; }
  .search-btn { min-width: 0; width: 38px; padding: 0; justify-content: center; border: 0; background: none; }
  .search-btn__label, .search-btn kbd { display: none; }
  .trial-btn { padding: 0 10px; font-size: 13px; }
  .article h1 { font-size: 30px; }
  .article h2 { font-size: 24px; }
  .article .navigation-links { grid-template-columns: 1fr; }
  .article .navigation-links__next { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, *::backdrop { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .sidebar, .site-footer, .navigation-links { display: none !important; }
  .main { padding: 0; }
}
