/* plasmoid — owned docs chrome. Small, no framework. Light/dark via CSS variables.
 *
 * COLOUR tokens (--bg, --fg, --accent, …, themed light/dark) come from the generated
 * /assets/tokens.css, which is linked BEFORE this file and is project-overridable
 * (drop a docs/tokens.css). Only theme-independent LAYOUT tokens live here. */

:root {
  /* Layout + spacing tokens (theme-independent). Colours: see /assets/tokens.css. */
  --sidebar-w: 17rem;
  --toc-w: 14rem;
  --topbar-h: 3.25rem;
  --maxw: 72rem;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--topbar-h) + 1rem); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Pointer (hand) cursor on every interactive control — links, buttons, and the
   native <details> disclosures used for nav groups and the version/language
   switchers. Global so menus never fall back to the default arrow cursor. */
a[href], button, summary, label[for], [role="button"] { cursor: pointer; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Visible keyboard focus everywhere (mouse clicks stay clean via :focus-visible). */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
/* main is focusable only as the skip-link target; don't ring it. */
main:focus-visible { outline: none; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--fg); font-size: 1.05rem; display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 1.6rem; width: auto; display: block; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  height: 2rem;
  min-width: 2rem;
  cursor: pointer;
  font-size: 1rem;
}
.icon-btn:hover { background: var(--bg-alt); }
#sidebar-toggle { display: none; }

/* Version/language switchers: native <details> disclosure of real <a> links
   (no JS, keyboard-accessible, middle-clickable). */
.switcher { position: relative; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 2rem;
  padding: 0 0.5rem;
  cursor: pointer;
  list-style: none;          /* drop the default disclosure triangle (Firefox) */
  white-space: nowrap;
  font-size: 0.85rem;
}
.switch::-webkit-details-marker { display: none; }  /* and WebKit */
.switch::after {
  content: "\25BE";          /* ▾ */
  font-size: 0.8em;
  color: var(--fg-muted);
}
.switch:hover { background: var(--bg-alt); }
.switcher-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  z-index: 50;
}
.switcher-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  color: var(--fg);
  font-size: 0.9rem;
  white-space: nowrap;
}
.switcher-item:hover { background: var(--bg-alt); text-decoration: none; }
.switcher-item.current { color: var(--accent); font-weight: 600; }
/* "latest" pill on the newest version in the switcher */
.ver-latest {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  color: #fff;
  background: var(--grad-accent);
}

/* Search — centered in the topbar (absolutely positioned over the flex row). */
.search {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(42rem, 48vw);
}
#search-input {
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 2rem;
  padding: 0 0.7rem;
  width: 100%;
}
.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 2.4rem;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 0.4rem;
}
.search-results a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  color: var(--fg);
}
.search-results a:hover, .search-results a.active { background: var(--bg-alt); text-decoration: none; }
.search-results .sr-title { font-weight: 600; }
.search-results .sr-ctx { color: var(--fg-muted); font-size: 0.85rem; }
.search-results .sr-empty { padding: 0.6rem; color: var(--fg-muted); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
/* Collapsible nav groups (native <details>, no JS). The active page's ancestor
   groups get `open` at build time. */
.nav-group { margin: 0.5rem 0; }
.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin-bottom: 0.35rem;
}
summary.nav-section-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  list-style: none;          /* drop the default disclosure triangle (Firefox) */
  user-select: none;
}
summary.nav-section-title::-webkit-details-marker { display: none; }  /* and WebKit */
summary.nav-section-title::before {
  content: "\25B8";          /* ▸ — rotates to ▾ when open */
  font-size: 0.7em;
  line-height: 1;
  transition: transform 0.15s ease;
}
details.nav-group[open] > summary.nav-section-title::before { transform: rotate(90deg); }
summary.nav-section-title:hover { color: var(--fg); }
.nav-group-body {
  padding-left: 0.55rem;
  margin: 0.15rem 0 0 0.3rem;
  border-left: 1px solid var(--border);
}
@media (prefers-reduced-motion: reduce) {
  summary.nav-section-title::before { transition: none; }
}
.nav-item {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  color: var(--fg);
  font-size: 0.93rem;
}
.nav-item:hover { background: var(--bg-alt); text-decoration: none; }
.nav-item.active { background: var(--accent); color: var(--accent-fg); }

