/* Hayya's Library (public/prayer-library.js): the Moulid app's look, inside
   the prayer app. Everything is under #viewLibrary so none of it reaches the
   prayer, Quran or adhkar screens, whose class names (.ln, .btn, .group...)
   some of these share. */
#viewLibrary {
  --lfs: 30px;
  --lpanel: #f4eee0;
  --lfaint: #b7ae9c;
  --lml: 'Noto Sans Malayalam', 'Malayalam MN', 'Kartika', sans-serif;
  --lar: 'Amiri', 'Scheherazade New', 'Geeza Pro', 'Noto Naskh Arabic', serif;
  flex: 1; max-width: 900px; width: 100%; margin: 14px auto 0;
}
#viewLibrary [lang="ml"] { font-family: var(--lml); }
#viewLibrary .lb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.7); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
#viewLibrary .lb-btn svg { width: 17px; height: 17px; }
#viewLibrary .lb-btn.icon { padding: 9px; }
#viewLibrary .lb-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#viewLibrary .lb-search { position: relative; }
#viewLibrary .lb-search input {
  width: 100%; padding: 13px 16px 13px 44px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.75);
  font: inherit; font-size: 16px; color: var(--ink); outline: none; -webkit-appearance: none; appearance: none;
}
#viewLibrary .lb-search input:focus { border-color: var(--gold-soft); background: #fff; }
#viewLibrary .lb-search svg { position: absolute; left: 15px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#viewLibrary .lb-cont {
  margin: 14px 0 4px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--lpanel);
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
}
#viewLibrary .lb-cont .lab { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
#viewLibrary .lb-cont .tt { font-weight: 600; font-size: 16px; margin-top: 2px; }
#viewLibrary .lb-cont .wh { font-size: 13px; color: var(--muted); }
#viewLibrary .lb-cont .ar { font-family: var(--lar); font-size: 22px; color: var(--gold-pale); margin-left: auto; }
#viewLibrary .lb-coll { margin-top: 26px; }
#viewLibrary .lb-coll > h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
#viewLibrary .lb-coll > h2 .mlh { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }
#viewLibrary .lb-cnote { margin: 6px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
#viewLibrary .lb-group { margin-top: 20px; }
#viewLibrary .lb-group h3 { margin: 0 0 10px 2px; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#viewLibrary .lb-group h3::after { content: ""; flex: 1; height: 1px; background: var(--line); min-width: 20px; }
#viewLibrary .lb-group h3 .mlh, #viewLibrary .lb-group h3 small { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 12px; color: var(--lfaint); }
#viewLibrary .lb-group h3 .ar { font-family: var(--lar); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 15px; color: var(--lfaint); }
#viewLibrary .lb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
#viewLibrary .lb-item {
  display: flex; flex-direction: column; gap: 3px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  padding: 13px 15px 12px; border-radius: 16px; border: 1px solid var(--line); background: #fff;
}
#viewLibrary .lb-item:active { transform: scale(.985); }
#viewLibrary .lb-item .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
#viewLibrary .lb-item .tt { font-weight: 600; font-size: 15.5px; }
#viewLibrary .lb-item .ar { font-family: var(--lar); font-size: 20px; color: var(--gold-pale); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; max-width: 50%; }
#viewLibrary .lb-item .ml { font-size: 13.5px; color: var(--muted); line-height: 1.5; text-align: left; align-self: flex-start; }
#viewLibrary .lb-item .by { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
#viewLibrary .lb-none { padding: 30px 0; text-align: center; color: var(--muted); line-height: 1.6; }
#viewLibrary .lb-src { margin: 30px 0 0; font-size: 12px; line-height: 1.6; color: var(--lfaint); text-align: center; }
#viewLibrary .lb-inside { margin: 18px auto 0; display: flex; }

