/* ═══════════════════════════════════════════════════════════════ */
/* Physics Wiki — extends shared tokens.css + layout.css           */
/* ═══════════════════════════════════════════════════════════════ */

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header (matches questions/roadmap pattern) ── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

.wiki-title-link {
  text-decoration: none;
}

.wiki-title-link:hover {
  color: var(--text);
  text-decoration: none;
}

/* ── Page layout ── */
.page-layout {
  flex: 1;
  margin-top: 44px;
}

/* ═══════════════════════════════════════════════════════════════ */
/* Sidebar — indented tree nav with CSS lines                     */
/* ═══════════════════════════════════════════════════════════════ */

.page-sidebar.wiki-nav {
  position: fixed;
  top: 44px;
  left: 0;
  width: 390px;
  height: calc(100vh - 44px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* Section header (matches paper sidebar sb-section-head) */
.nav-section-head {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.nav-section-head span {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tree container */
.nav-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

/* Base nav node — button reset */
.nav-node {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 4px 10px;
  border: none;
  background: none;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  gap: 5px;
  position: relative;
}

.nav-node:hover {
  background: var(--bg-2);
}

.nav-node.active {
  background: rgba(232, 240, 254, 0.5);
  color: var(--accent);
  font-weight: 600;
}

/* Depth 0: subfields — bold, full color */
.nav-node.depth-0 {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  padding-left: 10px;
  margin-top: 2px;
}

/* Depth 1: programs — indented, medium color */
.nav-node.depth-1 {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  padding-left: 28px;
}

/* Vertical trunk from subfield dot — first child extends up to connect */
.nav-node.depth-1::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  border-left: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.35;
}

.nav-node.depth-1.tree-first::before {
  top: -12px;
}

/* Horizontal branch to label */
.nav-node.depth-1::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 50%;
  width: 10px;
  border-top: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.35;
}

/* Last visible depth-1 child: trunk stops at midpoint */
.nav-node.depth-1.tree-last::before {
  bottom: 50%;
}

/* Depth 2: concepts — further indented, lightest color */
.nav-node.depth-2 {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-3);
  padding-left: 42px;
}

/* Vertical trunk from program level + horizontal branch */
.nav-node.depth-2::before {
  content: '';
  position: absolute;
  left: 30px;
  top: 0;
  bottom: 0;
  border-left: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.35;
}

.nav-node.depth-2.tree-first::before {
  top: -12px;
}

.nav-node.depth-2::after {
  content: '';
  position: absolute;
  left: 30px;
  top: 50%;
  width: 10px;
  border-top: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.35;
}

/* Last visible depth-2 child: trunk stops at midpoint */
.nav-node.depth-2.tree-last::before {
  bottom: 50%;
}

/* Continuing subfield trunk through depth-2 rows */
.tree-trunk-cont {
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  border-left: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.35;
  pointer-events: none;
}

/* Color dot for subfields */
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Paper count badge */
.nav-count {
  font-size: 9px;
  color: var(--text-3);
  font-family: var(--font);
  font-weight: 400;
  margin-left: auto;
  flex-shrink: 0;
  padding-left: 6px;
}

/* ── Main content area ── */
.wiki-main {
  max-width: clamp(600px, 80%, 860px);
  width: 100%;
  margin-left: 390px;
  padding: 24px 32px 60px;
  flex: 1;
  min-width: 0;
}

.technical-reference-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.technical-reference {
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.technical-reference-links {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.technical-reference-external {
  color: var(--text-3);
  font-size: 12px;
}

.technical-reference p {
  margin: 4px 0;
}

.theme-key-concepts {
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 0;
  margin: 12px 0 16px;
}

.theme-key-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.theme-key-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.theme-preview-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 112px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  background: var(--bg);
}

.theme-preview-card:hover {
  border-color: var(--text-3);
  text-decoration: none;
}

.theme-preview-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.theme-preview-meta {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.2;
}

.theme-preview-summary {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.theme-child-list {
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.theme-child-row {
  position: relative;
  padding: 8px 0 8px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.theme-child-row::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  border-left: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.28;
}

.theme-child-row::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 18px;
  width: 8px;
  border-top: 1.5px solid var(--tree-color, var(--border));
  opacity: 0.28;
}

.theme-child-row:last-child {
  border-bottom: none;
}

.theme-child-row-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.theme-child-row-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.theme-child-count {
  color: var(--text-3);
  font-size: 10px;
  white-space: nowrap;
}

.theme-child-desc {
  margin: 3px 0 0;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
}

.theme-child-sublinks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.4;
}

.theme-child-sublinks span {
  color: var(--text-3);
}

/* ── Concept tag row (shown at top of articles) ── */
.art-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.art-tags {
  line-height: normal;
}

.art-tags .fp-chip {
  padding: 4px 10px;
  font-weight: 500;
  border: none;
  color: #fff;
  text-decoration: none;
}

.art-tags .fp-chip.active-chip {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.38);
}

/* ── Landing page ── */
.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.landing-kicker {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.landing-title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 8px;
}

.landing-sub {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  max-width: 620px;
}

.landing-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 8px;
  min-width: 220px;
}

