/* Edge of the Decade — Restrained long-form reading stylesheet
   No external fonts, no gradients, no colored left-border stripes, offline-first. */

:root {
  color-scheme: light dark;
  --bg: #faf8f4;
  --surface: #f2efe8;
  --text: #1a1916;
  --muted: #545047;
  --rule: #d9d4c9;
  --rule-strong: #9c9689;
  --code-bg: #efece3;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1d1c19;
    --text: #e9e6dd;
    --muted: #a8a396;
    --rule: #302e28;
    --rule-strong: #635f54;
    --code-bg: #22211d;
  }
}

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 0.85rem;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Sticky top table-of-contents bar */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.site-nav-inner {
  max-width: 68ch;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
}

.site-nav-inner.wide {
  max-width: 64rem;
}

.site-brand {
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.1rem 0;
  border-bottom: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text);
  border-bottom-color: var(--rule-strong);
}

.nav-links a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}

/* Main column */
main {
  max-width: 68ch;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3.5rem;
}

main.wide {
  max-width: 64rem;
}

main.wide > p,
main.wide > ul,
main.wide > ol,
main.wide > blockquote,
main.wide > .note-box,
main.wide > .status-box,
main.wide > header,
main.wide > section > p,
main.wide > section > ul,
main.wide > section > ol,
main.wide > section > .note-box {
  max-width: 68ch;
}

/* Typography */
header.doc-header {
  padding-bottom: 1.75rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--rule-strong);
}

.kicker {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}

.tagline {
  font-size: 1.15rem;
  font-style: italic;
  color: var(--muted);
  margin: 0 0 1.15rem;
  line-height: 1.48;
}

.meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
}

.meta strong {
  color: var(--text);
  font-weight: 600;
}

h2 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.015em;
  margin: 2.5rem 0 0.9rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

section:first-of-type > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.9rem 0 0.7rem;
}

p {
  margin: 0 0 1.05rem;
}

ul,
ol {
  margin: 0 0 1.15rem;
  padding-left: 1.35rem;
}

li {
  margin-bottom: 0.55rem;
}

li > ul,
li > ol {
  margin-top: 0.45rem;
  margin-bottom: 0.35rem;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.16em;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-strong);
}

a:hover,
a:focus-visible {
  text-decoration-color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.08rem 0.3rem;
  border-radius: 2px;
}

a.cite {
  font-family: var(--font-mono);
  font-size: 0.84em;
  text-decoration: none;
  border-bottom: 1px dotted var(--rule-strong);
  white-space: nowrap;
}

a.cite:hover,
a.cite:focus-visible {
  border-bottom-style: solid;
  border-bottom-color: var(--text);
}

/* Framed callouts and blockquotes: full thin border or top/bottom rule, never a one-sided colored stripe */
blockquote,
.note-box,
.status-box {
  margin: 1.35rem 0;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  font-size: 0.98rem;
}

blockquote {
  font-style: italic;
}

blockquote p:last-child,
.note-box p:last-child,
.note-box ul:last-child,
.status-box p:last-child {
  margin-bottom: 0;
}

.status-box {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--muted);
}

.status-box strong {
  color: var(--text);
}

/* Inline secondary / unverified notes and badges */
.weak-label {
  font-family: var(--font-sans);
  font-size: 0.86em;
  color: var(--muted);
  font-style: italic;
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.1rem 0.42rem;
  border: 1px solid var(--rule-strong);
  color: var(--text);
  background: var(--surface);
  vertical-align: baseline;
  white-space: nowrap;
}

/* Chapter table of contents box */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  border-top: 1px solid var(--rule);
}

.toc-list li {
  margin: 0;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}

.toc-title {
  display: block;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.toc-desc {
  display: block;
  font-size: 0.94rem;
  color: var(--muted);
}

/* Prediction list & headline blocks */
.headline-predictions {
  list-style: none;
  padding: 0;
  margin: 1.15rem 0 1.5rem;
  border-top: 1px solid var(--rule);
}

.headline-predictions li {
  margin: 0;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}

.pred-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.2rem;
}

/* Responsive tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.25rem 0 1.75rem;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.48;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

thead th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

.source-entry {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--rule);
  max-width: 68ch;
}

.source-entry:target {
  background: var(--surface);
  padding: 1.15rem;
  border: 1px solid var(--rule-strong);
}

.source-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.45rem;
  font-family: var(--font-sans);
}

.source-id {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
}

.source-pub {
  font-size: 0.86rem;
  color: var(--muted);
}

.source-quote {
  margin: 0.6rem 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  font-size: 0.94rem;
  font-style: italic;
}

.source-meta {
  font-family: var(--font-sans);
  font-size: 0.83rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.source-url {
  word-break: break-all;
}

/* Prev / Next chapter pager */
.chapter-pager {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-strong);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  max-width: 68ch;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
}

.site-footer.wide {
  max-width: 64rem;
}

.site-footer p {
  margin: 0 0 0.45rem;
  max-width: 68ch;
}

/* Print stylesheet */
@media print {
  :root {
    --bg: #ffffff;
    --surface: #f7f7f7;
    --text: #000000;
    --muted: #333333;
    --rule: #cccccc;
    --rule-strong: #666666;
  }

  .skip-link,
  .site-nav,
  .chapter-pager {
    display: none;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.5;
  }

  main,
  main.wide,
  .site-footer,
  .site-footer.wide {
    max-width: none;
    padding: 0;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  .source-entry,
  .note-box,
  blockquote,
  tr {
    break-inside: avoid;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    word-break: break-all;
  }
}
