/*
 * (c) Copyright 2026, Nostos Genomics
 * IFU presentation layer — loaded after bootstrap.css, style.css and custom.css.
 * Presentation only: no content is added here except the callout labels (NOTE / WARNING).
 *
 * Colour tokens (WCAG 2.2 AA contrast on white in brackets):
 *   text        #1f2933 (14.8:1)   muted text  #52606d (6.4:1)
 *   heading     #04444D (10.8:1)   link/teal   #006d79 (6.1:1)
 *   brand teal  #008594 (borders and fills only, 4.4:1)
 */

:root {
  --ifu-text: #1f2933;
  --ifu-muted: #52606d;
  --ifu-heading: #04444D;
  --ifu-link: #006d79;
  --ifu-brand: #008594;
  --ifu-border: #d9e2e6;
  --ifu-zebra: #f7f9fa;
  --ifu-note-bg: #eef7f8;
  --ifu-note-bar: #008594;
  --ifu-warn-bg: #fff4e5;
  --ifu-warn-bar: #c2410c;
  --ifu-warn-text: #7c2d12;
  --ifu-code-bg: #f1f4f6;
  --ifu-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ifu-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- Base typography ---------- */

/* Bootstrap 3 sets html{font-size:10px}; reset so rem = 16px */
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--ifu-font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ifu-text);
  -webkit-font-smoothing: antialiased;
}

.content p,
.content li,
.content dd {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ifu-text);
}

.content p {
  margin: 0 0 1rem;
  padding: 0;
}

.content ul,
.content ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.content li { margin: 0.25rem 0; }
.content li > p { margin-bottom: 0.25rem; }
.content li ul, .content li ol { margin: 0.25rem 0 0.5rem; }
ol li ul li { padding-left: 0; }

strong { color: inherit; font-weight: 600; }

/* ---------- Links & focus ---------- */

a, .btn { text-decoration: none; }

.content a {
  color: var(--ifu-link);
  text-decoration: underline !important;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.content a:hover { color: var(--ifu-heading); text-decoration-thickness: 2px; }

a:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ifu-link) !important;
  outline-offset: 2px;
}

/* ---------- Headings ---------- */

.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
  font-family: var(--ifu-font);
  color: var(--ifu-heading);
  line-height: 1.3;
  padding: 0;
  scroll-margin-top: 1rem;
}

/* Chapter */
.content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 3.5rem 0 1.25rem;
  padding-top: 1.5rem;
  border-top: 3px solid var(--ifu-brand);
}

/* Section */
.content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--ifu-border);
}

.content h3 { font-size: 1.25rem; font-weight: 600; margin: 2.25rem 0 0.75rem; }
.content h4 { font-size: 1.0625rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }
.content h5 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; color: var(--ifu-text); }
.content h6 { font-size: 0.9375rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: var(--ifu-muted); }

