/* =========================================================================
   Scientific Instrument Control — light, professional theme
   ========================================================================= */
:root {
  /* Palette — soft, easy on the eyes */
  --bg: #f6f9fb;
  --surface: #ffffff;
  --surface-2: #eef4f7;
  --ink: #1d2b33;
  --ink-soft: #4a5b65;
  --ink-faint: #6e7f88;
  --border: #dbe6ec;
  --border-strong: #c4d6df;

  /* Accents */
  --teal: #1f6f8b;
  --teal-dark: #155367;
  --green: #2a9d8f;
  --purple: #9b5de5;
  --amber: #e9a23b;
  --accent: var(--teal);

  /* Code surface (light) */
  --code-bg: #f3f7f9;
  --code-inline-bg: #e9f1f4;
  --code-border: #dde8ed;

  /* Layout */
  --header-h: 64px;
  --maxw: 1280px;
  --shell: 1280px; /* content shell aligns with the header bar */
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 54, 66, .06), 0 8px 24px rgba(20, 54, 66, .06);
  --shadow-hover: 0 4px 10px rgba(20, 54, 66, .10), 0 16px 40px rgba(20, 54, 66, .12);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }

a { color: var(--teal); text-decoration: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--teal);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

.icon { width: 1.1em; height: 1.1em; display: inline-block; vertical-align: -0.15em; flex: none; }
.icon.flip { transform: rotate(180deg); }

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-logo { width: 34px; height: 34px; transition: transform .3s ease; }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }
.brand-text { font-size: 1.05rem; }

.site-nav { display: flex; align-items: center; gap: .35rem; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .85rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .95rem;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.nav-icon { color: var(--teal); transition: transform .2s ease; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link:hover .nav-icon { transform: translateY(-1px); }
.nav-link.is-active {
  background: linear-gradient(135deg, var(--teal), var(--green));
  color: #fff;
}
.nav-link.is-active .nav-icon { color: #fff; }

/* =========================================================================
   Main / footer scaffolding
   ========================================================================= */
.site-main { flex: 1 0 auto; width: 100%; }

.site-footer {
  flex-shrink: 0;
  margin-top: 4rem;
  background: #143642;
  color: #cfe0e6;
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 3vw, 2rem);
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem;
}
.footer-brand { display: flex; flex-direction: column; gap: .75rem; }
.footer-logo { width: 48px; height: 48px; }
.footer-brand p { margin: 0; max-width: 46ch; color: #aac4cd; }
.footer-heading { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: #8fb0ba; margin: 0 0 .75rem; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.footer-nav a { color: #d8e7ec; transition: color .2s ease, padding-left .2s ease; }
.footer-nav a:hover { color: #fff; padding-left: 4px; }
.footer-base {
  border-top: 1px solid rgba(255, 255, 255, .1);
  text-align: center;
  padding: 1rem;
  font-size: .85rem;
  color: #8fb0ba;
}

/* =========================================================================
   Hero / front page
   ========================================================================= */
.hero {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1rem, 3vw, 2rem) 1rem;
  text-align: center;
}
.hero-logo { display: block; }
.hero-logo-svg {
  width: clamp(110px, 18vw, 168px);
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(31, 111, 139, .25));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-title {
  margin: 1.25rem auto .5rem;
  font-size: clamp(1.9rem, 1.2rem + 3vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 18ch;
  background: linear-gradient(120deg, var(--teal), var(--green) 55%, var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lede {
  font-size: clamp(1.1rem, 1rem + .6vw, 1.4rem);
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 auto 1.5rem;
}
.hero-text { max-width: 72ch; margin: 0 auto; text-align: left; color: var(--ink-soft); }
.hero-text p { margin: 0 0 1rem; }

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin: 2rem auto 0;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1.3rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-weight: 650;
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.cta-btn .cta-icon {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
}
.cta-arrow { color: var(--accent); transition: transform .22s ease; }
.cta-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}
.cta-btn:hover .cta-arrow { transform: translateX(4px); }

.home-sections { max-width: var(--maxw); margin: 4rem auto 0; padding: 0 clamp(1rem, 3vw, 2rem); }
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); margin: 0 0 .4rem; color: var(--ink); }
.section-head p { color: var(--ink-faint); margin: 0; }

/* =========================================================================
   Cards / grids
   ========================================================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1.25rem;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--accent, var(--teal));
  opacity: .85;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.card h3 { margin: .25rem 0 .5rem; font-size: 1.18rem; color: var(--teal-dark); }
.card h3 a { color: inherit; }
.card p { margin: 0 0 .75rem; color: var(--ink-soft); font-size: .97rem; }
.card-cta { display: inline-flex; align-items: center; gap: .35rem; font-weight: 650; color: var(--accent, var(--teal)); }
.card:hover .card-cta .icon { transform: translateX(3px); }
.card-cta .icon { transition: transform .2s ease; }
.card-meta { font-size: .82rem; color: var(--ink-faint); font-weight: 600; }
.card-icon {
  display: inline-grid; place-items: center;
  width: 2.6rem; height: 2.6rem; border-radius: 12px;
  color: #fff; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #fff));
}
.section-card .card-links { list-style: none; margin: .75rem 0 0; padding: .75rem 0 0; border-top: 1px solid var(--border); display: grid; gap: .4rem; }
.section-card .card-links a { color: var(--ink-soft); font-size: .92rem; }
.section-card .card-links a:hover { color: var(--accent); }

/* =========================================================================
   Content shell + prose
   ========================================================================= */
.content-shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 3vw, 2rem) 2rem;
}
.page-intro h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); margin: .25rem 0 .5rem; color: var(--teal-dark); }
.page-intro p { color: var(--ink-soft); max-width: 75ch; }

