/* Google Fonts - Karla for headers */
@import url('https://fonts.googleapis.com/css2?family=Karla:wght@400;500;600;700;800&display=swap');

/* NLR Color Palette */
:root {
  /* NLR Mesa Blue */
  --md-primary-fg-color: #0079C2;
  --md-primary-fg-color--light: #00A3E4;
  --md-primary-fg-color--dark: #005a91;

  /* Accent - NLR Rocky Blue */
  --md-accent-fg-color: #003A69;
  --md-accent-fg-color--transparent: rgba(0, 163, 228, 0.1);

  /* NLR additional colors for reference */

  /* NLR Golden Sun */
  --nlr-yellow: #DB9728;
  --nlr-green: #819E7E;
  --nlr-gray: #CEC3BA;
  --nlr-light-gray: #f6f4f1;
}

/* Header font - Karla, all uppercase */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-family: 'Karla', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Header styling */
.md-header {
  background-color: var(--md-primary-fg-color);
}

/* Navigation tabs */
.md-tabs {
  background-color: var(--md-primary-fg-color);
}

/* Links */
.md-typeset a {
  color: var(--md-primary-fg-color);
}

.md-typeset a:hover {
  color: var(--md-primary-fg-color--light);
}

/* Code blocks */
.md-typeset code {
  background-color: rgba(0, 121, 194, 0.1);
}

/* Admonitions - Info */
.md-typeset .admonition.info,
.md-typeset details.info {
  border-color: var(--md-primary-fg-color);
}

.md-typeset .info > .admonition-title,
.md-typeset .info > summary {
  background-color: rgba(0, 121, 194, 0.1);
}

.md-typeset .info > .admonition-title::before,
.md-typeset .info > summary::before {
  background-color: var(--md-primary-fg-color);
}

/* Admonitions - Warning */
.md-typeset .admonition.warning,
.md-typeset details.warning {
  border-color: var(--nlr-yellow);
}

.md-typeset .warning > .admonition-title,
.md-typeset .warning > summary {
  background-color: rgba(255, 196, 35, 0.1);
}

/* Admonitions - Success */
.md-typeset .admonition.success,
.md-typeset details.success {
  border-color: var(--nlr-green);
}

.md-typeset .success > .admonition-title,
.md-typeset .success > summary {
  background-color: rgba(125, 165, 68, 0.1);
}

/* Tables */
.md-typeset table:not([class]) th {
  background-color: var(--md-primary-fg-color);
  color: white;
}

.md-typeset table:not([class]) tr:hover {
  background-color: var(--md-accent-fg-color--transparent);
}

/* Footer */
.md-footer {
  background-color: var(--nlr-gray);
}

/* Search highlight */
.md-search__form {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Override mkdocs-material TOC scroll-spy with our own */
.md-nav--secondary .md-nav__link--active {
  color: inherit !important;
  font-weight: inherit !important;
}

.md-nav--secondary .toc-active {
  color: var(--md-primary-fg-color) !important;
}

/* Make "Table of contents" label darker to match left nav headers */
.md-nav--secondary > .md-nav__title {
  color: rgba(0, 0, 0, 0.87) !important;
}

/* --- Tighten above-the-fold whitespace --- */

/* Reduce gap between tabs bar and content */
.md-main__inner {
  margin-top: 0;
}

.md-content__inner {
  padding-top: 0.5rem;
}

/* Tighter h1: smaller size, less bottom margin */
.md-typeset h1 {
  font-size: 1.6rem;
  margin-bottom: 0.4em;
  margin-top: 0;
}

/* Tighter h2/h3/h4/h5/h6 spacing */
.md-typeset h2 {
  font-size: 1.2rem;
  margin-top: 0.8em;
  margin-bottom: 0.25em;
}

.md-typeset h3 {
  margin-top: 0.6em;
  margin-bottom: 0.2em;
}

.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  margin-top: 0.5em;
  margin-bottom: 0.15em;
}

/* Reduce paragraph spacing */
.md-typeset p {
  margin-top: 0.4em;
  margin-bottom: 0.4em;
}

/* Tighten left sidebar top alignment */
.md-sidebar {
  padding-top: 0.5rem;
}

/* Tighten table margins */
.md-typeset table {
  margin-top: 0.4em;
  margin-bottom: 0.6em;
}

/* --- End tighten whitespace --- */

/* Content max width */
.md-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* Hide the logo icon and remove its reserved space */
.md-header__button.md-logo {
  display: none !important;
}

