/* pyssg docs theme - self-contained, no external dependencies.
   Light and dark palettes follow the OS color-scheme preference, matching the
   Highlight plugin's code stylesheet. */

:root {
  --brand: #5145cd;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --brand-contrast: #ffffff;

  --bg: #ffffff;
  --bg-soft: #f9fafb;
  --bg-mute: #f3f4f6;
  --bg-elevated: #ffffff;

  --fg: #1f2328;
  --fg-soft: #4b5563;
  --fg-mute: #6b7280;

  --border: #e5e7eb;
  --border-soft: #eef0f2;

  --code-bg: #f6f8fa;
  --code-fg: #24292f;
  --code-inline-bg: #eef1f4;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);

  --radius: 8px;
  --radius-lg: 14px;
  --max: 1320px;
  --content-max: 760px;
  --sidebar-w: 276px;
  --header-h: 60px;

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

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #a5b4fc;
    --brand-strong: #c7d2fe;
    --brand-soft: #1e1b4b;
    --brand-contrast: #1e1b2e;

    --bg: #0d1117;
    --bg-soft: #131a23;
    --bg-mute: #161d27;
    --bg-elevated: #161d27;

    --fg: #e6edf3;
    --fg-soft: #b6c2cf;
    --fg-mute: #8b949e;

    --border: #232b36;
    --border-soft: #1c232d;

    --code-bg: #161b22;
    --code-fg: #c9d1d9;
    --code-inline-bg: #1c2430;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  text-decoration: underline;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--header-h);
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: block;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
}

.topbar .tagline {
  flex: 1;
  min-width: 0;
  color: var(--fg-mute);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  /* Hug the right edge at every width, even when the tagline (the flex spacer)
     is hidden on small screens. */
  margin-left: auto;
}
.topbar-link {
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--fg-soft);
  font-size: 14px;
  font-weight: 500;
}
.topbar-link:hover {
  background: var(--bg-mute);
  color: var(--fg);
  text-decoration: none;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 2px 6px 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
}
.lang-globe {
  color: var(--fg-mute);
  margin-right: 2px;
}
.lang-switcher .lang {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--fg-mute);
}
.lang-switcher a.lang:hover {
  color: var(--fg);
  background: var(--bg-mute);
  text-decoration: none;
}
.lang-switcher .lang.active {
  color: var(--brand-contrast);
  background: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: var(--max);
  margin: 0 auto;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 28px 14px 48px 24px;
}
.sidebar nav {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
}

.nav-home,
.nav-link {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--fg-soft);
  font-size: 14px;
  line-height: 1.45;
}
.nav-home {
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}
.nav-header {
  display: block;
  margin: 18px 0 4px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-mute);
}
.nav-link:hover,
.nav-home:hover {
  background: var(--bg-mute);
  color: var(--fg);
  text-decoration: none;
}
.nav-link.active,
.nav-home.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}
.nav-children {
  margin: 2px 0 2px 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

/* ---------- Content ---------- */

.content {
  min-width: 0;
  padding: 40px 56px 80px;
}
.content article {
  max-width: var(--content-max);
}

article h1,
article h2,
article h3,
article h4 {
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.015em;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
article h1 {
  font-size: 2.2rem;
  margin: 0 0 0.6em;
}
article h2 {
  font-size: 1.5rem;
  margin: 2.2em 0 0.7em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
article h3 {
  font-size: 1.2rem;
  margin: 1.6em 0 0.5em;
}
article h4 {
  font-size: 1.02rem;
  margin: 1.3em 0 0.4em;
}

article p,
article ul,
article ol {
  margin: 0.85em 0;
}
article li {
  margin: 0.35em 0;
}
article li::marker {
  color: var(--fg-mute);
}

article strong {
  font-weight: 650;
  color: var(--fg);
}

article hr {
  margin: 2.4em 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* Anchor links generated by the toc extension */
.headerlink {
  margin-left: 0.35em;
  color: var(--fg-mute);
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
h1:hover .headerlink,
h2:hover .headerlink,
h3:hover .headerlink,
h4:hover .headerlink {
  opacity: 1;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-inline-bg);
  padding: 0.16em 0.42em;
  border-radius: 5px;
}
a code {
  color: inherit;
}

pre {
  margin: 1.1em 0;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  color: var(--code-fg);
}
.highlight {
  margin: 1.1em 0;
  border-radius: var(--radius);
  overflow: hidden;
}
.highlight pre {
  margin: 0;
}

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

article table {
  width: 100%;
  margin: 1.3em 0;
  border-collapse: collapse;
  font-size: 0.92em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
article th,
article td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
article th {
  background: var(--bg-soft);
  font-weight: 600;
}
article tbody tr:last-child td {
  border-bottom: none;
}
article tbody tr:hover {
  background: var(--bg-soft);
}

/* ---------- Blockquote / callouts ---------- */

article blockquote {
  margin: 1.2em 0;
  padding: 0.6em 1.1em;
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-soft);
  color: var(--fg-soft);
}
article blockquote p {
  margin: 0.4em 0;
}

/* ---------- Hero (home) ---------- */

.hero {
  padding: 28px 0 8px;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 600;
}
.hero-title {
  margin: 20px 0 0;
  font-size: 3.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  background: linear-gradient(120deg, var(--fg) 30%, var(--brand) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-tagline {
  margin: 18px 0 0;
  max-width: 640px;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--fg-soft);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--brand);
  color: var(--brand-contrast);
}
.btn-primary:hover {
  background: var(--brand-strong);
}
.btn-ghost {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--fg);
}
.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

/* ---------- Feature cards ---------- */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 40px 0;
}
.feature {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  transition: border-color 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
}
.feature:hover {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.feature h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}
.feature p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--fg-soft);
  line-height: 1.55;
}
.feature-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* ---------- Prev / next ---------- */

.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.prevnext a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.prevnext a:hover {
  border-color: var(--brand);
  text-decoration: none;
}
.prevnext .next {
  text-align: right;
  grid-column: 2;
}
.prevnext .pn-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-mute);
}
.prevnext .pn-title {
  font-weight: 600;
  color: var(--fg);
}

/* ---------- List pages ---------- */

.entry-list {
  list-style: none;
  padding: 0;
  margin: 1.4em 0 0;
  display: grid;
  gap: 12px;
}
.entry {
  margin: 0;
}
.entry a {
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-weight: 600;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.entry a:hover {
  border-color: var(--brand);
  transform: translateX(2px);
  text-decoration: none;
}

/* ---------- Footer ---------- */

.sitefoot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 56px 48px;
  border-top: 1px solid var(--border);
  color: var(--fg-mute);
  font-size: 14px;
}

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  :root {
    --content-max: 100%;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
  }
  .sidebar nav {
    position: static;
    max-height: none;
  }
  .content {
    padding: 28px 20px 64px;
  }
  .topbar .tagline {
    display: none;
  }
  .hero-title {
    font-size: 2.4rem;
  }
  .prevnext {
    grid-template-columns: 1fr;
  }
  .prevnext .next {
    grid-column: 1;
    text-align: left;
  }
  .sitefoot {
    padding: 24px 20px 40px;
  }
}