/* Content */
.content { padding: 2rem 2.5rem; min-width: 0; }
.page { display: grid; grid-template-columns: minmax(0, 1fr) var(--toc-w); gap: 3rem; }
/* Explicit placement so DOM order (TOC first) doesn't swap the columns. */
/* Content fills its column 100%; the TOC keeps its fixed track on the right. */
.prose { grid-column: 1; min-width: 0; max-width: none; }
.prose pre.code { max-width: 100%; }
.prose h1 { font-size: 2rem; line-height: 1.2; margin-top: 0; }
.prose h2 { margin-top: 2.5rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }
.prose h1, .prose h2, .prose h3, .prose h4 { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.prose img { max-width: 100%; }
.prose code {
  background: var(--bg-code);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.9em;
}
.prose pre.code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.5;
}
.prose pre.code code { background: none; padding: 0; font-size: 0.875rem; }
.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.4rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
  background: var(--bg-alt);
  border-radius: 0 6px 6px 0;
}
.prose table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.7rem; text-align: left; }
.prose th { background: var(--bg-alt); }

/* TOC */
.toc {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: calc(var(--topbar-h) + 1rem);
  align-self: start;
  font-size: 0.85rem;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  max-height: calc(100vh - var(--topbar-h) - 3rem);
  overflow-y: auto;
}
.toc-title { font-weight: 600; color: var(--fg-muted); display: block; margin-bottom: 0.4rem; }
.toc a { display: block; color: var(--fg-muted); padding: 0.15rem 0; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc-l3 { padding-left: 0.8rem; }
.toc-l4 { padding-left: 1.6rem; }

/* Page meta */
.page-meta {
  grid-column: 1;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* Home */
.home { max-width: 60rem; margin: 0 auto; }
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h1 { font-size: 2.75rem; margin: 0 0 0.5rem; }
.tagline { font-size: 1.2rem; color: var(--fg-muted); max-width: 40rem; margin: 0 auto 1.5rem; }
.hero-cta { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
/* Buttons — brand treatment (solid Cherenkov + glow; tokens from /assets/tokens.css). */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1.35rem;
  border-radius: 9px; font-weight: 700; border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .2s ease, background .18s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); box-shadow: var(--btn-shadow); }
.btn-primary:hover { background: var(--btn-bg-hover); transform: translateY(-1px); box-shadow: var(--btn-shadow-hover); }
.btn-primary:active { background: var(--btn-bg-active); transform: translateY(0); box-shadow: var(--btn-shadow); }
.btn-secondary { background: var(--bg-elev); border-color: var(--border); color: var(--fg); }
.btn-secondary:hover { background: var(--bg-alt); border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  transform: translateY(-1px); box-shadow: var(--btn-shadow-soft); }
.btn-secondary:active { transform: translateY(0); box-shadow: none; }
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
}
.feature {
  position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 12px;
  padding: 1.3rem; background: var(--bg-elev);
  transition: transform .15s ease, border-color .15s ease;
}
.feature::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--grad-main); opacity: 0; transition: opacity .2s;
}
.feature:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--ramp-3) 45%, var(--border)); }
.feature:hover::before { opacity: 1; }
.feature h3 { margin-top: 0; }
.home-prose { max-width: var(--maxw); margin: 0 auto; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2.5rem;
  display: flex;
  gap: 1rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
}
.built-with { margin-left: auto; }

/* Versions table */
.versions-table .badge {
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
}
.muted { color: var(--fg-muted); }

/* Responsive */
@media (max-width: 60rem) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 48rem) {
  #sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    width: min(20rem, 85vw);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    z-index: 35;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .content { padding: 1.25rem; }
  /* On phones the search returns to the flex flow and grows to fill. */
  .search { position: static; transform: none; width: auto; flex: 1 1 auto; min-width: 0; }
}
