/* SPDX-FileCopyrightText: 2026 Olivier Guyon et al
   SPDX-License-Identifier: LGPL-3.0-or-later */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 2.5px;
  background: linear-gradient(90deg, var(--accent), var(--cat-online_calib), var(--good));
  z-index: 95;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, width 0.08s linear;
}

.reading-progress.visible {
  opacity: 1;
}

.page-shell {
  width: 100%;
  max-width: none;
  margin: 1.15rem 0 2.5rem;
  padding: 0 1.25rem;
}

.page-shell.has-sidebar {
  display: grid;
  grid-template-columns: clamp(260px, 18vw, 330px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

body.sidebar-collapsed .page-shell.has-sidebar {
  grid-template-columns: minmax(0, 1fr);
}

body.sidebar-collapsed .site-sidebar {
  display: none;
}

main.container {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.page-shell.has-sidebar main.container {
  max-width: none;
}

/* Comfortable reading line length for narrative prose while keeping tables,
   charts, explorers, code blocks, and figure grids full-bleed. */
main.container > p,
main.container > ul,
main.container > ol,
main.container > blockquote.callout {
  max-width: 82ch;
}

@media (max-width: 1024px) {
  .page-shell.has-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .page-shell {
    margin: 0.65rem auto 2rem;
    padding: 0 0.65rem;
  }
  main.container { padding: 1rem; border-radius: 10px; }
}

h1, h2, h3, h4 {
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-top: 1.7rem;
  margin-bottom: 0.72rem;
  scroll-margin-top: calc(var(--header-h, 4.5rem) + 1rem);
}

h1 {
  margin-top: 0;
  font-size: 1.72rem;
  font-weight: 750;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.55rem;
}

h2 {
  font-size: 1.28rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.34rem;
}

h3 {
  font-size: 1.08rem;
  font-weight: 650;
}

.heading-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.42rem;
  padding: 0.08rem 0.32rem;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72em;
  font-weight: 600;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  opacity: 0;
  vertical-align: middle;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

h2:hover > .heading-anchor,
h3:hover > .heading-anchor,
h4:hover > .heading-anchor,
.heading-anchor:focus-visible,
.heading-anchor.copied {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--border);
}

.heading-anchor.copied {
  color: var(--good);
  background: var(--good-soft);
  border-color: var(--good);
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.14rem 0.36rem;
  border-radius: 5px;
}

.pre-wrap {
  position: relative;
  margin: 0.9rem 0;
}

pre {
  background: var(--pre-bg);
  color: var(--pre-text);
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  overflow-x: auto;
  font-size: 0.835rem;
  line-height: 1.55;
  margin: 0;
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  border-radius: 0;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  padding: 0.22rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #334155;
  background: rgba(30, 41, 59, 0.92);
  color: #e2e8f0;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.copy-btn:hover {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.copy-btn.copied {
  opacity: 1;
  background: #047857;
  border-color: #10b981;
  color: #ffffff;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--muted); font-size: 0.88em; }
.hidden { display: none !important; }

.site-footer {
  width: 100%;
  max-width: none;
  margin: 0 0 2rem;
  padding: 0.4rem 1.25rem 0;
  color: var(--muted);
  font-size: 0.84rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
