/* llmwiki viewer — minimal typography + layout. Dark-mode-friendly defaults. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-muted: #f7f7f8;
  --surface: #ffffff;
  --surface-raised: #fbfbfc;
  --fg: #16181d;
  --fg-muted: #5f6470;
  --border: #e1e2e6;
  --accent: #2a6df4;
  --accent-soft: rgba(42, 109, 244, 0.1);
  --missing: #b00020;
  --max-content-width: 72ch;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --bg-muted: #1e2026;
    --surface: #14161b;
    --surface-raised: #20232a;
    --fg: #e7e8ec;
    --fg-muted: #9ea3ad;
    --border: #2c2f36;
    --accent: #7eb1ff;
    --accent-soft: rgba(126, 177, 255, 0.14);
    --missing: #ff8a8a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

/* Universal visible-focus ring so keyboard navigation is always
 * obvious. Spec §Slice 5 acceptance: "keyboard focus states are
 * visible." */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.app-header {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.app-brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.6rem;
}
.app-logo {
  width: 2rem;
  height: 2rem;
  flex: none;
  object-fit: contain;
}
.app-title { font-size: 1.05rem; }
.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg);
  background: var(--surface-raised);
  font-weight: 700;
  line-height: 1;
}
.github-link:hover,
.github-link:focus-visible {
  background: var(--accent-soft);
  text-decoration: none;
}
.github-mark {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: currentColor;
}
.github-stars {
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.app-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 260px;
  gap: 0;
  min-height: calc(100vh - 3rem);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-muted);
  padding: 1rem;
  overflow-y: auto;
}
.sidebar.search-active [data-sidebar] { display: none; }
.sidebar h2 {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-muted); margin: 1rem 0 0.5rem;
}
.sidebar details { margin: 0.65rem 0; }
.sidebar summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.35rem;
}
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li a {
  display: block;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  color: var(--fg);
  line-height: 1.35;
}
.sidebar li a:hover, .sidebar li a:focus-visible { background: var(--surface); }
.sidebar li a[aria-current="page"] { background: var(--accent); color: #fff; }

.sidebar-search {
  margin-bottom: 0.75rem;
}
.sidebar-search input[type="search"] {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.search-results {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.search-results[hidden] { display: none; }
.search-results .empty {
  font-style: italic;
  color: var(--fg-muted);
  padding: 0.4rem 0.5rem;
}
.search-results a {
  display: block;
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  color: var(--fg);
}
.search-results a:hover,
.search-results a:focus-visible {
  background: var(--surface);
}
.search-results .result-title {
  display: block;
  font-weight: 600;
}
.search-results .result-snippet {
  display: block;
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.1rem;
}
.search-results .result-kind {
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.4rem;
}

.main-pane {
  padding: 2rem;
  width: min(100%, var(--max-content-width));
  overflow-x: auto;
}
.main-pane:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.main-pane h1, .main-pane h2, .main-pane h3 { line-height: 1.25; }
.main-pane h1 { margin-top: 0; }
.main-pane pre {
  background: var(--bg-muted); padding: 0.75rem 1rem; border-radius: 6px;
  overflow-x: auto;
}
.main-pane code { background: var(--bg-muted); padding: 0.1em 0.3em; border-radius: 3px; }
.main-pane pre code { background: none; padding: 0; }

.support-rail {
  border-left: 1px solid var(--border);
  padding: 1rem; background: var(--bg-muted); font-size: 0.875rem;
}
.support-rail dt { font-weight: 700; color: var(--fg-muted); margin-top: 0.7rem; }
.support-rail dd { margin: 0.25rem 0; }

.placeholder { color: var(--fg-muted); font-style: italic; }
[data-missing="true"] {
  color: var(--missing);
  text-decoration: underline dotted;
  text-underline-offset: 0.18em;
}

.warning-banner {
  background: rgba(176, 0, 32, 0.08); color: var(--missing);
  padding: 0.5rem 0.75rem; border-radius: 4px; margin-bottom: 1rem;
}

.health-dashboard {
  display: grid;
  gap: 1rem;
}
.metric-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.25rem;
  margin: 0;
}
.metric-list .metric { display: contents; }
.health-dashboard dt { color: var(--fg-muted); }
.health-dashboard dd { margin: 0; font-variant-numeric: tabular-nums; }

.home-dashboard {
  width: min(100%, 58rem);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.metric-grid .metric {
  padding: 0.85rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.metric-grid dt {
  color: var(--fg-muted);
  font-size: 0.82rem;
}
.metric-grid dd {
  margin: 0.15rem 0 0;
  font-size: 1.65rem;
  font-weight: 750;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.home-action a {
  display: inline-flex;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  background: var(--accent-soft);
}
.recent-section { margin-top: 1.5rem; }
.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}
.recent-list a {
  display: block;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 800px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    max-height: 16rem;
  }
  .support-rail {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .main-pane {
    padding: 1rem;
  }
}

/* Graph pane */
.graph-pane {
  width: 100%;
  height: calc(100vh - 3rem);
  min-height: 32rem;
  padding: 0;
  overflow: hidden;
  position: relative;
}
.graph-pane svg { display: block; width: 100%; height: 100%; }
.graph-tooltip {
  position: absolute;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  pointer-events: none;
  display: none;
  z-index: 10;
  max-width: 220px;
}
.graph-tooltip .tip-title { font-weight: 600; color: #e2e8f0; }
.graph-tooltip .tip-meta  { font-size: 11px; color: #7a8fa6; margin-top: 2px; }
.graph-tooltip .tip-hint  { font-size: 10px; color: #4a5568; margin-top: 4px; }
.graph-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  pointer-events: none;
  z-index: 5;
}
.graph-legend-heading {
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  margin-bottom: 6px;
}
.graph-legend-heading + .graph-legend-heading { margin-top: 8px; }
.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7a8fa6;
  margin-bottom: 3px;
}
.graph-legend-item:last-child { margin-bottom: 0; }
.graph-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.node-label {
  fill: #e2e8f0;
}
@media (prefers-color-scheme: light) {
  .node-label { fill: #1a202c; }
}
