/* The bar js/page-reader.js builds: Read, Stop, Read from here and the speed,
   in a rounded bar pinned near the bottom of the screen, matching the one on
   the books' own Read page.

   One definition, used by every page that loads js/page-reader.js. It lived in
   budget-machine.css until 2026-11-06, when the reader was put on the book
   series pages as well and those pages do not load that stylesheet. Copying it
   would have been a third set of the same rules to keep in step.

   The colours come from the --bm-* variables where a page defines them, and
   from the fallback beside each one where it does not, so this works on a page
   with its own palette and on a page with none.
*/

/* The heights are 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. */
.pr-bar {
  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(--bm-white, #ffffff);
  border: 1px solid var(--bm-border, #cbd5e1); border-radius: 999px;
  box-shadow: var(--bm-shadow, 0 10px 25px -4px rgba(15, 23, 42, 0.12)); padding: 0.5rem 1rem;
}
.pr-bar .pr-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; box-sizing: border-box; padding: 0 0.85rem;
  border: 1px solid var(--bm-border, #cbd5e1); border-radius: var(--bm-radius, 5px);
  background: var(--bm-white, #ffffff); color: var(--bm-text, #0f172a);
  font: 700 0.78rem var(--bm-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace); text-transform: uppercase; letter-spacing: 0.03em;
  cursor: pointer;
}
.pr-bar .pr-btn:hover { border-color: var(--bm-accent, #0284c7); color: var(--bm-accent, #0284c7); }
.pr-bar .pr-btn[hidden] { display: none; }
/* Stop and Read from here come and go with what the reader is doing, and a
   button that disappears takes its width with it -- the bar was 424px idle and
   491px once Stop appeared. Held means the slot stays and the button does not:
   invisible, unclickable, out of the tab order and not announced, so the bar is
   one width in every state. */
.pr-bar .pr-btn.is-held {
  visibility: hidden;
  pointer-events: none;
}
/* The width holds the longest thing this button ever says, which is "Read from
   where we left off". 14rem fitted "Read this page" and "Pause reading" but not
   that, so the bar was one width at rest with a kept place and another while
   reading -- the thing the status line was taken out of the bar to prevent. */
.pr-bar .pr-read {
  background: var(--bm-accent, #0284c7); border-color: var(--bm-accent, #0284c7); color: #ffffff; min-width: 17rem;
}
.pr-bar .pr-read:hover { background: var(--bm-accent-hover, #0369a1); border-color: var(--bm-accent-hover, #0369a1); color: #ffffff; }
/* Shown only while words are selected, which is the gesture that picks where
   to start reading from. It is an outlined button rather than a filled one, so
   the filled Read button stays the one obvious thing on the bar. */
.pr-bar .pr-here { border-color: var(--bm-accent, #0284c7); color: var(--bm-accent, #0284c7); }
.pr-bar .pr-here:hover { background: var(--bm-accent, #0284c7); color: #ffffff; }
/* 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. */
.pr-bar { transition: bottom 0.15s ease-out; }
.pr-bar.is-lifted { bottom: 7.5rem; }
.pr-bar .pr-speed-label {
  font: 700 0.72rem var(--bm-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--bm-light, #64748b); margin-left: 1rem;
}
.pr-bar .pr-speed {
  padding: 0 2rem 0 0.7rem; line-height: 1; text-transform: none;
  -webkit-appearance: none; -moz-appearance: none; appearance: 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;
}
/* The status sits ABOVE the bar rather than inside it, and that is what keeps
   the bar one size.

   Inside the bar it was flex: 1 1 100%, so its own words decided how wide the
   bar had to be: 424px at rest and 640px once it was reading, growing sideways
   into whatever was beside it and downwards from 54px to 96px. Taking it out of
   the bar's flow means the buttons alone decide the size, so the bar is the
   same shape whether it is idle, reading or paused.

   It carries its own background because it now floats over the page rather
   than over the bar's own panel. */
.pr-bar .pr-status {
  position: absolute; bottom: 100%; left: 0; right: 0;
  margin: 0 0 0.35rem; padding: 0.3rem 0.7rem;
  font: 400 0.85rem var(--bm-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); color: var(--bm-muted, #475569); text-align: center;
  background: var(--bm-white, #ffffff); border: 1px solid var(--bm-border, #cbd5e1);
  border-radius: var(--bm-radius, 5px); box-shadow: var(--bm-shadow, 0 10px 25px -4px rgba(15, 23, 42, 0.12));
  overflow-wrap: anywhere;
}
/* The status line is always in the bar, and empty until the reader has
   something to say. Because it is flex: 1 1 100% it claims a whole row of its
   own even with nothing in it, and its top margin then made the bar taller than
   its buttons -- so the buttons sat above the middle instead of on it. Taking
   the empty row out of the layout is what actually centres them; align-items
   was already centre and could not help while a second row existed. */
.pr-bar .pr-status:empty { display: none; }
/* The words being read, so a person watching the screen can follow them. */
.pr-speaking { background: #e0f2fe; box-shadow: 0 0 0 0.25rem #e0f2fe; border-radius: 2px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pr-speaking { background: #0c3550; box-shadow: 0 0 0 0.25rem #0c3550; }
  :root:not([data-theme="light"]) .pr-bar .pr-read { color: #04202f; }
  :root:not([data-theme="light"]) .pr-bar .pr-read:hover { color: #04202f; }
}
/* On a phone the rounded pill fights the narrow screen, where the bar is
   nearly the full width and a soft edge reads as a mistake. */
@media (max-width: 700px) {
  .pr-bar { left: 0.6rem; right: 0.6rem; bottom: 0.6rem; transform: none; max-width: none; border-radius: 3px; }
  /* 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. */
  .pr-bar.is-lifted { bottom: calc(7.5rem + 30px); }
  .pr-bar .pr-btn, .pr-bar .pr-speed { border-radius: 3px; }
  .pr-bar .pr-read { min-width: 0; flex: 1 1 6rem; }
  .pr-bar .pr-speed { flex: 0 0 auto; }
  /* The word "Speed" is taken off a narrow screen so the three controls stay
     on one line. It is still there for a screen reader, which is what names
     the dropdown out loud for somebody who cannot see it. */
  .pr-bar .pr-speed-label {
    position: absolute; width: 1px; height: 1px; margin: 0; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}
