/*
 * PSH / OJS 3.5 native layout repair (reversible)
 * Scope: native OJS frontend only. No ISTP Workflow changes.
 * IMPORTANT: Only affects markup actually rendered by OJS.
 * A missing/disabled OJS sidebar cannot be recreated with CSS.
 * Append near the END of Journal Style Sheet, after the existing theme overrides.
 */

/* 1) Default OJS published-article details (abstract/references | metadata).
 * Use the native .main_entry and .entry_details, not custom Article View markup.
 */
@media screen and (min-width: 900px) {
  .pkp_structure_main .obj_article_details > .row {
    display: grid !important;
    grid-template-columns: minmax(0, 1.85fr) minmax(240px, 0.9fr) !important;
    align-items: start;
    gap: 0;
    width: auto;
    max-width: none;
    min-width: 0;
  }

  .pkp_structure_main .obj_article_details > .row::before,
  .pkp_structure_main .obj_article_details > .row::after {
    display: none !important;
    content: none !important;
  }

  .pkp_structure_main .obj_article_details > .row > .main_entry,
  .pkp_structure_main .obj_article_details > .row > .entry_details {
    float: none !important;
    clear: none !important;
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box;
  }

  .pkp_structure_main .obj_article_details > .row > .main_entry {
    margin: 0 !important;
    padding: 0 24px 0 0;
  }

  .pkp_structure_main .obj_article_details > .row > .entry_details {
    margin: 0 !important;
    padding: 0 0 0 22px;
    border-left: 1px solid #e1e7eb;
    border-top: 0 !important;
    overflow-wrap: anywhere;
  }

  /* OJS may separately render a sidebar outside the article details.
   * Give the article columns enough room if both are present.
   */
  .pkp_structure_content:has(> .pkp_structure_sidebar)
    .obj_article_details > .row {
    grid-template-columns: minmax(0, 1.5fr) minmax(210px, 0.9fr) !important;
  }
}

/* 2) Other native navigation pages. Only repair an EXISTING OJS sidebar;
 * do not create, force-show or re-enable disabled sidebar blocks.
 */
@media screen and (min-width: 1050px) {
  body:not(.pkp_page_index) .pkp_structure_content:has(> .pkp_structure_sidebar) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 27%);
    column-gap: 18px;
    align-items: start;
  }
  body:not(.pkp_page_index) .pkp_structure_content:has(> .pkp_structure_sidebar)
    > .pkp_structure_main {
    float: none !important;
    width: auto !important;
    min-width: 0;
    max-width: none !important;
    margin: 0 !important;
  }
  body:not(.pkp_page_index) .pkp_structure_content:has(> .pkp_structure_sidebar)
    > .pkp_structure_sidebar {
    float: none !important;
    width: auto !important;
    min-width: 0;
    max-width: none;
    margin: 0;
  }
}

/* 3) Smaller screens: restore single column and readable spacing. */
@media screen and (max-width: 899px) {
  .pkp_structure_main .obj_article_details > .row {
    display: block !important;
  }
  .pkp_structure_main .obj_article_details > .row > .main_entry,
  .pkp_structure_main .obj_article_details > .row > .entry_details {
    float: none !important;
    clear: both !important;
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}
