/* Shared styling for the chapter-by-chapter book reader: books/read.html
   (the signed-in shelf) and chaos.html (the free public Chaos reader). */
:root {
  --white: #ffffff; --bg-main: #f8fafc; --bg-subtle: #f1f5f9; --paper: #ffffff;
  --border-color: #cbd5e1; --text-main: #0f172a; --text-muted: #475569; --text-light: #64748b;
  --accent-blue: #0284c7; --accent-blue-hover: #0369a1;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --font-book: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-5: 5px;
  --shadow-warm-md: 0 10px 25px -4px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-stack); background: var(--bg-main); color: var(--text-main); line-height: 1.5; }
.bay { max-width: 1240px; margin: 0 auto; padding: 0 1.5rem; }
header { width: 100%; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; background: rgba(255,255,255,0.96); z-index: 50; }
header .bay { display: flex; justify-content: space-between; align-items: center; padding-top: 0.85rem; padding-bottom: 0.85rem; gap: 1rem; }
@font-face { font-family: "Brand Marker"; src: url("/fonts/PermanentMarker-Regular.ttf") format("truetype"); font-display: swap; }
header a.logo { font-family: "Brand Marker", var(--font-stack); font-size: 1.35rem; color: var(--text-main); text-decoration: none; display: flex; align-items: center; gap: 0.55rem; }
header a.logo img { width: 26px; height: 26px; border-radius: 6px; display: block; }
.back-link { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--accent-blue); }
.page-section { padding: clamp(1.5rem, 3vw, 2.5rem) 0; }
.page-title-block { border-left: 4px solid var(--accent-blue); padding: 0.2rem 0 0.2rem 1rem; margin: 0 0 1.5rem; }
.page-title-block h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.page-title-block .tagline { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-blue); margin: 0.2rem 0 0.4rem; }
.page-title-block p { margin: 0; color: var(--text-muted); max-width: 70ch; }
.downloads { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
/* A button the page has hidden really is hidden. `.btn` sets its own
   `display`, and any rule an author writes beats the browser's own rule for
   the `hidden` attribute, so without this line a hidden button stays on
   screen: the Stop button sat in the reading bar before anything was
   reading, and stayed there after a stop. */
.btn[hidden] { display: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 0.85rem; border-radius: var(--radius-5); font: 700 0.78rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.03em; text-decoration: none; border: 1px solid var(--border-color); color: var(--text-main); background: var(--white); cursor: pointer; }
.btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn[disabled] { opacity: 0.4; cursor: default; }
.reader { display: flex; align-items: flex-start; gap: 1.5rem; }
.chapter-menu { flex: 0 0 280px; position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; background: var(--white); border: 1px solid var(--border-color); border-radius: var(--radius-5); box-shadow: var(--shadow-warm-md); padding: 0.8rem; }
.chapter-menu .menu-heading { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); margin: 0.2rem 0.4rem 0.5rem; }
.chapter-menu .part-name { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-blue); margin: 0.9rem 0.4rem 0.3rem; }
.chapter-menu a { display: block; padding: 0.4rem 0.55rem; border-radius: var(--radius-5); color: var(--text-muted); text-decoration: none; font-size: 0.86rem; line-height: 1.3; }
.chapter-menu a:hover { background: var(--bg-subtle); color: var(--accent-blue); }
/* The chapter being read is marked in italics, not in bold. Changed 2026-11-11
   on explicit instruction ("I dont like the bolded text so much as the
   italics"), so the menu and the page agree instead of the menu shouting. */
