/* Open Line — book site
   Light by default, dark by toggle or system preference. */

:root {
  --bg:        #ffffff;
  --bg-alt:    #f6f7f8;
  --bg-sunk:   #eceef0;
  --ink:       #14181c;
  --ink-soft:  #4c565d;
  --ink-faint: #7c8892;
  --rule:      #dfe3e7;
  --amber:     #a97c14;
  --amber-bg:  #faf1dc;
  --teal:      #0f8577;
  --teal-bg:   #e2f3ef;
  --paper:     #fdfbf6;
  --paper-ink: #23282c;
  --shadow:    0 1px 2px rgba(16,22,28,.06), 0 8px 24px rgba(16,22,28,.07);
  --shadow-lg: 0 2px 6px rgba(16,22,28,.08), 0 24px 60px rgba(16,22,28,.14);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Source Serif Pro", Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1080px;
}

:root[data-theme="dark"] {
  --bg:        #0d1117;
  --bg-alt:    #131a24;
  --bg-sunk:   #0a0e14;
  --ink:       #e8edf2;
  --ink-soft:  #aab5bf;
  --ink-faint: #7f8b96;
  --rule:      #232c38;
  --amber:     #d9a63b;
  --amber-bg:  #1e1808;
  --teal:      #46b3a2;
  --teal-bg:   #0a1a17;
  --paper:     #151c25;
  --paper-ink: #dfe6ec;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 24px 60px rgba(0,0,0,.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0d1117;
    --bg-alt:    #131a24;
    --bg-sunk:   #0a0e14;
    --ink:       #e8edf2;
    --ink-soft:  #aab5bf;
    --ink-faint: #7f8b96;
    --rule:      #232c38;
    --amber:     #d9a63b;
    --amber-bg:  #1e1808;
    --teal:      #46b3a2;
    --teal-bg:   #0a1a17;
    --paper:     #151c25;
    --paper-ink: #dfe6ec;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 24px 60px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

a { color: var(--teal); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 720px; }

/* ---------- nav ---------- */

.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.nav-in {
  max-width: var(--wrap); margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand {
  font-weight: 700; letter-spacing: .16em; font-size: 14px;
  text-transform: uppercase; color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.nav-links a {
  color: var(--ink-soft); text-decoration: none; font-size: 14.5px;
  white-space: nowrap;            /* a wrapped nav link doubles the bar height */
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.nav-buy {
  color: var(--teal); font-weight: 600; border: 1px solid var(--teal);
  padding: 6px 13px; border-radius: 7px;
}
.nav-links a.nav-buy:hover { background: var(--teal); color: #fff; }
@media (max-width: 720px) { .nav-links a.hide-sm { display: none; } }
/* below this the bar cannot hold brand, both links, the button and the toggle */
@media (max-width: 620px) {
  .nav-links a.hide-xs { display: none; }
  .nav-links { gap: 14px; }
  .nav-in { gap: 12px; padding-inline: 16px; }
  .brand { font-size: 13px; letter-spacing: .12em; }
}

.themer {
  border: 1px solid var(--rule); background: var(--bg-alt); color: var(--ink-soft);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; padding: 0; flex: none;
}
.themer:hover { color: var(--ink); border-color: var(--ink-faint); }
.themer svg { width: 17px; height: 17px; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
.i-sun { display: none; }
.i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 22px; border-radius: 9px; font-size: 15.5px; font-weight: 600;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: color-mix(in srgb, var(--teal) 88%, #000); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--ink-faint); }

/* ---------- hero ---------- */

.hero {
  padding: 84px 0 76px;
  background:
    radial-gradient(900px 420px at 78% -8%, var(--teal-bg), transparent 62%),
    radial-gradient(700px 380px at 6% 4%, var(--amber-bg), transparent 60%);
  border-bottom: 1px solid var(--rule);
}
.hero-grid {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 60px; align-items: center;
}

.kicker {
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--amber); font-weight: 700; margin: 0 0 20px;
}
h1.title {
  font-family: var(--sans);
  font-size: clamp(46px, 8vw, 82px); line-height: .98; letter-spacing: -.02em;
  font-weight: 800; margin: 0 0 22px;
}
.sub {
  font-family: var(--serif); font-size: clamp(19px, 2.3vw, 23px); line-height: 1.45;
  color: var(--ink-soft); margin: 0 0 30px; max-width: 30em;
}
.byline {
  font-size: 13.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 32px; font-weight: 600;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.cta-note { font-size: 14px; color: var(--ink-faint); margin: 18px 0 0; }

.hero-art { position: relative; display: flex; justify-content: flex-end; }
.hero-art img {
  width: auto; max-width: 100%; max-height: 460px; border-radius: 4px;
  box-shadow: var(--shadow-lg);
  transform: perspective(1400px) rotateY(-11deg) rotateX(2deg);
  transition: transform .5s cubic-bezier(.2,.7,.3,1);
}
.hero-art img:hover { transform: perspective(1400px) rotateY(-4deg) rotateX(1deg); }
@media (prefers-reduced-motion: reduce) { .hero-art img { transform: none; } }

@media (max-width: 900px) {
  .hero { padding: 52px 0 56px; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  /* title and buttons lead; the cover follows them */
  .hero-art { justify-content: center; }
  .hero-art img { max-height: 340px; }
}
@media (max-width: 620px) {
  .hero-art img { max-height: 300px; }
}

/* ---------- generic section ---------- */

section { padding: 78px 0; }
section.alt { background: var(--bg-alt); border-block: 1px solid var(--rule); }
.eyebrow {
  font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--teal); font-weight: 700; margin: 0 0 14px;
}
h2 {
  font-size: clamp(28px, 4vw, 38px); line-height: 1.15; letter-spacing: -.015em;
  font-weight: 750; margin: 0 0 20px;
}
h3 { font-size: 19px; line-height: 1.3; margin: 0 0 10px; font-weight: 700; }
.lede { font-family: var(--serif); font-size: 20px; line-height: 1.6; color: var(--ink-soft); }
p { margin: 0 0 18px; }

/* pull quote from the book */
.pull {
  font-family: var(--serif); font-size: clamp(24px, 3.4vw, 34px); line-height: 1.35;
  margin: 0; padding: 8px 0 8px 30px; border-left: 4px solid var(--amber);
  color: var(--ink);
}
.pull cite { display: block; margin-top: 18px; font: 600 13px/1 var(--sans);
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); font-style: normal; }

/* ---------- the question / cards ---------- */

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 40px; }
@media (max-width: 860px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--bg); border: 1px solid var(--rule); border-radius: 12px;
  padding: 26px 24px; box-shadow: var(--shadow);
}
section.alt .card { background: var(--bg); }
.card .n {
  font: 700 12px/1 var(--mono); letter-spacing: .1em; color: var(--amber);
  display: block; margin-bottom: 14px;
}
.card p { color: var(--ink-soft); font-size: 15.5px; margin: 0; }

/* ---------- figures ---------- */

.figs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px; margin-top: 40px; }
@media (max-width: 780px) { .figs { grid-template-columns: 1fr; } }
figure.fig {
  margin: 0; background: #fff; border: 1px solid var(--rule); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow);
}
figure.fig img { width: 100%; }
figure.fig a { display: block; }
figure.fig .zoom {
  font: 600 12px/1 var(--sans); color: var(--ink-faint);
  padding: 0 18px 14px; background: var(--bg); display: none;
}
@media (max-width: 780px) { figure.fig .zoom { display: block; } }
figure.fig figcaption {
  font-size: 14px; color: var(--ink-soft); padding: 14px 18px 16px;
  background: var(--bg); border-top: 1px solid var(--rule);
}

/* ---------- contents ---------- */

.toc { margin-top: 36px; border-top: 1px solid var(--rule); }
.toc-part {
  font: 700 11.5px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase;
  color: var(--amber); padding: 30px 0 12px;
}
.toc-row {
  display: flex; gap: 20px; align-items: baseline;
  padding: 13px 4px; border-bottom: 1px solid var(--rule);
}
.toc-row .num {
  font: 600 13px/1 var(--mono); color: var(--ink-faint); width: 26px; flex: none;
}
.toc-row .nm { font-weight: 600; }
.toc-row .bl { color: var(--ink-faint); font-size: 14.5px; margin-left: auto; text-align: right; }
@media (max-width: 700px) { .toc-row .bl { display: none; } }
.toc-row.free { background: var(--teal-bg); border-radius: 8px; padding-inline: 12px; }
.toc-row.free .free-tag {
  font: 700 10.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: #fff; background: var(--teal); padding: 5px 9px; border-radius: 20px; margin-left: auto;
}

/* ---------- quotes (placeholders until supplied) ---------- */

/* one quote runs as a single centred feature; .grid takes over from two up */
.quotes { margin-top: 40px; }
.quotes.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
@media (max-width: 820px) { .quotes.grid { grid-template-columns: 1fr; } }
blockquote.endorse {
  margin: 0; background: var(--bg); border: 1px solid var(--rule); border-left: 3px solid var(--amber);
  border-radius: 10px; padding: 26px 26px 22px; box-shadow: var(--shadow);
}
blockquote.endorse p {
  font-family: var(--serif); font-size: 18px; line-height: 1.55; color: var(--ink); margin: 0 0 18px;
}
blockquote.endorse footer {
  font-size: 13.5px; color: var(--ink-faint); font-weight: 600;
}
blockquote.endorse.feature {
  max-width: 780px; margin-inline: auto; padding: 40px 44px 34px;
  border-left-width: 4px;
}
blockquote.endorse.feature p { font-size: 22px; line-height: 1.5; margin-bottom: 14px; }
blockquote.endorse.feature p:last-of-type { margin-bottom: 24px; }
blockquote.endorse.feature footer { font-size: 14.5px; }
@media (max-width: 620px) { blockquote.endorse.feature { padding: 30px 26px 24px; }
  blockquote.endorse.feature p { font-size: 19px; } }

/* ---------- authors ---------- */

.authors { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
@media (max-width: 780px) { .authors { grid-template-columns: 1fr; gap: 32px; } }
.author .portrait {
  width: 132px; height: 132px; border-radius: 50%; object-fit: cover;
  object-position: center 28%;
  border: 3px solid var(--bg); box-shadow: var(--shadow); margin: 0 0 20px;
  background: var(--bg-alt);
}
.author h3 { margin-bottom: 4px; }
.author .role {
  font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--amber); font-weight: 700; margin: 0 0 14px;
}
.author p { color: var(--ink-soft); font-size: 15.5px; }

/* ---------- final cta ---------- */

.finale {
  background: var(--bg-sunk); border-top: 1px solid var(--rule); text-align: center;
}
.finale h2 { max-width: 16em; margin-inline: auto; }
.finale .lede { max-width: 34em; margin: 0 auto 32px; }
.finale .cta-row { justify-content: center; }

footer.site {
  padding: 40px 0 56px; border-top: 1px solid var(--rule);
  font-size: 14px; color: var(--ink-faint);
}
footer.site .fl { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
footer.site a { color: var(--ink-faint); }
footer.site .sp { margin-left: auto; }
@media (max-width: 640px) { footer.site .sp { margin-left: 0; } }

/* ================= READER ================= */

body.reader { background: var(--bg-sunk); }

.reader-bar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px) saturate(1.6);
  border-bottom: 1px solid var(--rule);
}
.reader-bar .nav-in { gap: 14px; }
.reader-title {
  font-size: 14px; color: var(--ink-faint); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 720px) { .reader-title { display: none; } }

.stage { padding: 34px 16px 20px; display: grid; place-items: center; }

/* the book object */
.book {
  position: relative;
  width: min(1000px, 100%);
  aspect-ratio: 10 / 7;
  perspective: 2600px;
}
@media (max-width: 820px) { .book { aspect-ratio: 2 / 3; } }
@media (max-width: 820px) and (max-height: 700px) { .book { aspect-ratio: 3 / 4; } }

.leaf-stack { position: absolute; inset: 0; transform-style: preserve-3d; }

/* Each sheet occupies the right half in spread mode and flips about the spine. */
.sheet {
  position: absolute; top: 0; left: 50%; width: 50%; height: 100%;
  transform-origin: left center; transform-style: preserve-3d;
  transition: transform .78s cubic-bezier(.42,.02,.24,1);
  will-change: transform;
}
.sheet.flipped { transform: rotateY(-180deg); }
.sheet.instant { transition: none; }

.face {
  position: absolute; inset: 0; backface-visibility: hidden; overflow: hidden;
  background: var(--paper); color: var(--paper-ink);
  border: 1px solid var(--rule);
}
.face.back { transform: rotateY(180deg); }
.face.front { border-left: none; box-shadow: inset 14px 0 24px -18px rgba(0,0,0,.45); }
.face.back  { border-right: none; box-shadow: inset -14px 0 24px -18px rgba(0,0,0,.45); }

/* single-page (narrow) mode: sheet fills the whole book, no spine shadow */
.book.single .sheet { left: 0; width: 100%; }
.book.single .face { box-shadow: none; border: 1px solid var(--rule); }
.book.single .cover-left { display: none; }

/* the static left board behind the stack */
.cover-left {
  position: absolute; top: 0; left: 0; width: 50%; height: 100%;
  background: var(--paper); color: var(--paper-ink);
  border: 1px solid var(--rule); border-right: none;
  box-shadow: inset -14px 0 24px -18px rgba(0,0,0,.45);
  overflow: hidden;
}

.page {
  height: 100%; padding: 7% 9% 6%;
  display: flex; flex-direction: column;
  font-family: var(--serif); font-size: clamp(13px, 1.42vw, 16.5px); line-height: 1.62;
  overflow: hidden;
}
.page-body { flex: 1 1 auto; overflow: hidden; }
.page p { margin: 0 0 .85em; text-align: justify; hyphens: auto; }
.page p:first-child { margin-top: 0; }
.page h2.ch-h {
  font-family: var(--sans); font-size: 1.7em; line-height: 1.15; font-weight: 800;
  letter-spacing: -.01em; margin: 0 0 .7em; text-align: left; hyphens: none;
}
.page .ch-num {
  font: 700 .72em/1 var(--sans); letter-spacing: .22em; text-transform: uppercase;
  color: var(--amber); margin: 0 0 1em;
}
.page blockquote {
  margin: 1.1em 0; padding-left: 1.1em; border-left: 3px solid var(--amber);
  font-style: italic; color: var(--ink-soft);
}
.page blockquote p { text-align: left; }
.page figure { margin: 1em 0; text-align: center; }
.page figure img { width: 100%; }
.page figure figcaption {
  font: .78em/1.4 var(--sans); color: var(--ink-faint); margin-top: .5em; text-align: left;
}
.page .folio {
  flex: none; padding-top: 10px; margin-top: 6px;
  font: 600 .72em/1 var(--sans); letter-spacing: .1em;
  color: var(--ink-faint); display: flex; justify-content: space-between;
}
.page .folio .bk { text-transform: uppercase; letter-spacing: .16em; }

/* opening / closing boards */
.page.board {
  justify-content: center; align-items: center; text-align: center;
  background: linear-gradient(160deg, var(--bg-alt), var(--paper));
}
.page.board p { text-align: center; }
.page.board .bt {
  font-family: var(--sans); font-size: 2.1em; font-weight: 800; letter-spacing: .04em;
  margin: 0 0 .5em;
}
.page.board .bs { color: var(--ink-soft); font-size: .95em; max-width: 22em; margin: 0 0 1.6em; }
.page.board .ba {
  font: 600 .78em/1.6 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint);
}
.page.board .rule { width: 60px; height: 3px; background: var(--amber); margin: 0 0 1.6em; }

/* controls */
.controls {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 6px 16px 46px; flex-wrap: wrap;
}
.pgbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rule);
  background: var(--bg); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow); flex: none;
}
.pgbtn:hover:not(:disabled) { border-color: var(--ink-faint); }
.pgbtn:disabled { opacity: .34; cursor: default; }
.pgbtn svg { width: 18px; height: 18px; }
.counter {
  font: 600 13px/1 var(--sans); letter-spacing: .1em; color: var(--ink-faint);
  min-width: 106px; text-align: center; text-transform: uppercase;
}
.progress {
  width: min(1000px, 100%); height: 3px; background: var(--rule);
  border-radius: 3px; overflow: hidden; margin: 0 auto 22px;
}
.progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .5s ease; }

