/* reading-tools: styles (see reading-tools.js). Classes on <html> and <body>:
   rt-font-lexend | rt-font-atkinson, rt-space-wide | rt-space-xwide, rt-size-l | rt-size-xl */

/* ---------- Settings: the Reading group */
.rt-set { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.rt-set-title { font-size: 1.1rem; margin: 0 0 4px; }
.rt-set-intro { margin: 0 0 12px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.rt-field { border: 0; margin: 0 0 10px; padding: 12px 16px; background: #f7f6fc; border-radius: var(--r-md); min-width: 0; }
.rt-legend { float: left; width: 100%; padding: 0; margin: 0 0 8px; font-weight: 800; color: var(--ink); }
.rt-seg { clear: both; display: flex; flex-wrap: wrap; gap: 6px; }
.rt-opt { position: relative; flex: 1 1 auto; min-width: 0; cursor: pointer; }
.rt-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.rt-opt span { display: block; text-align: center; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; color: var(--ink-soft); font-weight: 600; font-size: .9rem; line-height: 1.3; transition: background .15s, border-color .15s, color .15s; }
.rt-opt:hover span { border-color: #c9d2de; }
.rt-opt input:checked + span { background: var(--violet); border-color: var(--violet); color: #fff; }
.rt-opt input:focus-visible + span { outline: 3px solid var(--violet-soft); outline-offset: 1px; box-shadow: 0 0 0 1px var(--violet); }
.rt-toggles { margin-top: 0; }
.rt-note { margin: 8px 2px 0; font-size: .85rem; color: var(--ink-soft); line-height: 1.5; }
.rt-note[hidden] { display: none; }

/* ---------- test player hooks */
.ex-hook[data-hook="rt-autoread"] { display: none; }
.rt-fb-say { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; }
.rt-fb-say .st-ic { width: 15px; height: 15px; }

/* ---------- Font: the chosen font for body and headings alike (no serif) */
body.rt-font-lexend {
  --font-body: "Lexend", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Lexend", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body.rt-font-atkinson {
  --font-body: "Atkinson Hyperlegible", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Atkinson Hyperlegible", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body.rt-font-lexend, body.rt-font-atkinson { font-family: var(--font-body); }
:is(body.rt-font-lexend, body.rt-font-atkinson) :is(.ex-article, .viz-quote blockquote, .lib-body, input, textarea, select) { font-family: var(--font-body); }
:is(body.rt-font-lexend, body.rt-font-atkinson) .ex-article .is-ref-start::before { font-family: var(--font-body); }
/* Atkinson Hyperlegible has regular and bold only: keep headings bold rather than a faux middle weight */
body.rt-font-atkinson :is(h1, h2, h3, h4, strong, b) { font-weight: 700; }

/* ---------- Line spacing: body text, lessons, tests, set texts, vocabulary */
:is(body.rt-space-wide, body.rt-space-xwide) :is(
  .sub-learn, .lv-lesson, .lv-sec, .lv-keyidea, .lv-tip, .lv-steps, .lv-example, .lv-check, .lv-check-q, .lv-check-opt, .lv-check-fb,
  .ex-stem, .ex-prompt:not(.is-sum), .ex-sub, .ex-opt, .ex-article, .ex-fb, .ex-fb-ms, .ex-textlink,
  .lib-body, .vx-card, .vx-meaning, .vx-sentence, .vx-q-prompt, .vx-big, .vx-m, .st-card p, .st-empty) {
  overflow-wrap: break-word;
}
body.rt-space-wide :is(
  .sub-learn, .lv-lesson, .lv-keyidea, .lv-tip, .lv-steps, .lv-check-q, .lv-check-opt, .lv-check-fb,
  .ex-stem, .ex-prompt:not(.is-sum), .ex-sub, .ex-opt, .ex-article, .ex-fb, .ex-fb-ms,
  .lib-body, .vx-meaning, .vx-sentence, .vx-q-prompt, .vx-big, .vx-m, .st-card p) {
  line-height: 1.85; word-spacing: .12em; letter-spacing: .015em;
}
body.rt-space-xwide :is(
  .sub-learn, .lv-lesson, .lv-keyidea, .lv-tip, .lv-steps, .lv-check-q, .lv-check-opt, .lv-check-fb,
  .ex-stem, .ex-prompt:not(.is-sum), .ex-sub, .ex-opt, .ex-article, .ex-fb, .ex-fb-ms,
  .lib-body, .vx-meaning, .vx-sentence, .vx-q-prompt, .vx-big, .vx-m, .st-card p) {
  line-height: 2.1; word-spacing: .22em; letter-spacing: .035em;
}
/* more room between paragraphs too */
body.rt-space-wide :is(.sub-learn p, .ex-article p, .lib-body p) { margin-bottom: 1.1em; }
body.rt-space-xwide :is(.sub-learn p, .ex-article p, .lib-body p) { margin-bottom: 1.35em; }
/* fractions, sums and tables keep their own spacing so they still line up */
:is(body.rt-space-wide, body.rt-space-xwide) :is(.frac, .ex-calc, table, .viz-nl) { letter-spacing: normal; word-spacing: normal; }
:is(body.rt-space-wide, body.rt-space-xwide) .frac { line-height: 1; }
:is(body.rt-space-wide, body.rt-space-xwide) .ex-article :is(h2, h3) { line-height: 1.35; }

/* ---------- Text size: everything in rem scales from <html>; body text (16px in theme.css) follows */
html.rt-size-l { font-size: 112.5%; }
html.rt-size-xl { font-size: 125%; }
body.rt-size-l, body.rt-size-xl { font-size: 1rem; }

/* the test screen's height allows for its top bar, which grows with the text */
html.rt-size-l .exam { height: calc(100vh - 108px); height: calc(100dvh - 108px); }
html.rt-size-xl .exam { height: calc(100vh - 120px); height: calc(100dvh - 120px); }

/* nothing wider than a phone: let rows wrap and grids shrink */
:is(body.rt-size-l, body.rt-size-xl) .ex-options { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
:is(body.rt-size-l, body.rt-size-xl) .lv-check-opts { grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }
:is(body.rt-size-l, body.rt-size-xl) :is(.ex-opt, .lv-check-opt, .vx-m, .vx-word, .vx-big, .lib-body, .ex-article, .sub-learn, .lv-lesson, .ex-prompt, .ex-stem) { overflow-wrap: break-word; min-width: 0; }
:is(body.rt-size-l, body.rt-size-xl) .vx-word { overflow-wrap: anywhere; }
:is(body.rt-size-l, body.rt-size-xl) .ex-text-tabs button { max-width: 260px; }

@media (max-width: 860px) {
  :is(body.rt-size-l, body.rt-size-xl) .ex-qhead { flex-wrap: wrap; row-gap: 8px; }
  html.rt-size-l .exam { height: calc(100dvh - 135px); }
  html.rt-size-xl .exam { height: calc(100dvh - 150px); }
  :is(body.rt-size-l, body.rt-size-xl) .ex-prompt.is-sum, :is(body.rt-size-l, body.rt-size-xl) .ex-calc { font-size: 1.45rem; }
  :is(body.rt-size-l, body.rt-size-xl) .vx-card { padding: 20px; gap: 18px; }
}
@media (max-width: 480px) {
  html.rt-size-xl { font-size: 118.75%; }   /* 19px: extra large still fits a 320–375px screen */
  :is(body.rt-size-l, body.rt-size-xl) .ex-options { grid-template-columns: 1fr; }
  :is(body.rt-space-xwide) .ex-article { letter-spacing: .02em; word-spacing: .15em; }
}
