/* Colour themes for the library and the app: light (the site's own colours), sepia and dark.
   Hand-written. The theme is chosen in the reading view or the app's settings (localStorage 'lib-reader:prefs',
   theme auto | light | sepia | dark; see site/assets/library/prefs.js and research/bible-data-contract.md).
   The small script in every page's head (scripts/build_site.py, THEME_SCRIPT) applies it before first paint:
   - on the website, only /app/, /offline/, /bible/ and the library's reading view take the theme, and the default
     is light; library pages outside the reading view keep the site's light colours, like the rest of the site;
   - when the site runs as the installed app, the default is auto (the device's light or dark setting) and the
     library pages take the theme too.
   Pages that take the theme get html.cnz-themed; every library and app page gets data-rd-theme="light|sepia|dark"
   (the reading view's colours are in reader.css and key off html.lib-reading instead).
   Most colours follow from the site variables (--paper, --ink, --muted, --tint, --line, --accent, --gold), which the
   plan card and the reader also use; the rules below fix the few places the site sets colours directly. */

html.cnz-themed[data-rd-theme="dark"]{
  --paper:#0f1c28;--ink:#ece4d4;--muted:#a7b3bc;--tint:#16283a;--line:#294052;--accent:#e9bd76;--gold:#e9bd76;
  --cz-body:#d3d9de;--cz-card:#14263a;--cz-deep:#0a1520;--cz-link:#f0c27e;--cz-btn:#e9bd76;--cz-btn-fg:#10202d;--cz-btn-hover:#f4d39b;
  color-scheme:dark}