.hint { text-align: center; font-size: 13.5px; color: var(--ink-faint); padding: 0 16px 40px; }
.hint .kb { display: inline; }
@media (max-width: 620px) { .hint .kb { display: none; } .hint .tap::after { content: ' to turn the page.'; } }
.hint kbd {
  font: 600 12px/1 var(--mono); border: 1px solid var(--rule); border-bottom-width: 2px;
  border-radius: 5px; padding: 3px 6px; background: var(--bg); color: var(--ink-soft);
}

/* end-of-chapter call to action, shown under the book */
.reader-cta {
  max-width: 660px; margin: 0 auto; padding: 0 16px 80px; text-align: center;
}
.reader-cta h2 { font-size: 27px; }
.reader-cta .cta-row { justify-content: center; }

/* fallback: no-JS gets plain scrolling prose */
.noscript-prose { max-width: 700px; margin: 0 auto; padding: 40px 24px 80px; font-family: var(--serif); }

/* ---------- breadcrumbs and glossary ---------- */

.crumbs { font-size: 13.5px; color: var(--ink-faint); margin-bottom: 22px; }
.crumbs a { color: var(--ink-faint); text-decoration: none; }
.crumbs a:hover { color: var(--teal); text-decoration: underline; }
.crumbs span[aria-hidden] { margin: 0 6px; }

h1.gloss-h1 {
  font-size: clamp(32px, 5vw, 46px); line-height: 1.1; letter-spacing: -.02em;
  font-weight: 800; margin: 0 0 20px;
}

dl.gloss { margin: 44px 0 0; border-top: 1px solid var(--rule); }
.gterm { padding: 22px 4px; border-bottom: 1px solid var(--rule); scroll-margin-top: 84px; }
.gterm:target { background: var(--amber-bg); border-radius: 8px; padding-inline: 14px; }
.gterm dt {
  font-weight: 700; font-size: 17.5px; margin: 0 0 8px; color: var(--ink);
}
.gterm dd {
  margin: 0; color: var(--ink-soft); font-family: var(--serif);
  font-size: 17px; line-height: 1.6;
}
