/* padho-wiki article stylesheet */

:root {
  --bg: #fdfaf3;
  --bg-elevated: #f7f1e3;
  --bg-box: #f3ecd9;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --ink-mute: #7a7a6a;
  --accent: #c84033;
  --accent-soft: #e88a7e;
  --rule: #d8cfb9;
  --content-width: 720px;

  /* Forward-compatibility aliases — agents (Gemini Flash, Pro, future
     models) intuitively reach for `--wiki-*` prefixed names because the
     SVG class is `.wiki-svg`. The build pipeline rewrites these in the
     markdown source, but we keep the aliases here as a second safety net. */
  --wiki-bg: var(--bg);
  --wiki-bg-elevated: var(--bg-elevated);
  --wiki-bg-box: var(--bg-box);
  --wiki-ink: var(--ink);
  --wiki-text: var(--ink);
  --wiki-stroke: var(--ink);
  --wiki-text-muted: var(--ink-mute);
  --wiki-muted: var(--ink-mute);
  --wiki-accent: var(--accent);
  --wiki-accent-soft: var(--accent-soft);
  --wiki-rule: var(--rule);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110d;
    --bg-elevated: #1d1a14;
    --bg-box: #25211a;
    --ink: #f0ead8;
    --ink-soft: #c2bca8;
    --ink-mute: #8a8472;
    --accent: #ff7a6b;
    --accent-soft: #c84033;
    --rule: #3a342a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Newsreader', Charter, 'Iowan Old Style', Georgia, serif;
  font-size: 19px;
  line-height: 1.65;
  font-feature-settings: 'kern', 'liga', 'onum';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.site-header {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 0.8rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  font-family: 'Inter', system-ui, sans-serif;
}
.site-logo {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-logo .dot { color: var(--accent); }
.site-nav { display: flex; gap: 1.5rem; font-size: 0.9rem; }
.site-nav a { color: var(--ink-soft); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }

.wiki-article {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
.breadcrumb {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--ink-mute);
  margin-bottom: 2rem;
}
.breadcrumb a { color: var(--ink-mute); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 0.4rem; color: var(--rule); }

.article-header h1 {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 3.2rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--ink);
}
.article-description {
  font-size: 1.35rem;
  line-height: 1.45;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 1.2rem;
  max-width: 36em;
}
.article-meta {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--ink-mute);
  margin: 0 0 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.meta-tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--bg-box);
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 500;
}

.article-body p {
  margin: 1.2rem 0;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hanging-punctuation: first last;
}
.article-body p:first-child { margin-top: 0; }
.article-body h2 {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 3rem 0 1rem;
  color: var(--ink);
}
.article-body h3 {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 1.35rem;
  margin: 2.2rem 0 0.8rem;
  color: var(--ink);
}
.article-body strong { font-weight: 600; color: var(--ink); }
.article-body em { font-style: italic; }
.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.article-body a:hover { text-decoration-thickness: 2px; }

.article-body code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--bg-box);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.article-body pre {
  background: var(--bg-box);
  padding: 1rem 1.2rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.article-body pre code { background: none; padding: 0; }

.article-body ul, .article-body ol { margin: 1.2rem 0; padding-left: 1.4rem; }
.article-body li { margin: 0.4rem 0; }

.article-body table {
  border-collapse: collapse;
  margin: 1.5rem auto;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.92rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  overflow: hidden;
}
.article-body th, .article-body td {
  padding: 0.6rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
.article-body th {
  font-weight: 600;
  background: var(--bg-box);
  color: var(--ink);
}
.article-body tr:last-child td { border-bottom: none; }

/* TL;DR box (admonition or legacy) */
.article-body .tldr,
.article-body .admonition.tldr {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  padding: 1.1rem 1.4rem;
  margin: 1.5rem 0 2.5rem;
  border-radius: 0 6px 6px 0;
  font-size: 1rem;
  line-height: 1.55;
}
.article-body .tldr strong:first-child,
.article-body .admonition.tldr .label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 0.4rem;
}

/* Definition box */
.article-body .definition,
.article-body .admonition.definition {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  padding: 1.2rem 1.4rem;
  margin: 1.8rem 0;
  border-radius: 6px;
}
.article-body .definition .label,
.article-body .admonition.definition .label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* Worked example box */
.article-body .example,
.article-body .admonition.example {
  background: var(--bg-elevated);
  border-left: 3px solid var(--ink-mute);
  padding: 1rem 1.4rem;
  margin: 1.8rem 0;
  border-radius: 0 6px 6px 0;
}
.article-body .example .label,
.article-body .admonition.example .label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 0.5rem;
}
.article-body .example .step { margin: 0.7rem 0; }
.article-body .example .why,
.article-body .admonition.example .why {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 0.2rem;
  display: block;
}

/* Going deeper gate */
.article-body .going-deeper-gate,
.article-body .admonition.going-deeper {
  background: var(--bg-box);
  border: 1px dashed var(--rule);
  padding: 0.9rem 1.3rem;
  margin: 2rem 0 1rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-style: italic;
  border-radius: 6px;
}
.article-body .admonition.going-deeper .label {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-style: normal;
  margin-bottom: 0.4rem;
}

/* SVG figures */
.article-body figure {
  margin: 1.8rem auto;
  text-align: center;
}
.article-body figure svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.article-body figcaption {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--ink-mute);
  margin-top: 0.8rem;
  max-width: 32em;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.article-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--ink-mute);
}

