/* Boekviewer — Major Milestones huisstijl */
:root {
  --dark-olive: #3D4A1A;
  --lime: #BFCF3A;
  --mid-olive: #5A6B2A;
  --light-olive: #7A8C3A;
  --lime-light: #D4E05A;
  --cream: #F5F3E8;
  --dark-bg: #2A3312;
  --bar-h: 58px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  background: var(--dark-bg);
  color: #fff;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { color: inherit; }

/* ── Bovenbalk ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--bar-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
  background: rgba(42,51,18,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(191,207,58,.18); z-index: 50;
}
.back { color: rgba(255,255,255,.7); text-decoration: none; font-size: .85rem; white-space: nowrap; }
.back:hover { color: var(--lime); }
.title { flex: 1; min-width: 0; text-align: center; }
.title strong { display: block; font-size: .95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title span { display: block; font-size: .72rem; color: rgba(255,255,255,.5); letter-spacing: .04em; }
.actions { display: flex; gap: .5rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: 6px; border: 0;
  font-size: .85rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .2s, transform .2s, box-shadow .2s, color .2s, border-color .2s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--lime); color: var(--dark-olive); }
.btn-primary:hover { background: var(--lime-light); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(191,207,58,.3); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25); }
.btn-ghost:hover { border-color: var(--lime); color: var(--lime); }

/* ── Podium ── */
.stage {
  position: fixed; top: var(--bar-h); bottom: var(--bar-h); left: 0; right: 0;
  overflow: hidden; outline: none;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(122,140,58,.30) 0%, rgba(42,51,18,0) 62%),
    radial-gradient(ellipse at 50% 120%, rgba(0,0,0,.5) 0%, rgba(0,0,0,0) 60%),
    var(--dark-bg);
}
.stage.zoomed { overflow: auto; cursor: grab; }
.stage.zoomed.panning { cursor: grabbing; }
.stage-inner {
  min-width: 100%; min-height: 100%; width: max-content;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 75px;
}
.stage.zoomed .stage-inner { padding: 32px; }
#book-wrap { position: relative; flex: none; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
#book-wrap.closed-front { transform: translateX(-25%); }
#book-wrap.closed-back  { transform: translateX(25%); }
body.portrait #book-wrap.closed-front,
body.portrait #book-wrap.closed-back { transform: none; }
#book { filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)) drop-shadow(0 4px 8px rgba(0,0,0,.35)); }