/* Section numbers: present but quieter than the title */
.content .header-section-number {
  color: var(--ifu-muted);
  font-weight: 500;
  margin-right: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Code ---------- */

code {
  font-family: var(--ifu-mono);
  font-size: 0.875em;
  color: var(--ifu-text);
  background: var(--ifu-code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  white-space: pre-wrap;
}

pre {
  font-family: var(--ifu-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ifu-text);
  background: var(--ifu-code-bg);
  border: 1px solid var(--ifu-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

pre code { background: none; padding: 0; white-space: pre; }

/* ---------- Tables ---------- */

.content table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  border: 1px solid var(--ifu-border);
  margin: 1.25rem 0 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  background: #fff;
}

.content th,
.content td {
  border: 0;
  border-bottom: 1px solid var(--ifu-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
  color: var(--ifu-text);
  line-height: 1.5;
}

.content td + td,
.content th + th { border-left: 1px solid var(--ifu-border); }

.content thead th,
.content table > tbody > tr:first-child > th {
  background: var(--ifu-link);
  color: #fff;
  font-weight: 600;
  border-bottom: 0;
}

/* HTML tables without <thead>: a first row where every cell is a single bold label acts as the header */
.content table:not(:has(> thead)) > tbody > tr:first-child:not(:has(> td:not(:has(> strong:only-child)))) > td {
  background: #e8f1f3;
  color: var(--ifu-heading);
  font-weight: 600;
}

.content tbody tr:nth-child(even) { background: var(--ifu-zebra); }
.content tbody tr:hover { background: #eef4f6; }

.content td p, .content th p { margin: 0 0 0.5rem; max-width: none; }
.content td p:last-child, .content th p:last-child { margin-bottom: 0; }
.content td ul, .content td ol { margin: 0; max-width: none; }

/* Sticky header row on long tables (screen only) */
@media screen {
  .content thead th { position: sticky; top: 0; z-index: 1; }
}

/* Narrow screens: wide tables scroll instead of squeezing */
@media (max-width: 767px) {
  .content table { display: block; overflow-x: auto; }
}

/* ---------- Callouts (NOTE / WARNING) ---------- */

.hs-callout-type-note,
.hs-callout-type-warning,
.hs-callout-type-tip {
  position: relative;
  margin: 1.25rem 0 1.5rem;
  padding: 2.1rem 1rem 0.85rem 1.1rem;
  border: 0;
  border-left: 4px solid var(--ifu-note-bar);
  border-radius: 0 6px 6px 0;
  background: var(--ifu-note-bg);
  color: var(--ifu-text);
  line-height: 1.6;
  break-inside: avoid;
}

.hs-callout-type-note::before,
.hs-callout-type-warning::before,
.hs-callout-type-tip::before {
  position: absolute;
  top: 0.6rem;
  left: 1.1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hs-callout-type-note::before { content: "Note"; color: var(--ifu-link); }

.hs-callout-type-warning {
  border-left-color: var(--ifu-warn-bar);
  background: var(--ifu-warn-bg);
}
.hs-callout-type-warning::before { content: "Warning"; color: var(--ifu-warn-text); }

.hs-callout-type-tip { border-left-color: #2f855a; background: #f0f9f4; }
.hs-callout-type-tip::before { content: "Tip"; color: #22543d; }

.hs-callout-type-note p,
.hs-callout-type-warning p,
.hs-callout-type-tip p { margin: 0 0 0.5rem; }
.hs-callout-type-note > :last-child,
.hs-callout-type-warning > :last-child,
.hs-callout-type-tip > :last-child { margin-bottom: 0; }

/* ---------- Images ---------- */

.content img {
  max-width: 100%;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Screenshots (marked by js/custom.js from their natural size) */
.content img.ifu-screenshot {
  display: block;
  max-width: min(100%, 900px);
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--ifu-border);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(16, 42, 67, 0.08);
}

.content .hs-callout-type-note img,
.content .hs-callout-type-warning img,
.content .hs-callout-type-tip img,
.content img[src*="favicon"] {
  max-width: 24px;
  vertical-align: middle;
  display: inline;
  margin: 0;
  border: 0;
  box-shadow: none;
}

/* ---------- Page frame ---------- */

.ifu-header {
  border-bottom: 1px solid var(--ifu-border);
  padding: 2.5rem 1rem 2rem;
  text-align: center;
}

.ifu-header img { width: 56px; height: 56px; }

.ifu-header h1.title {
  font-family: var(--ifu-font);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--ifu-heading);
  margin: 0.75rem 0 0.25rem;
  padding: 0;
  line-height: 1.2;
}

.ifu-header .ifu-subtitle {
  color: var(--ifu-muted);
  font-size: 1rem;
  margin: 0;
  padding: 0;
}

.ifu-header .ifu-version {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--ifu-border);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--ifu-muted);
  font-variant-numeric: tabular-nums;
}

/* One width for everything in the column (text, tables, headings, callouts):
   52rem of content keeps lines readable (~90 characters) and tables aligned with the text.
   On wide screens the column is centred in the space next to the sidebar. */
.content {
  padding: 1rem 2rem 4rem 2.5rem;
  max-width: calc(52rem + 4.5rem);
  box-sizing: border-box;
}

/* ---------- Sidebar / table of contents ---------- */

.docs-sidebar {
  font-family: var(--ifu-font);
  padding: 1.25rem 1rem 2rem 1.25rem;
}

@media (min-width: 992px) {
  .docs-sidebar {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--ifu-border);
  }
}

.ifu-switchers {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.ifu-switchers select.form-control {
  margin: 0 !important;
  width: auto;
  height: 32px;
  padding: 0.2rem 0.5rem;
  font-size: 0.875rem;
  color: var(--ifu-text);
}

.ifu-toc-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ifu-muted);
  margin: 0.5rem 0 0.5rem;
}

.docs-sidebar .nav > li > a {
  color: var(--ifu-text);
  font-size: 0.9375rem;
  line-height: 1.4;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  border-left: 2px solid transparent;
}

.docs-sidebar .nav .nav > li { padding-left: 0.75rem; font-size: 0.875rem; }
.docs-sidebar ul.nav ul.nav ul.nav > li { padding-left: 0.75rem; font-size: 0.8125rem; }
.docs-sidebar ul.nav ul.nav ul.nav ul.nav > li { padding-left: 0.75rem; font-size: 0.8125rem; }

.docs-sidebar .nav .nav > li > a { color: var(--ifu-muted); padding-top: 0.2rem; padding-bottom: 0.2rem; }

.docs-sidebar .nav li > a > span.toc-section-number {
  color: var(--ifu-muted);
  min-width: 2.25rem;
  font-variant-numeric: tabular-nums;
}

.docs-sidebar .nav > li:not(.active) > a:hover {
  color: var(--ifu-link);
  background: #f2f7f8;
  border-left: 2px solid var(--ifu-border);
}

.docs-sidebar .nav > .active > a,
.docs-sidebar .nav > .active:hover > a,
.docs-sidebar .nav > .active:focus > a {
  color: var(--ifu-link);
  background: #eef6f7;
  border-left: 2px solid var(--ifu-link);
  font-weight: 600;
}

@media (min-width: 992px) {
  /* Chapters always visible; sections only for the active chapter; deeper levels for the active branch */
  .docs-sidebar ul.nav ul.nav { display: none; padding-bottom: 0.25rem; }
  .docs-sidebar ul.nav li.active > ul.nav { display: block; }
}

/* ---------- Small screens ---------- */

@media (max-width: 991px) {
  .content { padding: 1rem 1rem 3rem; }
  .docs-sidebar { border-bottom: 1px solid var(--ifu-border); max-height: none; }
  .docs-sidebar ul.nav ul.nav { display: none; }
}

/* ---------- Print (browser print; the CI PDF uses css/ifu-print.css) ---------- */

@media print {
  .docs-sidebar, .ifu-switchers, #versionSwitcher, #languageSwitcher { display: none !important; }
  .col-md-9 { width: 100% !important; }
  body { font-size: 10.5pt; }
  .content p, .content ul, .content ol, .content h1, .content h2,
  .content h3, .content h4, .hs-callout-type-note, .hs-callout-type-warning { max-width: none; }
  .content { max-width: none; }
  .content h1, .content h2, .content h3, .content h4 { break-after: avoid; }
  .content tr, .content img, .hs-callout-type-note, .hs-callout-type-warning { break-inside: avoid; }
  .content thead { display: table-header-group; }
  .content a { color: var(--ifu-link) !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Two-column layout: the sidebar column spans the page so the TOC can stick ---------- */

@media (min-width: 992px) {
  .ifu-layout { display: flex; align-items: stretch; margin-left: 0; }
  .ifu-layout > [class*="col-"] { float: none; }
  .ifu-layout > .col-md-3 { flex: 0 0 300px; max-width: 300px; padding: 0; }
  .ifu-layout > .col-md-9 { flex: 1 1 0; width: auto; min-width: 0; margin-left: auto; margin-right: auto; }
  /* Centre the title over the text column, not over the whole page (the sidebar is 300px wide) */
  .ifu-header { padding-left: calc(300px + 1rem); }
}