html.cnz-themed[data-rd-theme="sepia"]{
  --paper:#f5ecd9;--ink:#33291e;--muted:#6b5a46;--tint:#ece0c5;--line:#dbcca9;--accent:#93531f;--gold:#c99a4a;
  --cz-body:#433628;--cz-card:#faf4e6;--cz-deep:#3a2e22;--cz-link:#874411;--cz-btn:#3a2e22;--cz-btn-fg:#f8f0de;--cz-btn-hover:#4d3e2e}

html.cnz-themed[data-rd-theme="dark"] body,html.cnz-themed[data-rd-theme="sepia"] body{background:var(--paper);color:var(--ink)}
html.cnz-themed[data-rd-theme="dark"] .masthead,html.cnz-themed[data-rd-theme="sepia"] .masthead,
html.cnz-themed[data-rd-theme="dark"] .skip,html.cnz-themed[data-rd-theme="sepia"] .skip{background:var(--paper)}
html.cnz-themed[data-rd-theme="dark"] .menu-toggle,html.cnz-themed[data-rd-theme="sepia"] .menu-toggle{background:transparent;color:var(--ink)}
html.cnz-themed[data-rd-theme="dark"] .brand img{filter:brightness(0) invert(.9) sepia(.25)}
html.cnz-themed[data-rd-theme="sepia"] .brand img{filter:sepia(.6) brightness(.85)}

/* text */
html.cnz-themed[data-rd-theme] .prose p,html.cnz-themed[data-rd-theme] .prose li,
html.cnz-themed[data-rd-theme] .lib-text p,html.cnz-themed[data-rd-theme] .lib-panel p,html.cnz-themed[data-rd-theme] .lib-list p,
html.cnz-themed[data-rd-theme] .lib-feature p,html.cnz-themed[data-rd-theme] .lib-notes li{color:var(--cz-body,#334955)}
html.cnz-themed[data-rd-theme="light"] .prose p,html.cnz-themed[data-rd-theme="light"] .prose li,
html.cnz-themed[data-rd-theme="light"] .lib-panel p,html.cnz-themed[data-rd-theme="light"] .lib-list p,
html.cnz-themed[data-rd-theme="light"] .lib-feature p,html.cnz-themed[data-rd-theme="light"] .lib-notes li{color:#334955}
html.cnz-themed[data-rd-theme="light"] .lib-text p{color:#26394a}
html.cnz-themed[data-rd-theme="dark"] .prose a:not(.button),html.cnz-themed[data-rd-theme="sepia"] .prose a:not(.button),
html.cnz-themed[data-rd-theme="dark"] .lib-panel a,html.cnz-themed[data-rd-theme="dark"] .lib-credit a,
html.cnz-themed[data-rd-theme="dark"] .lib-text a:not(.bref){color:var(--cz-link)}
html.cnz-themed[data-rd-theme="dark"] a:hover{color:var(--cz-link)}

/* surfaces */
html.cnz-themed[data-rd-theme="dark"] .lib-feature,html.cnz-themed[data-rd-theme="sepia"] .lib-feature,
html.cnz-themed[data-rd-theme="dark"] .link-card,html.cnz-themed[data-rd-theme="sepia"] .link-card,
html.cnz-themed[data-rd-theme="dark"] .argument-card,html.cnz-themed[data-rd-theme="sepia"] .argument-card,
html.cnz-themed[data-rd-theme="dark"] .lib-chips a,html.cnz-themed[data-rd-theme="sepia"] .lib-chips a{background:var(--cz-card)}
html.cnz-themed[data-rd-theme="dark"] .lib-rx,html.cnz-themed[data-rd-theme="sepia"] .lib-rx,
html.cnz-themed[data-rd-theme="dark"] .coc-today,html.cnz-themed[data-rd-theme="sepia"] .coc-today,
html.cnz-themed[data-rd-theme="dark"] .invitation,html.cnz-themed[data-rd-theme="sepia"] .invitation,
html.cnz-themed[data-rd-theme="dark"] .top-verse,html.cnz-themed[data-rd-theme="sepia"] .top-verse{background:var(--cz-deep);color:#f3eee4}
html.cnz-themed[data-rd-theme="dark"] .lib-rx,html.cnz-themed[data-rd-theme="dark"] .coc-today{border:1px solid var(--line)}
html.cnz-themed[data-rd-theme] .coc-today blockquote,html.cnz-themed[data-rd-theme] .invitation h2{color:#f6f1e7}
html.cnz-themed[data-rd-theme="dark"] .lib-rx li{border-color:#22384b}
html.cnz-themed[data-rd-theme="dark"] .lib-flag{color:#10202d}
/* AA contrast fixes (review 2026-10-12): links and text on the deep sepia panels, and dark-theme colours site.css and library.css set directly */
html.cnz-themed[data-rd-theme="sepia"] .coc-today a:not(.button),html.cnz-themed[data-rd-theme="sepia"] .lib-rx a:not(.button){color:#f0c27e}
html.cnz-themed[data-rd-theme="sepia"] .coc-today p,html.cnz-themed[data-rd-theme="sepia"] .lib-rx p{color:#efe6d6}
html.cnz-themed[data-rd-theme="dark"] .coc-list summary{color:var(--cz-link)}
html.cnz-themed[data-rd-theme="dark"] .lib-contents .lib-sum{color:var(--muted)}
html.cnz-themed[data-rd-theme="dark"] mark,html.cnz-themed[data-rd-theme="dark"] #lib-search mark{background:rgba(233,189,118,.3)}

/* buttons */
html.cnz-themed[data-rd-theme="dark"] .button,html.cnz-themed[data-rd-theme="sepia"] .button,
html.cnz-themed[data-rd-theme="dark"] .prose a.button,html.cnz-themed[data-rd-theme="sepia"] .prose a.button{background:var(--cz-btn);color:var(--cz-btn-fg);border-color:var(--cz-btn)}
html.cnz-themed[data-rd-theme="dark"] .button:hover,html.cnz-themed[data-rd-theme="sepia"] .button:hover{background:var(--cz-btn-hover);color:var(--cz-btn-fg)}
html.cnz-themed[data-rd-theme="dark"] .button.secondary,html.cnz-themed[data-rd-theme="sepia"] .button.secondary,
html.cnz-themed[data-rd-theme="dark"] .prose a.button.secondary,html.cnz-themed[data-rd-theme="sepia"] .prose a.button.secondary{background:transparent;color:var(--ink);border-color:var(--line)}
html.cnz-themed[data-rd-theme="dark"] .button.secondary:hover,html.cnz-themed[data-rd-theme="sepia"] .button.secondary:hover{background:var(--tint)}
html.cnz-themed[data-rd-theme="dark"] .nav-links .contact-link{border-color:var(--line)}

/* search (Pagefind UI) */
html.cnz-themed[data-rd-theme="dark"] #lib-search,html.cnz-themed[data-rd-theme="dark"] .app-search{
  --pagefind-ui-primary:#e9bd76;--pagefind-ui-text:#ece4d4;--pagefind-ui-background:#0f1c28;--pagefind-ui-border:#2f4759;--pagefind-ui-tag:#16283a}
html.cnz-themed[data-rd-theme="sepia"] #lib-search,html.cnz-themed[data-rd-theme="sepia"] .app-search{
  --pagefind-ui-primary:#3a2e22;--pagefind-ui-text:#33291e;--pagefind-ui-background:#faf4e6;--pagefind-ui-border:#d3c29c;--pagefind-ui-tag:#ece0c5}
html.cnz-themed[data-rd-theme="dark"] #lib-search .pagefind-ui__result-link{color:#f0c27e}
html.cnz-themed[data-rd-theme="sepia"] #lib-search .pagefind-ui__result-link{color:#874411}

/* verse pop-ups and footnote pop-ups outside the reading view */
html.cnz-themed[data-rd-theme="dark"]:not(.lib-reading) .rd-pop{--rd-bg:#14263a;--rd-fg:#e3dccd;--rd-line:#2f4759;--rd-accent:#e9bd76;--rd-link:#f0c27e}
html.cnz-themed[data-rd-theme="sepia"]:not(.lib-reading) .rd-pop{--rd-bg:#faf4e6;--rd-fg:#33291e;--rd-line:#dbcca9;--rd-accent:#93531f;--rd-link:#874411}

@media (prefers-reduced-motion:no-preference){html.cnz-themed body{transition:background-color .2s ease}}
html.cnz-themed[data-rd-theme="dark"] .bv-pop,html.cnz-themed[data-rd-theme="sepia"] .bv-pop{background:var(--cz-card);box-shadow:0 18px 48px rgba(0,0,0,.4)}
html.cnz-themed[data-rd-theme="dark"] .vv-menu,html.cnz-themed[data-rd-theme="sepia"] .vv-menu{background:var(--cz-card);box-shadow:0 18px 48px rgba(0,0,0,.4)}
/* focus rings in the theme's accent (site.css draws them in the light theme's brown) */
html.cnz-themed[data-rd-theme="dark"] :focus-visible{outline-color:var(--accent)}
/* the app moves focus to a panel's heading for screen readers; no ring on a heading that cannot be clicked */
html.cnz-themed [tabindex="-1"]:focus:not(:focus-visible),.app h1[tabindex="-1"]:focus,.app h2[tabindex="-1"]:focus{outline:none}
html.cnz-themed[data-rd-theme="dark"] .bv-head,html.cnz-themed[data-rd-theme="sepia"] .bv-head{background:var(--cz-deep)}

/* ---------- reading settings controls (prefs.js): in the reading view's settings panel and the app's Settings ---------- */
.cz-prefs{display:grid;gap:4px}
.cz-pref-label{font:700 11px/1.4 var(--sans);letter-spacing:.12em;text-transform:uppercase;color:var(--rd-accent,var(--accent));margin:12px 0 8px}
.cz-seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:6px}
.cz-seg button{min-height:46px;padding:4px 2px;border:1px solid var(--rd-line,var(--line));border-radius:6px;background:var(--rd-bg,var(--paper));
  color:var(--rd-fg,var(--ink));font:500 14px/1.2 var(--sans);cursor:pointer}
.cz-seg button[aria-pressed="true"]{border:2px solid var(--rd-accent,var(--accent));font-weight:700}
.cz-seg button:focus-visible{outline:3px solid var(--rd-accent,var(--accent));outline-offset:2px}
.cz-seg-font{grid-auto-flow:row;grid-template-columns:repeat(3,1fr)}
.cz-seg-size button span{font-family:'Libre Caslon Text',Georgia,serif}
.cz-size-1 span{font-size:13px}.cz-size-2 span{font-size:16px}.cz-size-3 span{font-size:19px}.cz-size-4 span{font-size:22px}.cz-size-5 span{font-size:26px}
.cz-font-classic span{font:400 16px 'Libre Caslon Text',Georgia,serif}
.cz-font-book span{font:400 16px Literata,Georgia,serif}
.cz-font-modern span{font:500 15px 'DM Sans',system-ui,sans-serif}
.cz-font-clear span{font:400 15px 'Atkinson Hyperlegible',Verdana,sans-serif}
.cz-font-system span{font:400 15px system-ui,-apple-system,'Segoe UI',Roboto,sans-serif}
.cz-leading-1 span,.cz-leading-2 span,.cz-leading-3 span,.cz-width-1 span,.cz-width-2 span,.cz-width-3 span{font-size:13.5px}
.cz-theme-light{background:#fff!important;color:#1f2f3c!important}
.cz-theme-sepia{background:#f6eedc!important;color:#3a2e22!important}
.cz-theme-dark{background:#0f1c28!important;color:#e3dccd!important}
.cz-theme-auto{background:linear-gradient(135deg,#fff 0 50%,#0f1c28 50% 100%)!important;color:#1f2f3c!important}
.cz-theme-auto span{background:#fff;border-radius:4px;padding:1px 7px;box-shadow:0 0 0 1px rgba(0,0,0,.08)}
