/* DMI Maritime Research v1.6.2 — interior page integration repair.
   These rules deliberately target the OJS 3.5 native page structure rather
   than replacing search/submission/article templates or manipulating content.
   Load after the parent default theme and the DMI base theme stylesheet. */

/* 1. Reliable outer reading grid with native OJS sidebars. Prevent legacy
      PKP float/width rules from allowing the sidebar to escape the container. */
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) {
  box-sizing: border-box;
  width: 100% !important;
  max-width: 1200px !important;
  margin: 0 auto !important;
  padding: 28px 22px 60px !important;
  min-height: 0;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_content.has_sidebar:not(.dmi-fullwidth) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(235px, 270px);
  gap: 24px;
  align-items: start;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_main,
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_sidebar {
  position: relative;
  float: none !important;
  clear: none !important;
  box-sizing: border-box;
  width: auto !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_main {
  padding: 28px clamp(22px, 3vw, 36px) 36px !important;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_sidebar {
  padding: 22px 19px !important;
  overflow-wrap: anywhere;
  border-radius: 10px;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar .pkp_block {
  margin: 0 0 18px;
  padding: 0 0 16px;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar .pkp_block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar a,
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar button { overflow-wrap: anywhere; }
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar .pkp_block > h2,
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar .pkp_block > h3 {
  margin: 0 0 12px;
  font-size: 19px;
  line-height: 1.3;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar .pkp_block > p { margin: 0 0 12px; }
body.dmi-theme.dmi-header-fixed .pkp_structure_sidebar .pkp_block > p:last-child { margin-bottom: 0; }


/* 2. Native OJS breadcrumb/title stack. Reset inherited float, height and
      padding from default/third-party styles; never use negative offsets. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main > .page {
  display: flow-root;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > .cmp_breadcrumbs {
  display: block !important;
  position: static !important;
  float: none !important;
  clear: both !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 0 15px !important;
  background: transparent !important;
  box-shadow: none !important;
  line-height: 1.5;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > .cmp_breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  list-style: none;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.5;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > .cmp_breadcrumbs ol > li {
  display: inline-flex;
  align-items: center;
  float: none !important;
  clear: none !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.5;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > h1 {
  position: static !important;
  clear: none !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 0 22px !important;
  font-size: clamp(30px, 3.25vw, 43px);
  line-height: 1.16;
  letter-spacing: -.025em;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > h1 + form,
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > h1 + .cmp_form {
  margin-top: 0 !important;
}

/* 3. Search: compact title, clean query field, readable advanced filters;
      preserve OJS GET parameters, hooks, and result pagination. */
body.dmi-theme.dmi-header-fixed .page_search > .cmp_breadcrumbs { margin-bottom: 12px !important; }
body.dmi-theme.dmi-header-fixed .page_search > h1 { margin-bottom: 21px !important; }
body.dmi-theme.dmi-header-fixed .page_search form.cmp_form { margin: 0 !important; }
body.dmi-theme.dmi-header-fixed .page_search .search_input { margin: 0 0 16px !important; padding: 0 !important; }
body.dmi-theme.dmi-header-fixed .page_search .search_input .query {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  height: auto;
  padding: 11px 15px;
  border: 1px solid #b7ccd6;
  border-radius: 8px;
  background-color: #fff;
  color: var(--dmi-deep);
  font: 400 17px/1.5 var(--dmi-sans);
  box-shadow: none;
}
body.dmi-theme.dmi-header-fixed .page_search .search_input .query:focus {
  border-color: var(--dmi-blue);
  box-shadow: 0 0 0 3px rgba(20, 101, 130, .12);
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced {
  min-width: 0;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 9px clamp(15px, 2vw, 22px) 19px !important;
  border: 1px solid var(--dmi-line) !important;
  border-radius: 8px;
  background: #fcfefe;
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .date_range,
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .author {
  float: none !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 16px;
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .author { margin-bottom: 0; }
body.dmi-theme.dmi-header-fixed .page_search .search_advanced > legend {
  max-width: 100%;
  margin: 0;
  padding: 0 7px;
  font: 600 15px/1.4 var(--dmi-sans);
  color: var(--dmi-navy);
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced :is(input, select) { max-width: 100%; }
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .date_range fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 0 !important;
  margin: 0 0 13px !important;
  border: 0 !important;
  min-width: 0;
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .date_range fieldset legend {
  display: block;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 0 0 6px;
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .date_range select {
  flex: 1 1 73px;
  width: auto !important;
  max-width: 100%;
  min-width: 68px;
  min-height: 40px;
  padding: 6px 7px;
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .author .label {
  display: block;
  margin: 7px 0 5px;
  font-size: 14px;
  font-weight: 600;
}
body.dmi-theme.dmi-header-fixed .page_search .search_advanced .author input {
  min-height: 42px;
  padding: 8px 10px;
}

body.dmi-theme.dmi-header-fixed .page_search .submit { margin: 18px 0 0; }
body.dmi-theme.dmi-header-fixed .page_search .submit button { min-height: 44px; padding: 11px 20px; }
body.dmi-theme.dmi-header-fixed .page_search .search_results { margin: 27px 0 0 !important; padding-left: 0 !important; list-style: none !important; }
body.dmi-theme.dmi-header-fixed .page_search .search_results > li {
  padding: 17px 0;
  margin: 0;
  border-bottom: 1px solid var(--dmi-line);
}
body.dmi-theme.dmi-header-fixed .page_search .search_results > li:first-child { padding-top: 0; }

/* Article headings are nested in OJS's .obj_article_details, not direct
   children of .page. Apply the same compact breadcrumb-to-title rhythm. */
body.dmi-theme.dmi-header-fixed .page_article > .cmp_breadcrumbs + .obj_article_details {
  margin-top: 0 !important;
  padding-top: 0 !important;
}
body.dmi-theme.dmi-header-fixed .page_article .obj_article_details > .page_title {
  margin-top: 0 !important;
}
/* Keep long-form reading comfortable without constraining tables or issue grids. */
body.dmi-theme.dmi-header-fixed .page_about > p,
body.dmi-theme.dmi-header-fixed .page_about > .about > p { max-width: 78ch; }

/* 4. Shared inside pages. Titles and native article/issue/form controls
      remain readable with long scholarly metadata and nested content. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(.obj_article_summary, .obj_issue_summary) {
  max-width: 100%;
  overflow-wrap: anywhere;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(.cmp_form, form, fieldset, table, iframe) {
  max-width: 100%;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(img, video) { max-width: 100%; height: auto; }
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(pre, table) { overflow-x: auto; }
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(.obj_article_summary, .obj_issue_summary) .title {
  overflow-wrap: anywhere;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(input, select, textarea) {
  box-sizing: border-box;
}

/* 5. Mobile and tablet. Sidebar moves underneath the reading content;
      no overlap, invisible columns, or clipped filters at narrow widths. */
@media (max-width: 991px) {
  body.dmi-theme.dmi-header-fixed .pkp_structure_content.has_sidebar:not(.dmi-fullwidth) {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_main,
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_sidebar {
    flex: none !important;
    width: 100% !important;
  }
  body.dmi-theme.dmi-header-fixed .page_search .date_range,
  body.dmi-theme.dmi-header-fixed .page_search .author {
    float: none !important;
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}
@media (max-width: 640px) {
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) {
    padding: 18px 13px 42px !important;
  }
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_main {
    padding: 23px 18px 29px !important;
  }
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_sidebar {
    padding: 19px 18px !important;
  }
  body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > .cmp_breadcrumbs { margin-bottom: 11px !important; }
  body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > h1 {
    font-size: clamp(28px, 7.5vw, 36px);
    margin-bottom: 18px !important;
  }
  body.dmi-theme.dmi-header-fixed .page_search .search_advanced {
    padding: 10px 13px 15px !important;
  }
  body.dmi-theme.dmi-header-fixed .page_search .search_input .query { font-size: 16px; }
}
@media (max-width: 350px) {
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) { padding-left: 9px !important; padding-right: 9px !important; }
  body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_main { padding-left: 13px !important; padding-right: 13px !important; }
  body.dmi-theme.dmi-header-fixed .page_search .date_range :is(select, input) { max-width: 100%; }
}


/* 6. Remove unintended vertical frame lines on interior pages.
      Keep the main content card and sidebar borders, but ensure the outer
      layout wrapper itself does not draw side rails or pseudo-element lines. */
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) {
  border: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth)::before,
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth)::after,
body.dmi-theme.dmi-header-fixed .pkp_structure_page::before,
body.dmi-theme.dmi-header-fixed .pkp_structure_page::after,
body.dmi-theme.dmi-header-fixed .pkp_structure_content_wrapper::before,
body.dmi-theme.dmi-header-fixed .pkp_structure_content_wrapper::after {
  content: none !important;
  display: none !important;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_main,
body.dmi-theme.dmi-header-fixed .pkp_structure_content:not(.dmi-fullwidth) > .pkp_structure_sidebar {
  isolation: isolate;
}


/* ========================================================================
   v1.6.4 — BREADCRUMB / HEADING RHYTHM CORRECTION
   Root of previous miss: direct-child selectors did not cover custom pages
   with the heading nested in a plugin-generated wrapper. These rules are
   scoped to internal pages, not the editorial homepage.
   ======================================================================== */

/* Consistent compact breadcrumb layout even for plugin-generated pages. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page .cmp_breadcrumbs,
body.dmi-theme.dmi-header-fixed .pkp_structure_main > .cmp_breadcrumbs {
  position: static !important;
  display: block !important;
  float: none !important;
  clear: none !important;
  height: auto !important;
  min-height: 0 !important;
  margin-block: 0 14px !important;
  padding-block: 0 !important;
}

/* Page headings can be direct descendants OR nested inside plugin markup.
   Avoid targeting arbitrary h2/h3 elements inside article content. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page h1,
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page .page_title {
  margin-block-start: 0 !important;
  padding-block-start: 0 !important;
  min-height: 0 !important;
}

/* Neutralize padding/margin on wrappers between breadcrumbs and their h1;
   handles native static pages and the custom-page plugin's extra wrappers. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page .cmp_breadcrumbs ~ :is(div,section,header):has(h1),
body.dmi-theme.dmi-header-fixed .pkp_structure_main > .cmp_breadcrumbs ~ :is(div,section,header):has(h1) {
  margin-block-start: 0 !important;
  padding-block-start: 0 !important;
  min-height: 0 !important;
}
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(.page_header,.page_heading,.page_title_wrapper,.page_content_header):has(h1),
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page :is(.page_header,.page_heading,.page_title_wrapper,.page_content_header):has(.page_title) {
  margin-block-start: 0 !important;
  padding-block-start: 0 !important;
  min-height: 0 !important;
}


/* Nested custom-page wrappers can add padding at a second level. Reset only
   ancestors that actually contain the page's first heading. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page .cmp_breadcrumbs ~ :is(div,section,header):has(h1) :is(div,section,header):has(h1) {
  margin-block-start: 0 !important;
  padding-block-start: 0 !important;
  min-height: 0 !important;
}

/* First-title guard for custom content. Keep all remaining article sections
   and OJS forms in their normal flow. */
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > :is(h1,.page_title),
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > :is(div,section,header):has(> h1) > h1,
body.dmi-theme.dmi-header-fixed .pkp_structure_main .page .cmp_breadcrumbs ~ :is(h1,.page_title) {
  margin-block: 0 18px !important;
  line-height: 1.18;
}
@media(max-width:640px) {
  body.dmi-theme.dmi-header-fixed .pkp_structure_main .page .cmp_breadcrumbs,
  body.dmi-theme.dmi-header-fixed .pkp_structure_main > .cmp_breadcrumbs {
    margin-block-end: 11px !important;
  }
  body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > :is(h1,.page_title),
  body.dmi-theme.dmi-header-fixed .pkp_structure_main .page > :is(div,section,header):has(> h1) > h1 {
    margin-block-end: 16px !important;
  }
}