.md-header__title {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

/* --- Citation styles --- */

/* Citation placeholders: styled pills shown while citations load */
.cite-placeholder {
  display: inline-block;
  background: rgba(0, 0, 0, 0.06);
  color: transparent;
  border-radius: 3px;
  font-size: 0.85em;
  padding: 0.05em 0.4em;
  vertical-align: baseline;
  min-width: 1.5em;
  height: 1em;
  animation: cite-placeholder-pulse 1.2s ease-in-out infinite;
}

.cite-placeholder-block {
  display: block;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding: 0.6em 0.8em;
  margin: 0.5em 0;
  height: 1.2em;
  animation: cite-placeholder-pulse 1.2s ease-in-out infinite;
}

@keyframes cite-placeholder-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Fade in rendered citation elements */
.cite-inline,
.cite-full,
.cite-formats {
  animation: cite-fade-in 0.2s ease-out forwards;
}

@keyframes cite-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Inline citation styling */
.cite-inline {
  /* Inherits text styling by default */
}

/* Citation links */
.cite-link {
  text-decoration: none;
  color: inherit;
}

.cite-link:hover {
  color: var(--md-primary-fg-color);
}

/* Citation hover tooltip (real DOM element for interactive content) */
.cite-tooltip {
  position: absolute;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--nlr-light-gray);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 0.65em 0.8em;
  max-width: 400px;
  width: max-content;
  font-size: 1.4em;
  line-height: 1.5;
  color: var(--md-default-fg-color);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.12s ease-out;
}

.cite-tooltip.visible {
  opacity: 1;
}

/* Arrow */
.cite-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
  border-bottom: none;
}

.cite-tooltip::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--nlr-light-gray);
  border-bottom: none;
}

/* Links inside tooltip */
.cite-tooltip a {
  color: var(--md-primary-fg-color);
  text-decoration: none;
  word-break: break-all;
}

.cite-tooltip a:hover {
  text-decoration: underline;
}

/* Invisible bridge between citation and tooltip so hover doesn't break */
.cite-tooltip-bridge {
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

/* When tooltip is below the link, flip the arrow and bridge */
.cite-tooltip-below::after {
  bottom: auto;
  top: -6px;
  border-top: none;
  border-bottom: 6px solid #fff;
}

.cite-tooltip-below::before {
  bottom: auto;
  top: -7px;
  border-top: none;
  border-bottom: 6px solid var(--nlr-light-gray);
}

.cite-tooltip-below .cite-tooltip-bridge {
  bottom: auto;
  top: -8px;
}

/* Error state for unknown citation keys */
.cite-error {
  color: #d32f2f;
  border-bottom: 1px dashed #d32f2f;
  cursor: help;
}

/* Full inline citation [!@key] */
.cite-full {
  margin-bottom: 0.5em;
  line-height: 1.5;
}

.cite-full .csl-entry {
  display: inline;
}

/* Bibliography container */
.cite-bibliography {
  margin-top: 1em;
}

/* Numbered bibliography list */
.cite-bib-list {
  padding-left: 2em;
  line-height: 1.6;
}

.cite-bib-list li {
  margin-bottom: 0.75em;
  padding-left: 0.5em;
}

.cite-bibliography .csl-entry {
  margin-bottom: 0.75em;
  padding-left: 2em;
  text-indent: -2em;
  line-height: 1.5;
}

/* --- Citation format tabs --- */

/* Collapsible wrapper */
.cite-formats {
  margin-top: 0.25em;
  margin-bottom: 1.25em;
  border: 1px solid var(--nlr-light-gray);
  border-radius: 4px;
  font-size: 0.85em;
}

.cite-formats summary {
  cursor: pointer;
  padding: 0.4em 0.75em;
  font-weight: 600;
  color: var(--nlr-gray);
  user-select: none;
}

/* Remove MkDocs Material admonition icon and native marker; use a right-side chevron */
.md-typeset .cite-formats > summary::before {
  display: none !important;
}
.md-typeset .cite-formats > summary::after {
  display: none !important;
}
.md-typeset .cite-formats > summary {
  padding-left: 0.75em;
  padding-right: 2em;
  min-height: unset;
  list-style: none;
  position: relative;
}
.md-typeset .cite-formats > summary::-webkit-details-marker {
  display: none;
}
/* Chevron on the right side, rotates when open */
.cite-formats > summary .cite-chevron {
  position: absolute;
  right: 0.75em;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.2s ease;
  display: inline-flex;
  color: var(--nlr-gray);
}
.cite-formats[open] > summary .cite-chevron {
  transform: translateY(-50%) rotate(90deg);
}

.cite-formats summary:hover {
  color: var(--md-primary-fg-color);
}

.cite-formats[open] summary {
  border-bottom: 1px solid var(--nlr-light-gray);
}

.cite-formats-inner {
  padding: 0.5em 0.75em;
}

/* Tab bar */
.cite-format-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--nlr-light-gray);
  margin-bottom: 0.5em;
}

