/* Open Library Publications — targeted fixes — 2026-09-08 v80
 * Baseline: openlibTheme(4).zip
 * Scope only:
 * 1) exact light/dark portal geometry parity
 * 2) dark-mode frontend text contrast
 * 3) PDF viewer loading/recovery presentation
 */

/* --------------------------------------------------------------------------
   1. PORTAL DARK/LIGHT GEOMETRY PARITY
   Final light-mode margin is 30px because journal-layout-fix-0829-v1.css is
   loaded after stable-red-layout. The old dark selector (36px) has higher
   specificity, which created the visible ~6px downward jump.
   -------------------------------------------------------------------------- */
html[data-openlib-color-mode="dark"] body.openlib-site-index .openlib_search_panel--primary,
html[data-openlib-color-mode="dark"] body.openlib-site-index:not(.openlib-search-is-fixed) .openlib_search_panel--primary {
  margin-top: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 30px !important;
  margin-left: 0 !important;
}

/* When the search bar is floating, both modes must use zero margin. */
html[data-openlib-color-mode="dark"] body.openlib-site-index.openlib-search-is-fixed .openlib_search_panel--primary {
  margin: 0 !important;
}

/* --------------------------------------------------------------------------
   2. DARK MODE READABILITY
   Do not change geometry here. Only restore readable foreground colours for
   OJS content elements that still inherit light-theme greys/blacks.
   -------------------------------------------------------------------------- */
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main > .page,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .obj_article_details,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .obj_issue_toc,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .openlib_current_issue_panel,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .openlib_additional_content_panel {
  color: #d5dbe5 !important;
}

html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main p,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .description,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .description p,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .authors,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .published,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .meta,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .abstract,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .keywords,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .value,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .openlib_journal_profile__description,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .openlib_journal_profile__description p,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_sidebar .content,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_sidebar .content p {
  color: #cbd3df !important;
}

html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main h1,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main h2,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main h3,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main h4,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .title,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main .title a {
  color: #f5f7fa !important;
}

html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main label,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main legend,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main dt,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main dd,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main small {
  color: #cbd3df !important;
}

/* Keep links visibly distinct on dark surfaces. */
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main a:not(.cmp_button):not(.obj_galley_link) {
  color: #ff8f98 !important;
}
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main a:not(.cmp_button):not(.obj_galley_link):hover,
html[data-openlib-color-mode="dark"] body.openlib-journal-page .pkp_structure_main a:not(.cmp_button):not(.obj_galley_link):focus {
  color: #ffb0b6 !important;
}

/* --------------------------------------------------------------------------
   3. PDF VIEWER: NO EMPTY WHITE CANVAS WHILE PDF.JS STARTS
   The overlay is created by pdf-viewer-recovery-0908-v2.js and removed only
   after PDF.js has actually rendered a page canvas.
   -------------------------------------------------------------------------- */
html body.pkp_page_article.pkp_op_view .galley_view {
  background: #d1d5db !important;
}

html body.pkp_page_article.pkp_op_view .galley_view iframe {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 500px !important;
  border: 0 !important;
  background: #d1d5db !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.openlib_pdf_loading {
  position: absolute;
  z-index: 8;
  inset: 48px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #d1d5db;
  color: #202938;
  text-align: center;
  transition: opacity .16s ease, visibility .16s ease;
}

.openlib_pdf_loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.openlib_pdf_loading__card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 92%;
  padding: 11px 15px;
  border-radius: 14px;
  background: #202938;
  color: #fff;
  box-shadow: 0 10px 28px rgba(17,24,39,.18);
  font-size: 12px;
  font-weight: 700;
}

.openlib_pdf_loading__spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: openlibPdfSpin .8s linear infinite;
}

.openlib_pdf_loading__fallback {
  display: none;
  margin-left: 4px;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 8px;
  color: #fff !important;
  text-decoration: none !important;
  white-space: nowrap;
}
.openlib_pdf_loading.is-slow .openlib_pdf_loading__fallback { display: inline-flex; }

@keyframes openlibPdfSpin { to { transform: rotate(360deg); } }

@media (max-width: 767px) {
  .openlib_pdf_loading__card { flex-wrap: wrap; justify-content: center; }
}
