/* TZPL docs site shell: fixed header, docs menu, prev/next links, and the
   overrides that let the shell coexist with each page's own self-contained
   styling. Injected into every staged page by site/build.py. Theme follows
   the pages' existing convention: dark by default, `html.light` for light,
   persisted under the `tzpl-docs-theme` localStorage key. */

:root {
  --tzpl-header-h: 3rem;
  --tzpl-sh-bg: #16171f;
  --tzpl-sh-border: #2a2d3a;
  --tzpl-sh-fg: #c9d1d9;
  --tzpl-sh-muted: #8b949e;
  --tzpl-sh-accent: #58a6ff;
  --tzpl-sh-hover: #21222c;
}
html.light {
  --tzpl-sh-bg: #f8f9fb;
  --tzpl-sh-border: #e2e5ea;
  --tzpl-sh-fg: #1a1a1a;
  --tzpl-sh-muted: #64748b;
  --tzpl-sh-accent: #2563eb;
  --tzpl-sh-hover: #eef0f4;
}

/* ---- Coexistence overrides ------------------------------------------- */

html { scroll-padding-top: calc(var(--tzpl-header-h) + 1rem); }
body { padding-top: var(--tzpl-header-h) !important; }

/* Family-A pages: full-height sticky per-page TOC sidebar starts below the
   fixed header instead of underneath it. */
body > nav.sidebar {
  top: var(--tzpl-header-h) !important;
  height: calc(100vh - var(--tzpl-header-h)) !important;
}

/* Family-B pages float their own theme toggle at the top right, which the
   header now occupies; the header provides the toggle instead. */
body > .theme-toggle { display: none !important; }

/* ---- Header ----------------------------------------------------------- */

.tzpl-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--tzpl-header-h);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1rem;
  background: var(--tzpl-sh-bg);
  border-bottom: 1px solid var(--tzpl-sh-border);
  color: var(--tzpl-sh-fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1;
}
.tzpl-header a { color: var(--tzpl-sh-fg); text-decoration: none; }
.tzpl-header a:hover { color: var(--tzpl-sh-accent); }

.tzpl-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  color: var(--tzpl-sh-accent) !important;
}

.tzpl-quicklinks { display: flex; gap: 0.9rem; }
.tzpl-quicklinks a { color: var(--tzpl-sh-muted); }

.tzpl-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.tzpl-theme {
  background: none;
  border: 1px solid var(--tzpl-sh-border);
  border-radius: 6px;
  color: var(--tzpl-sh-fg);
  font-size: 0.95rem;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
}
.tzpl-theme:hover { border-color: var(--tzpl-sh-accent); }

/* ---- Docs menu -------------------------------------------------------- */

.tzpl-menu { position: relative; }
.tzpl-menu summary {
  list-style: none;
  cursor: pointer;
  color: var(--tzpl-sh-fg);
  padding: 0.35rem 0.2rem;
  user-select: none;
}
.tzpl-menu summary::-webkit-details-marker { display: none; }
.tzpl-menu summary::after { content: " ▾"; color: var(--tzpl-sh-muted); font-size: 0.75em; }
.tzpl-menu[open] summary, .tzpl-menu summary:hover { color: var(--tzpl-sh-accent); }

.tzpl-menu-panel {
  position: absolute;
  top: calc(100% + 0.55rem);
  left: -0.5rem;
  min-width: 17rem;
  max-height: calc(100vh - var(--tzpl-header-h) - 2rem);
  overflow-y: auto;
  background: var(--tzpl-sh-bg);
  border: 1px solid var(--tzpl-sh-border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  padding: 0.85rem 1rem 1rem;
}
.tzpl-menu-section h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tzpl-sh-muted);
}
.tzpl-menu-section:first-child h3 { margin-top: 0; }
.tzpl-menu-section a {
  display: block;
  padding: 0.28rem 0.45rem;
  margin: 0 -0.45rem;
  border-radius: 5px;
  white-space: nowrap;
}
.tzpl-menu-section a:hover { background: var(--tzpl-sh-hover); }
.tzpl-menu-section a.tzpl-current-page {
  color: var(--tzpl-sh-accent);
  font-weight: 600;
}

/* ---- Prev/next footer links ------------------------------------------ */

.tzpl-prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 60rem;
  margin: 3.5rem auto 0;
  padding: 1.25rem 1.2rem 2.5rem;
  border-top: 1px solid var(--tzpl-sh-border);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
}
.tzpl-prevnext a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--tzpl-sh-accent);
  font-weight: 600;
  font-size: 0.95rem;
}
.tzpl-prevnext a:hover { text-decoration: underline; }
.tzpl-prevnext a span {
  font-weight: 400;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tzpl-sh-muted);
}
.tzpl-next { text-align: right; margin-left: auto; }

