/* A wider page than tabi's default (1000px): text and code blocks share it;
   tighter line spacing in articles (tabi: double-spaced); tables left-aligned. */
:root {
  --max-layout-width: 1200px;
}

article p,
article li {
  line-height: 1.6;
}

/* Table text aligned left (tabi centres it). */
article table,
article table th {
  text-align: start;
}

/* Section levels that are easy to tell apart: h2 larger, with a rule above
   and more space; h3 smaller and closer to its text. */
article h2 {
  font-size: 1.55rem;
  margin-top: 2.2em;
  padding-top: 0.7em;
  border-top: 1px solid var(--divider-color);
}

article h3 {
  font-size: 1.12rem;
  margin-top: 1.6em;
}

/* The same gap under every heading, whatever follows it: tabi gives
   paragraphs a small top margin and lists none. Margins collapse, so the
   heading's bottom margin sets the gap in both cases. */
article :is(h2, h3, h4) {
  margin-bottom: 0.8rem;
}

/* The first section (Overview) sits right under the title and the table
   of contents: no rule or extra space above it. */
article section.body > h2:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* Series navigation (templates/components/series_page.html): an "All parts"
   heading like "Table of contents", and below it the parts in one row,
   "Part 1 · Part 2 · …", the current part in bold. */
.series-page-intro {
  margin-block-end: 3.5rem;
}

.series-page-intro h3 {
  margin-top: 0.6rem;
  margin-bottom: 0.3rem;
}

/* Under the date line, the series block follows directly. */
article:has(.series-page-intro) ul.meta {
  margin-bottom: 0;
}

/* The browser closes tabi's <p> before the heading and the list. */
.series-page-intro p:empty {
  display: none;
}

.series-page-intro ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  margin: 0;
  padding: 0;
}

.series-page-intro li {
  list-style: none;
}

.series-page-intro li + li::before {
  content: "·";
  margin-inline-end: 0.8rem;
  color: var(--meta-color);
}

.series-page-intro li[aria-current="page"] {
  font-weight: 600;
}

/* Figures open full size on click (static/js/lightbox.js). */
figure img.zoomable {
    cursor: zoom-in;
}
html.lightbox-open {
    overflow: hidden;
}
dialog.lightbox {
    max-width: 100vw;
    max-height: 100vh;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-out;
    outline: none;
}
dialog.lightbox::backdrop {
    background: rgba(0, 0, 0, 0.88);
}
dialog.lightbox img {
    display: block;
    max-width: 96vw;
    max-height: 94vh;
    margin: 3vh auto;
}
.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
    opacity: 1;
}

/* Lists in admonitions line up with the paragraphs, which tabi pulls left
   under the icon, and keep the paragraphs' spacing. */
.admonition-content > ul,
.admonition-content > ol {
  margin-inline-start: -1.75rem;
  margin-block-end: 0;
  padding-inline-start: 1.5rem;
}

/* Run timelines: a paragraph that starts with a time mark
   (<span class="t">T+5 min</span>) reads as a log entry, with space above
   and the mark as a small monospace tag. */
article p:has(> .t:first-child) {
  margin-block-start: 2.2rem;
}
article p > .t:first-child {
  display: inline-block;
  margin-inline-end: 0.5rem;
  padding: 0 0.45rem;
  border-radius: 4px;
  font-family: var(--code-font, ui-monospace, monospace);
  font-size: 0.85em;
  color: var(--air, #a99cff);
  background: rgba(169, 156, 255, 0.1);
}

/* A coloured square before each section heading, so headings stand out
   when scrolling: violet and larger for h2, mint and smaller for h3. The
   uppercase labels (table of contents, series navigation) get none. */
article h2::before,
article h3:not(.series-page-intro h3, :has(+ .toc-container))::before {
  content: "";
  display: inline-block;
  vertical-align: middle;
  margin-inline-end: 0.55em;
  border-radius: 2px;
  position: relative;
  top: -0.08em;
}
article h2::before {
  width: 0.5em;
  height: 0.5em;
  background: var(--air, #a99cff);
}
article h3:not(.series-page-intro h3, :has(+ .toc-container))::before {
  width: 0.42em;
  height: 0.42em;
  background: rgb(120, 220, 170);
}