/* Article-scoped SVG palette */
.wiki-article .wiki-svg { font-family: 'Inter', sans-serif; font-size: 13px; }
.wiki-article .wiki-svg .axis { stroke: var(--rule); stroke-width: 1; }
.wiki-article .wiki-svg .curve { stroke: var(--ink); stroke-width: 2; fill: none; }
.wiki-article .wiki-svg .secant { stroke: var(--accent-soft); stroke-width: 1.5; opacity: 0.6; }
.wiki-article .wiki-svg .tangent { stroke: var(--accent); stroke-width: 2.5; }
.wiki-article .wiki-svg .pt { fill: var(--accent); }
.wiki-article .wiki-svg .label { fill: var(--ink-soft); font-size: 12px; }
.wiki-article .wiki-svg .label-mute { fill: var(--ink-mute); font-size: 11px; }
.wiki-article .wiki-svg .readout {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
}
.wiki-article .wiki-svg .readout-bg {
  fill: var(--bg-elevated);
  stroke: var(--rule);
  stroke-width: 1;
}
.wiki-article .wiki-svg circle[data-draggable] {
  stroke: var(--bg);
  stroke-width: 3;
  cursor: grab;
  transition: r 0.15s ease;
}
.wiki-article .wiki-svg circle[data-draggable]:hover { stroke-width: 4; }
.wiki-article .wiki-svg [data-interactive] {
  user-select: none;
  -webkit-user-select: none;
}
.wiki-article .wiki-svg .drag-hint {
  fill: var(--ink-mute);
  font-size: 11px;
  font-style: italic;
  font-family: 'Inter', sans-serif;
}
/* Catch-alls for class names the agent reliably invents. Cheaper than
   teaching it the exact palette via the prompt; if a future article uses
   one of these, it just renders correctly. */
.wiki-article .wiki-svg .axis-arrow { fill: var(--rule); stroke: var(--rule); }
.wiki-article .wiki-svg .set-box { stroke: var(--rule); stroke-width: 1.5; fill: var(--bg-elevated); fill-opacity: 0.6; }
.wiki-article .wiki-svg .set-label { font-size: 1.05em; font-weight: 600; fill: var(--ink); font-family: 'Inter', sans-serif; }
.wiki-article .wiki-svg .num-example { font-size: 0.85em; fill: var(--ink-mute); font-family: 'Inter', sans-serif; }

/* Zoomable number-line buttons (the [+] and [−] beside a data-zoom-line) */
.wiki-article .wiki-svg .zoom-btn rect {
  fill: var(--bg-box);
  stroke: var(--rule);
  stroke-width: 1;
  transition: fill 0.15s ease, stroke 0.15s ease;
}
.wiki-article .wiki-svg .zoom-btn text {
  fill: var(--ink-soft);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.wiki-article .wiki-svg .zoom-btn:hover rect {
  fill: var(--bg-elevated);
  stroke: var(--accent);
}
.wiki-article .wiki-svg .zoom-btn:hover text { fill: var(--accent); }
.wiki-article .wiki-svg .zoom-line-content text {
  user-select: none;
  -webkit-user-select: none;
}

/* KaTeX overrides */
.katex { font-size: 1.05em !important; }
.katex-display {
  margin: 1.2em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 680px) {
  body { font-size: 17px; }
  .article-header h1 { font-size: 2.2rem; }
  .article-description { font-size: 1.15rem; }
  .wiki-article { padding: 1.5rem 1.2rem 3rem; }
  .article-body table { font-size: 0.85rem; }
  .article-body th, .article-body td { padding: 0.5rem 0.7rem; }
}

/* ========== Admin overlay ========== */
.wiki-admin-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--accent);
  color: white;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  padding: 0.55rem 1.2rem;
  display: none;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.wiki-admin-bar.show { display: flex; }
.wiki-admin-bar .left,
.wiki-admin-bar .right { display: flex; align-items: center; gap: 0.8rem; }
.wiki-admin-bar .badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.wiki-admin-bar .badge.draft { background: rgba(255, 255, 255, 0.3); }
.wiki-admin-bar .slug {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  opacity: 0.85;
}
.wiki-admin-bar button,
.wiki-admin-bar a {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.wiki-admin-bar button:hover,
.wiki-admin-bar a:hover { background: rgba(255, 255, 255, 0.3); }
.wiki-admin-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
body.has-admin-bar { padding-top: 2.6rem; }

/* Drafts dropdown panel */
.wiki-drafts-panel {
  position: fixed;
  top: 2.7rem;
  right: 1rem;
  z-index: 9998;
  width: min(420px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  display: none;
}
.wiki-drafts-panel.show { display: block; }
.wiki-drafts-panel .panel-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  color: var(--ink);
}
.wiki-drafts-panel .panel-header .count {
  color: var(--ink-mute);
  font-weight: 400;
  font-size: 0.78rem;
}
.wiki-drafts-panel .panel-empty,
.wiki-drafts-panel .panel-loading {
  padding: 1.2rem 1.1rem;
  color: var(--ink-mute);
  font-style: italic;
}
.wiki-drafts-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.wiki-drafts-panel li {
  border-bottom: 1px solid var(--rule);
}
.wiki-drafts-panel li:last-child { border-bottom: none; }
.wiki-drafts-panel li a {
  display: block;
  padding: 0.8rem 1.1rem;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.1s;
}
.wiki-drafts-panel li a:hover {
  background: var(--bg-elevated);
}
.wiki-drafts-panel li .draft-title {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
.wiki-drafts-panel li .draft-slug {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-mute);
}
.wiki-drafts-panel li .draft-desc {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
  line-height: 1.4;
}
