/* Long-form reading pages for pmj104.com/writing. Tokens match the site's styles.css. */
:root {
  --bg: #f2f0eb;
  --ink: #0d0d0d;
  --muted: rgb(13 13 13 / 0.55);
  --accent: #ff3b1f;
  --gap: 1rem;
  --pad: clamp(1rem, 2.5vw, 2rem);
  --measure: 40rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 1.0625rem;
  line-height: 1.62;
}

::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover, a:focus-visible { color: var(--accent); }

.page { padding: var(--pad); max-width: 82rem; margin: 0 auto; }

.rule-row {
  display: flex;
  justify-content: space-between;
  gap: var(--gap);
  border-top: 3px solid var(--ink);
  padding-top: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.rule-row a { text-decoration: none; }

/* ---- masthead ---- */
.masthead { margin: clamp(2.5rem, 8vh, 5rem) 0 clamp(2rem, 6vh, 4rem); max-width: 60rem; }
.eyebrow {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.masthead h1 {
  margin: 0;
  font-weight: 900;
  font-size: clamp(2.2rem, 5.5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
}
.byline { margin: 1rem 0 0; font-size: 0.95rem; font-weight: 600; }
.version { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }
.version a { color: inherit; }
.subtitle { margin: 1.25rem 0 0; font-size: 1.1rem; color: var(--muted); max-width: 40rem; line-height: 1.4; }

/* ---- layout ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(12rem, 16rem) minmax(0, var(--measure));
  column-gap: clamp(2rem, 6vw, 6rem);
  border-top: 1px solid var(--ink);
  padding-top: 1.5rem;
  margin-bottom: 4rem;
}

.toc { position: sticky; top: 1.5rem; align-self: start; max-height: calc(100svh - 3rem); overflow: auto; font-size: 0.85rem; line-height: 1.35; }
.toc h2 { margin: 0 0 0.75rem; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc > ul > li { border-top: 1px solid var(--ink); padding: 0.45rem 0; }
.toc > ul > li:last-child { border-bottom: 1px solid var(--ink); }
.toc > ul > li > a { font-weight: 600; }
.toc ul ul { margin-top: 0.3rem; padding-left: 0.75rem; }
.toc ul ul li { padding: 0.12rem 0; color: var(--muted); }
.toc a { text-decoration: none; }
/* section being read (set by the script in paper.html) */
@media screen {
  .toc a.is-current { color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); padding-left: 0.45rem; margin-left: -0.45rem; transition: color 160ms ease; }
  .toc a.is-current-parent { color: var(--accent); }
}

/* ---- paper ---- */
.paper { min-width: 0; }
.paper h1 {
  margin: 3.5rem 0 1rem;
  padding-top: 0.6rem;
  border-top: 3px solid var(--ink);
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.paper > h1:first-child { margin-top: 0; }
.paper h2 { margin: 2.5rem 0 0.75rem; font-size: 1.25rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1.15; }
.paper h3 { margin: 2rem 0 0.5rem; font-size: 1.05rem; font-weight: 600; }
.paper p { margin: 0 0 1.1rem; hyphens: auto; }
.paper ul, .paper ol { padding-left: 1.2rem; margin: 0 0 1.1rem; }
.paper li { margin-bottom: 0.5rem; }
.paper blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 3px solid var(--accent); }
.paper strong { font-weight: 600; }

/* tables */
.paper table { width: 100%; border-collapse: collapse; margin: 1.5rem 0 2rem; font-size: 0.85rem; line-height: 1.35; display: block; overflow-x: auto; }
.paper caption { caption-side: bottom; text-align: left; padding-top: 0.6rem; font-size: 0.8rem; color: var(--muted); }
.paper thead th { text-align: left; font-weight: 600; border-top: 3px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 0.45rem 0.6rem 0.45rem 0; }
.paper td { border-bottom: 1px solid rgb(13 13 13 / 0.2); padding: 0.4rem 0.6rem 0.4rem 0; vertical-align: top; }
.paper td:last-child, .paper th:last-child { padding-right: 0; }

/* references: hanging indent */
#references ~ p { padding-left: 1.5rem; text-indent: -1.5rem; font-size: 0.9rem; line-height: 1.45; margin-bottom: 0.6rem; overflow-wrap: anywhere; }

.colophon { color: var(--muted); font-weight: 400; text-transform: none; }

.print-only { display: none; }

/* download button */
.actions { margin: 1.75rem 0 0; }
.button {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.button:hover, .button:focus-visible { background: var(--ink); color: var(--bg); outline: none; }

/* landing pages (no contents column) */
.paper.wide { grid-column: 1 / -1; max-width: 52rem; }

/* index lists, styled like the home page link groups */
.index-list ul { list-style: none; margin: 0 0 2rem; padding: 0; }
.index-list li { border-top: 1px solid var(--ink); margin: 0; padding: 0.8rem 0; }
.index-list li:last-child { border-bottom: 1px solid var(--ink); }
/* list straight under the page rule: avoid a double line */
.paper > .index-list:first-child li:first-child { border-top: 0; }
.index-list li > p { margin: 0; }
.index-list li > p:first-child { font-size: 1.2rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1.2; }
.index-list li > p:first-child strong { font-weight: 900; }
.index-list li > p:first-child a { text-decoration: none; }
.index-list li > p:first-child a::after { content: "→"; display: inline-block; margin-left: 0.3em; transition: transform 160ms ease; }
.index-list li > p:first-child a:hover::after { transform: translateX(3px); }
.index-list li > p + p { margin-top: 0.3rem; color: var(--muted); font-size: 0.95rem; }
.index-list li > p + p a { color: var(--ink); }
.index-list .status { color: var(--accent); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; margin-left: 0.4rem; }

/* ---- 2026 edition pages ---- */
.crumbs { min-width: 0; }
.crumbs [aria-current] { color: var(--muted); }
.layout.edition .side { position: sticky; top: 1.5rem; align-self: start; max-height: calc(100svh - 3rem); overflow: auto; }
.layout.edition .side .toc { position: static; max-height: none; overflow: visible; }
.layout.edition .side .toc + .toc { margin-top: 2rem; }
.edition-menu ul, .edition-menu-foot ul { list-style: none; margin: 0; padding: 0; }
.edition-menu li.sub, .edition-menu-foot li.sub { padding-left: 0.75rem; }
.edition-menu > ul > li.sub > a { font-weight: 400; }
.edition-menu a[aria-current], .edition-menu-foot a[aria-current] { color: var(--accent); }
.edition-menu-foot { display: none; }

/* wide tables scroll inside their own container */
.table-wrap { overflow-x: auto; margin: 1.5rem 0 2rem; -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.paper .table-wrap table { display: table; margin: 0; }
.paper .table-wrap.wide table { min-width: 44rem; }
.paper .table-wrap td, .paper .table-wrap th { overflow-wrap: normal; }

/* cross-references */
.paper a.xref { text-decoration-style: dotted; }

/* endnotes */
.paper .footnotes { margin-top: 3rem; font-size: 0.9rem; line-height: 1.45; }
.paper .footnotes h2 { border-top: 3px solid var(--ink); padding-top: 0.6rem; }
.paper .footnotes ol { padding-left: 1.4rem; }
.paper .footnotes li { margin-bottom: 0.6rem; }
.paper .footnotes li p { margin: 0; }
.paper .footnote-ref sup { font-size: 0.7em; line-height: 0; font-weight: 600; }
.paper .footnote-ref { text-decoration: none; }
.paper .footnote-back { text-decoration: none; margin-left: 0.25rem; }

/* citeproc reference lists */
.paper h2#references { border-top: 3px solid var(--ink); padding-top: 0.6rem; margin-top: 3rem; }
.paper .csl-entry { padding-left: 1.5rem; text-indent: -1.5rem; font-size: 0.9rem; line-height: 1.45; margin-bottom: 0.6rem; overflow-wrap: anywhere; }
.paper .citation a { text-decoration: none; }

/* previous / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin: 4rem 0 0; border-top: 3px solid var(--ink); padding-top: 0.8rem; }
.pager a { text-decoration: none; font-weight: 900; letter-spacing: -0.02em; line-height: 1.2; }
.pager .next { grid-column: 2; text-align: right; }
.pager-label { display: block; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 0.25rem; }
.edition-menu-foot h2 { margin: 2.5rem 0 0.75rem; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.edition-menu-foot li { border-top: 1px solid var(--ink); padding: 0.45rem 0; margin: 0; font-size: 0.9rem; }
.edition-menu-foot li:last-child { border-bottom: 1px solid var(--ink); }
.edition-menu-foot a { text-decoration: none; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; max-height: none; margin-bottom: 2.5rem; }
  .toc ul ul { display: none; }
  .layout.edition .side { position: static; max-height: none; overflow: visible; }
  .layout.edition .side .edition-menu { display: none; }
  .edition-menu-foot { display: block; }
}

@media (max-width: 600px) {
  .top .top-mid { display: none; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { grid-column: 1; text-align: left; }
}

/* Briefing for founders and managers: the "At a glance" rules in a ruled box (one printed page). */
.at-a-glance { border-top: 3px solid var(--ink); border-bottom: 1px solid var(--ink); margin: 2rem 0 2.5rem; padding: 0.25rem 0 0.75rem; }
.at-a-glance h2 { margin-top: 0.75rem; }
.at-a-glance ol { padding-left: 1.4rem; }
.at-a-glance li { margin: 0.55rem 0; }

@page {
  size: A4;
  margin: 22mm 20mm 22mm;
  @bottom-center { content: counter(page); font-family: "Inter Tight", Arial, sans-serif; font-size: 8.5pt; color: #777; }
}
@page :first { @bottom-center { content: none; } }

@media print {
  body { background: #fff; font-size: 10.5pt; line-height: 1.5; }
  .page { padding: 0; max-width: none; }
  .top, .colophon, .actions { display: none; }
  .print-only { display: block; }
  a { text-decoration: none; color: inherit; }

  /* title page */
  .masthead { min-height: 230mm; margin: 0; padding-top: 70mm; break-after: page; border-top: 3px solid var(--ink); }
  .masthead h1 { font-size: 30pt; }
  .print-source { margin-top: 3rem; font-size: 9pt; color: var(--muted); }

  /* contents page */
  .layout { display: block; border: 0; padding: 0; margin: 0; }
  .toc { position: static; max-height: none; overflow: visible; break-after: page; font-size: 10pt; }
  .toc ul ul { display: block; }

  .paper h1 { break-before: page; margin-top: 0; font-size: 18pt; }
  .paper > h1:first-child { break-before: avoid; }
  .paper h1, .paper h2, .paper h3 { break-after: avoid; }
  .paper p { orphans: 3; widows: 3; hyphens: auto; }
  .paper table { display: table; font-size: 8.5pt; }
  .paper thead { display: table-header-group; }
  .paper tr { break-inside: avoid; }
  #references ~ p { font-size: 9pt; }

  /* 2026 edition: navigation off, tables fit the page in smaller type */
  .side, .pager, .edition-menu-foot, .crumbs { display: none; }
  .table-wrap { overflow: visible; margin: 1rem 0 1.5rem; }
  .paper .table-wrap table { width: 100%; font-size: 8pt; }
  .paper .table-wrap.wide table { min-width: 0; font-size: 7pt; line-height: 1.25; }
  .paper .table-wrap td, .paper .table-wrap th { overflow-wrap: break-word; hyphens: auto; }
  .paper .table-wrap caption { font-size: 7.5pt; }
  .layout.combined .paper h2 { break-before: auto; }
  .paper .footnotes { font-size: 8.5pt; break-before: auto; }
  .paper .csl-entry { font-size: 9pt; }
  .paper a.xref { text-decoration: none; }
  .at-a-glance { break-after: page; border-bottom: 0; margin: 0; }
  .at-a-glance li { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Chapter and section numbers: keep a clear gap before the title despite tight heading tracking. */
.secnum { margin-right: 0.45em; letter-spacing: normal; font-variant-numeric: tabular-nums; }
h1 .secnum { margin-right: 0.35em; }
