/* eswat2-mcp — styling for /posts pages.
   Single source of truth for both the page and the sidebar nav. These pages deliberately
   do NOT link render.css: it carries document-level rules for bare elements (table, th,
   p, ul, h1-h4 …) that leak into post content and fight this file. Everything needed is
   declared here, explicitly.

   The nav rules below are ported from render.css and re-pointed at this file's palette,
   so the sidebar follows the same light/dark tokens as the page around it. If the nav
   markup in _build_render_nav_html() changes, update the selectors here to match. */

@font-face { font-family: 'Iosevka'; src: url('/fonts/iosevka-latin-300-normal.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Iosevka'; src: url('/fonts/iosevka-latin-300-italic.woff2') format('woff2'); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: 'Iosevka'; src: url('/fonts/iosevka-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Podkova'; src: url('/fonts/podkova-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Podkova'; src: url('/fonts/podkova-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --ground:  #f7f6f2;
  --surface: #ffffff;
  --sunken:  #efede6;
  --ink:     #1a1a18;
  --muted:   #6b6a64;
  --rule:    rgba(0,0,0,0.12);
  --rule-strong: rgba(0,0,0,0.26);
  --mark:    #9b2c1f;
  --mark-wash: rgba(155,44,31,0.07);

  --font-body: 'Iosevka', ui-monospace, "SF Mono", Menlo, monospace;
  --font-head: 'Podkova', Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:  #1a1a18;
    --surface: #232220;
    --sunken:  #2a2926;
    --ink:     #f0eee8;
    --muted:   #a0a09a;
    --rule:    rgba(255,255,255,0.13);
    --rule-strong: rgba(255,255,255,0.28);
    --mark:    #e0866f;
    --mark-wash: rgba(224,134,111,0.10);
  }
}

:root[data-theme="dark"] {
  --ground:  #1a1a18;
  --surface: #232220;
  --sunken:  #2a2926;
  --ink:     #f0eee8;
  --muted:   #a0a09a;
  --rule:    rgba(255,255,255,0.13);
  --rule-strong: rgba(255,255,255,0.28);
  --mark:    #e0866f;
  --mark-wash: rgba(224,134,111,0.10);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 43rem;
  margin: 0 auto;
  /* Top min is 4rem (64px), not a smaller value: #nav-btn is fixed at top:16px and
     38px tall, so anything under 54px puts the hamburger on top of the masthead on
     mobile. render.css clears it with a flat 64px on `main`; this matches. */
  padding: clamp(4rem, 7vw, 5rem) clamp(1.1rem, 4vw, 2rem) 5rem;
  display: flex;
  flex-direction: column;
  gap: 2.75rem;
}

/* ── Masthead ─────────────────────────────────────────────── */

.masthead { display: flex; flex-direction: column; gap: 1rem; }

/* Unpublished-draft marker. Used in the masthead meta bar and beside index entries. */
.draft, .revised {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mark);
  background: var(--mark-wash);
  border: 1px solid var(--mark);
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
  white-space: nowrap;
}
.meta .draft, .meta .revised { padding: 0.05rem 0.4rem; }
h2 .draft, h2 .revised { margin-left: 0.5rem; position: relative; top: -0.15em; }

/* ── Editorial corrections ────────────────────────────────────
   Used only on archived posts, where the body is reproduced from elsewhere and a
   statement has since become wrong. The original text stays on the page, struck
   through; the correction follows it. Never silently rewrite an archived sentence. */

del.was {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--mark);
  text-decoration-thickness: 1px;
}
ins.now {
  color: var(--mark);
  text-decoration: none;
  border-bottom: 1px dashed var(--mark);
}
ins.now::before { content: "→ "; }
.mark-sample { color: var(--mark); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule-strong);
}

.meta .status {
  color: var(--mark);
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0.05rem 0.4rem;
}

.post-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.85rem, 5.5vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0;
}

.standfirst {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
  max-width: 34rem;
}

/* ── Channel matrix ───────────────────────────────────────── */
/* Three rows because the entry has three fields, and the whole
   point is that they do not all reach the same places. */

.channels {
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow-x: auto;
  background: var(--surface);
}

table.chan {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.83rem;
}

table.chan th, table.chan td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

