/* Lean Pool exposition — shared stylesheet.
   Loaded by every page. Defines the design tokens, base/reset, shared header,
   buttons/chips/badges, the declaration side panel, and all graph-page styles.
   Viewer/landing-specific styles live in viewer.css (owned by the viewer). */

/* ---------- design tokens ---------- */

:root {
  --bg: #faf9f7;
  --fg: #1c1c1c;
  --muted: #6b6960;
  --card: #ffffff;
  --border: #e3ded4;
  --accent: #1a6baa;
  --accent-fg: #ffffff;
  --hover: #f0ede6;
  --kind-theorem: #8250df;
  --kind-lemma: #1a7f37;
  --kind-def: #0969da;
  --kind-abbrev: #54aeff;
  --kind-instance: #bf8700;
  --kind-structure: #cf222e;
  --kind-class: #a40e26;
  --kind-inductive: #bc4c00;
  --kind-axiom: #57606a;
  --kind-opaque: #57606a;
  --star: #bf8700;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --fg: #e8e6e1;
    --muted: #94917f;
    --card: #201f1c;
    --border: #38352e;
    --accent: #5ea3d8;
    --accent-fg: #10222f;
    --hover: #26241f;
    --kind-theorem: #b197f5;
    --kind-lemma: #57ab5a;
    --kind-def: #539bf5;
    --kind-abbrev: #76b6f7;
    --kind-instance: #daaa3f;
    --kind-structure: #e5534b;
    --kind-class: #f47067;
    --kind-inductive: #e0823d;
    --kind-axiom: #768390;
    --kind-opaque: #768390;
    --star: #daaa3f;
  }
}

/* ---------- base / reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
}

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

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4 {
  line-height: 1.3;
}

/* Generic centered content column for landing/viewer pages. */
.page-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ---------- shared site header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 48px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.site-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.site-title:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 18px;
  overflow-x: auto;
}

.site-nav a {
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
  line-height: 48px;
}

.site-nav a:hover {
  color: var(--fg);
}

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
}

.btn:hover {
  background: var(--hover);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn-accent:hover {
  background: var(--accent);
  opacity: 0.9;
}

.btn:focus-visible,
.search-input:focus-visible,
.dep-link:focus-visible,
.panel-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- chips ---------- */

.kind-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.kind-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--muted);
  flex: none;
}

.kind-dot.k-theorem { background: var(--kind-theorem); }
.kind-dot.k-lemma { background: var(--kind-lemma); }
.kind-dot.k-def { background: var(--kind-def); }
.kind-dot.k-abbrev { background: var(--kind-abbrev); }
.kind-dot.k-instance { background: var(--kind-instance); }
.kind-dot.k-structure { background: var(--kind-structure); }
.kind-dot.k-class { background: var(--kind-class); }
.kind-dot.k-inductive { background: var(--kind-inductive); }
.kind-dot.k-axiom { background: var(--kind-axiom); }
.kind-dot.k-opaque { background: var(--kind-opaque); }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: transparent;
  vertical-align: middle;
  white-space: nowrap;
}

.badge-prov-human { color: var(--kind-lemma); border-color: currentcolor; }
.badge-prov-ai { color: var(--kind-theorem); border-color: currentcolor; }
.badge-prov-mix { color: var(--kind-inductive); border-color: currentcolor; }

.badge-private {
  color: var(--muted);
  background: var(--hover);
  border-color: var(--border);
  font-family: var(--font-sans);
  font-weight: 400;
  margin-left: 8px;
}

/* ---------- search input ---------- */