.chapter-menu a.is-active { background: var(--bg-subtle); color: var(--accent-blue); font-style: italic; }
.menu-toggle { display: none; }
.page { scroll-margin-top: 90px; flex: 1 1 auto; min-width: 0; background: var(--paper); border: 1px solid var(--border-color); border-radius: var(--radius-5); box-shadow: var(--shadow-warm-md); padding: clamp(1.25rem, 4vw, 3rem); }
.page .chapter-part { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-blue); margin: 0 0 0.3rem; }
.page h2.chapter-title { font-family: var(--font-book); font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin: 0 0 1.5rem; line-height: 1.2; }
.chapter-body { font-family: var(--font-book); font-size: 1.12rem; line-height: 1.75; max-width: 66ch; }
.chapter-body p { margin: 0 0 1.1em; }
/* Emphasis inside a chapter is set in italics rather than in bold, for every
   book. Added 2026-11-11 on explicit instruction. The reason it was asked for
   is real: a novel marks a line with <em> and reads light, while the cited
   non-fiction marks its notices and its lead-in phrases with <strong> and the
   page turns into a wall of heavy type. The words in the books are untouched
   -- only how they are set changes -- so the exact wording the notice rule
   requires is still there letter for letter. Emphasis inside emphasis goes
   back upright, which is the old typesetting rule and the only way a reader
   can see the inner phrase at all. */
.chapter-body strong,
.chapter-body b { font-weight: inherit; font-style: italic; }
.chapter-body em strong,
.chapter-body em b,
.chapter-body strong em,
.chapter-body b em,
.chapter-body strong i,
.chapter-body b i { font-style: normal; }
/* A subhead in a chapter stays a subhead, in the book face, one step up from
   the text, without the browser's own heavy default weight. */
