/**
 * Eigan blog styles.
 *
 * Loaded after /tokens.css. Every color comes from a token — no hardcoded hex.
 * Brand discipline: light ground, Midnight Navy text, radius 0–2px, hairline
 * navy borders, no gradients, no drop shadows.
 *
 * The site chrome (header, footer, buttons) mirrors site/index.html so the blog
 * reads as the same site. If that chrome changes there, change it here too.
 */

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

:root {
  /* page-local aliases, built only from tokens — same set index.html uses.
     Both ink shades clear WCAG AA (4.5:1) on white, --card and --secondary. */
  --line: var(--eigan-border-hairline);
  --line-strong: rgba(27, 35, 85, 0.16);
  --ink-2: rgba(27, 35, 85, 0.75);
  --ink-3: rgba(27, 35, 85, 0.66);
  --nav-h: 64px;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--eigan-signal-blue); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 24px; }
@media (min-width: 1024px) { .wrap { padding-inline: 48px; } }

/* ---------- Header (mirrors index.html) ---------- */
header.site {
  position: sticky; top: 0; z-index: 50;
  background: var(--background);
  border-bottom: 1px solid var(--line);
}
header.site .bar { display: flex; align-items: center; height: var(--nav-h); gap: 32px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; text-decoration: none; }
.brand img { height: 27px; width: auto; display: block; transform: translateY(1.7px); }
.brand .wordmark {
  font-family: var(--font-display); font-weight: 600; font-size: 19px;
  letter-spacing: 0.15em; color: var(--foreground);
}
nav.main { display: none; gap: 28px; flex: 1; }
@media (min-width: 900px) { nav.main { display: flex; } }
nav.main a {
  font-family: var(--font-display); font-size: 14px; font-weight: 500;
  color: var(--ink-2); text-decoration: none;
}
nav.main a:hover { color: var(--foreground); }
nav.main a[aria-current="page"] { color: var(--foreground); }
.bar .actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.menu { margin-left: auto; }
@media (min-width: 900px) { .menu { display: none; } }
.menu summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 11px; color: var(--foreground);
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] .panel {
  position: absolute; left: 0; right: 0; top: var(--nav-h);
  background: var(--background); border-bottom: 1px solid var(--line);
  padding: 16px 24px 24px; display: grid; gap: 4px;
}
.menu .panel a {
  font-family: var(--font-display); font-size: 15px; font-weight: 500;
  color: var(--foreground); text-decoration: none; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

/* ---------- Buttons (mirrors index.html) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: 0.02em;
  border-radius: var(--radius); border: 1px solid transparent;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--eigan-signal-blue); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--eigan-card); padding: 3px 9px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-2);
}
.chip-draft {
  border-color: var(--eigan-signal-blue);
  color: var(--eigan-signal-blue);
  background: var(--background);
}

.draft-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  border: 1px solid var(--eigan-signal-blue); border-radius: var(--radius);
  background: var(--eigan-card); padding: 12px 16px; margin-bottom: 32px;
  font-size: 13px; color: var(--ink-2);
}

/* ---------- Blog index ---------- */
.blog-head { padding-block: 72px 0; text-align: center; }
.blog-head h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.25rem, 5vw, 3rem); line-height: 1.05; letter-spacing: -0.025em;
}
.blog-head p { max-width: 52ch; margin: 16px auto 0; font-size: 17px; color: var(--ink-2); }

.post-list {
  list-style: none;
  max-width: 760px; margin: 56px auto 96px;
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.post-list li + li { border-top: 1px solid var(--line); }
.post-list a {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding-block: 28px; text-decoration: none; color: inherit;
}
.post-list .row-text { min-width: 0; }
.post-list h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 20px; line-height: 1.25; letter-spacing: -0.01em;
}
.post-list h2 .chip { margin-left: 10px; vertical-align: 3px; }
.post-list a:hover h2 { color: var(--eigan-signal-blue); }
.post-list .excerpt { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.post-list .meta {
  margin-top: 10px;
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-3);
}
.post-list .arrow { flex-shrink: 0; margin-top: 4px; color: var(--ink-3); }
.post-list a:hover .arrow { color: var(--eigan-signal-blue); }
.empty { max-width: 760px; margin: 56px auto 96px; color: var(--ink-3); }

.feed-note {
  max-width: 760px; margin: 0 auto 96px;
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-3);
}
.feed-note a { color: var(--ink-3); }
.feed-note a:hover { color: var(--eigan-signal-blue); }

/* ---------- Post layout ---------- */
.post-layout { display: flex; gap: 48px; align-items: flex-start; }
.post-main { min-width: 0; flex: 1; max-width: 760px; }

.post-head { padding-block: 56px 0; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink-2); text-decoration: none; margin-bottom: 32px;
}
.back:hover { color: var(--foreground); }
.post-head .tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.post-head h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 2.75rem); line-height: 1.08; letter-spacing: -0.025em;
  text-wrap: balance;
}
.standfirst { margin-top: 18px; max-width: 60ch; font-size: 18px; line-height: 1.6; color: var(--ink-2); }

