/* generated by the build from dev/site-lib/reader.* and books/book.css - edit those */
/* the fonts are shared with the unicode tools (/tools/unicode/fonts/web, made by dev/site-lib/make-fonts.sh); in the apps,
   where the pages are local files, that url fails and the copy in common/ put there by dev/sync-apps.sh is used */
@font-face { font-family: 'Abhaya Uni'; src: url('/tools/unicode/fonts/web/AbhayaUni-Regular.woff2') format('woff2'), url('AbhayaUni-Regular.woff2') format('woff2'); font-weight: normal; font-display: swap; }
@font-face { font-family: 'Abhaya Uni'; src: url('/tools/unicode/fonts/web/AbhayaUni-Bold.woff2') format('woff2'), url('AbhayaUni-Bold.woff2') format('woff2'); font-weight: bold; font-display: swap; }
/* only the letters of the site titles (make-fonts.sh) */
@font-face { font-family: 'Alakamanda Uni Title'; src: url('/tools/unicode/fonts/web/AlakamandaUni-Title.woff2') format('woff2'), url('AlakamandaUni-Title.woff2') format('woff2'); font-display: swap; }

/* themes: light (default), sepia and dark - chosen in the reading settings, set on <html data-theme> before the first paint */
:root {
    --bg: #fdfbf7;
    --surface: #f6f0e6;
    --surface-2: #ece2d2;
    --text: #29231c;
    --muted: #6b6155;
    --border: #e4d9c7;
    --heading: #6e2b12;
    --link: #9a3d12;
    --accent: #c2621f;
    --accent-soft: #f6e3d1;
    --verse: #7d3a14;
    --shadow: 0 1px 2px rgba(70, 45, 20, .08), 0 3px 10px rgba(70, 45, 20, .06);
    --font-scale: 1;
    --appbar-h: 52px;
    color-scheme: light;
}
:root[data-theme="sepia"] {
    --bg: #f4ead5;
    --surface: #ebdfc3;
    --surface-2: #e0d0ac;
    --text: #3a2d1f;
    --muted: #6d5b44;
    --border: #d8c6a1;
    --heading: #5f280c;
    --link: #8a360c;
    --accent: #a8521a;
    --accent-soft: #e8d2ae;
    --verse: #7a3510;
}
:root[data-theme="dark"] {
    --bg: #161412;
    --surface: #211e1a;
    --surface-2: #2d2924;
    --text: #e8e1d5;
    --muted: #a69c8d;
    --border: #39332b;
    --heading: #f0c08a;
    --link: #f2b56f;
    --accent: #e0954a;
    --accent-soft: #3b2b1b;
    --verse: #e9b27c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 3px 10px rgba(0, 0, 0, .3);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Abhaya Uni', 'Noto Serif Sinhala', 'Iskoola Pota', serif;
    font-size: calc(1.1875rem * var(--font-scale));
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
    overflow-wrap: break-word; /* long pali compounds on narrow phones */
}
a { color: var(--link); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 24px; height: 24px; fill: currentColor; flex-shrink: 0; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar: hides while scrolling down, comes back when scrolling up */
.appbar {
    position: sticky; top: 0; z-index: 20;
    height: var(--appbar-h);
    display: flex; align-items: center; gap: 2px;
    padding: 0 4px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: transform .2s ease;
}
.appbar.hidden { transform: translateY(-100%); }
/* search field in the bar (web); in the apps, which can not search yet, the title instead */
.appbar-search { flex: 1; min-width: 0; position: relative; margin: 0 6px; }
.appbar-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.appbar-search input {
    width: 100%; height: 40px; padding: 0 12px 0 38px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 1rem;
}
.appbar-search input::placeholder { color: var(--muted); opacity: .8; }
.appbar-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.appbar-title.app-only { display: none; }
.local .appbar-title.app-only { display: block; }
.local .appbar-search { display: none; }
.appbar-title {
    flex: 1; min-width: 0; margin: 0 4px;
    font-size: 1rem; font-weight: bold; line-height: 1.3;
    color: var(--heading);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar-title a { color: inherit; text-decoration: none; }
.appbar-title.brand { font-family: 'Alakamanda Uni Title', 'Abhaya Uni', serif; font-weight: normal; font-size: 1.5rem; text-align: center; margin: 0 8px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; height: 44px; border-radius: 22px;
    color: var(--heading); text-decoration: none;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface-2); }
.settings-btn { font-weight: bold; font-size: 1.05rem; font-family: Georgia, serif; }

/* reading settings panel */
.settings {
    position: fixed; z-index: 30; top: calc(var(--appbar-h) + 4px); right: 8px;
    width: min(320px, calc(100vw - 16px));
    padding: 14px 16px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
    font-size: 1rem; line-height: 1.4;
}
.settings[hidden] { display: none; }
.settings h2 { font-size: .85rem; font-weight: normal; color: var(--muted); margin: 0 0 6px; }
.settings .row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.settings .row:last-child { margin-bottom: 0; }
.settings .size-btn {
    flex: 1; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
    font-weight: bold;
}
.settings .size-btn.larger { font-size: 1.3rem; }
.settings output { min-width: 3.5em; text-align: center; color: var(--muted); }
.theme-choice {
    flex: 1; height: 56px; border-radius: 10px; border: 2px solid var(--border);
    display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .85rem;
}
.theme-choice[data-choice="light"] { background: #fdfbf7; color: #29231c; }
.theme-choice[data-choice="sepia"] { background: #f4ead5; color: #3a2d1f; }
.theme-choice[data-choice="dark"] { background: #161412; color: #e8e1d5; }
.theme-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* breadcrumb: one line that scrolls sideways */
.crumbs {
    display: flex; align-items: center; gap: 2px;
    overflow-x: auto; white-space: nowrap; scrollbar-width: none;
    padding: 6px 12px; margin: 0;
    font-size: .875rem; line-height: 1.4; color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 6px 2px; }
.crumbs a:hover { color: var(--link); }
.crumbs .icon { width: 16px; height: 16px; opacity: .6; }

/* reading column */
.page { max-width: 42rem; margin: 0 auto; padding: 0 16px; }
.prose p { margin: 0 0 0.9em; }
@media (min-width: 40rem) { .prose p { text-align: justify; } }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.4; font-weight: bold; }
.page-title { display: flex; align-items: flex-start; gap: 4px; margin: 20px 0 12px; }
.page-title h1 { flex: 1; min-width: 0; margin: 6px 0 0; font-size: 1.5em; }
.page-title .icon-btn { margin-top: 2px; }

.lead { color: var(--muted); font-size: .95em; margin: 4px 0 16px; }
.note { font-size: .9rem; line-height: 1.6; color: var(--muted); text-align: center; padding: 20px 16px 28px; border-top: 1px solid var(--border); margin-top: 24px; }
.note a { color: var(--link); }
.note .icon { width: 18px; height: 18px; }

/* verse lines of two padas: one pada a line on phones, the second indented */
@media (max-width: 40rem) {
    .pada { display: block; padding-left: 1em; text-indent: -1em; } /* a pada that still wraps hangs under itself */
    .pada-2 { padding-left: 2.5em; }
    .pada-sep { display: none; }
}

/* search: not in the apps, where the pages are local files that can not load the index */
.local .search-link { display: none; }
.search-page { padding-top: 8px; }
.search-scope { display: flex; gap: 16px; font-size: .9rem; color: var(--muted); margin: 4px 4px 0; }
.search-scope { flex-wrap: wrap; column-gap: 16px; row-gap: 0; }
.search-scope label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.search-scope .book-name { color: var(--heading); font-weight: bold; }
.singlish-note { font-size: .95rem; color: var(--muted); margin: -8px 0 8px; line-height: 1.6; }
.singlish-note:empty { display: none; }
.singlish-note b { color: var(--heading); }
.alt-btn { display: inline-block; margin: 6px 6px 0 0; padding: 0 14px; min-height: 40px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--link); }
.results { list-style: none; margin: 0; padding: 0; }
.results li { border-bottom: 1px solid var(--border); }
.results a { display: block; padding: 12px 2px; text-decoration: none; color: var(--text); line-height: 1.45; }
.result-title { display: block; font-weight: bold; color: var(--link); }
.result-book { display: block; font-size: .95rem; color: var(--muted); margin-top: 2px; }
.result-excerpt { display: block; font-size: .9rem; margin-top: 4px; }
.result-excerpt mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.more-btn[hidden] { display: none; }
.more-btn { display: block; margin: 16px auto; padding: 0 24px; height: 44px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); }

/* continue reading */
.continue { margin: 16px 0 8px; }
.continue h2 { font-size: 1rem; color: var(--muted); font-weight: normal; margin: 0 0 6px 4px; }
.continue-item { position: relative; margin-bottom: 8px; }
.continue-card { display: block; padding: 10px 48px 12px 14px; background: var(--accent-soft); border-radius: 12px; text-decoration: none; color: var(--text); line-height: 1.35; }
.continue-dismiss { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.continue-dismiss:hover { color: var(--heading); background: var(--surface-2); }
.continue-dismiss .icon { width: 20px; height: 20px; }
.continue-title { display: block; font-weight: bold; color: var(--heading); }
.continue-meta { display: block; font-size: .85em; color: var(--muted); margin: 2px 0 8px; }
.continue-bar { display: block; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.continue-bar span { display: block; height: 100%; background: var(--accent); }

/* previous / next */
.pager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin: 28px 0 8px; }
.pager a {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 14px; min-height: 64px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
    text-decoration: none; color: var(--text); line-height: 1.35;
}
.pager a:hover { border-color: var(--accent); }
.pager .next { grid-column: 2; text-align: right; align-items: flex-end; }
.pager-label { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }
.pager-label .icon { width: 16px; height: 16px; }
.pager-title { overflow-wrap: anywhere; font-size: .95rem; color: var(--link); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

#toast {
    position: fixed; z-index: 40; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    max-width: calc(100vw - 32px);
    padding: 10px 18px; border-radius: 22px;
    background: #2b2620; color: #fff; font-size: .9rem; line-height: 1.4; text-align: center;
    transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

@media print {
    .appbar, .settings, .crumbs, .pager, .note, #toast, button { display: none !important; }
    body { background: #fff; color: #000; font-size: 12pt; }
}

/* ---- books site (after dev/site-lib/reader.css) ---- */

/* site index: the books by section */
.shelf { margin: 20px 0 8px; }
.shelf h2 { font-size: 1rem; color: var(--muted); font-weight: normal; margin: 0 0 6px 4px; letter-spacing: .02em; }
.book-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.book-list li + li { border-top: 1px solid var(--border); }
.book-list a { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 16px; min-height: 56px; text-decoration: none; color: var(--text); line-height: 1.35; }
.book-list a:hover { background: var(--surface-2); }
.book-list .book-text { flex: 1; min-width: 0; }
.book-name { display: block; font-weight: bold; color: var(--heading); font-size: 1.05em; }
.book-author { display: block; font-size: .85em; color: var(--muted); }
.book-list .icon { color: var(--muted); }

/* book index: title page, introduction and the table of contents */
.book-head { text-align: center; margin: 24px 0 8px; }
.book-head h1 { font-size: 1.6em; margin: 0; }
.book-head .lead { margin: 4px 0 0; }
.front-matter { margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.front-matter summary { cursor: pointer; padding: 10px 16px; min-height: 44px; font-weight: bold; color: var(--heading); list-style: none; display: flex; align-items: center; gap: 6px; }
.front-matter summary::-webkit-details-marker { display: none; }
.front-matter summary .icon { transition: transform .2s ease; transform: rotate(90deg); }
.front-matter[open] summary .icon { transform: rotate(-90deg); }
.front-matter .front-body { padding: 0 16px 8px; }
.front-matter p { margin: 0 0 .7em; }

.toc { margin: 8px 0 16px; }
.toc-row { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--border); line-height: 1.4; }
.toc-row > a { flex: 1; min-width: 0; padding: 10px 4px; text-decoration: none; color: var(--text); }
.toc-row > a:hover { color: var(--link); }
.toc-row[data-level="1"] > a { font-weight: bold; color: var(--heading); }
.toc-row[data-level="2"] { padding-left: 16px; }
.toc-row[data-level="3"] { padding-left: 32px; font-size: .95em; }
.toc-row[data-level="4"] { padding-left: 48px; font-size: .95em; }
.toc-toggle, .toc-leaf { flex-shrink: 0; width: 36px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.toc-leaf .icon { width: 18px; height: 18px; opacity: .5; }
.toc-toggle .icon { transition: transform .2s ease; }
.toc-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
/* opening and closing a branch: the row heights animate from 0 to their size */
.toc-children { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s ease; }
.toc-children > .toc-inner { overflow: hidden; min-height: 0; }
.toc-item.closed > .toc-children { grid-template-rows: 0fr; }
.toc.no-anim .toc-children, .toc.no-anim .toc-toggle .icon { transition: none; }

/* bookmark star */
.star { color: var(--muted); }
.star .on { display: none; }
.star.active { color: var(--accent); }
.star.active .on { display: inline; }
.star.active .off { display: none; }
.toc-row .star { opacity: .55; }
.toc-row .star.active { opacity: 1; }

/* sub headings at the end of a chapter */
.subheadings { margin: 24px 0 8px; padding-top: 4px; border-top: 2px solid var(--border); }
.subheadings > h2 { font-size: .9rem; color: var(--muted); font-weight: normal; margin: 8px 0 0; }

/* styles from the word documents */
.gatha { margin: 0.6em 0 0.9em 1.25em; padding-left: 0.9em; border-left: 3px solid var(--accent-soft); color: var(--verse); }
.gatha > p { margin: 0 !important; text-align: start !important; }
.subhead { color: var(--heading); font-weight: bold; font-size: 1.1em; margin: 1.2em 0 .4em; }
.subhead > p { margin: 0 !important; }
.largefont { font-size: 1.15em; }
.centered, .centered p { text-align: center !important; }
.prose ol, .prose ul { padding-left: 1.6em; margin: 0 0 .9em; }
/* lists made from numbered paragraphs keep their own marker (1. / (අ) / i.) as text, hanging in the margin */
.prose ol.enum, .prose ul.enum { list-style: none; padding-left: 2.4em; }
ol.enum > li > .li-num, ul.enum > li > .li-num { display: inline-block; min-width: 2.4em; margin-left: -2.4em; padding-right: .3em; color: var(--heading); }
.gatha + .gatha { margin-top: -.3em; }
.prose li { margin-bottom: .35em; }
.prose li > p { margin: 0 0 .35em; }
.prose b, .prose strong { color: var(--heading); }

/* jathaka images */
.image-placeholder { margin: 20px 0; text-align: center; }
.image-placeholder img { width: 100%; height: auto; display: block; border-radius: 12px; box-shadow: var(--shadow); }
.image-placeholder .img-label { display: block; margin-top: 8px; font-size: .9rem; line-height: 1.5; color: var(--muted); }

/* gatha numbers in the mahavansa */
span.gatha-number { font-size: 0.6em; vertical-align: baseline; position: relative; top: -0.6em; margin-left: 1px; }

.prose table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; max-width: 100%; }
.prose td, .prose th { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; line-height: 1.5; }
.prose td > p { margin: 0 !important; text-align: left !important; }
/* the palibhashavatharana 1 book by ven ariyadassana */
table.max-width thead { color: var(--heading); text-align: center; }
table.max-width td.separator { background: var(--surface); width: 10px; }

ol.footnotes { margin: 28px 0 0; padding: 12px 0 0 1.4em; border-top: 1px solid var(--border); font-size: .85em; line-height: 1.6; color: var(--muted); }
ol.footnotes li p { margin: 0 0 .4em !important; text-align: start !important; }
a.footnote-ref { text-decoration: none; font-size: .8em; vertical-align: super; line-height: 0; padding: 0 1px; }

/* bookmarks page */
.bookmark-list { list-style: none; margin: 16px 0; padding: 0; }
.bookmark-list li { display: flex; align-items: center; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--border); line-height: 1.45; }
.bookmark-list .bm-text { flex: 1; min-width: 0; }
.bookmark-list .bm-book { display: block; font-size: .85em; color: var(--muted); }
.bookmark-list .bm-date { font-size: .8em; color: var(--muted); }
.bookmark-list a { text-decoration: none; }
