/* ============================================================
   Latent Minds Institute · article design system
   Inspired by Anthropic research papers (transformer-circuits)
   and Epoch AI's data pages: sober type, generous whitespace,
   figure panels that earn their place.
   ============================================================ */

:root {
  --bg:         #FCFCFA;
  --bg-panel:   #FFFFFF;
  --bg-tint:    #F6F5F1;
  --ink:        #191918;
  --ink-2:      #45443F;
  --ink-3:      #6E6D66;
  --ink-4:      #A3A29A;
  --rule:       #E9E7E0;
  --rule-2:     #D9D7CE;
  --accent:     #6b1f1a;
  --accent-2:   #8a2b23;
  --accent-bg:  rgba(107, 31, 26, 0.07);
  --good:       #1B7A4A;
  --bad:        #B02020;
  --warn:       #B4690E;
  --viz-blue:   #3B5BA9;
  --sans:       'Inter', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, sans-serif;
  --serif:      'Source Serif 4', 'Georgia', 'Times New Roman', serif;
  --mono:       'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --w-prose:    700px;
  --w-wide:     880px;
  --nav-h:      60px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: 18px; line-height: 1.7; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--ink); color: var(--bg); }
img { max-width: 100%; height: auto; }

/* ---------- nav ---------- */
.site-nav { position: sticky; top: 0; z-index: 100; background: rgba(252,252,250,0.92); border-bottom: 1px solid var(--rule); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.site-nav .nav-inner { max-width: var(--w-wide); margin: 0 auto; padding: 0 24px; height: var(--nav-h); display: flex; align-items: center; justify-content: space-between; }
.site-nav .nav-logo { font-family: var(--sans); font-weight: 600; font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; }
.site-nav .nav-links { display: flex; gap: 28px; list-style: none; }
.site-nav .nav-links a { font-family: var(--sans); font-size: 13.5px; color: var(--ink-3); transition: color 160ms ease; }
.site-nav .nav-links a:hover, .site-nav .nav-links a.active { color: var(--ink); }
.menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.menu-btn span { display: block; width: 20px; height: 1.5px; background: var(--ink); margin: 5px 0; }

/* ---------- article ---------- */
.article { max-width: var(--w-prose); margin: 0 auto; padding: 64px 24px 96px; }
.article-meta { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 22px; }
.article-meta .type { color: var(--accent); }
.article-title { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 5.4vw, 44px); line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 14px; }
.article-dek { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 20px; line-height: 1.5; color: var(--ink-3); margin-bottom: 8px; }
.article-rule { border: none; border-top: 1px solid var(--ink); margin: 30px 0 40px; position: relative; }
.article-rule::after { content: ""; position: absolute; top: 2px; left: 0; right: 0; border-top: 1px solid var(--ink); }
.article-cover { margin: 8px 0 36px; }
.article-cover img { border-radius: 3px; display: block; }

/* prose */
.prose p { margin-bottom: 1.15em; }
.prose h2 { font-family: var(--serif); font-weight: 600; font-size: 25px; line-height: 1.3; letter-spacing: -0.01em; margin: 2.2em 0 0.7em; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.prose h2 strong { font-weight: 600; }
.prose h3 { font-family: var(--serif); font-weight: 600; font-size: 20px; margin: 1.8em 0 0.6em; }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose a { color: var(--accent); border-bottom: 1px solid rgba(107,31,26,0.3); transition: border-color 150ms; }
.prose a:hover { border-bottom-color: var(--accent); }
.prose ul, .prose ol { margin: 0 0 1.15em 1.4em; }
.prose li { margin-bottom: 0.4em; }
.prose blockquote { border-left: 2px solid var(--accent); padding: 4px 0 4px 22px; margin: 1.6em 0; font-style: italic; color: var(--ink-2); }
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 2.5em auto; width: 120px; }
.prose code { font-family: var(--mono); font-size: 0.82em; background: var(--bg-tint); border: 1px solid var(--rule); padding: 1px 6px; border-radius: 3px; }
.prose img { border-radius: 3px; margin: 1.5em 0; }

/* poetry variant */
.prose.poetry { font-size: 19px; line-height: 1.85; }
.prose.poetry p { margin-bottom: 1.05em; }