.cite-format-tab {
  background: none;
  border: none;
  padding: 0.4em 1em;
  cursor: pointer;
  font-size: 0.9em;
  font-family: inherit;
  color: var(--nlr-gray);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.cite-format-tab:hover {
  color: var(--md-primary-fg-color);
}

.cite-format-tab.active {
  color: var(--md-primary-fg-color);
  border-bottom-color: var(--md-primary-fg-color);
  font-weight: 600;
}

/* Tab content panels */
.cite-format-content {
  position: relative;
}

.cite-format-content:not(.active) {
  display: none;
}

.cite-format-pre {
  margin: 0;
  padding: 0.75em;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.9em;
  line-height: 1.5;
}

.cite-format-content.cite-mono .cite-format-pre {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  white-space: pre;
}

/* Pre wrapper for inline copy button */
.cite-format-pre-wrapper {
  position: relative;
}

.cite-copy-inline {
  position: absolute;
  top: 0.4em;
  right: 0.4em;
  opacity: 0.4;
  transition: opacity 0.15s;
  padding: 0.25em !important;
  border: none !important;
  background: rgba(255, 255, 255, 0.8) !important;
  border-radius: 3px !important;
}

.cite-format-pre-wrapper:hover .cite-copy-inline {
  opacity: 1;
}

.cite-copy-inline.copied {
  opacity: 1 !important;
}

/* Action bar (copy + save buttons) */
.cite-action-bar {
  display: flex;
  gap: 0.5em;
  margin-top: 0.4em;
}

/* Copy button */
.cite-copy-btn,
.cite-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.25em 0.6em;
  background: none;
  border: 1px solid var(--nlr-light-gray);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  font-family: inherit;
  color: var(--nlr-gray);
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.cite-copy-btn:hover,
.cite-save-btn:hover {
  color: var(--md-primary-fg-color);
  border-color: var(--md-primary-fg-color);
  background-color: rgba(0, 121, 194, 0.05);
}

.cite-copy-btn.copied,
.cite-save-btn.saved {
  color: var(--nlr-green);
  border-color: var(--nlr-green);
}

/* On pages with a bibliography (e.g. references), show format tabs
   without the outer box so they blend into the page flow */
.cite-bib-page .cite-formats {
  border: none;
  border-radius: 0;
}

.cite-bib-page .cite-formats[open] summary {
  border-bottom: none;
}

.cite-bib-page .cite-formats-inner {
  padding-left: 0;
}

/* --- Cite Dataset Widget --- */

.cite-dataset-widget {
  margin-top: 2em;
}

.cite-widget-details {
  border: 1px solid var(--nlr-light-gray);
  border-radius: 6px;
}

/* Summary bar */
.cite-widget-summary {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.6em 1em;
  padding-right: 2.5em;
  background: rgba(0, 121, 194, 0.06);
  color: var(--md-primary-fg-color);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  position: relative;
  border-radius: 6px;
}

.cite-widget-details[open] > .cite-widget-summary {
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid var(--nlr-light-gray);
}

.cite-widget-summary::-webkit-details-marker {
  display: none;
}

/* Override MkDocs Material admonition styles on the summary */
.md-typeset .cite-widget-details > summary::before,
.md-typeset .cite-widget-details > summary::after {
  display: none !important;
}
.md-typeset .cite-widget-details > summary {
  padding-left: 1em;
  padding-right: 2.5em;
  min-height: unset;
  list-style: none;
}

.cite-widget-summary .cite-widget-icon {
  display: inline-flex;
  flex-shrink: 0;
}

.cite-widget-summary .cite-chevron {
  position: absolute;
  right: 0.75em;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.2s ease;
  display: inline-flex;
  color: var(--md-primary-fg-color);
}

.cite-widget-details[open] > .cite-widget-summary .cite-chevron {
  transform: translateY(-50%) rotate(90deg);
}

/* Body */
.cite-widget-body {
  padding: 1em;
}

/* Location selector */
.cite-widget-locations {
  margin-bottom: 1em;
}

.cite-widget-locations-label {
  font-size: 0.9em;
  margin-bottom: 0.5em;
  color: var(--nlr-gray);
}

.cite-widget-select-all-row {
  margin-bottom: 0.5em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--nlr-light-gray);
}

.cite-widget-select-all-row .cite-widget-checkbox-label {
  font-size: 0.85em;
  color: var(--nlr-gray);
}

.cite-widget-location-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.25em 1em;
}

.cite-widget-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.9em;
  cursor: pointer;
  padding: 0.15em 0;
}

.cite-widget-checkbox-label input[type="checkbox"] {
  accent-color: var(--md-primary-fg-color);
  cursor: pointer;
}

/* Hint text below checkboxes */
.cite-widget-hint {
  font-size: 0.8em;
  color: var(--nlr-gray);
  margin-top: 0.5em;
  margin-bottom: 0;
  font-style: italic;
}

/* Format tabs container */
.cite-widget-tabs-container {
  min-height: 2em;
}

/* Override inner format tabs inside the widget — remove wrapper chrome */
.cite-widget-tabs-container .cite-formats {
  border: none;
  margin-top: 0;
  margin-bottom: 0;
  border-radius: 0;
}

.cite-widget-tabs-container .cite-formats > summary {
  display: none;
}

.cite-widget-tabs-container .cite-formats-inner {
  padding: 0;
}