.landing-stats span {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text-2);
  font-size: 11px;
  background: var(--bg);
}

.landing-stats strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.landing-section {
  margin-bottom: 24px;
}

.landing-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.article-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.article-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  color: inherit;
  text-decoration: none;
  min-height: 126px;
}

.article-card:hover {
  border-color: var(--text-3);
  text-decoration: none;
}

.article-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.article-card-path {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-card-summary {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

#sfGrid {
  display: none !important;
}

.sf-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.sf-card:hover {
  border-color: var(--text-3);
  text-decoration: none;
}

.sf-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.sf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.sf-name {
  font-size: 13px;
  font-weight: 600;
}

.sf-desc {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.45;
}

.sf-meta {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 5px;
}

/* ═══════════════════════════════════════════════════════════════ */
/* Article — Wikipedia-style prose                                 */
/* ═══════════════════════════════════════════════════════════════ */

.art-crumb {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 2px;
}

.art-crumb.art-crumb-under-title {
  margin-top: 5px;
  margin-bottom: 10px;
}

.art-crumb a {
  color: var(--accent);
  text-decoration: none;
}

.art-crumb a:hover {
  text-decoration: underline;
}

#wikiArticle h1 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0;
}

.art-meta {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Prose body ── */
.art-body {
  font-size: 13px;
  line-height: 1.7;
}

.art-body p {
  margin-bottom: 10px;
  text-align: justify;
  hyphens: auto;
}

.art-body h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 8px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border-subtle);
}

.art-body h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 5px;
}

.wiki-figure {
  clear: both;
  margin: 16px 0 18px;
  padding: 12px 14px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg);
}

.wiki-figure svg {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
}

.wiki-figure figcaption {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: left;
}

.wiki-figure-boundary {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

.wiki-figure-boundary-accent {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
}

.wiki-figure-region {
  fill: color-mix(in srgb, var(--accent) 14%, transparent);
  stroke: none;
}

.wiki-figure-region.strong {
  fill: color-mix(in srgb, var(--accent) 20%, transparent);
}

.wiki-figure-region.dark {
  fill: color-mix(in srgb, var(--text) 18%, transparent);
}

.wiki-figure-surface {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.wiki-figure-surface.dashed {
  stroke-dasharray: 6 6;
}

.wiki-figure-line {
  stroke: var(--border);
  stroke-width: 2;
  stroke-linecap: round;
}

.wiki-figure-black-hole {
  fill: color-mix(in srgb, var(--text) 9%, transparent);
  stroke: var(--text-2);
  stroke-width: 2;
}

.wiki-figure-point {
  fill: var(--accent);
}

.wiki-figure-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-anchor: middle;
}

.wiki-figure-label.accent {
  fill: var(--accent);
}

.wiki-figure-label.muted {
  fill: var(--text-3);
  font-size: 11px;
  font-weight: 400;
}

.wiki-figure-label.light {
  fill: var(--text);
  font-weight: 600;
}

/* Concept links — Wikipedia blue */
a.cl {
  color: var(--accent);
  text-decoration: none;
}

a.cl:hover {
  text-decoration: underline;
}

/* Inline citation links */
a.pl {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}

a.pl:hover {
  text-decoration: underline;
}

/* Callout box for central question */
.art-callout {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 14px 0;
  border-radius: 0 4px 4px 0;
  font-style: italic;
  font-size: 13px;
  line-height: 1.55;
}

.art-callout-label {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 2px;
}

/* Open questions in articles */
.art-oq {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  line-height: 1.5;
}

.art-oq:last-child {
  border-bottom: none;
}

.art-oq-meta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.art-oq-diff {
  display: inline-block;
  width: 32px;
  height: 4px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

/* Paper entries — use shared .sr-* classes from layout.css */
/* Allow text wrapping in article context */
.art-body .search-result-item {
  align-items: flex-start;
  gap: 8px;
}

.art-body .sr-t {
  white-space: normal;
}

.art-body .sr-t a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.1s;
}

.art-body .sr-t a:hover {
  color: var(--accent);
}

/* See also chips */
.see-also-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0;
}