/* ---------- figure panels (Anthropic-style) ---------- */
.figure { margin: 2.2em 0 2.6em; border: 1px solid var(--rule-2); border-radius: 6px; background: var(--bg-panel); overflow: hidden; font-family: var(--sans); }
.figure-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--bg-tint); }
.figure-head .fig-no { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.figure-head .fig-no b { color: var(--accent); font-weight: 600; }
.figure-head .fig-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--viz-blue); }
.figure-head .fig-tag::before { content: "\25CF"; margin-right: 6px; animation: figpulse 2.2s infinite; }
@keyframes figpulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .figure-head .fig-tag::before { animation: none; } }
.figure-body { padding: 18px 16px; }
.figure-caption { font-family: var(--sans); font-size: 13px; line-height: 1.55; color: var(--ink-3); padding: 12px 16px; border-top: 1px solid var(--rule); }

/* controls inside figures */
.figure .controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 22px; margin-bottom: 16px; }
.figure .ctl label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; font-family: var(--sans); }
.figure .ctl label output { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.figure input[type=range] { width: 100%; accent-color: var(--accent); height: 22px; }
.figure .segrow { display: flex; flex-wrap: wrap; }
.figure button.seg { font-family: var(--mono); font-size: 12px; padding: 6px 12px; border: 1px solid var(--ink); border-right-width: 0; background: var(--bg-panel); color: var(--ink); cursor: pointer; }
.figure button.seg:first-child { border-radius: 3px 0 0 3px; }
.figure button.seg:last-child { border-right-width: 1px; border-radius: 0 3px 3px 0; }
.figure button.seg.on { background: var(--ink); color: var(--bg); }
.figure button.seg:focus-visible, .figure input:focus-visible { outline: 2px solid var(--viz-blue); outline-offset: 2px; }
.figure .readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 14px; }
.figure .stat { border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; background: var(--bg); }
.figure .stat .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.figure .stat .v { font-family: var(--mono); font-size: 19px; font-weight: 600; margin-top: 3px; }
.figure .stat .v.pos { color: var(--good); } .figure .stat .v.neg { color: var(--bad); } .figure .stat .v.warn { color: var(--warn); }
.figure svg text { font-family: var(--mono); }

/* ---------- article footer ---------- */
.article-footer { margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--rule-2); font-family: var(--sans); font-size: 13px; color: var(--ink-4); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.article-footer a { color: var(--ink-2); font-weight: 500; }
.article-footer a:hover { color: var(--accent); }

/* ---------- archive lists ---------- */
.archive { max-width: var(--w-prose); margin: 0 auto; padding: 64px 24px 96px; font-family: var(--sans); }
.archive-kicker { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 16px; }
.archive-title { font-family: var(--serif); font-weight: 600; font-size: clamp(32px, 6vw, 48px); letter-spacing: -0.015em; margin-bottom: 12px; }
.archive-desc { font-size: 15px; color: var(--ink-3); line-height: 1.65; max-width: 540px; margin-bottom: 20px; }
.archive-section { margin-top: 52px; }
.archive-section > h2 { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); padding-bottom: 10px; border-bottom: 1px solid var(--ink); margin-bottom: 4px; }
.entry { display: block; padding: 20px 12px; margin: 0 -12px; border-bottom: 1px solid var(--rule); border-radius: 4px; transition: background 160ms ease; }
.entry:hover { background: var(--bg-tint); }
.entry .e-meta { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.entry .e-meta .e-type { color: var(--accent); }
.entry .e-title { font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1.3; letter-spacing: -0.01em; margin-bottom: 5px; }
.entry .e-desc { font-size: 13.5px; color: var(--ink-3); line-height: 1.55; max-width: 600px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--rule); }
.site-footer .footer-inner { max-width: var(--w-wide); margin: 0 auto; padding: 36px 24px; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; font-family: var(--sans); font-size: 12.5px; color: var(--ink-4); }
.site-footer a { color: var(--ink-3); font-weight: 500; }
.site-footer a:hover { color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .site-nav .nav-links { display: none; }
  .menu-btn { display: block; }
  .site-nav .nav-links.open { display: flex; flex-direction: column; position: absolute; top: var(--nav-h); left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--rule); padding: 14px 24px 20px; gap: 14px; }
  body { font-size: 17px; }
  .article, .archive { padding-top: 44px; }
}
