/* ═══════════════════════════════════════════════════════════
   THE SONG IN OUR BONES — digital edition
   Shared stylesheet for every page.
   Typography follows the print book: bold geometric caps for structure
   (Futura PT), humanist sans for reading (Gill Sans Nova), via Adobe Fonts.
   Black on white. No ornament. Air.
   ═══════════════════════════════════════════════════════════ */
:root {
  --ink: #1a1a1a;
  --ink-soft: #555555;
  --ink-mute: #8a8a8a;
  --paper: #ffffff;
  --line: #d6d6d6;
  --line-strong: #1a1a1a;
  --display: 'futura-pt', 'Futura', 'Avenir Next', sans-serif;
  --text: 'gill-sans-nova', 'Gill Sans', sans-serif;
  --measure: 34em;
  --hl: #f7e9a3;   /* quiet marker yellow; alternatives: #fbe7b5 (warmer) · #e9eef3 (near-grey) */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  font-family: var(--text);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
em { font-style: italic; }           /* italics are reserved for quotations */
.title { font-style: normal; }       /* book and article titles: never italic */
.strong { font-weight: 700; font-style: normal; }

/* Highlighter — the one color on the site. */
.hl, a.xref {
  color: var(--ink); text-decoration: none; font-weight: inherit;
  background-image: linear-gradient(to top, transparent 10%, var(--hl) 10%, var(--hl) 78%, transparent 78%);
  padding: 0 0.12em; margin: 0 -0.12em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: background-image 0.15s;
}
a.xref:hover { background-image: linear-gradient(to top, transparent 10%, #f0dc7d 10%, #f0dc7d 78%, transparent 78%); }
a { color: var(--ink); }
a.ext { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
a.ext:hover { border-bottom-color: var(--ink); }

/* ─── Top bar (built by book.js) ─── */
.toc-bar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.toc-inner {
  max-width: 1200px; margin: 0 auto; padding: 0.85rem 2rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.toc-brand {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.68rem; letter-spacing: 0.08em; color: var(--ink); text-decoration: none;
}
.draft-flag {
  margin-left: 1.25rem; margin-right: auto;
  font-family: var(--text); font-size: 0.62rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute);
}
.toc-toggle {
  background: none; border: 1px solid var(--ink); color: var(--ink);
  padding: 0.35rem 0.8rem; cursor: pointer;
  font-family: var(--text); font-weight: 400; font-size: 0.68rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}
.toc-toggle:hover { background: var(--ink); color: var(--paper); }

/* ─── Contents panel (built by book.js) ─── */
.toc-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 100%; max-width: 420px;
  background: var(--paper); border-left: 1px solid var(--line);
  padding: 4rem 2.5rem 2.5rem; overflow-y: auto; z-index: 200;
  transform: translateX(100%); transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
.toc-panel.open { transform: translateX(0); }
.toc-close {
  position: absolute; top: 1.1rem; right: 1.4rem; background: none; border: none;
  font-size: 1.5rem; line-height: 1; color: var(--ink); cursor: pointer; font-weight: 300;
}
.toc-panel h3 {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.68rem; letter-spacing: 0.1em; color: var(--ink); margin-bottom: 1.75rem;
}
.toc-overlay {
  position: fixed; inset: 0; background: rgba(26,26,26,0.25); z-index: 150;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.toc-overlay.open { opacity: 1; pointer-events: auto; }

/* Contents list — used in the panel and on the home page */
.toc-list { list-style: none; }
.toc-list > li { padding: 0.85rem 0; border-top: 1px solid var(--line); }
.toc-list > li:last-child { border-bottom: 1px solid var(--line); }
.toc-num {
  display: block; font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.58rem; letter-spacing: 0.1em; color: var(--ink-mute); margin-bottom: 0.2rem;
}
.toc-title {
  display: block; font-family: var(--text); font-weight: 400; font-size: 1rem;
  line-height: 1.3; color: var(--ink); text-decoration: none;
}
.toc-title.live { font-weight: 700; }
.toc-byline {
  display: block; margin-top: 0.2rem;
  font-family: var(--text); font-weight: 400; font-size: 0.85rem; color: var(--ink-soft);
}
.toc-title.dim { color: var(--ink-mute); font-weight: 300; }
.toc-sublist { list-style: none; margin-top: 0.5rem; }
.toc-sublist li { padding: 0.25rem 0; }
.toc-sublist a, .toc-coming {
  display: block; font-family: var(--text); font-weight: 300; font-size: 0.9rem;
  color: var(--ink-soft); text-decoration: none; padding-left: 1rem;
  border-left: 1px solid var(--line); transition: color 0.15s, border-color 0.15s;
}
.toc-sublist a:hover { color: var(--ink); border-left-color: var(--ink); }
.toc-sublist li.current a { color: var(--ink); font-weight: 700; border-left-color: var(--ink); }
.toc-coming { color: var(--ink-mute); }
.draft-tag {
  margin-left: 0.4rem; font-size: 0.55rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute); font-weight: 400;
}

/* ─── Page grid: one grid for every page ─── */
.page-grid {
  max-width: 1200px; margin: 0 auto; padding: 0 2rem;
  display: grid; grid-template-columns: 1fr 2fr 1.4fr; column-gap: 3rem; align-items: start;
}
.page-grid > .col-left { grid-column: 1; text-align: right; }
.page-grid > .col-center { grid-column: 2; min-width: 0; }
.page-grid > .col-right { grid-column: 3; min-width: 0; }

/* ─── Home page ─── */
.home { padding: 8rem 0 2.5rem; }
.book-author {
  display: block; font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.7rem; letter-spacing: 0.1em; color: var(--ink-soft); margin-bottom: 1.25rem;
}
.book-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 2.1rem; letter-spacing: 0.02em; line-height: 1.15; color: var(--ink);
}
.book-subtitle {
  font-family: var(--text); font-size: 1.05rem; line-height: 1.5; color: var(--ink-soft);
  margin-top: 0.9rem; max-width: var(--measure);
}
.home-body { padding: 0 0 4rem; }
.home-note { font-size: 1.02rem; line-height: 1.62; max-width: var(--measure); margin-bottom: 2.5rem; }
.home-contents { max-width: var(--measure); }
.lineage { margin-top: 3rem; max-width: var(--measure); font-size: 0.82rem; line-height: 1.55; color: var(--ink-soft); }

/* ─── A section that isn't published yet (live site only) ─── */
.coming-page { padding: 9rem 0 6rem; }
.coming-page .coming-label {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.62rem; letter-spacing: 0.1em; color: var(--ink-mute); margin-bottom: 1rem;
}
.coming-page p { margin-top: 1.25rem; max-width: var(--measure); }

/* ─── Chapter opener — as in the book: title high on the page, then air ─── */
.opener { padding: 9rem 0 4.5rem; }
.chapter-title {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 1.55rem; letter-spacing: 0.02em; line-height: 1.25; color: var(--ink);
}

.chapter-sub {
  font-family: var(--text); font-size: 1.02rem; color: var(--ink-soft); margin-top: 0.6rem;
}

/* ─── Foreword ─── */
.foreword { padding: 0 0 4rem; }
.foreword-sign {
  text-align: right !important; max-width: var(--measure);
  font-family: var(--text); color: var(--ink); margin-top: 1.75rem !important;
}

.also-by {
  font-family: var(--text); font-weight: 400; font-size: 0.6rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute);
  margin-bottom: 1rem;
}
.also-by-work { margin: 0 0 2rem; }
.also-by-work img { width: 100%; height: auto; display: block; }
.also-by-work figcaption {
  margin-top: 0.5rem; font-family: var(--text); font-size: 0.78rem; line-height: 1.45; color: var(--ink-soft);
}
.also-by-work figcaption .title { color: var(--ink); font-weight: 700; }

/* ─── Epigraph — body-size text, attribution right-aligned, exactly as printed ─── */
.epigraph { padding: 0 0 3.5rem; }
.epigraph-inner { max-width: var(--measure); }
.epigraph blockquote {
  font-family: var(--text); font-weight: 400; font-size: 1.02rem; line-height: 1.6;
  font-style: normal; color: var(--ink);
}
.epigraph cite {
  display: block; text-align: right; font-style: normal;
  font-family: var(--text); font-weight: 300; font-size: 1.02rem; color: var(--ink);
  margin-top: 0.15rem;
}

/* ─── Three-column reading section ─── */
.three-col { padding: 2.5rem 0 4rem; }
.three-col.first { padding-top: 2.5rem; }
.three-col:not(.first) { padding-top: 6rem; }   /* a section page opens with air, like a new page */
.three-col > .col-left { align-self: stretch; display: flex; flex-direction: column; position: static; }
.three-col > .col-left .level3 { position: sticky; top: 84px; align-self: flex-end; background: var(--paper); z-index: 3; }

/* Level 3 — section heading, left column, with a rule beneath */
.level3 {
  display: inline-block;
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.7rem; letter-spacing: 0.08em; line-height: 1.4; color: var(--ink);
  padding-bottom: 0.55rem; border-bottom: 1px solid var(--line-strong); text-align: right;
}

/* Margin quotes — one holds the slot beneath the heading at a time (see book.js) */
.margin-quote {
  position: sticky; top: 9.5rem; align-self: flex-end;
  max-width: 100%; text-align: right; margin: 0;
  background: var(--paper); z-index: 2; padding-bottom: 0.25rem;
  transition: opacity 0.35s ease;
}
.margin-quote.passed { opacity: 0; pointer-events: none; }
.margin-quote blockquote {
  font-family: var(--text); font-weight: 400; font-style: normal;
  font-size: 0.86rem; line-height: 1.5; color: var(--ink);
}
.margin-quote .mq-cite {
  display: block; margin-top: 0.6rem;
  font-family: var(--text); font-weight: 400; font-style: normal;
  font-size: 0.72rem; line-height: 1.45; color: var(--ink-soft);
}
.margin-quote .mq-cite a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--ink); }
.margin-quote .mq-cite a:hover { color: var(--ink-mute); border-bottom-color: var(--ink-mute); }
.margin-quote .mq-cite .title { display: block; font-style: normal; color: var(--ink-soft); margin-top: 0.15rem; }