/* the reader */
#viewLibrary .lb-bar {
  position: sticky; top: 0; z-index: 5; margin: 0 -18px; padding: 10px 18px; background: rgba(253,251,246,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
}
#viewLibrary .lb-tt { flex: 1; min-width: 0; }
#viewLibrary .lb-tt b { display: block; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#viewLibrary .lb-tt span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#viewLibrary .lb-bar .lb-btn { padding: 8px 10px; font-size: 13px; }
#viewLibrary .lb-bar .lb-btn.icon { padding: 8px; }
#viewLibrary .lb-secs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#viewLibrary .lb-secs::-webkit-scrollbar { display: none; }
#viewLibrary .lb-secs button { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.6); font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
#viewLibrary .lb-secs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#viewLibrary .lb-secs button i { font-style: normal; font-family: var(--lar); margin-left: 6px; color: var(--lfaint); }
#viewLibrary .lb-secs button.on i { color: rgba(255,255,255,.6); }
#viewLibrary .lb-secsel { width: 100%; margin: 12px 0 4px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.75); font: inherit; font-size: 15px; color: var(--ink); }
#viewLibrary .lb-about { margin: 14px 0 6px; padding: 14px 16px; border-radius: 14px; background: var(--lpanel); font-size: 14px; line-height: 1.55; color: var(--muted); }
#viewLibrary .lb-about b { color: var(--ink); font-weight: 600; font-family: var(--lar); font-size: 18px; }
#viewLibrary .lb-about .cr { opacity: .75; }
#viewLibrary .lb-text { padding: 8px 0 40px; }
#viewLibrary .lb-text .sh { text-align: center; margin: 30px 0 16px; }
#viewLibrary .lb-text .sh .ar { font-family: var(--lar); font-size: calc(var(--lfs) * .9); color: var(--gold); line-height: 1.6; }
#viewLibrary .lb-text .sh .en { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-top: 4px; font-weight: 600; }
#viewLibrary .lb-text .bism { text-align: center; font-family: var(--lar); font-size: calc(var(--lfs) * 1.05); color: var(--gold-pale); margin: 8px 0 20px; line-height: 2; }
#viewLibrary .lb-text .ln { padding: 10px 0; scroll-margin-top: 80px; border-bottom: 1px dashed rgba(120,95,40,.14); }
#viewLibrary .lb-text .ln:last-child { border-bottom: 0; }
#viewLibrary .lb-text .ln .a { direction: rtl; font-family: var(--lar); font-size: var(--lfs); line-height: 2; color: var(--ink); text-align: right; }
#viewLibrary .lb-text .ln.v .a { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 .6em; text-align: center; }
#viewLibrary .lb-text .ln.v .a span:not(.vn) { flex: 1 1 42%; min-width: 0; text-align: center; }
#viewLibrary .lb-text .ln .sep { flex: none !important; color: var(--gold-soft); opacity: .8; font-size: .7em; }
#viewLibrary .lb-text .ln.c .a { text-align: center; }
#viewLibrary .lb-text .ln .a .st { color: var(--gold-soft); font-size: .62em; padding: 0 .35em; opacity: .85; }
#viewLibrary .lb-text .ln .a .vn { font-family: var(--sans); font-size: .5em; color: var(--gold); padding: 0 .4em; vertical-align: middle; white-space: nowrap; }
#viewLibrary .lb-text .ln .a .vn.k { cursor: pointer; text-decoration: underline dotted; }
#viewLibrary .lb-text .ln .t { font-size: 15px; color: var(--muted); font-style: italic; text-align: center; margin-top: 2px; line-height: 1.5; }
#viewLibrary .lb-text .ln .e { font-size: 15px; color: var(--muted); text-align: center; margin: 4px auto 0; line-height: 1.55; max-width: 640px; }
#viewLibrary .lb-text .ln.p .t, #viewLibrary .lb-text .ln.p .e { text-align: left; max-width: none; }
#viewLibrary .lb-text .ln .s { font-size: 12px; color: var(--lfaint); text-align: center; margin-top: 5px; line-height: 1.5; }
#viewLibrary .lb-text .ln .h { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin: 8px 0 2px; text-align: right; }
#viewLibrary .lb-text .ln .rr { text-align: center; }
#viewLibrary .lb-text .ln .r { display: inline-block; margin: 4px auto 0; padding: 3px 12px; border-radius: 999px; background: var(--lpanel); color: var(--gold-pale); font-size: 12.5px; font-weight: 600; cursor: pointer; user-select: none; -webkit-user-select: none; }
#viewLibrary .lb-text .ln .r.done { background: var(--gold); color: #fff; }
#viewLibrary .lb-text.ml .ln .a { direction: ltr; font-family: var(--lml); font-size: calc(var(--lfs) * .74); line-height: 1.8; text-align: left; }
#viewLibrary .lb-text.ml .ln.v .a, #viewLibrary .lb-text.ml .ln.c .a { text-align: center; }
#viewLibrary .lb-text.ml .ln .h { text-align: left; }
#viewLibrary.noe .lb-text .e, #viewLibrary.not .lb-text .t { display: none; }
#viewLibrary .lb-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }
#viewLibrary .lb-nav .lb-btn { flex: 1; }
@keyframes lbfound { 0%, 35% { background: rgba(176,137,47,.22); box-shadow: 0 0 0 10px rgba(176,137,47,.22); } 100% { background: transparent; box-shadow: 0 0 0 10px transparent; } }
#viewLibrary .ln.found, #viewLibrary .sh.found { animation: lbfound 2.6s ease-out; border-radius: 10px; }