/* Text fills the full width of the content shell (not a narrow column),
   while the shell itself stays aligned with the header bar. */
.prose { width: 100%; }
.prose > * { max-width: 100%; }

.prose h1 {
  font-size: clamp(1.8rem, 1.3rem + 2vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  background: linear-gradient(120deg, var(--teal), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.prose h2 {
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.85rem);
  margin: 2.4rem 0 .9rem;
  padding-bottom: .35rem;
  color: var(--teal-dark);
  border-bottom: 2px solid var(--surface-2);
}
.prose h3 { font-size: 1.28rem; margin: 1.8rem 0 .6rem; color: var(--ink); }
.prose h4 { font-size: 1.08rem; margin: 1.4rem 0 .5rem; color: var(--ink); }
.prose p { margin: 0 0 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.4rem; }
.prose li { margin: .35rem 0; }
.prose li::marker { color: var(--teal); }

.prose strong { color: var(--ink); font-weight: 700; }
.prose blockquote {
  margin: 1.2rem 0; padding: .8rem 1.2rem;
  border-left: 4px solid var(--green);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
}

/* In-page anchors clear the sticky header */
.prose :is(h1, h2, h3, h4, h5, h6),
[id] { scroll-margin-top: calc(var(--header-h) + 16px); }

/* Header anchor links (markdown-it-anchor headerLink) */
.prose :is(h2, h3, h4) a {
  color: inherit;
  text-decoration: none;
}
.prose :is(h2, h3, h4) a:hover { color: var(--teal); }

/* Prose links */
.prose p a, .prose li a, .related a, .breadcrumbs a {
  color: var(--teal);
  font-weight: 600;
  background-image: linear-gradient(var(--teal), var(--teal));
  background-size: 0% 2px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size .25s ease, color .2s ease;
}
.prose p a:hover, .prose li a:hover { background-size: 100% 2px; color: var(--teal-dark); }

/* Inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--code-inline-bg);
  color: #155b6e;
  padding: .12em .4em;
  border-radius: 5px;
  border: 0;
}

/* =========================================================================
   Code blocks
   ========================================================================= */
.code-block {
  position: relative;
  margin: 1.4rem 0;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  box-shadow: var(--shadow);
}
.code-block::after {
  content: attr(data-lang);
  position: absolute;
  top: .5rem; left: .85rem;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}
.code-block pre {
  margin: 0;
  padding: 2.1rem 1.1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .9rem;
  line-height: 1.6;
  color: #243b43;
}
.code-block code { font-family: inherit; }
.copy-btn {
  position: absolute;
  top: .5rem; right: .5rem;
  z-index: 2;
  font: 600 .72rem/1 var(--font-body);
  letter-spacing: .03em;
  padding: .4rem .65rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .2s ease;
}
.copy-btn:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.copy-btn.copied { background: var(--green); color: #fff; border-color: var(--green); }

/* Prism light token theme tuned to the palette */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7f9aa3; font-style: italic; }
.token.punctuation { color: #5a6b73; }
.token.keyword, .token.boolean, .token.atrule, .token.important { color: #9b5de5; font-weight: 600; }
.token.string, .token.char, .token.attr-value, .token.regex { color: #2a9d8f; }
.token.number, .token.constant, .token.symbol { color: #c2602b; }
.token.function, .token.class-name { color: #1f6f8b; font-weight: 600; }
.token.operator, .token.entity, .token.url { color: #b5468a; }
.token.property, .token.tag, .token.attr-name { color: #1f6f8b; }
.token.builtin, .token.namespace { color: #155367; }
.token.deleted { color: #c0392b; }
.token.inserted { color: #2a9d8f; }

/* =========================================================================
   Tables
   ========================================================================= */
.table-wrap {
  overflow-x: auto;
  margin: 1.4rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 460px; font-size: .94rem; }
.table-wrap th, .table-wrap td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); }
.table-wrap thead th { background: var(--surface-2); color: var(--teal-dark); font-weight: 700; position: sticky; top: 0; }
.table-wrap tbody tr:nth-child(even) { background: #fafcfd; }
.table-wrap tbody tr:hover { background: var(--surface-2); }

/* =========================================================================
   Task-list checkboxes
   ========================================================================= */
.prose ul:has(> .task-list-item) { list-style: none; padding-left: .2rem; }
.prose .task-list-item { list-style: none; margin: .5rem 0; }
.prose .task-list-item::marker { content: ""; }
.prose .task-list-item > label {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  cursor: pointer;
}
.prose .task-list-item.is-checked > label { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--ink-faint); }
.task-list-item-checkbox {
  appearance: none;
  -webkit-appearance: none;
  margin: .28em 0 0;
  width: 1.15em; height: 1.15em;
  flex: none;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  position: relative;
}
.task-list-item-checkbox:hover { border-color: var(--teal); }
.task-list-item-checkbox:checked { background: var(--green); border-color: var(--green); }
.task-list-item-checkbox:checked::after {
  content: "";
  position: absolute;
  left: .32em; top: .12em;
  width: .3em; height: .58em;
  border: solid #fff;
  border-width: 0 .16em .16em 0;
  transform: rotate(45deg);
}

/* =========================================================================
   Breadcrumbs / related / subpages
   ========================================================================= */
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0 0 1.5rem; padding: 0; font-size: .9rem; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-faint); }
.breadcrumbs .crumb-sep { color: var(--border-strong); width: .9em; height: .9em; }
.breadcrumbs [aria-current=page] { color: var(--ink-soft); font-weight: 600; }

.subpages { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.subpages-title, .related-title { font-size: 1.35rem; margin: 0 0 1.1rem; color: var(--teal-dark); }

.related { margin-top: 2.5rem; padding: 1.5rem; background: var(--surface-2); border-radius: var(--radius); }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.related-up a { font-weight: 700; }
.related a { color: var(--teal); }
.related a:hover { color: var(--teal-dark); }
.related .icon { width: 1em; height: 1em; }

.index-section { margin: 2.5rem 0; }
.index-section-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.index-section-head h2 { margin: 0 0 .3rem; font-size: 1.5rem; }
.index-section-head h2 a { color: var(--teal-dark); }
.index-section-head p { margin: 0; color: var(--ink-soft); }

/* =========================================================================
   FAQ accordions / mermaid / math
   ========================================================================= */
.faq { display: grid; gap: .75rem; margin: 1.2rem 0; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.faq-item summary {
  cursor: pointer; list-style: none;
  padding: 1rem 1.2rem; font-weight: 650; color: var(--teal-dark);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.4rem; color: var(--teal); transition: transform .2s ease; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover { background: var(--surface-2); }
.faq-item > :not(summary) { padding: 0 1.2rem; }
.faq-item > :not(summary):last-child { padding-bottom: 1rem; }

.mermaid { text-align: center; margin: 1.4rem 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.25rem 1rem; overflow-x: auto; }
.mermaid > svg { max-width: 100%; height: auto; }

/* Caption rendered under a diagram (markdown italic line immediately after) */
.diagram-caption { text-align: center; font-size: .9rem; color: var(--ink-faint); margin: -0.6rem 0 1.6rem; }

/* Zoomable diagram affordance */
.diagram-zoomable { position: relative; cursor: zoom-in; transition: border-color .2s ease, box-shadow .2s ease; }
.diagram-zoomable:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.diagram-zoomable:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.diagram-zoom-hint {
  position: absolute;
  top: .6rem; right: .6rem;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .55rem;
  font-size: .72rem; font-weight: 650;
  color: var(--teal-dark);
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: 999px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.diagram-zoom-hint svg { width: 14px; height: 14px; }
.diagram-zoomable:hover .diagram-zoom-hint,
.diagram-zoomable:focus-visible .diagram-zoom-hint { opacity: 1; transform: translateY(0); }

/* Fullscreen lightbox */
body.no-scroll { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(15, 35, 43, .82);
  backdrop-filter: blur(4px);
  animation: lb-fade .18s ease;
}
.lightbox[hidden] { display: none; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox-content {
  margin: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 2.25rem);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  max-width: 96vw; max-height: 92vh;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.lightbox-close {
  position: absolute; top: clamp(.75rem, 2vw, 1.5rem); right: clamp(.75rem, 2vw, 1.5rem);
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  font-size: 1.8rem; line-height: 1;
  color: #fff; background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%; cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .28); transform: rotate(90deg); }
.math-block { margin: 1.4rem 0; overflow-x: auto; padding: .5rem 0; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 720px) {
  .footer-inner { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .nav-link span { display: none; }
  .nav-link { padding: .55rem; }
  .hero-text { text-align: left; }
}

@media (min-width: 1400px) {
  :root { --shell: 1480px; --maxw: 1480px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 404 page */
.error-page { text-align: center; padding: 2rem 0 3rem; }
.error-page .error-code {
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 800; line-height: 1; margin: 0;
  background: linear-gradient(120deg, var(--teal), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-page ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.error-page ul li a {
  display: inline-block; padding: .5rem 1rem; border-radius: 999px;
  background: var(--surface-2); color: var(--teal-dark); font-weight: 600;
}
.error-page ul li a:hover { background: var(--teal); color: #fff; }

html { scroll-behavior: smooth; }
