/* "Easier to Read" mode (2026-11-03) — see readable.js and docs/history/easier-to-read-mode-2026-11-03.md.
   Everything here is scoped to html[data-readability="easier"], which readable.js sets from the `readability`
   preference (prefs.js). With the attribute absent this file does nothing at all.

   This file holds the parts that are plain CSS: a larger root size (the site sizes almost everything in rem,
   so this scales it all), a brighter palette (every page colors text through these variables), and a roomier
   line height. The parts that cannot be one-line overrides — a floor under the many tiny font sizes, and the
   swap from the decorative / serif faces to clearer sans-serif ones — are generated by readable.js from the
   pages' own stylesheets. Load order does not matter: the attribute prefix out-ranks the pages' own :root and
   class rules. */

html[data-readability="easier"] {
  /* --root-pct is set by readable.js from the `textSize` preference (default 140). */
  font-size: calc(var(--root-pct, 140) * 1%);

  --text: #fbf6e6;
  --text-soft: #eee6cd;
  --muted: #b9af96;
  --gold: #efd078;
  --border: #4d4d4d;
  --surface: #1a1a1a;
  /* Chinese content in the dictionary entry only, for now (rules below). 1.36 at the 140% default, easing as the
     root size grows so the headword does not get enormous: 1 + 0.4 * (125 / root%). */
  --zh-scale: calc(1 + 0.4 * 125 / var(--root-pct, 140));
}

html[data-readability="easier"] body {
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Form controls often do not inherit the page font or size by default. */
html[data-readability="easier"] input,
html[data-readability="easier"] textarea,
html[data-readability="easier"] select,
html[data-readability="easier"] button {
  font-family: inherit;
}

/* Links and focus: easier to find. */
html[data-readability="easier"] a:focus-visible,
html[data-readability="easier"] button:focus-visible,
html[data-readability="easier"] input:focus-visible,
html[data-readability="easier"] textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Fixed-width slots the generic font-size floor (readable.js) deliberately skips. */
html[data-readability="easier"] .dial-pole-label { font-size: 0.74rem; }
html[data-readability="easier"] .era-en { font-size: 0.68rem; overflow-wrap: anywhere; }

/* The page navigation is fixed and larger in this mode; leave room so it does not sit on the title seal. */
html[data-readability="easier"] header { padding-top: 4.5rem; width: 100%; max-width: 100%; }

/* Top navigation: sized by hand (readable.js skips it) — bigger than standard, but compact enough that it does not
   wrap into a tall stack on a phone, where it sits in the normal flow above the page. */
html[data-readability="easier"] .contact-link,
html[data-readability="easier"] .nav-more-btn,
html[data-readability="easier"] .nav-back-btn,
html[data-readability="easier"] .nav-script-toggle { font-size: 15px; }
@media (max-width: 640px) {
  html[data-readability="easier"] .contact-link,
  html[data-readability="easier"] .nav-more-btn,
  html[data-readability="easier"] .nav-back-btn,
  html[data-readability="easier"] .nav-script-toggle { font-size: 13.5px; }
}

/* Inline-styled text (markup built in JS) cannot be reached by the stylesheet rewrite in readable.js. */
html[data-readability="easier"] [style*="IM Fell English"] { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important; }
html[data-readability="easier"] [style*="Noto Serif SC"] { font-family: 'Noto Sans SC', 'PingFang TC', 'PingFang SC', 'Microsoft JhengHei', 'Microsoft YaHei', sans-serif !important; }

/* Bigger type needs rows that wrap and panels that can shrink on a narrow screen. */
html[data-readability="easier"] .register-badges { flex-wrap: wrap; row-gap: 0.3rem; }
html[data-readability="easier"] .sd-layout > * { min-width: 0; }
@media (max-width: 720px) {
  html[data-readability="easier"] .panel { padding: 1rem; }
}
html[data-readability="easier"] .source-name { flex: 0 1 auto; flex-wrap: wrap; max-width: 100%; }
html[data-readability="easier"] .nav-more-panel { min-width: 250px; }

/* Bigger Chinese in the dictionary entry (2026-11-03 trial). Content Chinese only — headword, register glyph, Chinese
   glosses/examples, compound terms. UI labels (.zh in the nav, .accordion-title-zh, dial labels) are left alone.
   Sizes that inherit use em so they follow whatever the surrounding text size already is. */
html[data-readability="easier"] .result-headword { font-size: calc(2.4rem * var(--zh-scale)); }
html[data-readability="easier"] .register-char { font-size: calc(1.6rem * var(--zh-scale)); }
html[data-readability="easier"] .lex-term,
html[data-readability="easier"] .mi-char { font-size: calc(1.1rem * var(--zh-scale)); }
html[data-readability="easier"] .sense-gloss-zh,
html[data-readability="easier"] .lex-gloss-zh,
html[data-readability="easier"] .example .zh { font-size: calc(1em * var(--zh-scale)); }

/* At the larger text sizes the reader's per-unit "Add these words" pill is wider than a phone; let it wrap instead of overflowing. */
html[data-readability="easier"] .add-flashcards-btn { white-space: normal; max-width: 100%; border-radius: 1.1rem; text-align: left; }
html[data-readability="easier"] .unit-head { flex-wrap: wrap; gap: 0.3rem 0.6rem; }

/* The 古文 / 現代文 chip row is a fit-content flex row; at the largest sizes it is wider than a phone panel. Let it wrap and shrink. */
html[data-readability="easier"] .register-toggle { flex-wrap: wrap; max-width: 100%; row-gap: 0.2rem; padding: 0.5rem 0.7rem; }

/* Long unbroken tokens (citations like 《Analects•Zizhang》:) can be wider than a phone panel at the largest sizes. */
html[data-readability="easier"] .sd-layout { overflow-wrap: anywhere; }

/* The title seal has a fixed pixel width on some pages; let it grow with the text instead of wrapping the name onto two lines. */
html[data-readability="easier"] .seal { width: auto; min-width: 140px; padding-left: 1rem; padding-right: 1rem; }
html[data-readability="easier"] .seal-char { white-space: nowrap; }

/* Long unbroken strings (an email address, a URL) can be wider than a phone at the larger sizes; break them only if they would overflow. */
html[data-readability="easier"] p,
html[data-readability="easier"] li,
html[data-readability="easier"] td,
html[data-readability="easier"] a { overflow-wrap: break-word; }
