/* Prodigy Brains — reader pop-up for books, syllabus and sample papers (js/resources.js).
   Used on the homepage and books.html, which have different stylesheets, so the values are written out here.
   Flat: ink border, no shadow, no gradient. */
.reader { width: min(1120px, calc(100% - 24px)); height: min(920px, calc(100% - 24px)); max-width: none; max-height: none; padding: 0; border: 2px solid #1B1A2E; border-radius: 16px; background: #FFFFFF; color: #1B1A2E; overflow: hidden; }
.reader[open] { display: flex; flex-direction: column; }
.reader::backdrop { background: rgba(27, 26, 46, 0.8); }
.reader__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 8px 8px 16px; background: #FFF8E1; border-bottom: 2px solid #1B1A2E; }
.reader__title { flex: 1 1 200px; margin: 0; font-size: 18px; font-weight: 800; line-height: 1.3; color: #1B1A2E; }
.reader__title:focus { outline: none; }
.reader__pick { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.reader__pick select { min-height: 40px; padding: 0 8px; border: 2px solid #1B1A2E; border-radius: 8px; background: #FFFFFF; color: #1B1A2E; font: inherit; font-weight: 700; }
.reader__new { font-size: 14px; font-weight: 700; color: #1B1A2E; text-decoration: underline; text-decoration-color: #F0A020; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.reader__close { display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 2px solid #1B1A2E; border-radius: 8px; background: #FFFFFF; color: #1B1A2E; cursor: pointer; }
.reader__close:hover { background: #FFC933; }
.reader__close svg { width: 24px; height: 24px; }
.reader :focus-visible { outline: 3px solid #1B1A2E; outline-offset: 2px; }
.reader__frame { position: relative; flex: 1; min-height: 0; background: #F4F1E8; }
.reader__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.reader__loading, .reader__empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; font-size: 18px; color: #4A4860; }
.reader__empty { background: #FFFFFF; font-weight: 700; color: #1B1A2E; }
.reader__empty[hidden], .reader__frame iframe[hidden], .reader__pick[hidden], .reader__new[hidden] { display: none; }
@media (max-width: 599px) {
  .reader { width: 100%; height: 100%; border-radius: 0; border-width: 0; }
  .reader__bar { position: relative; padding: 12px 16px; }
  .reader__title { flex-basis: 100%; order: -1; padding-right: 56px; }
  .reader__close { position: absolute; right: 8px; top: 8px; }
}
.reader .reader__title:focus-visible { outline: none; }

/* ---------- Book-opening animation (js/resources.js): cover swings open in 3D, then the reader appears ---------- */
.book-open { position: fixed; inset: 0; z-index: 2000; perspective: 2000px; overflow: hidden; background-color: rgba(27, 26, 46, 0.8); }
.book-open__book { position: absolute; transform-style: preserve-3d; will-change: transform, opacity; }
.book-open__pages, .book-open__leaf, .book-open__cover { position: absolute; inset: 0; }
/* the block of pages: cream paper with a few page edges showing on the right and bottom */
.book-open__pages { background: #FFFDF6; border: 1px solid #D9D2BF; border-radius: 4px 10px 10px 4px; }
.book-open__pages i { position: absolute; left: 12%; right: 10%; height: 2px; border-radius: 2px; background: #E9E2CF; }
.book-open__pages i:nth-child(1) { top: 18%; right: 34%; height: 6px; background: #D9D2BF; }
.book-open__pages i:nth-child(2) { top: 32%; }
.book-open__pages i:nth-child(3) { top: 40%; }
.book-open__pages i:nth-child(4) { top: 48%; right: 22%; }
.book-open__pages i:nth-child(5) { top: 56%; right: 40%; }
.book-open__pages::after { content: ""; position: absolute; top: 3px; bottom: -5px; right: -5px; left: 6px; z-index: -1; border-radius: 4px 10px 10px 4px; background: #F1EBDA; border: 1px solid #D9D2BF; }
.book-open__leaf { transform-origin: left center; background: #FFFDF6; border: 1px solid #D9D2BF; border-radius: 4px 10px 10px 4px; backface-visibility: visible; }
.book-open__cover { transform-origin: left center; transform-style: preserve-3d; }
.book-open__front, .book-open__back { position: absolute; inset: 0; border-radius: 4px 10px 10px 4px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.book-open__front { background: #FFFFFF; border: 2px solid #1B1A2E; border-left-width: 10px; }
.book-open__front img { display: block; width: 100%; height: 100%; object-fit: contain; }
.book-open__back { transform: rotateY(180deg); background: #FFF8E1; border: 2px solid #1B1A2E; border-right-width: 10px; border-radius: 10px 4px 4px 10px; }
.book-open__label { position: absolute; left: 12px; top: 12px; padding: 4px 12px; border-radius: 999px; background: #FFC933; border: 2px solid #1B1A2E; color: #1B1A2E; font-size: 14px; font-weight: 800; line-height: 1.4; }
.book-open__label[hidden] { display: none; }
.reader[open] { animation: reader-in 0.34s ease-out both; }
@keyframes reader-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reader[open] { animation: none; } }
