/* =====================================================================
 *  Dhamma PDF Reader — gold/maroon theme to match the site.
 * ===================================================================== */
.dpr {
  --dpr-maroon: var(--maroon, #6e1f15);
  --dpr-gold: var(--emerald, #c8932a);
  --dpr-gold-d: #8a4e12;
  --dpr-cream: var(--surface-2, #f7f1e2);
  --dpr-ink: var(--ink, #2a2018);
  --dpr-line: rgba(110, 31, 21, .16);
  display: flex;
  flex-direction: column;
  width: 100%;
  height: clamp(520px, 78vh, 920px);
  margin: 1.25rem 0;
  border: 1px solid var(--dpr-line);
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(200, 147, 42, .10), transparent 60%),
    #efe7d4;
  box-shadow: 0 18px 50px -24px rgba(60, 24, 8, .5), 0 2px 0 rgba(255, 255, 255, .5) inset;
  font-family: var(--sans, "Inter Tight", system-ui, sans-serif);
  position: relative;
  outline: none;
}
.dpr * { box-sizing: border-box; }

/* toolbar */
.dpr-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .7rem;
  background: linear-gradient(180deg, #7d2418, var(--dpr-maroon));
  color: #ffe9c8;
  border-bottom: 1px solid rgba(0, 0, 0, .25);
  flex-wrap: wrap;
  box-shadow: 0 2px 10px -4px rgba(0, 0, 0, .5);
  z-index: 3;
}
.dpr-title {
  font-family: var(--serif, "Fraunces", Georgia, serif);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: .2px;
  color: #ffe9b0;
  margin-right: auto;
  padding-left: .25rem;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dpr-page-ctrl, .dpr-zoom-ctrl, .dpr-actions {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: rgba(0, 0, 0, .18);
  border: 1px solid rgba(255, 220, 150, .22);
  border-radius: 999px;
  padding: .2rem .3rem;
}
.dpr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #ffe6ad;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease, color .15s ease;
}
.dpr-btn:hover { background: rgba(255, 220, 150, .2); color: #fff4d6; }
.dpr-btn:active { transform: scale(.92); }
.dpr-btn:focus-visible { outline: 2px solid #ffd372; outline-offset: 1px; }
.dpr-page-input {
  width: 42px;
  text-align: center;
  font: 600 .9rem/1 var(--sans, system-ui, sans-serif);
  color: #3a1109;
  background: #ffe9b8;
  border: 1px solid rgba(255, 220, 150, .5);
  border-radius: 8px;
  padding: .28rem .2rem;
}
.dpr-page-input:focus { outline: 2px solid #ffd372; }
.dpr-page-total { font-size: .85rem; color: #ffdd99; padding: 0 .35rem 0 .1rem; opacity: .9; }
.dpr-zoom-label {
  min-width: 52px;
  border: 0;
  background: transparent;
  color: #ffe6ad;
  font: 600 .85rem/1 var(--sans, system-ui, sans-serif);
  cursor: pointer;
  padding: .3rem .2rem;
  border-radius: 8px;
}
.dpr-zoom-label:hover { background: rgba(255, 220, 150, .2); }

/* scroll stage */
.dpr-scroll {
  flex: 1;
  overflow: auto;
  overflow-x: auto;
  scroll-behavior: smooth;
  background:
    repeating-linear-gradient(45deg, rgba(110, 31, 21, .015) 0 12px, transparent 12px 24px),
    #e6dcc6;
  padding: 18px 0 28px;
  -webkit-overflow-scrolling: touch;
}
.dpr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-width: min-content;
  padding: 0 18px;
}
.dpr-page {
  position: relative;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 30px -14px rgba(40, 16, 6, .55), 0 0 0 1px rgba(110, 31, 21, .08);
  overflow: hidden;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dpr-canvas { display: block; }
.dpr-page-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9a472;
  font: 500 .9rem/1 var(--sans, system-ui, sans-serif);
  letter-spacing: .5px;
  background:
    linear-gradient(180deg, #fff, #faf5e9);
}
.dpr-page-num::before {
  content: "";
  width: 22px; height: 22px;
  margin-right: 10px;
  border: 2px solid #e3d4a8;
  border-top-color: var(--dpr-gold);
  border-radius: 50%;
  animation: dpr-spin .8s linear infinite;
}

/* status / error overlay */
.dpr-status {
  position: absolute;
  left: 50%; top: 58%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: .6rem;
  background: rgba(255, 252, 244, .96);
  border: 1px solid var(--dpr-line);
  color: var(--dpr-ink);
  padding: .7rem 1.1rem;
  border-radius: 12px;
  box-shadow: 0 16px 40px -18px rgba(40, 16, 6, .5);
  font-size: .95rem;
  max-width: 80%;
  text-align: center;
  z-index: 4;
}
.dpr-status a { color: var(--dpr-gold-d); font-weight: 600; }
.dpr-status.dpr-error { border-color: #c98; }
.dpr-spin {
  width: 18px; height: 18px;
  border: 2px solid #e3d4a8;
  border-top-color: var(--dpr-gold);
  border-radius: 50%;
  animation: dpr-spin .8s linear infinite;
}
@keyframes dpr-spin { to { transform: rotate(360deg); } }

/* fullscreen */
.dpr.dpr-isfull { height: 100vh; margin: 0; border-radius: 0; }
.dpr:fullscreen { background: #e6dcc6; }

@media (max-width: 640px) {
  .dpr { height: 72vh; border-radius: 12px; }
  .dpr-title { max-width: 100%; margin-bottom: .3rem; order: -1; flex-basis: 100%; }
  .dpr-bar { gap: .4rem; }
  .dpr-actions .dpr-btn:nth-child(2) { display: none; } /* hide open-in-tab on phones; download remains */
}
@media (prefers-reduced-motion: reduce) {
  .dpr-scroll { scroll-behavior: auto; }
  .dpr-page-num::before, .dpr-spin { animation: none; }
}

/* ===== modal overlay reader (Books page) ===== */
.dpr-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(28, 10, 4, .78);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(8px, 2.5vw, 28px);
  animation: dpr-fade .2s ease;
}
@keyframes dpr-fade { from { opacity: 0 } to { opacity: 1 } }
.dpr-overlay-host { width: min(1100px, 100%); height: 100%; display: flex; }
.dpr-overlay-host .dpr { height: 100%; margin: 0; width: 100%; }
.dpr-overlay-close {
  position: absolute; top: 14px; right: 18px; z-index: 2;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 220, 150, .4);
  background: rgba(94, 24, 16, .9); color: #ffe6ad;
  font-size: 20px; cursor: pointer; line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
  transition: transform .12s, background .15s;
}
.dpr-overlay-close:hover { background: #7d2418; transform: scale(1.06); }

/* ===== Books library grid ===== */
#dhamma-books-app { --bk-maroon: var(--maroon, #6e1f15); --bk-gold: var(--emerald, #c8932a); --bk-gold-d: #8a4e12;
  max-width: 1040px; margin: 0 auto; font-family: var(--sans, "Inter Tight", system-ui, sans-serif); }
.bk-tools { display: flex; gap: .7rem; align-items: center; margin: 0 0 1.2rem; flex-wrap: wrap; }
.bk-search { position: relative; flex: 1 1 280px; }
.bk-search input { width: 100%; padding: .7rem .9rem .7rem 1rem; border: 1px solid rgba(110,31,21,.14); border-radius: 999px; background: #fff; font-size: 1rem; }
.bk-search input:focus { outline: 2px solid var(--bk-gold); }
.bk-count { font-size: .85rem; color: #7a6b58; }
.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 1.1rem; }
.bk-card { display: flex; flex-direction: column; cursor: pointer; border: 0; background: transparent; padding: 0; text-align: left; font: inherit; }
.bk-cover {
  position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden;
  background: linear-gradient(150deg, #7d2418, #5e1810 60%, #46110b);
  box-shadow: 0 14px 30px -16px rgba(40, 16, 6, .7), inset 0 0 0 1px rgba(255, 220, 150, .12);
  display: flex; align-items: center; justify-content: center; padding: 14px;
  transition: transform .16s ease, box-shadow .16s ease;
}
.bk-card:hover .bk-cover { transform: translateY(-4px); box-shadow: 0 22px 44px -18px rgba(40, 16, 6, .8); }
.bk-cover::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, rgba(255,220,150,.5), rgba(255,220,150,.05)); }
.bk-cover span { color: #ffe6ad; font-family: var(--serif, "Fraunces", Georgia, serif); font-weight: 600; font-size: .98rem; line-height: 1.28; text-align: center; max-height: 100%; overflow: hidden; }
.bk-cover .bk-wheel { position: absolute; bottom: 10px; right: 12px; font-size: 18px; color: rgba(255, 220, 150, .55); }
.bk-read { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: .4rem;
  background: rgba(46, 12, 7, .55); color: #fff; font-weight: 600; opacity: 0; transition: opacity .16s; }
.bk-card:hover .bk-read { opacity: 1; }
.bk-name { margin: .55rem .15rem 0; font-size: .9rem; font-weight: 600; color: var(--ink, #2a2018); line-height: 1.3; }
.bk-err { color: var(--bk-maroon); text-align: center; padding: 2rem; }

