/*
   word-explorer — searchable, audio-aligned study software for the Word.
   Copyright (C) 2026 the word-explorer authors

   This program is free software: you can redistribute it and/or modify it under
   the terms of the GNU Affero General Public License as published by the Free
   Software Foundation, either version 3 of the License, or (at your option) any
   later version.

   This program is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License along
   with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* Cormorant Garamond serif — the shared faithlife.org / Word Supply family look, applied
   here in The Desire of Ages' OWN colours: a deep clothbound burgundy + warm parchment +
   brass gold, evoking the 1898 book. (Keith Moore = blue+tan, Feldick = forest green,
   Joseph Prince = teal; this one is wine+parchment.) Falls back to Georgia / serif. */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&display=swap');

:root {
  /* Antique-book scheme: deep burgundy headings/links on warm parchment, with brass-gold
     masthead trim. Same faithlife structure as the sibling sites, different palette. */
  --ink: #2a2320; --muted: #6e6258; --line: #e0d6c2; --bg: #f6f1e7; --accent: #6b2b3a;
  --mark: #f3e2b8; --link: #6b2b3a; --visited: #7a5a44; --flag: #8a6d1f;
  --panel: #efe7d6; --panelline: #e0d3ba;   /* parchment panels (chapter picker, examples) */
  /* faithlife-style masthead accents, in the burgundy/gold palette */
  --accent-hover: #54212e; --gold: #b08a3e; --cream: #f8f4ea;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
body {
  font: 18px/1.65 var(--serif);
  color: var(--ink); background: var(--bg);
  max-width: 820px; margin: 0 auto; padding: 0 1rem 4rem;
  overflow-x: hidden;   /* contain the full-bleed masthead's 100vw */
}
header h1 { font-size: 1.4rem; margin: .2rem 0 .8rem; }
form[role=search] { display: block; }
.searchrow { display: flex; gap: .5rem; }
input[type=search] {
  flex: 1; font: inherit; padding: .6rem .8rem;
  border: 1px solid #ccc; border-radius: 8px; background: #fff;
}

/* corpus toggles */
.scopes { display: flex; flex-wrap: wrap; gap: 1rem; margin: .7rem 0 .2rem; }
.scope { font-size: .92rem; display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.tag {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .03em;
  padding: .05rem .35rem; border-radius: 4px; border: 1px solid transparent;
}
.tag.word { background: #e7f3e7; color: #275; border-color: #cbe3cb; }
.tag.asr  { background: #f3eee2; color: #856404; border-color: #e6dcc2; }
.tag.doc  { background: #e9edf6; color: #345; border-color: #cdd6e6; }

/* chapter toggle panel */
details.chapters { margin: .5rem 0 .2rem; font-size: .92rem; }
details.chapters summary { cursor: pointer; user-select: none; display: flex; align-items: center; gap: .6rem; }
.chcount { color: var(--muted); font-size: .85rem; }
.chbtns { margin-left: auto; }
.chbtns button {
  font: inherit; font-size: .8rem; padding: .15rem .6rem; background: #e9e9e2;
  color: #333; border: 1px solid #d3d3c8; border-radius: 6px; cursor: pointer;
}
.chgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .1rem .8rem; margin: .6rem 0 .2rem; max-height: 240px; overflow-y: auto;
  padding: .5rem; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.chgrid label {
  display: flex; align-items: baseline; gap: .4rem; font-size: .84rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.chgrid label span { overflow: hidden; text-overflow: ellipsis; }
button {
  font: inherit; padding: .6rem 1.1rem; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button:hover { filter: brightness(1.05); }
.hint, .empty, .count, .error { color: var(--muted); font-size: .92rem; }
.hint { margin: .6rem 0 0; }
.error { color: #b00; }
.count { margin: 1.2rem 0 .4rem; }
a { color: var(--link); }
a:visited { color: var(--visited); }

ol.results { list-style: none; padding: 0; margin: .5rem 0; }
ol.results li {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .7rem 0; border-top: 1px solid var(--line);
}
.play {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; margin-top: .1rem;
  border-radius: 50%; background: var(--accent); color: #fff;
  text-decoration: none; font-size: .8rem;
}
.play:hover { filter: brightness(1.08); }
.hit { min-width: 0; }
.meta { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; font-size: .85rem; }
.vid { font-weight: bold; }
.sub { color: var(--muted); }
.ts { color: var(--muted); font-family: ui-monospace, monospace; }
.play.book { background: #558; }
.flag {
  color: var(--flag); border: 1px solid currentColor; border-radius: 4px;
  padding: 0 .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
}
.snippet { display: block; margin-top: .2rem; text-decoration: none; color: var(--ink); }
.snippet:hover { color: #000; }
mark { background: var(--mark); padding: 0 .1em; border-radius: 2px; }

/* watch page */
.watch main { display: block; }
.back { display: inline-block; margin-bottom: .4rem; font-size: .9rem; text-decoration: none; }
video { width: 100%; border-radius: 10px; background: #000; position: sticky; top: 0; }
.jumped { font-size: .92rem; color: var(--muted); margin: .8rem 0; }
.transcript {
  border-top: 1px solid var(--line); padding-top: .8rem; color: #333;
}
.transcript .seg { cursor: pointer; padding: 1px 2px; border-radius: 3px; }
.transcript .seg:hover { background: var(--panel); }
.transcript .seg.active { background: var(--mark); }

/* book read-along player */
body.read main.doc { line-height: 1.85; }
.doc .seg { cursor: pointer; padding: 1px 2px; border-radius: 3px; }
.doc .seg:hover { background: var(--panel); }
.doc .seg.active { background: var(--mark); }
audio { width: 100%; position: sticky; top: 0; }

/* loader / front door */
.libstats { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.toolbar #processbtn { background: var(--accent); color: #fff; }
.sel-actions { display: inline-flex; gap: .3rem; }
.sel-actions button, #rebuildbtn {
  font: inherit; font-size: .82rem; padding: .35rem .7rem; border-radius: 7px; cursor: pointer;
  background: #e9e9e2; color: #333; border: 1px solid #d3d3c8;
}
#rebuildbtn { margin-left: auto; }
.matgroup { margin: 1.2rem 0; }
.matgroup h3 { font-size: 1rem; margin: .3rem 0; }
.mkind { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; border: 1px solid var(--line); padding: 0 .3rem; border-radius: 4px; }
.gcount { color: var(--muted); font-size: .8rem; font-weight: normal; }
.matlist { list-style: none; padding: 0; margin: .3rem 0; }
.matlist li { border-top: 1px solid var(--line); }
.matlist label { display: flex; align-items: center; gap: .6rem; padding: .45rem .2rem; cursor: pointer; }
.mname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msize { color: var(--muted); font-size: .8rem; font-family: ui-monospace, monospace; }
.status { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; padding: .05rem .4rem; border-radius: 4px; }
.status.ok { background: #e7f3e7; color: #275; }
.status.todo { background: #eef; color: #34a; }
.status.part { background: #f3eee2; color: #856404; }
.matlist li.done .mname { color: var(--muted); }

.jobpanel { border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; margin: 1rem 0; background: #fff; }
.jobpanel.hidden { display: none; }
.jobhead { display: flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: bold; }
.jobpanel pre { max-height: 260px; overflow: auto; background: #111; color: #cde; padding: .6rem; border-radius: 6px; font-size: .78rem; margin: .5rem 0 0; white-space: pre-wrap; }
.spinner { width: .9rem; height: .9rem; border: 2px solid #ccc; border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.topnav { float: right; font-size: .85rem; margin-left: 1rem; }

/* uploader (front door "take in files") */
.uploader, .process { border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; background: #fff; }
.uploader h2, .process h2 { font-size: 1.05rem; margin: .1rem 0 .7rem; }
.uprow { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin: .5rem 0; }
.uplabel { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); gap: .2rem; }
.uplabel select, .uplabel input[type=text] { font: inherit; font-size: .9rem; padding: .35rem .5rem; border: 1px solid #ccc; border-radius: 7px; background: #fff; color: var(--ink); }
input[type=file] { font: inherit; font-size: .85rem; }
.uphint { color: var(--muted); font-size: .8rem; flex: 1; min-width: 12rem; }
.uplist { list-style: none; padding: 0; margin: .6rem 0 0; }
.uplist li { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; font-size: .82rem; border-top: 1px solid var(--line); }
.uplist .un { flex: 1 1 40%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uplist .ub { flex: 1 1 40%; height: .5rem; background: #eee; border-radius: 4px; overflow: hidden; }
.uplist .ub i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.uplist .us { flex: 0 0 auto; color: var(--muted); font-family: ui-monospace, monospace; font-size: .75rem; min-width: 4rem; text-align: right; }
.uplist li.ok .us { color: #275; }
.uplist li.err .us { color: #b00; }
.uplist li.err .ub i { background: #b00; }

/* inventory */
.inventory table.inv { width: 100%; border-collapse: collapse; font-size: .82rem; margin: .8rem 0; }
.inventory .inv th, .inventory .inv td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.inventory .inv th { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.inventory .inv td.num { text-align: right; font-family: ui-monospace, monospace; }
.inventory .inv td.built { color: var(--muted); font-family: ui-monospace, monospace; white-space: nowrap; }
.inventory .dl { font-size: .82rem; margin-left: .6rem; }
.inventory h2 { font-size: 1.05rem; margin: 1.4rem 0 .3rem; }
ul.pending { list-style: none; padding: 0; margin: .3rem 0; }
ul.pending li { display: flex; gap: .6rem; align-items: baseline; padding: .3rem 0; border-top: 1px solid var(--line); font-size: .85rem; }
ul.pending .pf { color: var(--muted); font-size: .78rem; }
ul.pending .pn { flex: 1; }
ul.pending .ps { color: var(--muted); font-family: ui-monospace, monospace; font-size: .78rem; }

/* text document reader */
body.read.text main.doc { line-height: 1.75; }
.doc .passage { padding: .3rem .5rem; border-radius: 6px; margin: .1rem -.5rem; }
.doc .passage.active { background: var(--mark); }

@media (prefers-color-scheme: dark) {
  /* dark forest variant: deep pine near-black, bright leaf-green accent, brass trim */
  :root { --ink: #e6e8dc; --muted: #9aa58f; --line: #2c3327; --bg: #12160f;
          --accent: #5f9e63; --link: #8fc98f; --visited: #a9bd7e; --mark: #38492a;
          --panel: #1a2016; --panelline: #333d2b; --cream: #eef1e3; --gold: #c9a24b; }
  input[type=search], .uplabel select, .uplabel input[type=text] { background: #1e241a; color: #eef1e3; border-color: #3a4433; }
  .snippet { color: var(--ink); }
  .transcript .seg:hover { background: #24301c; }
  .uploader, .process, .inventory .inv td { background: #1c1c14; }
  .uplist .ub { background: #333; }
  .tag.doc { background: #1e2634; color: #9db4d6; border-color: #33415a; }
}

/* Les Feldick masthead — faithlife.org structure, Feldick's maroon/parchment palette:
   a full-bleed maroon bar with a gold underline and a centred serif wordmark. */
header {
  width: 100vw; margin-inline: calc(50% - 50vw);
  background: var(--accent); color: var(--cream);
  border-bottom: 4px solid var(--gold);
  padding: 1.1rem 0 1.3rem; margin-bottom: 1.4rem;
}
header > * { max-width: 820px; margin-inline: auto; padding-inline: 1rem; }
.topnav { display: block; float: none; margin: 0 0 .5rem; color: var(--gold); font-size: .95rem; }
.topnav:hover { color: #fff; }
.brand { margin: 0; }
.brand .wordmark {
  font-family: var(--serif); font-weight: 600; letter-spacing: .01em; line-height: 1.08;
  font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); color: var(--cream);
}
.brand .brandsub { color: rgba(247,243,227,.82); font-size: 1.05rem; margin-top: .2rem; }

/* verse-anchored search: query hint, the Word card, taught-segment list, pager */
.versehint { font-size: .9rem; color: var(--muted); margin: .5rem 0 .2rem; }
.versehint a { font-weight: 600; }
.chapters .opt { font-weight: 400; color: var(--muted); font-size: .82rem; }
.versehead { border: 1px solid var(--line); border-left: 4px solid var(--link);
             border-radius: 8px; padding: .7rem .9rem; margin: .2rem 0 1rem; background: rgba(46,82,51,.06); }
.versehead .verseref { font-weight: 700; font-size: 1.05rem; margin-bottom: .35rem; }
.versehead .pce { margin: .25rem 0; line-height: 1.6; }
.versehead .pce .pceref { color: var(--muted); font-family: ui-monospace, monospace; font-size: .78rem; margin-right: .4rem; }
.results.verses .dwell { color: var(--muted); font-family: ui-monospace, monospace; font-size: .78rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.4rem 0 .4rem; }
.pager .pg { font-weight: 600; }
.pager .pg.disabled { color: var(--muted); opacity: .5; }
.pager .pgnum { color: var(--muted); font-size: .85rem; }

/* "Click for search examples" drop-down */
/* book-picker + examples: lightest-blue panels */
details.chapters.books { margin: .6rem 0 .2rem; padding: .5rem .75rem .7rem; border-radius: 8px;
                   background: var(--panel); border: 1px solid var(--panelline); }
details.examples { margin: .6rem 0 .2rem; border: 1px solid var(--panelline); border-radius: 8px;
                   background: var(--panel); }
details.examples > summary { cursor: pointer; padding: .55rem .8rem; font-weight: 600;
                   color: var(--link); list-style: none; user-select: none; }
details.examples > summary::-webkit-details-marker { display: none; }
details.examples > summary::before { content: "\25B6"; font-size: .7em; margin-right: .5rem;
                   display: inline-block; transition: transform .15s; }
details.examples[open] > summary::before { transform: rotate(90deg); }
details.examples[open] > summary { border-bottom: 1px solid var(--panelline); }
.exbody { padding: .4rem .9rem .9rem; }
.exbody h3 { font-size: .95rem; margin: .9rem 0 .35rem; }
.exbody h3:first-child { margin-top: .3rem; }
.exbody p { margin: .35rem 0; font-size: .9rem; line-height: 1.5; color: var(--ink); }
.exlist { margin: .3rem 0 .3rem; padding-left: 1.1rem; }
.exlist li { margin: .35rem 0; font-size: .9rem; line-height: 1.5; }
.exlist a { font-family: ui-monospace, monospace; font-size: .85em; white-space: nowrap;
            background: rgba(46,82,51,.10); padding: .05rem .35rem; border-radius: 4px; }
.exbody .extip { margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--line); color: var(--muted); }

/* ── site menu: Bible-icon dropdown (the masthead "hamburger", as an open Bible) ──────── */
.fl-menuwrap { display: flex; justify-content: flex-end; margin: 0 0 .45rem; }
.fl-menu { position: relative; }
.fl-menu > summary { list-style: none; cursor: pointer; user-select: none; line-height: 1;
  display: inline-flex; align-items: center; gap: .45rem; font-size: 1.3rem;
  padding: .28rem .6rem; border: 1px solid var(--gold); border-radius: 8px;
  color: var(--gold); background: rgba(0,0,0,.14); }
.fl-menu > summary::-webkit-details-marker { display: none; }
.fl-menu > summary::after { content: "Menu"; font: 600 .85rem/1 var(--serif, Georgia, serif); }
.fl-menu > summary:hover,
.fl-menu[open] > summary { background: var(--gold); color: var(--accent); }
.fl-menupop { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 40; min-width: 15rem;
  background: #fff; border: 1px solid var(--panelline); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,.22); padding: .35rem; }
.fl-menuhdr { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: .4rem .6rem .2rem; }
.fl-menupop a { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem;
  padding: .5rem .6rem; border-radius: 6px; text-decoration: none; color: var(--ink); font-weight: 600; }
.fl-menupop a span { color: var(--muted); font-size: .78rem; font-weight: 400;
  font-family: system-ui, sans-serif; white-space: nowrap; }
.fl-menupop a:hover { background: var(--mark); color: var(--accent-hover); }