/* Reading: a tap on the text hides everything but the text. */
body.lbfocus header, body.lbfocus .tabs, body.lbfocus .navbar, body.lbfocus #viewLibrary .lb-bar,
body.lbfocus #viewLibrary .lb-secs, body.lbfocus #viewLibrary .lb-about, body.lbfocus #viewLibrary .lb-nav, body.lbfocus footer.made { display: none !important; }
body.lbreading footer.made { display: none; }
/* While reading, the text gets the room the clock and place had. */
body.lbreading header { display: none !important; }

/* search inside the texts: a page of its own over everything */
#viewLibrary .lb-finder { position: fixed; inset: 0; z-index: 60; background: var(--night-0, #fdfbf6); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.lbfinding { overflow: hidden; }
#viewLibrary .lb-fbox { max-width: 760px; margin: 0 auto; padding: 0 18px 40px; }
#viewLibrary .lb-fbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 14px 0 10px; background: rgba(253,251,246,.95); }
#viewLibrary .lb-fbar .lb-search { flex: 1; }
#viewLibrary .lb-fstat { font-size: 13px; color: var(--muted); padding: 2px; line-height: 1.5; }
#viewLibrary .lb-hits { display: flex; flex-direction: column; gap: 8px; }
#viewLibrary .lb-hit { display: block; width: 100%; text-align: left; padding: 11px 14px 10px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font: inherit; color: var(--ink); cursor: pointer; }
#viewLibrary .lb-hit .sn { display: block; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
#viewLibrary .lb-hit .sn.ar { direction: rtl; text-align: right; font-family: var(--lar); font-size: 21px; line-height: 1.8; }
#viewLibrary .lb-hit .sn.ml { font-family: var(--lml); }
#viewLibrary .lb-hit .sn.lt { color: var(--muted); }
#viewLibrary .lb-hit .wh { display: block; margin-top: 3px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
#viewLibrary .lb-hit mark { background: rgba(176,137,47,.28); color: var(--ink); border-radius: 4px; padding: 0 1px; }
#viewLibrary .lb-more { margin-top: 8px; width: 100%; }
#viewLibrary .lb-toast { position: fixed; left: 50%; bottom: calc(24px + var(--navh, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 70; opacity: 0; transition: opacity .3s; pointer-events: none; }
#viewLibrary .lb-toast.show { opacity: 1; }
@media (max-width: 640px) {
  #viewLibrary .lb-list { grid-template-columns: 1fr; }
  #viewLibrary .lb-text .ln.v .a span:not(.vn) { flex-basis: 100%; }
  #viewLibrary .lb-text .ln .sep { display: none; }
  #viewLibrary .lb-bar { gap: 5px; }
}