.search-input {
  flex: 0 1 340px;
  min-width: 140px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-count {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

/* ---------- graph page layout ---------- */

body.graph-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.info-strip {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.project-title {
  font-size: 17px;
  font-weight: 650;
  margin: 0;
}

/* card metadata strip (registry card + main results) */

.card-strip {
  padding: 6px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex: none;
  max-height: 30vh;
  overflow-y: auto;
  font-size: 13px;
}

.card-meta-line {
  color: var(--muted);
}

.card-meta-line a {
  color: var(--accent);
  text-decoration: none;
}

.card-meta-line a:hover {
  text-decoration: underline;
}

.card-summary {
  margin: 4px 0 0;
  max-width: 900px;
  color: var(--fg);
}

.main-results {
  margin-top: 4px;
}

.main-results summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  -webkit-user-select: none;
  user-select: none;
}

.main-result-list {
  margin: 4px 0 2px;
  padding-left: 18px;
}

.main-result-item {
  margin: 2px 0;
}

.main-result-item::marker {
  content: "★ ";
  color: var(--star);
  font-size: 11px;
}

.main-result-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

a.main-result-name {
  color: var(--accent);
  text-decoration: none;
}

a.main-result-name:hover {
  text-decoration: underline;
}

.main-result-informal {
  color: var(--muted);
}

.badge-main {
  border: 1px solid var(--star);
  color: var(--star);
}

.panel-informal {
  margin: 6px 0 0;
  font-style: italic;
  color: var(--muted);
}

/* minimal Lean file modal */

.minimal-modal {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 24px;
}

.minimal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.25);
  width: min(960px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  gap: 8px;
}

.minimal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.minimal-title {
  font-weight: 650;
  font-family: var(--font-mono);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.minimal-meta {
  color: var(--muted);
  font-size: 13px;
}

.minimal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.minimal-actions a.btn {
  text-decoration: none;
}

.minimal-note {
  color: var(--muted);
  font-size: 13px;
}

.minimal-code {
  flex: 1;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--bg);
  white-space: pre;
}

.info-stats {
  color: var(--muted);
  font-size: 13px;
}

.kind-legend {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-left: auto;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.breadcrumb-bar {
  padding: 6px 16px;
  font-size: 13px;
  color: var(--muted);
  background: var(--hover);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.breadcrumb-bar a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb-bar a:hover {
  text-decoration: underline;
}

/* ---------- graph viewport ---------- */

.graph-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.graph-viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.graph-viewport.dragging canvas {
  cursor: grabbing;
}

.graph-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 4px 9px;
  font-size: 12px;
  max-width: 420px;
  word-break: break-all;
}

.graph-tooltip .tt-name {
  font-family: var(--font-mono);
}

.graph-tooltip .tt-kind {
  color: var(--muted);
  margin-left: 8px;
}

.graph-message {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  max-width: 520px;
  padding: 0 20px;
}

/* ---------- declaration side panel ---------- */

.decl-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 6;
}

.panel-bar {
  flex: none;
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px 0;
}

.panel-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
}

.panel-close:hover {
  background: var(--hover);
  color: var(--fg);
}

.panel-body {
  overflow-y: auto;
  padding: 0 16px 28px;
}

.panel-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 8px;
  word-break: break-all;
}

.panel-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin: 4px 0;
  word-break: break-all;
}

.panel-links {
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  margin: 4px 0 10px;
}

.panel-actions {
  margin: 12px 0;
}

.panel-doc {
  font-size: 13px;
}

.panel-doc p {
  margin: 6px 0;
}

pre.statement {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
  margin: 8px 0 12px;
}

.panel-h {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 16px 0 4px;
}

.dep-list {
  list-style: none;
  margin: 2px 0 10px;
  padding: 0;
}

.dep-list li {
  margin: 2px 0;
}

.dep-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 1px 0;
  cursor: pointer;
  text-align: left;
  word-break: break-all;
}

.dep-link:hover {
  text-decoration: underline;
}

/* ---------- responsive ---------- */

@media (max-width: 800px) {
  .site-nav {
    gap: 12px;
  }

  .kind-legend {
    margin-left: 0;
    width: 100%;
  }

  .decl-panel {
    width: 100%;
    max-width: 100%;
  }
}