table.chan thead th {
  font-weight: 700;
  font-size: 0.64rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: var(--rule-strong);
}

table.chan tbody th { font-weight: 700; }
table.chan tbody tr:last-child th,
table.chan tbody tr:last-child td { border-bottom: 0; }

table.chan .yes { color: var(--ink); }
table.chan .no  { color: var(--mark); }
table.chan .qual { color: var(--muted); font-size: 0.78rem; }

tr.machine-only { background: var(--mark-wash); }
tr.machine-only th { color: var(--mark); }

/* ── Article ──────────────────────────────────────────────── */

article { display: flex; flex-direction: column; gap: 1.15rem; }

article h2 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 1.6rem 0 0;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

article > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

article p { margin: 0; }

article ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.7rem; }
article li { margin: 0; }

article a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
}
article a:hover { text-decoration-color: var(--mark); }
article a:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; border-radius: 2px; }

code {
  font-family: var(--font-body);
  font-size: 0.86em;
  background: var(--sunken);
  padding: 0.08em 0.34em;
  border-radius: 2px;
}

pre {
  margin: 0.3rem 0;
  background: var(--sunken);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.65;
}
pre code { background: none; padding: 0; font-size: inherit; }

.table-wrap { overflow-x: auto; margin: 0.3rem 0; }

table.plain {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.83rem;
}
table.plain th, table.plain td {
  text-align: left;
  padding: 0.55rem 1.1rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.plain th {
  font-weight: 700;
  font-size: 0.64rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: var(--rule-strong);
  white-space: nowrap;
}
table.plain tr:last-child td { border-bottom: 0; }
table.plain td:first-child { white-space: nowrap; }

.callout {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 1.1rem 1.25rem;
  margin: 0.3rem 0;
}
.callout p { margin: 0; }
.callout p + p { margin-top: 0.75rem; }

/* ── Footer ───────────────────────────────────────────────── */

.endnote {
  border-top: 1px solid var(--rule-strong);
  padding-top: 1.2rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}
.endnote a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
.endnote a:hover { text-decoration-color: var(--mark); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Inline text ──────────────────────────────────────────────
   Declared here because nothing else styles them now. The body face is Iosevka 300, and
   the browser default `font-weight: bolder` resolves to 400 from a 300 base — there is no
   400 face, so <strong> rendered at body weight until this rule existed. */

strong, b { font-weight: 700; }
em, i { font-style: italic; }

/* ── Links ────────────────────────────────────────────────────
   Declared here because nothing else styles them now. */

a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { opacity: 0.72; }

/* ── Sidebar nav (ported from render.css) ─────────────────── */

/* ── Nav / hamburger (pure CSS — no <script>, checkbox-hack toggle) ───────── */

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
#nav-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
#nav-btn:hover { background: var(--sunken); }
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}
#render-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 68px 18px 40px;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  will-change: transform;
  z-index: 25;
}
.nav-toggle:checked ~ .nav-overlay { opacity: 1; pointer-events: auto; }
.nav-toggle:checked ~ #render-nav { transform: translateX(0); }
.nav-brand {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 14px;
  text-decoration: none;
}
.nav-site-links, .nav-namespaces { list-style: none; margin: 0 0 16px; padding: 0; }
.nav-site-links { border-bottom: 1px solid var(--rule); padding-bottom: 14px; }
.nav-site-links li a {
  display: block;
  padding: 4px 2px;
  font-size: 13px;
  text-decoration: none;
}
.nav-site-links li a:hover { color: var(--muted); opacity: 1; }
.nav-group summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-transform: capitalize;
  padding: 5px 2px;
  list-style: none;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::before { content: "▸ "; }
.nav-group[open] summary::before { content: "▾ "; }
.nav-group ul {
  list-style: none;
  margin: 2px 0 8px 8px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--rule);
}
.nav-group li a {
  display: block;
  padding: 3px 2px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}
.nav-group li a:hover { color: var(--ink); opacity: 1; }
/* Print: hide the nav chrome. This rule lives inside @media print in render.css —
   extracting it flat is what blanked the nav on screen, so it stays wrapped here. */
@media print {
  #nav-btn, .nav-overlay, #render-nav, .nav-toggle { display: none !important; }
}
