/* ============================================================
   tomasruta.com — shared styles
   Typography & palette ported from communities-fund-website.
   Layout: sticky left sidebar (table of contents) + reading column,
   in the spirit of gradual-disempowerment.ai.
   ============================================================ */

:root {
  --bg:     #f5efe3;   /* warm cream */
  --ink:    #2a1f15;   /* dark warm brown — body text */
  --muted:  #6b5b48;   /* secondary text */
  --rule:   #c9bda6;   /* hairlines / borders */
  --accent: #a8482a;   /* terracotta — links on hover, active marker */

  --serif: "Source Serif 4", Georgia, "Iowan Old Style", "Apple Garamond", Cambria, "Times New Roman", serif;

  --measure:   660px;  /* reading column width */
  --sidebar-w: 196px;
  --gap:       60px;   /* space between sidebar and content */
  --body-size: 19px;
  --body-leading: 1.7;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 28px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--body-size);
  line-height: var(--body-leading);
  font-feature-settings: "onum" 1, "kern" 1, "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(42, 31, 21, 0.30);
  text-underline-offset: 2.5px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
::selection { background: rgba(168, 72, 42, 0.20); color: var(--ink); }

/* ---------- Layout: sidebar + content ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--gap);
  max-width: calc(var(--sidebar-w) + var(--gap) + var(--measure) + 80px);
  margin: 0 auto;
  padding: 0 40px;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 58px 0 36px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content {
  padding: 58px 0 30vh;
  min-width: 0;
}

article,
.page-body {
  max-width: var(--measure);
}

/* ---------- Sidebar identity ---------- */

.site-id { flex: 0 0 auto; margin-bottom: 34px; }
.site-id a { text-decoration: none; }
.site-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.005em;
}
.site-tagline {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 5px;
}

/* ---------- Sidebar table of contents ---------- */

.toc-toggle {
  display: none;             /* desktop: hidden; shown on mobile */
  appearance: none;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
}

.toc {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.32;
  padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc a:hover { color: var(--ink); }
.toc a.active {
  color: var(--ink);
  border-left-color: var(--accent);
  font-weight: 500;
}
.toc .toc-h3 a {
  padding-left: 28px;
  font-size: 0.85rem;
  color: var(--muted);
}

.sidebar-foot {
  flex: 0 0 auto;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
}
.sidebar-foot a { color: var(--muted); text-decoration: none; }
.sidebar-foot a:hover { color: var(--accent); }

/* ---------- Article typography ---------- */

.essay-title {
  font-size: 2.55rem;
  line-height: 1.08;
  font-weight: 450;
  letter-spacing: -0.017em;
  margin: 0 0 12px;
}
.essay-meta {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 1.9em;
}

.lede {
  font-size: 1.3em;
  line-height: 1.42;
  font-weight: 350;
  letter-spacing: -0.005em;
  margin: 0 0 1.2em;
}

article h2 {
  font-size: 1.5rem;
  font-weight: 540;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 2.5em 0 0.5em;
}
article h3 {
  font-size: 1.18rem;
  font-weight: 540;
  line-height: 1.3;
  margin: 1.9em 0 0.3em;
}
article h4 {
  font-size: 1rem;
  font-weight: 600;
  font-style: italic;
  margin: 1.5em 0 0.2em;
}
article p { margin: 0 0 1.15em; }
article ul { margin: 0 0 1.2em; padding-left: 1.25em; }
article li { margin: 0.3em 0; padding-left: 0.2em; }
article em { font-style: italic; }
article strong { font-weight: 600; }

article h2, article h3, article h4 { scroll-margin-top: 28px; }

.end-rule {
  border: none;
  border-top: 1px solid var(--rule);
  width: 60px;
  margin: 2.6em 0 1.6em;
}
.closing {
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}

/* ---------- Footnotes ---------- */

.footnote-ref { text-decoration: none; }
.footnote-ref sup { font-size: 0.7em; padding: 0 0.08em; }

.footnotes {
  margin-top: 4em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}
.footnotes hr { display: none; }       /* pandoc inserts one; rule above replaces it */
.footnotes ol { padding-left: 1.3em; margin: 0; }
.footnotes li { margin: 0.55em 0; scroll-margin-top: 28px; }
.footnotes p { margin: 0; }
.footnote-back { text-decoration: none; margin-left: 0.35em; }

/* ---------- Writing index ---------- */

.page-centered {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 60px 28px 26vh;
}

.page-title {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0 0 1.3em;
}
.essay-list { list-style: none; margin: 0; padding: 0; }
.essay-list > li {
  padding: 1.7em 0;
  border-top: 1px solid var(--rule);
}
.essay-list > li:first-child { border-top: none; padding-top: 0; }
.essay-link {
  font-size: 1.45rem;
  font-weight: 450;
  line-height: 1.25;
  letter-spacing: -0.014em;
  text-decoration: none;
}
.essay-link:hover { color: var(--accent); }
.essay-date {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 7px;
}
.essay-excerpt {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  :root { --body-size: 18px; }

  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 24px;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 38px 0 0;
    display: block;
  }
  .content { padding: 26px 0 18vh; }

  .site-id { margin-bottom: 14px; }

  .toc-toggle { display: inline-block; }
  .toc {
    display: none;
    margin-top: 16px;
    overflow: visible;
  }
  .toc.open { display: block; }

  .sidebar-foot { display: none; }

  .essay-title { font-size: 2.05rem; }
  .lede { font-size: 1.2em; }
}

/* ---------- Print ---------- */

@media print {
  .sidebar { display: none; }
  .layout { display: block; max-width: none; padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; }
}