/* ---- Scroll-spy highlight in family-A page sidebars ------------------- */

nav.sidebar a.tzpl-spy-current {
  color: var(--tzpl-sh-accent);
  font-weight: 600;
}

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

@media (max-width: 720px) {
  .tzpl-quicklinks { display: none; }
  .tzpl-menu-panel { position: fixed; left: 0.5rem; right: 0.5rem; min-width: 0; }
}

/* ---- Search button in the header ------------------------------------- */

.tzpl-search-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--tzpl-sh-border);
  border-radius: 6px;
  color: var(--tzpl-sh-muted);
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}
.tzpl-search-btn:hover { border-color: var(--tzpl-sh-accent); color: var(--tzpl-sh-fg); }
.tzpl-search-btn kbd {
  font-family: inherit;
  font-size: 0.7rem;
  border: 1px solid var(--tzpl-sh-border);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  color: var(--tzpl-sh-muted);
}

/* ---- Search modal ----------------------------------------------------- */

.tzpl-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 1rem 0;
  background: rgba(0, 0, 0, 0.55);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
}
.tzpl-search-box {
  width: 100%;
  max-width: 40rem;
  background: var(--tzpl-sh-bg);
  border: 1px solid var(--tzpl-sh-border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.tzpl-search-input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--tzpl-sh-fg);
  font-size: 1.05rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--tzpl-sh-border);
}
.tzpl-search-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem 0.2rem;
}
.tzpl-search-chips:empty { display: none; }
.tzpl-chip {
  background: none;
  border: 1px solid var(--tzpl-sh-border);
  border-radius: 999px;
  color: var(--tzpl-sh-muted);
  font-size: 0.78rem;
  padding: 0.15rem 0.7rem;
  cursor: pointer;
}
.tzpl-chip:hover { color: var(--tzpl-sh-fg); }
.tzpl-chip-on {
  border-color: var(--tzpl-sh-accent);
  color: var(--tzpl-sh-accent);
}
.tzpl-search-results {
  overflow-y: auto;
  padding: 0.6rem 0.6rem 0.8rem;
}
.tzpl-search-results:empty { padding: 0; }
.tzpl-sr-group { margin-bottom: 0.35rem; }
.tzpl-sr {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--tzpl-sh-fg);
}
.tzpl-sr:hover, .tzpl-sr.tzpl-sel { background: var(--tzpl-sh-hover); }
.tzpl-sr-section {
  float: right;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tzpl-sh-muted);
  margin-left: 0.6rem;
}
.tzpl-sr strong { color: var(--tzpl-sh-accent); font-size: 0.95rem; }
.tzpl-sr p {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--tzpl-sh-muted);
}
.tzpl-sr mark {
  background: none;
  color: var(--tzpl-sh-fg);
  font-weight: 600;
}
.tzpl-sr-sub {
  display: block;
  margin: 0.1rem 0 0.1rem 1.4rem;
  padding: 0.25rem 0.65rem;
  border-left: 2px solid var(--tzpl-sh-border);
  border-radius: 0 6px 6px 0;
  font-size: 0.84rem;
  text-decoration: none;
  color: var(--tzpl-sh-fg);
}
.tzpl-sr-sub:hover, .tzpl-sr-sub.tzpl-sel { background: var(--tzpl-sh-hover); }
.tzpl-search-note {
  padding: 1rem 1.1rem;
  color: var(--tzpl-sh-muted);
  font-size: 0.9rem;
}

/* ---- Split-page chrome: breadcrumb, chapter list, edit link ----------- */

.tzpl-crumb {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 1rem;
}
.tzpl-crumb a { color: var(--tzpl-sh-muted); text-decoration: none; }
.tzpl-crumb a:hover { color: var(--tzpl-sh-accent); }

.tzpl-chapters {
  columns: 2;
  gap: 2rem;
  list-style: none;
  padding-left: 0;
  margin: 1rem 0 2rem;
}
@media (max-width: 720px) { .tzpl-chapters { columns: 1; } }
.tzpl-chapters li { margin: 0.3rem 0; break-inside: avoid; }
.tzpl-chapters a { color: var(--tzpl-sh-accent); text-decoration: none; font-weight: 600; }
.tzpl-chapters a:hover { text-decoration: underline; }

.tzpl-editlink {
  text-align: center;
  font-size: 0.8rem;
  margin: 0 0 2rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
}
.tzpl-editlink a { color: var(--tzpl-sh-muted); text-decoration: none; }
.tzpl-editlink a:hover { color: var(--tzpl-sh-accent); }
.tzpl-foot .tzpl-prevnext { padding-bottom: 1rem; }
