/* docs.safg.ca theme, loaded after Bootstrap 5.3.3 and Milligram.
   Brand: primary #003876 (navy), body #4f4f4f, Fustat + Lora.
   Milligram sets html { font-size: 62.5% }, so 1rem = 10px here. */

:root {
  --docs-primary: #003876;
  --docs-text: #4f4f4f;
  --docs-muted: #6c757d;
  --docs-sidebar-bg: #f8f9fa;
  --docs-header-height: 60px;
  --docs-gutter: 2rem; /* shared left edge for the logo and the contents list */
}

html {
  height: 100%;
}

body {
  color: var(--docs-text);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--docs-header-height);
  font-family: "Fustat", sans-serif;
  overflow-x: hidden;
}

a {
  color: var(--docs-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  word-break: break-all;
}

figure,
img {
  max-width: 100%;
}

img {
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

h1 {
  font-family: "Lora", serif;
}

/* Body copy at regular weight; Milligram's 300 is hard to read at this size */
article p,
article li,
.section-list p {
  font-weight: 400;
}

/* Comfortable line length for the manual's text (about 70 characters) */
article > p,
article > ul,
article > ol,
.section-list {
  max-width: 64ch;
}

/* Visible focus for keyboard users */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--docs-primary);
  outline-offset: 3px;
  border-radius: 3px;
  box-shadow: none;
}

/* Header tools: search and the link back to safg.ca */
.header-tools {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
  margin-right: 1rem;
}

.site-search {
  width: 32rem;
  margin-left: 4rem;
  --pagefind-ui-scale: 0.75;
  --pagefind-ui-primary: var(--docs-primary);
  --pagefind-ui-text: var(--docs-text);
  --pagefind-ui-border: #ced4da;
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 5px;
  --pagefind-ui-font: "Fustat", sans-serif;
  position: relative;
}

/* Results open as a panel under the search box */
.site-search .pagefind-ui__drawer {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 0;
  width: min(60rem, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 0 1.6rem 1.6rem;
}

.site-search .pagefind-ui__drawer:empty,
.site-search .pagefind-ui__drawer:not(:has(*)) {
  display: none;
}

.site-search .pagefind-ui__result-link {
  font-family: "Lora", serif;
}

/* Compact search field that fits the 60px header; Milligram's purple focus replaced with navy */
.site-search .pagefind-ui__search-input {
  height: 4rem;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 400;
}

.site-search .pagefind-ui__search-input:focus {
  border-color: var(--docs-primary);
  outline: 2px solid rgba(0, 56, 118, 0.2);
  outline-offset: 0;
}

.site-search .pagefind-ui__search-clear {
  height: 3.2rem;
  top: 0.4rem;
  right: 0.4rem;
  margin: 0;
  padding: 0 1rem;
  line-height: 3.2rem;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--docs-muted);
  background: #fff;
  border: none;
}

.site-search .pagefind-ui__form::before {
  top: 1.25rem;
}

/* Milligram gives forms a bottom margin, which would make the header taller */
.site-search form {
  margin: 0;
}

/* Milligram styles every <button> purple; this one is a plain icon */
.search-toggle,
.search-toggle:hover,
.search-toggle:focus {
  height: auto;
  margin: 0;
  border: none;
  background: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--docs-text);
  padding: 0.6rem 0.8rem;
}

/* Link back to the main site, in the header on wide screens */
.site-link {
  font-size: 1.5rem;
  color: var(--docs-muted);
  margin-right: 1rem;
}

.site-link:hover {
  color: var(--docs-primary);
}

/* Header ------------------------------------------------------------------ */

header {
  background-color: #fff;
  z-index: 1000; /* above the mobile contents panel */
  padding-left: var(--docs-gutter) !important;
  border-bottom: 1px solid #e3e6ea;
}

.logo-image {
  height: 2.5em;
  max-width: 250px;
  max-height: 80px;
}

