@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400;1,9..144,500&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #ffffff;
  --bg-soft: #fafaf8;
  --fg: #141311;
  --muted: #7a766e;
  --line: #e7e3db;
  --accent: #b3521e;
  --accent-soft: #f4e3d3;
  --mark: #fbe9a8;
  --tag: #6b6355;

  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --maxw: 44rem;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

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

a { color: inherit; }

img { max-width: 100%; }

/* ---------- top bar ---------- */

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1.75rem 2rem;
  max-width: 74rem;
  margin: 0 auto;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--fg);
  justify-self: center;
  white-space: nowrap;
}

.wordmark .dim { color: var(--muted); font-style: italic; }

.back-link {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.back-link:hover { color: var(--fg); border-color: var(--fg); }

.topbar-right { display: flex; align-items: center; gap: 1.5rem; justify-self: end; }

.topbar-left { position: relative; display: flex; align-items: center; justify-self: start; }

/* hamburger */

.hamburger {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 30px; height: 22px;
  flex: 0 0 auto;
  background: none;
  border: 0;
  margin: 0;
  cursor: pointer;
  padding: 0;
}

.hamburger span {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--fg);
  transition: transform 0.2s ease, opacity 0.2s ease, top 0.2s ease;
}

.hamburger span:nth-child(1) { top: 0; }
.hamburger span:nth-child(2) { top: 10px; }
.hamburger span:nth-child(3) { top: 20px; }

.hamburger[aria-expanded="true"] span:nth-child(1) { top: 10px; transform: rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { top: 10px; transform: rotate(-45deg); }

.site-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 19, 17, 0.08);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 280px;
  max-width: 340px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.site-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.site-menu a {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.92rem;
  color: var(--fg);
}

.site-menu a:hover { background: var(--bg-soft); }
.site-menu a.is-active { color: var(--accent); font-weight: 600; }

.menu-links { display: flex; flex-direction: column; }

.menu-search {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
  margin-bottom: 0.2rem;
}

#search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--bg-soft);
  outline: none;
}

#search-input:focus { border-color: var(--accent); }

.search-results {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
}

.search-results:empty { margin-top: 0; }

.search-results a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  text-decoration: none;
}

.search-results a:hover { background: var(--bg-soft); }

.search-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--fg);
}

.search-snippet {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.search-empty {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
  margin: 0;
}

/* ---------- hero / intro ---------- */

.hero {
  max-width: var(--maxw);
  margin: 3.5rem auto 4.5rem;
  padding: 0 2rem;
}

.hero .eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
  font-weight: 600;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  line-height: 1.15;
  margin: 0 0 1.4rem;
  letter-spacing: -0.01em;
}

.hero .intro {
  font-size: 1.08rem;
  color: #322f2a;
  max-width: 40rem;
}

.hero .intro p { margin: 0 0 1rem; }

.hero .intro-placeholder {
  border-left: 3px solid var(--accent-soft);
  padding: 0.9rem 1.1rem;
  background: var(--bg-soft);
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
}

/* ---------- section framing ---------- */

.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 2rem;
}

.section-wide {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 2rem;
}

.section-label {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

hr.divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4.5rem 0;
}

/* ---------- article content (rendered markdown) ---------- */

.content { font-size: 1.02rem; }

.content h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  margin: 2.6rem 0 1rem;
  letter-spacing: -0.005em;
}

.content h1:first-child { margin-top: 0; }

.content h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.32rem;
  margin: 2.4rem 0 0.9rem;
}

.content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.8rem 0 0.6rem;
}

.content p { margin: 0 0 1.05rem; }

.content ul, .content ol {
  margin: 0 0 1.1rem;
  padding-left: 1.3rem;
}

.content li { margin: 0.3rem 0; }

.content strong { font-weight: 600; }

.content mark {
  background: var(--mark);
  color: var(--fg);
  padding: 0.05em 0.15em;
  border-radius: 2px;
}

.content a.wikilink {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.content a.wikilink:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.content span.wikilink-unresolved {
  color: var(--fg);
  border-bottom: 1px dotted var(--line);
  cursor: help;
}

.content blockquote {
  margin: 1.2rem 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-style: italic;
}

/* callouts */

.callout {
  margin: 1.6rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
}

.callout-title {
  margin: 0;
  padding: 0.8rem 1.1rem;
  font-weight: 600;
  font-size: 0.92rem;
  background: #f2ede2;
  border-bottom: 1px solid var(--line);
}

.callout-body { padding: 0.2rem 1.1rem 1rem; }
.callout-body p:first-child { margin-top: 0.8rem; }
.callout-body p:last-child { margin-bottom: 0.2rem; }

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

.graph-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at 1px 1px, #efece4 1px, transparent 0) 0 0/18px 18px,
    var(--bg);
  position: relative;
  overflow: hidden;
}

#graph-svg { width: 100%; height: 640px; display: block; cursor: grab; }
#graph-svg:active { cursor: grabbing; }

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin: 1.1rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.graph-legend .item { display: flex; align-items: center; gap: 0.5rem; }

.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}

.graph-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.9rem 0 0;
}

.node-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--fg);
  color: var(--bg);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  max-width: 220px;
  opacity: 0;
  transform: translate(-50%, -130%);
  transition: opacity 0.1s ease;
  z-index: 5;
  line-height: 1.3;
}

/* ---------- note metadata / related list ---------- */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 2.2rem;
}

.badge {
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
}

.badge-accent { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.related-list a {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.86rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.related-list a:hover { border-color: var(--accent); background: var(--accent-soft); }

.related-list a.is-tag { color: var(--tag); }
.related-list a.is-source { color: var(--accent); }

/* ---------- note page: content + sidebar ---------- */

.page-layout {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3.5rem;
  align-items: start;
}

.page-layout .content-col { min-width: 0; }

.sidebar {
  position: sticky;
  top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar-section-title {
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.8rem;
}

.sidebar .related-list { flex-direction: column; gap: 0.45rem; }

.sidebar .related-list a {
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0;
  width: 100%;
}

.sidebar .related-list a:hover { background: none; border-color: var(--accent); }

/* tag cloud */

.tag-cloud {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-cloud a {
  display: inline-block;
  text-decoration: none;
  color: var(--tag);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.tag-cloud a:hover { border-color: var(--tag); color: var(--fg); }

.tag-cloud a:nth-child(3n) { font-size: 0.78rem; }
.tag-cloud a:nth-child(3n+1) { font-size: 0.92rem; }
.tag-cloud a:nth-child(3n+2) { font-size: 0.85rem; }

@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; border-top: 1px solid var(--line); padding-top: 2rem; margin-top: 1rem; }
}

/* ---------- dedicated graph page ---------- */

.graph-page-wrap #graph-svg { height: 78vh; min-height: 520px; }

/* ---------- footer ---------- */

.site-footer {
  max-width: 74rem;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

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

@media (max-width: 640px) {
  .topbar, .hero, .section, .section-wide, .site-footer, .page-layout { padding-left: 1.25rem; padding-right: 1.25rem; }
  #graph-svg { height: 460px; }
  .graph-page-wrap #graph-svg { height: 70vh; }
}