.page { background: #fff; overflow: hidden; }
.page-inner { position: absolute; inset: 0; background: #fdfdfb; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #c9c9bd; font-size: .8rem; letter-spacing: .1em;
}
.ph::before {
  content: ""; width: 22px; height: 22px; margin-right: .6rem;
  border: 2px solid #e2e2d6; border-top-color: var(--light-olive); border-radius: 50%;
  animation: spin 1s linear infinite;
}
.page.ready .ph { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* boekvouw / rugschaduw */
.gutter { position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; z-index: 2; }
.page.left  .gutter { right: 0; background: linear-gradient(to left,  rgba(0,0,0,.22), rgba(0,0,0,.07) 30%, rgba(0,0,0,0)); }
.page.right .gutter { left: 0;  background: linear-gradient(to right, rgba(0,0,0,.22), rgba(0,0,0,.07) 30%, rgba(0,0,0,0)); }
.page.cover .gutter { width: 4%; opacity: .6; }
body.portrait .gutter { display: none; }

/* linklaag (PDF-hyperlinks) */
.links { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.links a {
  position: absolute; display: block; pointer-events: auto; cursor: pointer;
  border-radius: 2px; transition: background .15s, box-shadow .15s;
}
.links a:hover { background: rgba(191,207,58,.22); box-shadow: 0 0 0 1px rgba(122,140,58,.45); }
.links a:focus-visible { outline: 2px solid var(--light-olive); outline-offset: 1px; }

/* pijlen naast het boek */
.nav-arrow {
  position: fixed; top: calc(50%); transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.08); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, opacity .2s; z-index: 20;
}
.nav-arrow:hover { background: var(--lime); color: var(--dark-olive); }
.nav-arrow:disabled { opacity: .2; pointer-events: none; }
.nav-arrow svg { width: 22px; height: 22px; }
#prev { left: 16px; } #next { right: 16px; }

/* ── Onderbalk ── */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--bar-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: rgba(42,51,18,.94); backdrop-filter: blur(8px);
  border-top: 1px solid rgba(191,207,58,.18); z-index: 50;
}
.grp { display: flex; align-items: center; gap: .15rem; flex: none; }
.sep { width: 1px; height: 22px; background: rgba(255,255,255,.15); margin: 0 .35rem; }
.icon-btn {
  width: 36px; height: 36px; flex: none; border-radius: 6px; border: 0;
  background: transparent; color: rgba(255,255,255,.82);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--lime); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.off { color: rgba(255,255,255,.35); }
.pagefield { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: rgba(255,255,255,.7); margin: 0 .25rem; }
.pagefield input {
  width: 5.6em; height: 30px; text-align: center; border-radius: 5px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); color: #fff;
  font: inherit; font-variant-numeric: tabular-nums; font-weight: 600;
}
.pagefield input:focus { outline: none; border-color: var(--lime); }
.pagefield b { font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.scrub { flex: 1; display: flex; align-items: center; gap: .9rem; min-width: 0; }
.pageno { font-size: .76rem; color: rgba(255,255,255,.6); white-space: nowrap; font-variant-numeric: tabular-nums; }
input[type=range] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--lime) var(--p, 0%), rgba(255,255,255,.15) var(--p, 0%));
  outline: none; min-width: 60px;
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--lime); border: 3px solid var(--dark-bg); box-shadow: 0 0 0 1px var(--lime); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--lime); border: 3px solid var(--dark-bg); cursor: pointer; }
.zoom-val {
  min-width: 3.4em; height: 30px; border: 0; border-radius: 5px; background: transparent;
  color: rgba(255,255,255,.8); font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.zoom-val:hover { background: rgba(255,255,255,.08); color: var(--lime); }

/* ── Inhoudsopgave ── */
.drawer {
  position: fixed; top: var(--bar-h); bottom: var(--bar-h); left: 0; width: min(380px, 92vw);
  background: #fff; color: #333; z-index: 60;
  transform: translateX(-102%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; box-shadow: 8px 0 40px rgba(0,0,0,.35);
}
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 3px solid var(--lime); }
.drawer header h2 { font-size: 1rem; color: var(--dark-olive); }
.drawer header .icon-btn { color: #666; }
.drawer header .icon-btn:hover { background: var(--cream); color: var(--dark-olive); }
.toc { overflow-y: auto; padding: .5rem 0 1.5rem; flex: 1; }
.toc a {
  display: flex; gap: .75rem; justify-content: space-between; align-items: baseline;
  padding: .45rem 1.25rem; text-decoration: none; font-size: .84rem; line-height: 1.35; color: #333;
}
.toc a:hover { background: var(--cream); color: var(--dark-olive); }
.toc a.part { font-weight: 700; color: var(--dark-olive); margin-top: .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.toc a.sub { padding-left: 2rem; color: #555; }
.toc a.active { background: rgba(191,207,58,.22); }
.toc a .pg { color: #999; font-size: .75rem; font-variant-numeric: tabular-nums; flex: none; }
.toc .empty { padding: 1.25rem; color: #888; font-size: .85rem; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .3s; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ── Laden / fouten ── */
.loader {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; gap: 1.2rem;
  align-items: center; justify-content: center; background: var(--dark-bg); transition: opacity .5s;
  padding: 1.5rem; text-align: center;
}
.loader.hide { opacity: 0; pointer-events: none; }
.loader .mark { font-size: .75rem; letter-spacing: .25em; color: var(--lime); font-weight: 600; }
.loader h1 { font-size: 1.5rem; font-weight: 700; max-width: 30ch; line-height: 1.25; }
.loader .bar { width: 220px; height: 3px; background: rgba(255,255,255,.1); border-radius: 2px; overflow: hidden; }
.loader .bar i { display: block; height: 100%; width: 30%; background: var(--lime); animation: slide 1.2s ease-in-out infinite; }
.loader .bar i.det { animation: none; transition: width .2s; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.loader p { font-size: .82rem; color: rgba(255,255,255,.55); }
.loader .err { display: none; max-width: 42ch; line-height: 1.55; }
.loader .err p { color: rgba(255,255,255,.85); font-size: .9rem; margin-bottom: 1.2rem; }
.loader.failed .bar, .loader.failed #load-msg { display: none; }
.loader.failed .err { display: block; }
.noscript { position: fixed; inset: 0; z-index: 90; background: var(--dark-bg); display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; }
.noscript a { color: var(--lime); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 14px); transform: translate(-50%, 8px);
  background: rgba(0,0,0,.7); color: rgba(255,255,255,.92); font-size: .78rem;
  padding: .5rem .9rem; border-radius: 20px; z-index: 30; opacity: 0;
  transition: opacity .4s, transform .4s; pointer-events: none; white-space: nowrap; max-width: 92vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: none; border: 0; color: var(--lime); font-weight: 600; margin-left: .6rem; }

/* ── Mobiel ── */
@media (max-width: 760px) {
  :root { --bar-h: 52px; }
  .back .txt, .btn .txt, .title span { display: none; }
  .title strong { font-size: .8rem; }
  .topbar { padding: 0 .6rem; gap: .5rem; }
  .bottombar { padding: 0 .3rem; gap: .2rem; justify-content: space-between; }
  .btn { padding: .5rem .65rem; }
  .nav-arrow, .scrub, #sound, #fs, .sep, #zoom-val { display: none; }
  .stage-inner { padding: 12px 10px; }
  .icon-btn { width: 34px; }
  .pagefield input { width: 3.6em; }
}