.navbar-toggler {
  border: none;
  padding: 0.25rem 0.75rem;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(0, 0, 0, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* Contents (sidebar and mobile panel) ------------------------------------- */

/* Wide screens: 300px contents column; the text sits centred in the rest */
@media (min-width: 992px) {
  #sidebar {
    flex: 0 0 30rem;
    width: 30rem;
  }

  main {
    flex: 1 1 0;
    width: auto;
    max-width: none;
  }

  .content {
    max-width: 76ch;
    margin-inline: auto;
  }

}

#sidebar {
  background-color: var(--docs-sidebar-bg);
  padding-left: var(--docs-gutter);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

#sidebar > ul,
.offcanvas-body > ul {
  padding-left: 0;
}

.nav ul,
#sidebar ul {
  list-style-type: none;
  padding-right: 1.25em;
}

.level-1 ul {
  margin-left: 1.25em;
}

.level-1 > a {
  font-size: 1.1em;
  font-weight: 500;
  font-family: "Lora", serif;
}

.chapter-number {
  color: var(--docs-primary);
  padding-right: 0.25em;
}

.level-2 {
  display: flex;
  gap: 0.35em;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.level-2 .chapter-number {
  flex: 0 0 auto;
  min-width: 2.2em;
}

.level-1 {
  margin-bottom: 0.6rem;
}

.level-1 > a {
  display: flex;
  gap: 0.6em;
  padding-block: 0.3rem;
}

.level-1 > a .chapter-number {
  font-family: "Fustat", sans-serif;
  min-width: 1em;
  padding: 0;
}

.level-1 > ul {
  margin-top: 0.6rem;
}

/* The page you're on: a light navy tint with a thin bar on the left */
.level-2:has(> a[aria-current="page"]),
.level-1 > a[aria-current="page"] {
  background: rgba(0, 56, 118, 0.06);
  box-shadow: inset 3px 0 0 var(--docs-primary);
  border-radius: 0 4px 4px 0;
  margin-left: -1rem;
  padding: 0.5rem 1rem;
}

#sidebar a[aria-current="page"],
.offcanvas-body a[aria-current="page"] {
  font-weight: 500;
}

/* Mobile contents panel: full screen below the fixed header */
.offcanvas-top {
  height: calc(100vh - var(--docs-header-height)) !important;
  width: 100% !important;
  top: var(--docs-header-height) !important;
  z-index: 999 !important;
}

.offcanvas-backdrop {
  display: none !important;
}

.offcanvas-body .level-1 > a,
.offcanvas-body .level-2 > a {
  display: inline-block;
  padding-block: 0.8rem;
}

.offcanvas-body .level-2 {
  margin-bottom: 0;
}

/* Page content ------------------------------------------------------------ */

/* Milligram also defines .row (wider than its container); keep Bootstrap's */
.main-content > .row {
  width: auto;
  margin-inline: calc(-0.5 * var(--bs-gutter-x));
}

main {
  padding: 3.2rem 1rem 6.4rem;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.breadcrumb-trail .separator {
  margin-inline: 0.35em;
  color: var(--docs-muted);
}

/* Text rhythm (8px steps): title 20px, section headings 48px above / 12px below,
   paragraphs and lists 16px */
.breadcrumb-trail {
  margin-bottom: 2.4rem !important;
}

article h1 {
  margin-bottom: 2rem;
}

article h2,
article h3 {
  margin: 4.8rem 0 1.2rem;
}

article p,
article ul,
article ol {
  margin-bottom: 1.6rem;
}

/* Numbered and bulleted lists: markers outside the text, like the rest of the page */
article ol,
article ul {
  list-style-position: outside;
  margin-left: 0;
  padding-left: 2.25em;
}

article ol {
  list-style-type: decimal;
}

article ul {
  list-style-type: disc;
}

article li {
  margin-bottom: 0.4em;
  padding-left: 0.25em;
}

/* Sections listed on a chapter page */
.section-list {
  list-style: none;
  margin: 3.2rem 0 0;
  padding: 0;
}

.section-list li {
  margin: 0 0 3.2rem;
  padding: 0;
}

.section-list a {
  display: inline-flex;
  gap: 0.6em;
  font-family: "Lora", serif;
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.3;
}

.section-list .section-number {
  font-family: "Fustat", sans-serif;
  font-weight: 500;
}

.section-list p {
  margin: 0.6rem 0 0;
  color: var(--docs-text);
}

/* Chapter list on the manual's home page */
.chapter-list-heading {
  font-family: "Lora", serif;
  font-size: 2.4rem;
  font-weight: 500;
  margin: 4.8rem 0 1.6rem;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 64ch;
}

.chapter-list li {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  align-items: baseline;
  gap: 1.2rem;
  padding-block: 0.8rem;
  margin: 0;
}

.chapter-list-number {
  color: var(--docs-primary);
  font-weight: 500;
}

.chapter-list a {
  font-family: "Lora", serif;
  font-size: 1.8rem;
  font-weight: 500;
}

.chapter-list-meta {
  font-size: 1.4rem;
  color: var(--docs-muted);
  white-space: nowrap;
}

/* Previous / next links at the end of each page, each with a small label */
.pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.2rem;
  margin: 6.4rem 0 0;
  padding: 2.4rem 0 0;
  border-top: 1px solid #e3e6ea;
}

.pagination > div {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.pagination .next-page {
  text-align: right;
  align-items: flex-end;
}

.pagination-label {
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--docs-muted);
}

.pagination-prev,
.pagination-next {
  font-family: "Lora", serif;
  font-size: 1.7rem;
  font-weight: 500;
}

.pagination .bi {
  font-size: 0.85em;
}

.pagination .no-link {
  color: var(--docs-muted);
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 991.98px) {

  .content {
    padding-inline: var(--docs-gutter) !important;
  }
}

/* Phones and tablets: search opens as a full-width bar under the header */
@media (max-width: 991.98px) {
  .site-search {
    display: none;
    margin-left: 0;
    position: fixed;
    top: var(--docs-header-height);
    left: 0;
    right: 0;
    width: auto;
    padding: 1rem var(--docs-gutter);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
  }

  header.search-open .site-search {
    display: block;
  }

  .site-search {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
  }

  .site-search .pagefind-ui__drawer {
    position: static;
    width: auto;
    max-height: 60vh;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .header-tools {
    margin-right: 0;
    gap: 0;
  }
}

@media (max-width: 767.98px) {
  h1 {
    font-size: 3.2rem;
    line-height: 1.2;
  }

  h2 {
    font-size: 2.6rem;
    line-height: 1.25;
  }

  h3 {
    font-size: 2.2rem;
    line-height: 1.3;
  }

  h4 {
    font-size: 1.8rem;
    letter-spacing: -0.08rem;
    line-height: 1.35;
  }

  h5,
  h6 {
    font-size: 1.6rem;
    line-height: 1.4;
  }

  .section-list a {
    font-size: 1.8rem;
  }
}

/* Print: just the page, with its address --------------------------------- */

@media print {
  header,
  #sidebar,
  .offcanvas,
  .pagination,
  .site-search {
    display: none !important;
  }

  body {
    padding-top: 0;
    display: block;
    color: #000;
  }

  main {
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  .content {
    padding: 0 !important;
    max-width: none;
  }

  article > p,
  article > ul,
  article > ol {
    max-width: none;
  }

  /* Show where external links go */
  article a[href^="http"]:not([href*="safg.ca"])::after {
    content: " (" attr(href) ")";
    font-size: 0.9em;
    word-break: break-all;
  }

  .chapter-list li,
  .section-list li {
    break-inside: avoid;
  }

  .breadcrumb-trail::after {
    content: "Policies & Procedures Manual \2014  printed from " attr(data-url);
    display: block;
    margin-top: 0.4rem;
    font-size: 0.85em;
    color: #555;
  }
}
