/* =========================================================
	 Google Fonts with display=swap to prevent CLS
	 ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;550;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* =========================================================
	 CSS Custom Properties for Font Stacks
	 ========================================================= */
:root {
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

/* =========================================================
	 Root and Body Styling
	 ========================================================= */
html {
  font-family: var(--font-sans);
}

body {
  font-family: var(--font-sans);
}

code,
pre {
  font-family: var(--font-mono);
}

.header-link {
  text-align: center;
  font-size: 24px;
  border-bottom: 1px solid #eee;
}

.header-link > a {
  color: #2c1e47;
}

.sub-header {
  padding-top: 25px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.sub-header2 {
  padding-top: 10px;
}

/* Bootstrap 5 compatibility */
.page-header {
  padding-bottom: 9px;
  margin: 40px 0 20px;
  border-bottom: 1px solid #e5e5e5;
}

/* Bootstrap 5 Popover styles */
.popover {
  max-width: 300px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.popover-header {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  font-weight: 600;
  background-color: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.popover-body {
  padding: 0.5rem 0.75rem;
  color: #212529;
}

.function {
  cursor: pointer;
}

/* Links styling - be specific to not override other styles */
a {
  color: #0b5ed7;
  text-decoration: none;
  font-weight: 550;
}

a:hover {
  color: #0a58ca;
  text-decoration: underline;
}

/* Specific link overrides */
.file > a {
  color: #555;
}

.file > a:hover {
  color: #2c1e47;
  text-decoration: none;
}

.breadcrumb > li a {
  text-decoration: none;
  color: #0b5ed7;
}

.breadcrumb > li a:hover {
  text-decoration: underline;
}

pre,
code {
  font-size: 14px;
  border: 0;
  max-width: 100%;
  overflow: auto;
  word-wrap: break-word;
}

pre.description {
  background: none;
  margin: 0;
  padding: 0;
}

pre.syntax {
  display: inline-block;
  padding: 6px 8px;
  color: #c7254e;
  background-color: #f9f2f4;
  border-radius: 4px;
  border: 0;
}

/* Mobile-first: show sidebar as a top block on small screens, desktop overrides below */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 15px;
  background-color: #f5f5f5;
  border-bottom: 1px solid #eee;
}

.menu-toggle {
  font-size: 20px;
  line-height: 1;
  margin-right: 12px;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  cursor: pointer;
}

/* Sidebar is hidden by default on small screens and opened via JS */
.sidebar {
  display: none;
}

.sidebar.open {
  display: block;
  position: fixed;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 12px 15px;
  background-color: #f5f5f5;
  overflow-y: auto;
}

/* Hide duplicate logo inside sidebar on small screens (we show it in .mobile-header) */
.sidebar > .header-link {
  display: none;
}

.nav-functions {
  display: none;
}

.nav-functions.show {
  display: block;
}

/* Make nav links easier to tap on mobile */
.nav-sidebar {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-sidebar > li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  clear: both;
  float: none;
}

.nav-sidebar > li > a {
  padding: 12px 16px;
  line-height: 1.6;
  display: block;
  width: 100%;
}

.nav-functions .card-body {
  padding: 15px 0;
}

.nav-sidebar > li > a {
  padding: 0 20px;
}

.nav-sidebar > li.active > a,
.nav-sidebar > li.active > a:hover,
.nav-sidebar > li.active > a:focus {
  color: #fff;
  background-color: #0d6efd;
}

.permalink {
  color: #fff;
}

.permalink:hover {
  color: #f5f7fa;
}

.card.border-info > .card-header > .permalink {
  color: #084298;
}

.card:target {
  border-color: #fcf8e3;
}

.card:target > .card-header {
  color: #664d03;
  background-color: #fff3cd;
  border-color: #fcf8e3;
}

/* Bootstrap color contrast fixes for accessibility */
.bg-info {
  background-color: #0c63e4 !important;
}

.bg-info.text-white {
  color: #fff !important;
}

.bg-success {
  background-color: #198754 !important;
}

.bg-success.text-white {
  color: #fff !important;
}

.bg-warning {
  background-color: #ffc107 !important;
}

.bg-warning.text-dark {
  color: #000 !important;
  font-weight: 500;
}

.bg-danger {
  background-color: #dc3545 !important;
}

.bg-danger.text-white {
  color: #fff !important;
}

.container-fluid {
  /* slightly reduced padding for small screens */
  padding: 12px;
}

@media (min-width: 768px) {
  /* Desktop: show sidebar fixed and hide mobile header */
  .mobile-header {
    display: none;
  }

  body {
    margin-left: 300px;
  }

  .container-fluid {
    padding-right: 40px;
    padding-left: 40px;
  }

  .sidebar {
    display: block;
    position: fixed;
    top: 0px;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 300px;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
    background-color: #f5f5f5;
    border-right: 1px solid #eee;
  }

  /* show logo inside sidebar on desktop */
  .sidebar > .header-link {
    display: block;
    margin-bottom: 10px;
  }
}

.footer {
  border-top: 1px solid #eee;
  text-align: right;
  padding-top: 10px;
}

/* Breadcrumb: Bootstrap 5 compatible */
.breadcrumb {
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  background-color: transparent;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
}

.breadcrumb > li {
  display: inline-block;
}

.breadcrumb > li::before {
  content: "/";
  margin: 0 0.5rem;
  color: #6c757d;
}

.breadcrumb > li:first-child::before {
  content: none;
}

.breadcrumb > li a {
  text-decoration: none;
  color: #0d6efd;
}

.breadcrumb > li a:hover {
  text-decoration: underline;
}

.breadcrumb > li.ms-auto {
  margin-left: auto;
}

.breadcrumb > li.active {
  color: #495057;
}

/**
 * typeahead.js
 * https://github.com/twitter/typeahead.js
 */
.twitter-typeahead {
  width: 100%;
}

.tt-hint {
  color: #666;
}

.tt-menu {
  width: 100%;
  margin-top: 12px;
  padding: 8px 0;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  max-height: 400px;
  overflow-y: auto;
}

.tt-suggestion {
  padding: 3px 20px;
  font-size: 18px;
  line-height: 24px;
  cursor: pointer;
}

.tt-suggestion.tt-cursor {
  color: #fff;
  background-color: #0097cf;
}

.tt-suggestion p {
  margin: 0;
}

.tt-name {
  margin: 0 20px 5px 20px;
  padding: 3px 0;
  border-bottom: 1px solid #ccc;
}

/* =========================================================
	 Dark mode (inversion-based, experimental)
	 ========================================================= */

@media (prefers-color-scheme: dark) {
  html {
    filter: invert(0.85) hue-rotate(180deg);
  }
}

/* =========================================================
	 Accessibility: Focus Styles
	 ========================================================= */

/* Only show focus outline when using keyboard navigation (focus-visible) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #0b5ed7;
  outline-offset: 2px;
}

/* Remove default blue outline for mouse clicks */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

/* Enhanced focus for interactive elements */
.function:focus-visible {
  outline: 2px solid #0b5ed7;
  outline-offset: 1px;
  border-radius: 2px;
}

.function:focus:not(:focus-visible) {
  outline: none;
}

.nav-sidebar > li > a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.nav-sidebar > li > a:focus:not(:focus-visible) {
  outline: none;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  a:focus-visible,
  a:focus-visible,
  button:focus-visible,
  button:focus-visible,
  input:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  textarea:focus-visible,
  select:focus-visible,
  select:focus-visible,
  .function:focus-visible {
    outline: 1px solid #0b5ed7;
    outline-offset: 1px;
  }

  .nav-sidebar > li > a:focus-visible {
    outline: 1px solid #fff;
    outline-offset: -1px;
  }
}