.chapter-body h3 { font-family: var(--font-book); font-size: 1.1em; font-weight: 600; margin: 1.8em 0 0.6em; line-height: 1.3; }
.chapter-body hr { border: none; text-align: center; margin: 1.8em 0; }
.chapter-body hr::after { content: "* * *"; color: var(--text-light); letter-spacing: 0.5em; }
.chapter-body blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid var(--border-color); color: var(--text-muted); }
.chapter-nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.error-text { font-family: var(--font-mono); font-size: 0.85rem; color: #991b1b; }
footer { background: var(--text-main); color: #94a3b8; padding: 2rem 0; font-family: var(--font-mono); font-size: 0.78rem; text-align: center; margin-top: 2rem; }
@media (max-width: 900px) {
  .reader { flex-direction: column; }
  .chapter-menu { position: static; width: 100%; flex: 1 1 auto; max-height: none; }
  .chapter-menu nav { display: none; }
  .chapter-menu.is-open nav { display: block; }
  .menu-toggle { display: inline-flex; width: 100%; }
}
@media (prefers-color-scheme: dark) {
  :root { --white: #111827; --bg-main: #0b1220; --bg-subtle: #1f2937; --paper: #141b2b; --border-color: #334155; --text-main: #e5e7eb; --text-muted: #cbd5e1; --text-light: #94a3b8; }
  header { background: rgba(17,24,39,0.96); }
}
.reader-note { margin: 0.7rem 0 0 !important; font-size: 0.9rem; }
.reader-note a { color: var(--accent-blue); }

/* Reading the book out loud. The bar floats fixed near the bottom of the
   screen, so the Read/Pause/Stop buttons stay on screen no matter how far
   a person has scrolled through the chapter -- they never have to scroll
   back up to control a book that is already reading itself to them. */
.page-section { padding-bottom: 4.5rem; }
.book-listen {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.4rem;
  position: fixed; left: 50%; bottom: 1.1rem; transform: translateX(-50%); z-index: 60;
  max-width: calc(100vw - 2rem); background: var(--white); border: 1px solid var(--border-color);
  border-radius: 999px; box-shadow: var(--shadow-warm-md); padding: 0.5rem 1rem;
}
/* Wide enough for the longest thing it says, "Read from where we left off", so
   the bar is one width whatever state the reading is in. */
.book-listen .btn-listen { background: var(--accent-blue); border-color: var(--accent-blue); color: var(--white); min-width: 17rem; }
.book-listen .btn-listen:hover { background: var(--accent-blue-hover); border-color: var(--accent-blue-hover); color: var(--white); }
.book-listen .listen-speed-label { font: 700 0.72rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); margin-left: 1rem; }
/* The height, the font and the box sizing are all set here on purpose: a
   dropdown left to the browser comes out a few pixels shorter than a
   button beside it, and the row then reads as two things that nearly line
   up instead of one straight line. */
.book-listen .listen-speed {
  height: 36px; box-sizing: border-box; padding: 0 2rem 0 0.7rem; line-height: 1;
  -webkit-appearance: none; -moz-appearance: none; appearance: none; text-transform: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23475569'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center;
}
/* Shown only while words are selected, which is the gesture that picks where
   to start reading from. Outlined rather than filled, so the filled Read
   button stays the one obvious thing on the bar. */
.book-listen .btn-listen-here { border-color: var(--accent-blue); color: var(--accent-blue); }
.book-listen .btn-listen-here:hover { background: var(--accent-blue); color: var(--white); }
.book-listen .btn-listen-here[hidden] { display: none; }
.book-listen .listen-status { flex: 1 1 100%; margin: 0.2rem 0 0; font: 400 0.85rem var(--font-stack); color: var(--text-muted); text-align: center; }
/* Selecting words on a phone brings up the platform's own panel -- Copy,
   Share, Select all, Web search -- and on Android it sits across the bottom
   of the screen, over this bar, so the Read from here button it just revealed
   could not be pressed. Reported directly. While words are selected the bar
   lifts clear of that panel; it drops back the moment the selection goes. */
.book-listen { transition: bottom 0.15s ease-out; }
.book-listen.is-lifted { bottom: 7.5rem; }
/* Thirty pixels higher again on a phone, measured against the real panel:
   7.5rem alone still left the bar under the bottom edge of it. */
@media (max-width: 700px) {
  .book-listen.is-lifted { bottom: calc(7.5rem + 30px); }
}
/* The paragraph being read, so a person watching the screen can follow it. */
.chapter-body .is-speaking, .page h2.chapter-title.is-speaking { background: #e0f2fe; box-shadow: 0 0 0 0.35rem #e0f2fe; border-radius: 2px; }
/* A chapter the Reader cannot read out loud yet. Said in words under the
   title rather than only shown by dimming it: a faint line is easy to miss,
   and the first a person knew of it was pressing Read and getting nothing. */
.chapter-menu a.is-unrecorded { opacity: 0.6; }
.chapter-menu a.is-unrecorded .waiting {
  display: block; font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-light); margin-top: 0.1rem;
}

/* On a phone, the rounded corners do not work: the pill-shaped Read and Stop
   bar and the heavily rounded cards fight the narrow screen, where everything
   is nearly full width and a soft edge reads as a mistake rather than a style.
   Reported directly -- so on a phone only, every corner is 3 pixels.

   `--radius-5` is redefined here so anything that already uses it follows
   without being listed, and the handful of places with their own radius are
   named after it. The pill bar is the one that matters most: 999px on a bar
   that spans the screen looks broken. */
@media (max-width: 700px) {
  :root { --radius-5: 3px; }
  .book-listen,
  .btn,
  .chapter-menu,
  .chapter-menu a,
  .page,
  .book-listen .listen-speed,
  input,
  select,
  textarea,
  button {
    border-radius: 3px;
  }
  /* The mark on the words being read stays as it is: it is not a corner a
     person reads as an edge, and squaring it makes the highlight look like a
     block of colour. */

  /* The shared site menu's own buttons. Written at the same strength the menu
     writes them -- an id together with a class -- because a plain class is
     outranked and the buttons stayed rounded. This stylesheet is loaded after
     the menu's on every reader page so that these win. */
  #menu-burger.menu-opener,
  #mega-menu-opener,
  .mega-menu,
  .mega-menu-panel {
    border-radius: 3px;
  }
}
