/* Pojok Baca: kartu buku, rak, lencana, dan pembaca PDF. Dipakai website dan aplikasi. */
.bk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 16px; }
.bk {
  display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; position: relative;
  transition: transform .25s cubic-bezier(.2,.8,.3,1.4);
}
.bk:hover { transform: translateY(-6px) rotate(-1deg); }
.bk .cv {
  aspect-ratio: 3 / 4; border-radius: 6px 14px 14px 6px; overflow: hidden; position: relative; background: #e9f2fb;
  box-shadow: 0 12px 22px -12px rgba(13,47,95,.45), inset 6px 0 0 rgba(0,0,0,.08);
}
.bk .cv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bk .cv .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; text-align: center; font-weight: 800; color: #fff;
  background: linear-gradient(160deg, #1fb9d6, #1459b8); font-size: 14px; }
.bk .cv::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: linear-gradient(90deg, rgba(0,0,0,.18), transparent); }
.bk b { font-size: 14.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk small { color: #7b8799; font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk .lv { position: absolute; left: 8px; top: 8px; z-index: 2; }
.bk .done-mark { position: absolute; right: 8px; top: 8px; z-index: 2; width: 28px; height: 28px; border-radius: 50%; background: #1fa760; color: #fff;
  display: grid; place-items: center; box-shadow: 0 4px 10px rgba(0,0,0,.2); }
.bk .prog { height: 5px; border-radius: 5px; background: #e3e9f1; overflow: hidden; }
.bk .prog span { display: block; height: 100%; background: #ffc629; border-radius: 5px; }

.lv-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; color: #fff; letter-spacing: .02em; }
.lv-A { background: #ff6b35; }
.lv-B1 { background: #1fa760; }
.lv-B2 { background: #1fb9d6; }
.lv-B3 { background: #1459b8; }
.lv-C { background: #7a4cc4; }

/* Rak geser horizontal */
.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 160px); gap: 16px; overflow-x: auto; padding: 6px 4px 18px; scroll-snap-type: x mandatory; }
.shelf > * { scroll-snap-align: start; }
.shelf::-webkit-scrollbar { height: 8px; }
.shelf::-webkit-scrollbar-thumb { background: #cfdbea; border-radius: 8px; }

/* Pilihan jenjang */
.lv-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.lv-pick button, .lv-pick a {
  border: 2px solid #e3e9f1; background: #fff; border-radius: 18px; padding: 14px; text-align: left; cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 2px; transition: transform .2s, border-color .2s, box-shadow .2s; text-decoration: none;
}
.lv-pick button:hover, .lv-pick a:hover { transform: translateY(-3px); box-shadow: 0 10px 20px -12px rgba(13,47,95,.35); }
.lv-pick .on { border-color: #1459b8; box-shadow: 0 0 0 3px rgba(20,89,184,.15); }
.lv-pick b { font-size: 16px; }
.lv-pick small { color: #7b8799; font-size: 13px; }
.lv-pick .n { font-size: 12.5px; font-weight: 800; color: #1459b8; }

/* Lencana */
.badges-wrap { container-type: inline-size; }
.badges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@container (min-width: 720px) { .badges { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@container (max-width: 330px) { .badges { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.badge-it { text-align: center; padding: 16px 10px 14px; border-radius: 18px; background: #f6fafd; border: 1px dashed #cfdbea; color: #7b8799; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.badge-it .md { width: 58px; height: 58px; margin: 0 0 10px; border-radius: 50%; display: grid; place-items: center; background: #e3e9f1; color: #9aa6b6; flex: none; }
.badge-it b { display: block; font-size: 13.5px; line-height: 1.3; color: inherit; }
.badge-it small { font-size: 12px; margin-top: 2px; }
.badge-it.next { background: #fff; border: 1px solid #bcd3f0; color: #16263d; }
.badge-it.next .md { background: #e6f0fc; color: #1459b8; }
.badge-it.next small { color: #1459b8; font-weight: 700; }
.bd-track { width: 80%; height: 6px; margin-top: 8px; border-radius: 99px; background: #e3e9f1; overflow: hidden; }
.bd-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffc629, #ff9f1a); }
.badge-it.got { background: #fff8e0; border: 1px solid #ffe28a; color: #16263d; }
.badge-it.got .md { background: radial-gradient(circle at 35% 30%, #ffe27a, #ffb800); color: #7a4a00; box-shadow: 0 6px 16px -6px rgba(255,160,0,.8); animation: medalPop .7s cubic-bezier(.2,.8,.3,1.5); }
@keyframes medalPop { from { transform: scale(.4) rotate(-30deg); } to { transform: none; } }
@keyframes medalIn { from { transform: scale(.2) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Batang yang tumbuh saat terlihat */
[data-w] { transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
[data-h] { transition: height 1s cubic-bezier(.2,.8,.2,1); }

/* ---------- Pembaca PDF ---------- */
body.reader-open { overflow: hidden; }
.reader { position: fixed; inset: 0; z-index: 1000; background: #0f1d33; color: #fff; display: flex; flex-direction: column; animation: rdIn .25s ease; }
@keyframes rdIn { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.rd-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #0d2f5f; }
.rd-title { flex: 1; min-width: 0; }
.rd-title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.rd-brand { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #ffc629; }
.rd-logo { width: 40px; height: 40px; border-radius: 12px; background: #fff; padding: 3px; object-fit: contain; flex: none; }
.rd-license { display: flex; gap: 6px; align-items: flex-start; justify-content: center; padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); background: #0a2549; color: #9fc4ef; font-size: 12px; line-height: 1.45; text-align: center; }
.rd-license .ic { flex: none; margin-top: 2px; color: #ffc629; }
.rd-license a { color: #fff; font-weight: 700; }
.rd-title small { color: #9fc4ef; font-size: 13px; }
.rd-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.rd-btn:hover { background: rgba(255,255,255,.2); }
.rd-progress { height: 5px; background: rgba(255,255,255,.12); }
.rd-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffc629, #ff6b35); transition: width .4s ease; }
.rd-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; position: relative; padding: 8px; }
.rd-stage.zoomed { overflow: auto; place-items: start center; }
.rd-holder { display: grid; place-items: center; width: 100%; height: 100%; }
.rd-stage.zoomed .rd-holder { height: auto; }
.rd-sheet { background: #fff; border-radius: 4px; box-shadow: 0 20px 50px rgba(0,0,0,.45); cursor: pointer; max-width: none; }
.rd-stage.zoomed .rd-sheet { cursor: default; }
/* Halaman cerita StoryWeaver */
.rd-story { color: #16263d; border-radius: 14px; overflow: hidden; width: min(100%, calc(900px * var(--z, 1))); max-height: 100%; display: flex; flex-direction: column; font-size: calc(clamp(17px, 2.2vw, 22px) * var(--z, 1)); }
.rd-stage.zoomed .rd-story { max-height: none; }
.rd-story .rd-pic { flex: 1 1 auto; min-height: 0; background: #f3f6fa; display: grid; place-items: center; }
.rd-story .rd-pic img { width: 100%; height: 100%; max-height: 62vh; object-fit: contain; display: block; }
.rd-story .rd-text { padding: 18px 24px 22px; line-height: 1.6; font-weight: 600; overflow: auto; flex: none; max-height: 40vh; }
.rd-stage.zoomed .rd-story .rd-text { max-height: none; }
.rd-story .rd-text p { margin: 0 0 8px; }
.rd-story.cover { position: relative; }
.rd-story.cover img { width: 100%; max-height: 70vh; object-fit: cover; display: block; }
.rd-cover-t { padding: 16px 22px 20px; background: linear-gradient(135deg, #1fb9d6, #1459b8); color: #fff; }
.rd-cover-t h2 { color: #fff; margin: 0; font-size: 1.3em; }
.rd-cover-t p { margin: 4px 0 0; color: #e2f4ff; font-size: .8em; }
.rd-story.credits { padding: 22px 24px; font-size: 14.5px; line-height: 1.6; overflow: auto; }
.rd-credits h3 { display: flex; gap: 8px; align-items: center; color: #0d2f5f; margin: 0 0 10px; }
.rd-credits a { color: #1459b8; font-weight: 700; }
@media (min-width: 900px) {
  .rd-story.story.landscape { flex-direction: row; width: min(100%, calc(1150px * var(--z, 1))); height: min(100%, calc(620px * var(--z, 1))); }
  .rd-story.story.landscape .rd-pic { flex: 1.35; }
  .rd-story.story.landscape .rd-pic img { max-height: none; }
  .rd-story.story.landscape .rd-text { flex: 1; max-height: none; align-self: stretch; display: flex; flex-direction: column; justify-content: safe center; padding: 28px; }
}
.flip-next { animation: flipNext .35s ease; }
.flip-prev { animation: flipPrev .35s ease; }
@keyframes flipNext { from { opacity: .3; transform: translateX(40px) rotateY(-12deg); } to { opacity: 1; transform: none; } }
@keyframes flipPrev { from { opacity: .3; transform: translateX(-40px) rotateY(12deg); } to { opacity: 1; transform: none; } }
.rd-nav { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #0d2f5f; }
.rd-arrow { width: 56px; height: 48px; border-radius: 16px; border: 0; background: #ffc629; color: #0d2f5f; display: grid; place-items: center; cursor: pointer; }
.rd-arrow:disabled { opacity: .35; cursor: default; }
.rd-arrow:not(:disabled):active { transform: scale(.94); }
.rd-page { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.rd-page input { width: 64px; height: 40px; border-radius: 10px; border: 0; text-align: center; font: inherit; font-weight: 800; color: #0d2f5f; padding: 0 4px; }
.rd-loading { text-align: center; color: #cfe2f8; display: grid; justify-items: center; gap: 10px; max-width: 320px; }
.rd-book { width: 96px; height: 96px; border-radius: 28px; background: rgba(255,255,255,.08); display: grid; place-items: center; color: #ffc629; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.rd-load-track { width: 220px; height: 8px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; }
.rd-load-track span { display: block; height: 100%; width: 6%; background: #ffc629; transition: width .3s; }
.rd-pill { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 999px; border: 0; background: rgba(255,255,255,.14); color: #fff; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none; }
.rd-pill.sun { background: #ffc629; color: #0d2f5f; }
.rd-done { text-align: center; max-width: 440px; position: relative; padding: 20px; animation: rdIn .4s ease; }
.rd-done h2 { color: #fff; font-size: 28px; margin: 10px 0 4px; }
.rd-done p { color: #cfe2f8; margin: 6px 0; }
.rd-medal { width: 110px; height: 110px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; color: #7a4a00;
  background: radial-gradient(circle at 35% 30%, #ffe27a, #ffb800); box-shadow: 0 0 0 10px rgba(255,198,41,.18); animation: medalIn .8s cubic-bezier(.2,.8,.3,1.5) both; }
.rd-ask { margin-top: 16px !important; font-weight: 700; }
.rd-rate { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0 18px; }
.rd-rate button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 16px; border: 2px solid rgba(255,255,255,.2);
  background: transparent; color: #fff; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; min-width: 92px; }
.rd-rate button.on { background: #ffc629; color: #0d2f5f; border-color: #ffc629; transform: scale(1.06); }
.rd-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.rd-confetti { position: absolute; inset: -40px 0 auto; height: 0; pointer-events: none; }
.rd-confetti i { position: absolute; left: calc(var(--i) * 5.5%); top: 0; width: 9px; height: 14px; border-radius: 2px;
  background: hsl(calc(var(--i) * 47), 90%, 60%); animation: fall 1.8s ease-in calc(var(--i) * .06s) both; }
@keyframes fall { from { transform: translateY(-20px) rotate(0); opacity: 1; } to { transform: translateY(420px) rotate(540deg); opacity: 0; } }
@media (max-width: 899px) {
  .rd-story { overflow-y: auto; }
  .rd-story .rd-pic { flex: none; }
  .rd-story .rd-pic img { max-height: 46vh; }
  .rd-story .rd-text { max-height: none; overflow: visible; }
}
@media (max-width: 520px) {
  .rd-logo { width: 34px; height: 34px; }
  .hide-xs { display: none !important; }
  .rd-arrow { width: 52px; }
  .bk-grid { grid-template-columns: repeat(2, 1fr); gap: 18px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .bk, .reader, .flip-next, .flip-prev, .rd-book, .rd-medal, .badge-it.got .md, .rd-confetti i { animation: none !important; transition: none !important; }
  [data-w], [data-h] { transition: none; }
}

/* Tombol panah rak buku */
.shelf-wrap { position: relative; }
.shelf-arrow {
  position: absolute; top: 34%; transform: translateY(-50%); z-index: 5; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; color: #0d2f5f; display: grid; place-items: center; box-shadow: 0 8px 22px -6px rgba(13,47,95,.45);
  transition: transform .2s, background .2s, color .2s, opacity .2s;
}
.shelf-arrow:hover { background: #ffc629; transform: translateY(-50%) scale(1.1); }
.shelf-arrow.prev { left: -14px; }
.shelf-arrow.next { right: -14px; }
.shelf-arrow[hidden] { display: grid; opacity: 0; pointer-events: none; }
@media (max-width: 640px) {
  .shelf-arrow { width: 38px; height: 38px; }
  .shelf-arrow.prev { left: -6px; }
  .shelf-arrow.next { right: -6px; }
}

/* ---------- Simpan bacaan & baca selanjutnya ---------- */
.rd-btn.rd-save.on { background: #ffc629; color: #0d2f5f; }
.rd-btn.rd-save.on .ic { animation: savePop .35s cubic-bezier(.2,.9,.3,1.5); }
@keyframes savePop { from { transform: scale(.5); } }
.rd-stage .rd-done { max-height: 100%; overflow-y: auto; width: min(100%, 760px); max-width: none; scrollbar-width: thin; }
.rd-next { margin-top: 26px; text-align: left; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; }
.rd-next h3 { color: #fff; display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 18px; }
.rd-next h3 .ic { color: #ffc629; }
.rd-upnext { display: flex; gap: 16px; align-items: center; background: rgba(255,255,255,.07); border-radius: 18px; padding: 12px; animation: rdIn .4s ease; }
.rd-up-cover { position: relative; width: 120px; aspect-ratio: 3 / 4; border-radius: 6px 12px 12px 6px; overflow: hidden; border: 0; padding: 0; cursor: pointer; flex: none; background: #1d3a66; }
.rd-up-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.rd-up-cover:hover img { transform: scale(1.06); }
.rd-up-cover .ph, .rd-next-cv .ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; font-size: 12px; font-weight: 800; color: #fff; text-align: center; }
.rd-ring { position: absolute; inset: 50% auto auto 50%; width: 58px; height: 58px; transform: translate(-50%, -50%) rotate(-90deg); }
.rd-ring circle { fill: rgba(13,47,95,.55); stroke: rgba(255,255,255,.25); stroke-width: 3; }
.rd-ring circle.p { fill: none; stroke: #ffc629; stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; animation: ringFill linear forwards; }
@keyframes ringFill { to { stroke-dashoffset: 0; } }
.rd-play { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); color: #fff; }
.rd-upnext.stopped .rd-ring circle.p { animation-play-state: paused; opacity: 0; }
.rd-upnext.stopped [data-secs] { display: none; }
.rd-up-info { min-width: 0; display: grid; gap: 3px; }
.rd-up-info small { color: #ffc629; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: 12px; }
.rd-up-info b { color: #fff; font-size: 18px; line-height: 1.3; }
.rd-up-info .muted { color: #9fc4ef; font-size: 13.5px; }
.rd-up-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.rd-up-btns .rd-pill { padding: 10px 16px; }
.rd-next-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; margin-top: 14px; }
.rd-next-it { position: relative; display: grid; gap: 6px; animation: rdIn .4s ease both; }
.rd-next-it:nth-child(2) { animation-delay: .06s; } .rd-next-it:nth-child(3) { animation-delay: .12s; }
.rd-next-it:nth-child(4) { animation-delay: .18s; } .rd-next-it:nth-child(5) { animation-delay: .24s; }
.rd-next-it b { color: #e2eefc; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rd-next-cv { position: relative; aspect-ratio: 3 / 4; border-radius: 5px 10px 10px 5px; overflow: hidden; border: 0; padding: 0; cursor: pointer; background: #1d3a66; transition: transform .25s; }
.rd-next-cv:hover { transform: translateY(-4px) rotate(-1deg); }
.rd-next-cv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rd-next-sk { aspect-ratio: 3 / 4; border-radius: 10px; background: linear-gradient(90deg, #1b355e, #25467a, #1b355e); background-size: 200% 100%; animation: skm 1.2s ease-in-out infinite; }
@keyframes skm { to { background-position: -200% 0; } }
.rd-mini-save { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: rgba(255,255,255,.14); color: #fff; transition: background .2s, transform .2s; }
.rd-mini-save:hover { transform: scale(1.1); }
.rd-mini-save.on { background: #ffc629; color: #0d2f5f; }
.rd-next-it .rd-mini-save { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; background: rgba(13,47,95,.75); }
.rd-next-it .rd-mini-save.on { background: #ffc629; }
@media (max-width: 520px) {
  .rd-upnext { flex-direction: column; text-align: center; }
  .rd-up-btns { justify-content: center; }
  .rd-next-list { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}

/* Tombol simpan di kartu/halaman buku */
.save-btn.on { background: #ffc629 !important; color: #0d2f5f !important; border-color: #ffc629 !important; }
.save-btn.on .ic { animation: savePop .35s cubic-bezier(.2,.9,.3,1.5); }

/* Elemen tersembunyi di pembaca benar-benar hilang (display dari kelas tidak boleh menimpa atribut hidden) */
.reader [hidden] { display: none !important; }
/* Tombol Selesai di halaman terakhir */
.rd-arrow.finish { width: auto; padding: 0 20px; gap: 8px; display: inline-flex; align-items: center; font: inherit; font-weight: 800; font-size: 16px; background: #1fa760; color: #fff; animation: finishPulse 1.6s ease-in-out infinite; }
@keyframes finishPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(31,167,96,.55); } 50% { box-shadow: 0 0 0 10px rgba(31,167,96,0); } }
@media (prefers-reduced-motion: reduce) { .rd-arrow.finish { animation: none; } }
