/* translations.codebycarson.com — reader mode (reader.js). Loaded after
   style.css; paragraphs, notes and markers keep style.css's own rules. */

/* ---------- header ---------- */

.mode { display: inline-flex; }
.mode[hidden] { display: none; }
.mode button { border-radius: 0; }
.mode button:first-child { border-radius: 4px 0 0 4px; }
.mode button:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
.mode button[aria-pressed="true"] {
  position: relative;  /* its accent border sits over the neighbour's grey one */
  color: var(--accent);
  border-color: var(--accent);
}

.contents-open { display: none; }
.contents-open .ci { display: none; }

/* Reader mode: title, Pages | Text, Contents, theme. No pager, jump box,
   page details, layer tabs or readings toggle. */
.mode-read .pager,
.mode-read .meta,
.mode-read .layers,
.mode-read .readings-toggle { display: none; }
.mode-read .contents-open { display: inline-block; }

/* The bar's min-height is the measured --bar-h, which would otherwise keep the
   page view's taller, wrapped header. */
.mode-read .bar { flex-wrap: nowrap; min-height: 0; }
.mode-read .brand { flex: 1 1 auto; overflow: hidden; }
.mode-read .book-title { max-width: none; min-width: 0; }
.mode-read .controls { flex: none; gap: 0.5rem; margin-left: auto; }

/* The page view's panels stand down; the stage stays only so the cited-source
   pane, which lives in it, can still open. */
.mode-read .stage { display: contents; }
.mode-read .image-panel,
.mode-read .text-panel { display: none; }

.reader[hidden] { display: none; }

/* ---------- the text ---------- */

.reader { padding: 1.6rem 16px 3rem; }

/* The column is the container the sidenote rule in style.css measures. Kept
   to 62ch it stays under that rule's 38rem, so the notes fold under their
   paragraph; from 1100px it widens by a note column and they sit beside. */
.rd-col {
  position: relative;
  max-width: 62ch;
  margin: 0 auto;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.55;
  container-type: inline-size;
  overflow-wrap: break-word;
}

.rd-section + .rd-section { margin-top: 2.4rem; }
.rd-col .rd-heading { margin: 0 0 0.9rem; }

/* The title page is a stack of display lines. */
.rd-title .para .body { text-align: center; }
.rd-title .para { margin-bottom: 0.35rem; }

.rd-sentinel { height: 1px; }
.rd-sentinel[hidden] { display: none; }
.rd-error { margin-top: 1rem; }

@media (min-width: 1100px) {
  .rd-col { max-width: calc(62ch + 1.5rem + 18rem); }
  .rd-col .para:not(.has-notes),
  .rd-col .blk-heading { max-width: 62ch; }
}

/* ---------- page turns ---------- */

/* On a phone: a small raised link where the page turns, pushed to the right
   when the turn opens a paragraph. */
.pg-label {
  padding: 0 0.2em;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 0;
  vertical-align: super;
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
}
.pg-label:hover,
.pg-label:focus-visible { color: var(--accent); text-decoration: underline; }
.pg-label:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pg.at-start .pg-label {
  float: right;
  margin-left: 0.6rem;
  line-height: 1.9;
  vertical-align: baseline;
}

/* With room for a margin: out in the left gutter, on the line where the page
   turns, and a hairline at the very character. */
@media (min-width: 760px) {
  .pg-label,
  .pg.at-start .pg-label {
    position: absolute;
    left: -5.4rem;
    width: 4.4rem;
    margin: 0.3em 0 0;
    float: none;
    text-align: right;
    font-size: 0.72rem;
    line-height: 1.2;
    vertical-align: baseline;
  }
  .pg:not(.at-start)::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0.95em;
    margin: 0 1px;
    border-left: 1px dotted var(--muted);
    vertical-align: -0.12em;
  }
}

/* ---------- a note opened under its marker (phones) ---------- */

.rd-note {
  display: block;
  margin: 0.45rem 0 0.7rem;
  padding: 0.55rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-style: normal;
  font-weight: 400;
  text-align: left;
}
.rd-note .note { margin: 0; }
.mk[aria-expanded="true"] { color: var(--accent-hover); text-decoration: underline; }

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

dialog.rd-contents {
  width: min(30rem, calc(100vw - 32px));
  max-height: min(82dvh, 46rem);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
}
dialog.rd-contents[open] { display: flex; flex-direction: column; }
dialog.rd-contents::backdrop { background: rgba(0, 0, 0, 0.45); }
.rd-contents-head {
  position: relative;
  flex: none;
  padding: 0.9rem 1.2rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
.rd-contents-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
}
.rd-toc {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0.4rem 0 0.8rem;
  list-style: none;
}
.rd-toc a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.32rem 1.2rem;
  text-decoration: none;
  color: var(--text);
}
.rd-toc a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.rd-toc a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rd-toc a[aria-current] { color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.rd-toc-name { font-family: var(--serif); letter-spacing: 0.03em; }
.rd-toc-text .rd-toc-name { color: var(--muted); font-style: italic; letter-spacing: 0; }
.rd-toc-page { flex: none; color: var(--muted); font-size: 0.8rem; }
.rd-toc-title a,
.rd-toc-argument a { font-weight: 600; }

/* ---------- the cited-source pane, over the text on a wide screen ---------- */

@media (min-width: 900px) {
  .mode-read .source-pane {
    position: fixed;
    z-index: 20;
    top: var(--bar-h);
    right: 0;
    bottom: 0;
    width: min(26rem, 42vw);
    height: auto;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.25);
  }
}

/* ---------- phones: one header row ---------- */

@media (max-width: 700px) {
  .mode-read .bar { gap: 0.4rem; padding: 0.4rem 16px; }
  .mode-read .brand { gap: 0.25rem; }
  .mode-read .controls { gap: 0.35rem; }
  .mode-read .bar button { padding: 0.2rem 0.4rem; }
  .mode-read .theme { min-width: 1.75rem; }
}
@media (max-width: 480px) {
  /* The Contents label gives way to its icon (the name stays for screen
     readers), so title, toggle, contents and theme share one row at 390px. */
  .mode-read .contents-open .ct {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .mode-read .contents-open .ci { display: inline; }
}

/* ---------- embed (?embed=1) ---------- */

/* The frame is the viewport and the document never scrolls: the reader is
   the scroller, under the header. */
.embed.mode-read .reader {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