/* Body text — justified with hyphenation, as set in the book */
.col-center p {
  font-family: var(--text); font-weight: 400; font-size: 1.02rem; line-height: 1.62;
  color: var(--ink); max-width: var(--measure); margin: 0 0 1.35rem 0;
  text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.col-center p + p { margin-top: 0.1rem; }
.section-heading {
  font-family: var(--text); font-weight: 400; font-size: 1.15rem; line-height: 1.45;
  color: var(--ink); max-width: var(--measure); margin-bottom: 1.5rem;
}

/* Pull-quote — larger, lighter; the only "loud" moment on the page */
.col-center .pull-inline {
  font-family: var(--text); font-weight: 300; font-size: 1.45rem; line-height: 1.4;
  color: var(--ink); max-width: 26em; margin: 2.75rem 0; text-align: left;
  border: 0; padding: 0;
}

/* Section end — a short hairline, then the section turn */
.section-end { width: 3.5em; border-top: 1px solid var(--line-strong); margin: 3rem 0 0; }
.section-nav {
  display: flex; gap: 2rem; align-items: baseline; flex-wrap: wrap;
  margin-top: 1.4rem; max-width: var(--measure);
}
.section-nav a, .section-nav span {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.62rem; letter-spacing: 0.1em; color: var(--ink); text-decoration: none;
}
.section-nav a.next { border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
.section-nav a.next:hover { color: var(--ink-mute); border-bottom-color: var(--ink-mute); }
.section-nav a.contents { color: var(--ink-mute); }
.section-nav a.contents:hover { color: var(--ink); }
.section-nav span.next { color: var(--ink-mute); }

/* Right-column figures: first pins to the top, "end" pins to the bottom,
   anything with a paragraph anchor is aligned to it by book.js */
.three-col > .col-right { align-self: stretch; display: flex; flex-direction: column; }
.side-figure { margin: 0; width: 100%; }
.side-figure img { width: 100%; height: auto; display: block; }
.side-figure figcaption { margin-top: 0.5rem; }
.side-figure[data-anchor="end"] { margin-top: auto; }
.side-figure[data-anchor="stack"] { margin-top: 2rem; }
.credit {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--text); font-weight: 400; font-size: 0.6rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute);
}
.credit svg { width: 11px; height: 11px; display: block; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ─── Endnotes — small superscripts, quiet popovers ─── */
.fn { position: relative; display: inline; cursor: pointer; }
.fn sup {
  font-family: var(--text); font-weight: 400; font-size: 0.6em;
  vertical-align: super; line-height: 0; color: var(--ink); padding: 0 0.1em;
}
.fn:hover sup, .fn:focus-within sup, .fn.open sup { text-decoration: underline; }
.fn-body {
  position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%) translateY(8px);
  width: min(360px, 80vw); background: var(--paper);
  border: 1px solid var(--line); padding: 0.9rem 1.05rem 1rem;
  font-family: var(--text); font-weight: 300; font-size: 0.82rem; line-height: 1.5;
  color: var(--ink); text-align: left; text-transform: none; font-style: normal;
  box-shadow: 0 10px 28px rgba(26,26,26,0.10); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s;
}
.fn-body .fn-num {
  display: block; font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 0.55rem; letter-spacing: 0.1em; color: var(--ink-mute); margin-bottom: 0.35rem;
}
.fn-body em { font-style: italic; }
.fn-body .title { font-weight: 400; }
.fn-body .strong { font-weight: 700; }
.fn-body a { color: var(--ink); word-break: break-word; }
.fn:hover .fn-body, .fn:focus-within .fn-body, .fn.open .fn-body {
  opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(2px);
}
.pull-inline .fn sup { font-size: 0.45em; }