.byline { margin-top: 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.byline .who { display: flex; align-items: center; gap: 10px; }
.byline .avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--eigan-card);
  font-family: var(--font-mono); font-size: 12px; color: var(--foreground);
}
.byline .name { font-size: 14px; font-weight: 500; color: var(--foreground); }
.byline .sep { color: var(--line-strong); }
.byline time, .byline .rt { font-size: 14px; color: var(--ink-2); }

/* ---------- View toggle ---------- */
.view-toggle {
  margin-top: 32px;
  display: inline-flex;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--eigan-card); padding: 3px;
}
.view-toggle button {
  appearance: none; border: 0; cursor: pointer;
  background: transparent; color: var(--ink-2);
  font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: 0.02em;
  padding: 7px 16px; border-radius: var(--radius);
  transition: background-color .15s ease, color .15s ease;
}
.view-toggle button:hover { color: var(--foreground); }
.view-toggle button[aria-selected="true"] {
  background: var(--primary); color: var(--primary-foreground);
}

/* Without JS there is no toggle — both views render stacked under their headings. */
.no-js .view-toggle { display: none; }
.view-heading {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-3);
  margin-bottom: 20px;
}
.no-js .view + .view { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--line); }

/* With JS, one view at a time. data-view lives on <html>, set by a script in
   <head>, so the right view is chosen before first paint — no flash. */
html:not(.no-js) .view-heading { display: none; }
html:not(.no-js)[data-view="full"] .view-distillate { display: none; }
html:not(.no-js)[data-view="distillate"] .view-full { display: none; }

.post-body { margin-top: 40px; padding-top: 40px; border-top: 1px solid var(--line-strong); }

.view-note {
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-3);
}

/* ---------- Prose ---------- */
.prose { font-size: 16px; line-height: 1.75; color: var(--ink-2); }
.prose > * + * { margin-top: 20px; }
.prose h2 {
  margin-top: 48px; scroll-margin-top: calc(var(--nav-h) + 24px);
  font-family: var(--font-display); font-weight: 600;
  font-size: 24px; line-height: 1.25; letter-spacing: -0.015em; color: var(--foreground);
}
.prose h3 {
  margin-top: 36px; scroll-margin-top: calc(var(--nav-h) + 24px);
  font-family: var(--font-display); font-weight: 600;
  font-size: 18px; line-height: 1.3; color: var(--foreground);
}
.prose h2 .anchor, .prose h3 .anchor { color: inherit; text-decoration: none; }
.prose h2 .anchor:hover, .prose h3 .anchor:hover { color: var(--eigan-signal-blue); }
.prose strong { color: var(--foreground); font-weight: 600; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li + li { margin-top: 8px; }
.prose blockquote {
  border-left: 2px solid var(--eigan-signal-blue);
  padding: 4px 0 4px 20px; color: var(--ink-2); font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 40px; }
.prose img { max-width: 100%; height: auto; display: block; border: 1px solid var(--line); }
.prose figure { margin-block: 32px; }
.prose figcaption { margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.prose code {
  font-family: var(--font-mono); font-size: 0.875em;
  background: var(--eigan-secondary); padding: 2px 5px; border-radius: var(--radius);
  color: var(--foreground);
}
.prose pre {
  background: var(--eigan-card); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; font-size: 13.5px; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 10px 14px; text-align: left; }
.prose th {
  background: var(--eigan-card); color: var(--foreground);
  font-family: var(--font-display); font-weight: 600;
}

/* The distillate is short and scannable — tighter, and its bold leads carry it. */
.distillate { font-size: 16px; line-height: 1.7; color: var(--ink-2); }
.distillate > * + * { margin-top: 18px; }
.distillate strong { color: var(--foreground); font-weight: 600; }
.distillate ul { padding-left: 22px; }
.distillate li + li { margin-top: 8px; }

/* ---------- Table of contents ---------- */
.toc { display: none; }
@media (min-width: 1024px) {
  .toc { display: block; width: 220px; flex-shrink: 0; padding-top: 56px; }
}
.toc .sticky { position: sticky; top: calc(var(--nav-h) + 32px); }
.toc p.label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-3); margin-bottom: 14px;
}
.toc ul { list-style: none; display: grid; gap: 8px; }
.toc a { font-size: 13px; line-height: 1.45; color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--eigan-signal-blue); }

/* The distillate has no sections of its own, so the rail would be misleading. */
html:not(.no-js)[data-view="distillate"] .toc { visibility: hidden; }

/* ---------- Footer (mirrors index.html) ---------- */
footer.site { margin-top: 96px; padding-block: 56px 40px; border-top: 1px solid var(--line); }
footer.site .cols { display: grid; gap: 40px; }
@media (min-width: 700px) { footer.site .cols { grid-template-columns: 2fr 1fr 1fr; gap: 48px; } }
footer.site img { width: 120px; height: auto; display: block; }
footer.site .tagline { margin-top: 16px; max-width: 34ch; font-size: 14px; color: var(--ink-2); }
footer.site h4 {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-3);
}
footer.site ul { list-style: none; margin-top: 16px; display: grid; gap: 10px; }
footer.site ul a { font-size: 14px; color: var(--ink-2); text-decoration: none; }
footer.site ul a:hover { color: var(--foreground); text-decoration: underline; }
footer.site li.soon { font-size: 14px; color: var(--ink-3); }
footer.site .base {
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
}