.see-also-chip {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s;
}

.see-also-chip:hover {
  background: var(--bg-2);
}

/* Table of contents (right of article on wide screens) */
.art-toc {
  font-size: 11px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 4px;
  float: right;
  margin-left: 20px;
  max-width: 200px;
}

.art-toc-title {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.art-toc a {
  display: block;
  padding: 2px 0;
  color: var(--accent);
  text-decoration: none;
}

.art-toc a:hover {
  text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .page-sidebar.wiki-nav {
    display: none;
  }

  .wiki-main {
    margin-left: 0;
    max-width: 100%;
    padding: 12px 16px 40px;
  }

  .art-toc {
    display: none;
  }

  .landing-hero {
    grid-template-columns: 1fr;
  }

  .landing-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════ */
/* nLab-style structural elements — definitions, theorems, etc.  */
/* ═══════════════════════════════════════════════════════════════ */

/* ── Shared label style for structural boxes ── */
.art-definition-label,
.art-theorem-label,
.art-remark-label,
.art-proof-label {
  font-variant: small-caps;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-2);
  margin-bottom: 4px;
}

/* ── Definition box ── */
.art-definition {
  background: var(--bg-2);
  border-left: 3px solid var(--green);
  padding: 10px 14px;
  margin: 14px 0;
  border-radius: 0 4px 4px 0;
  font-size: 13.5px;
  line-height: 1.7;
}

.art-definition p {
  margin-bottom: 4px;
}

.art-definition p:last-child {
  margin-bottom: 0;
}

/* ── Theorem / Proposition / Conjecture box ── */
.art-theorem {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 14px 0;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  line-height: 1.7;
}

.art-theorem p {
  font-style: italic;
  margin-bottom: 4px;
}

.art-theorem p:last-child {
  margin-bottom: 0;
}

/* ── Remark / Warning callout ── */
.art-remark {
  background: var(--bg-3);
  border-left: 3px solid var(--text-3);
  padding: 10px 14px;
  margin: 14px 0;
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  line-height: 1.6;
}

.art-remark p {
  margin-bottom: 4px;
}

.art-remark p:last-child {
  margin-bottom: 0;
}

/* ── Proof sketch ── */
.art-proof {
  margin: 10px 0 14px 10px;
  font-size: 13px;
  line-height: 1.65;
}

.art-proof p {
  margin-bottom: 6px;
}

.art-proof::after {
  content: '\25AA';
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Inline notation highlight ── */
.art-notation {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Typography improvements for article body ── */
.art-body {
  line-height: 1.75;
}

.art-body h2 {
  font-size: 16px;
  margin-top: 28px;
}

/* ── Review summary text in search-result items ── */
.sr-summary {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.5;
  margin-top: 3px;
  white-space: normal;
}

/* ── Display equation styling ── */
.art-body .MathJax_Display,
.art-body mjx-container[display="true"] {
  margin: 16px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.art-body mjx-container:not([display="true"]) {
  overflow-wrap: normal;
}