/* ─── Running footer — as printed: centered small caps ─── */
footer {
  padding: 2.5rem 2rem 3rem; text-align: center;
  font-family: var(--text); font-weight: 400; font-size: 0.62rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
}
footer a { color: var(--ink-soft); text-decoration: none; }

/* ─── Reveal — quiet ─── */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity 0.9s ease, transform 0.9s ease; }
.reveal.in-view { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .page-grid { grid-template-columns: 1fr; row-gap: 1.5rem; }
  .page-grid > .col-left, .page-grid > .col-center, .page-grid > .col-right { grid-column: 1; text-align: left; }
  .three-col > .col-left { display: block; }
  .three-col > .col-left .level3, .margin-quote { position: static; }
  .three-col:not(.first) { padding-top: 3.5rem; }
  .level3 { text-align: left; }
  /* Phone: side elements are moved into the text flow by book.js, after their anchor */
  .side-figure.inline { margin: 1.5rem 0 2rem; max-width: var(--measure); }
  .side-figure.inline[data-anchor="end"] { margin-top: 1.5rem; }
  .margin-quote.inline {
    text-align: left; margin: 1.25rem 0 2rem; padding-left: 1rem;
    border-left: 1px solid var(--line-strong); max-width: var(--measure);
  }
  .opener, .home, .coming-page { padding-top: 5rem; }
  .opener { padding-bottom: 3rem; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .page-grid { padding: 0 1.25rem; }
  .col-center p { text-align: left; hyphens: manual; }
  .chapter-title { font-size: 1.3rem; }
  .book-title { font-size: 1.7rem; }
  .toc-inner { padding: 0.7rem 1.25rem; }
  .toc-panel { padding: 3rem 1.5rem 2rem; }
  .col-center .pull-inline { font-size: 1.25rem; }
}
