/*
 * GeoServer Brand Theme
 *
 * Aligns the documentation theme with the main GeoServer web application.
 * Brand tokens are defined in geoserver-brand.css (loaded via mkdocs.yml extra_css).
 */

/* --- Light mode colour overrides --- */
[data-md-color-scheme="default"] {
  --md-primary-fg-color:        var(--gs-brand-primary);
  --md-primary-fg-color--light: var(--gs-brand-primary-light);
  --md-primary-fg-color--dark:  var(--gs-brand-primary-dark);
  --md-primary-bg-color:        #ffffff;
  --md-accent-fg-color:         var(--gs-brand-accent);
  --md-typeset-a-color:         var(--gs-brand-link);
}

/* --- Dark mode colour overrides --- */
[data-md-color-scheme="slate"] {
  --md-primary-fg-color:        var(--gs-brand-primary);
  --md-primary-fg-color--light: var(--gs-brand-primary-light);
  --md-primary-fg-color--dark:  #004d66;
  --md-accent-fg-color:         var(--gs-brand-accent);
  --md-typeset-a-color:         var(--gs-brand-link-dark);
}

/* --- Brand gradient on the header bottom border (mirrors the app) --- */
.md-header {
  border-bottom: 0.25em solid transparent;
  border-image: var(--gs-brand-gradient) 1;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* --- Brand gradient on the navigation tabs bottom border --- */
.md-tabs {
  border-bottom: 0.2em solid transparent;
  border-image: var(--gs-brand-gradient) 1;
}

/* --- Link hover colour to match the app --- */
.md-typeset a:hover {
  color: var(--gs-brand-link-hover);
}
[data-md-color-scheme="slate"] .md-typeset a:hover {
  color: var(--gs-brand-link-dark-hover);
}

/* 
 * GeoServer Documentation - Navigation Styles
 * 
 * Navigation.tabs feature is disabled to prevent horizontal overflow.
 * All navigation is now accessible through the sidebar (hamburger menu on mobile).
 */

/* Ensure navigation is accessible on all screen sizes */
.md-nav__item {
  padding: 0 !important;
}

/* Target all navigation links with maximum specificity */
.md-sidebar .md-nav--primary .md-nav__link,
.md-nav--primary .md-nav__link,
.md-nav__link {
  display: block;
  padding: 0.25rem 0.8rem !important;  /* Reduced from 0.625em to match right TOC spacing */
}

/* Override for simple (non-container) links in active path - remove extra padding */
.md-nav--primary .md-nav__item:not(.md-nav__item--nested) > .md-nav__link {
  padding: 0.25rem 0.8rem !important;
}

/* Improve touch targets on mobile */
@media screen and (max-width: 47.9375em) {
  .md-nav__link {
    padding: 0.875em 1em !important;
    font-size: 0.9rem;
  }
  
  .md-nav__item--nested > .md-nav__link {
    font-weight: 600;
  }
}

/* 
 * Breadcrumb Navigation Styles
 * 
 * Customizes the Material for MkDocs navigation.path feature
 * to match GeoServer branding and improve readability.
 * Breadcrumbs use sticky positioning and stop at the header.
 */

/* Breadcrumb container - sticky positioning that stops at header */
.md-path {
  position: sticky;
  top: 4.8rem;  /* Header (2.4rem) + Navigation tabs (2.4rem) = 4.8rem */
  z-index: 1;  /* Lower z-index so hamburger menu (z-index: 4) appears above */
  margin: -1.5rem 0rem 1rem 0rem;
  padding: 0.35rem 0.8rem;  /* Reduced from 0.5rem to make it more compact */
  font-size: 0.75rem;  /* Reduced from 0.85rem for smaller text */
  color: rgba(255, 255, 255, 0.9);
  background-color: var(--md-primary-fg-color);  /* Blue background matching header */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);  /* Subtler shadow */
  transition: background-color 0.25s ease, box-shadow 0.2s ease;
}

/* Darker blue when mobile menu is open */
[data-md-toggle="drawer"]:checked ~ .md-container .md-path {
  background-color: var(--md-primary-fg-color--dark);
}

/* Enhanced shadow when scrolled */
.md-path.scrolled {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Breadcrumb list */
.md-path__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Breadcrumb items */
.md-path__item {
  display: flex;
  align-items: center;
}

/* Breadcrumb links */
.md-path__link {
  color: rgba(255, 255, 255, 0.7);  /* Much more transparent for non-current items */
  text-decoration: none;
  transition: color 0.2s ease;
}

/* Make only the first breadcrumb item uppercase (the top-level section) */
.md-path__item:first-child .md-path__link {
  text-transform: uppercase;
}

.md-path__link:hover {
  color: rgba(255, 255, 255, 1);
  text-decoration: underline;
}

.md-path__link:focus {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Current page (last breadcrumb) - make it clickable to go to parent index */
.md-path__item:last-child .md-path__link {
  color: rgba(255, 255, 255, 1);
  font-weight: 500;
  /* Removed pointer-events: none to make last breadcrumb clickable */
}

/* Breadcrumb separator - Material for MkDocs provides default separator */
/* We keep the default separator and only customize spacing if needed */

/* Mobile responsive behavior (< 768px) */
@media screen and (max-width: 47.9375em) {
  .md-path {
    font-size: 0.75rem;
    margin: -0.5rem -1rem 0.75rem -1rem;
    padding: 0.4rem 1rem;
    /* Sticky position adjusted for mobile header + tabs */
    top: 4.8rem;
  }
  
  .md-path__list {
    gap: 0.2rem;
  }
  
  /* Truncate long breadcrumb text on mobile */
  .md-path__link {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }
  
  /* Always show full text for current page */
  .md-path__item:last-child .md-path__link {
    max-width: none;
    white-space: normal;
  }
}

/* Tablet responsive behavior (768px - 1220px) */
@media screen and (min-width: 48em) and (max-width: 76.1875em) {
  .md-path {
    font-size: 0.8rem;
  }
  
  .md-path__link {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }
  
  .md-path__item:last-child .md-path__link {
    max-width: none;
    white-space: normal;
  }
}

/* Dark mode adjustments */
[data-md-color-scheme="slate"] .md-path {
  background-color: var(--md-primary-fg-color);
  border-bottom-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-md-color-scheme="slate"] .md-path__link {
  color: rgba(255, 255, 255, 0.9);
}

[data-md-color-scheme="slate"] .md-path__link:hover {
  color: rgba(255, 255, 255, 1);
}

[data-md-color-scheme="slate"] .md-path__item:last-child .md-path__link {
  color: rgba(255, 255, 255, 1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .md-path__link {
    font-weight: 600;
  }
  
  .md-path__link:focus {
    outline-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .md-path__link {
    transition: none;
  }
}


/* 
 * Table of Contents Customization
 * 
 * Change title to "Page Contents" and reduce spacing between items
 */

/* Change "Table of contents" to "Page Contents" - reinforces layout.html fix */
.md-sidebar--secondary .md-sidebar__scrollwrap .md-sidebar__inner::before {
  content: "Page Contents";
  display: block;
  font-weight: 700;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--md-default-fg-color--light);
  margin-bottom: 0.5rem;
}

/* Hide the original title */
.md-sidebar--secondary .md-nav__title {
  display: none;
}

/* Reduce spacing between TOC items */
.md-nav--secondary .md-nav__item {
  padding: 0;
  margin: 0;
  line-height: 1.1 !important;  /* Tighter line-height for TOC */
}

.md-nav--secondary .md-nav__link {
  padding: 0.1rem 0;  /* Very tight spacing - much less than main nav (0.25rem) */
  font-size: 0.75rem;
  color: var(--md-default-fg-color--light) !important;  /* Lighter grey to match PAGE CONTENTS heading */
  line-height: 1.1 !important;  /* Tighter line-height */
}

/* Reduce spacing for nested items */
.md-nav--secondary .md-nav__item .md-nav__item {
  padding-left: 0.8rem;
}

.md-nav--secondary .md-nav__item .md-nav__item .md-nav__link {
  padding: 0.05rem 0;  /* Extremely tight for nested TOC items */
}


/* 
 * Simple Tree View Connectors
 * 
 * Adds a subtle vertical line to show hierarchy in navigation
 */

/* Left sidebar - add vertical line for nested sections */
.md-nav--primary .md-nav__item--nested > .md-nav {
  border-left: 1px solid var(--md-default-fg-color--lightest);
  margin-left: 0.6rem;
  padding-left: 0.6rem;
}

/* Add vertical line for ALL items under top-level sections (User Manual, Developer Guide, etc.) */
.md-nav--primary > .md-nav__list > .md-nav__item > .md-nav__link.md-nav__container + .md-nav {
  border-left: 1px solid var(--md-default-fg-color--lightest);
  margin-left: 0.6rem;
  padding-left: 0.6rem;
}

/* Right sidebar (TOC) - add vertical line for nested items */
.md-nav--secondary .md-nav__list {
  border-left: 1px solid var(--md-default-fg-color--lightest);
  padding-left: 0.8rem;
  margin-left: 0.2rem;
}

/* Ensure the top-level TOC list also has the vertical line */
.md-nav--secondary > .md-nav__list {
  border-left: 1px solid var(--md-default-fg-color--lightest);
  padding-left: 0.8rem;
  margin-left: 0.2rem;
}

/* Dark mode - slightly brighter line */
[data-md-color-scheme="slate"] .md-nav--primary .md-nav__item--nested > .md-nav,
[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__list {
  border-left-color: var(--md-default-fg-color--lighter);
}


/* 
 * Reduce spacing for collapsed navigation sections
 */

/* CRITICAL: Consistent spacing for all navigation items */
.md-nav--primary .md-nav__item {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.5 !important;  /* Consistent line-height for all items */
}

/* Ensure links have consistent vertical spacing */
.md-nav--primary .md-nav__link {
  display: block !important;
  margin: 0 !important;
  line-height: 1.5 !important;  /* Match parent line-height */
}

/* The container div inside nested items - no extra spacing */
.md-nav__item--nested > .md-nav__link.md-nav__container {
  display: flex !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  line-height: 1.5 !important;  /* Match consistent line-height */
}

/* The actual link inside the container */
.md-nav__link.md-nav__container > .md-nav__link {
  display: block !important;
  padding: 0.25rem 0.8rem !important;
  margin: 0 !important;
  line-height: 1.5 !important;  /* Match consistent line-height */
  font-size: 0.8rem !important;
}

/* The label (expand/collapse button) */
.md-nav__link.md-nav__container > label.md-nav__link {
  padding: 0.25rem 0.8rem !important;
  margin: 0 !important;
  line-height: 1.5 !important;  /* Match consistent line-height */
  font-size: 0.8rem !important;
}

/* CRITICAL: Reduce row-gap between navigation items */
.md-nav__list {
  row-gap: 0 !important;
  gap: 0 !important;
  padding: 0 !important;  /* Remove all padding from lists */
  margin: 0 !important;   /* Remove all margin from lists */
}

/* Remove any default spacing from the nav container */
.md-nav__container {
  padding: 0 !important;
  margin: 0 !important;
}

/* Center the tabs list */
.md-tabs__list {
  justify-content: center !important;
}

/* Optional: Add some spacing between tabs for better visual separation */
.md-tabs__item {
  margin: 0 0.5rem;
}

/* Ensure tabs container uses flexbox for centering */
.md-tabs {
  display: flex;
  justify-content: center;
}

.md-tabs .md-grid {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Make navigation tabs uppercase */
.md-tabs__link {
  text-transform: uppercase !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
}


/* 
 * Fix duplicate page title in navigation
 * 
 * Material for MkDocs shows both a label (for TOC toggle) and a link
 * for the active page when it has a table of contents. This creates
 * visual duplication. Hide the label and keep only the link.
 */

/* Hide the label when the active page has both label and link with TOC */
.md-nav__item--active > label.md-nav__link:has(+ a.md-nav__link) {
  display: none !important;
}

/* Fallback for browsers without :has() support */
.md-nav__item--active > input.md-nav__toggle + label.md-nav__link {
  display: none !important;
}


/* 
 * Normalize navigation link font sizes
 * 
 * Material for MkDocs makes nested items (with sub-menus) larger than
 * regular items. This makes all navigation links the same size.
 */

/* Set consistent font size for all navigation links */
.md-nav--primary .md-nav__link,
.md-nav--primary .md-nav__link.md-nav__container,
.md-nav--primary .md-nav__link.md-nav__container > .md-nav__link,
.md-nav--primary .md-nav__link.md-nav__container > label.md-nav__link {
  font-size: 0.8rem !important;
}

/* Ensure nested item containers don't increase font size */
.md-nav__item--nested > .md-nav__link.md-nav__container {
  font-size: 0.8rem !important;
}


/* 
 * Make top-level section headings uppercase
 * 
 * Applies to main sections like "Developer Guide", "User Manual", etc.
 * but not to their sub-items.
 */

/* Target only direct children of the primary nav list (level 1 items) */
.md-nav--primary > .md-nav__list > .md-nav__item > .md-nav__link.md-nav__container > .md-nav__link {
  text-transform: uppercase !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
}


/*
 * Screenshot / image borders
 *
 * Makes documentation screenshots stand out from surrounding text.
 * Emoji images are excluded so they render inline without a border.
 */

/* Light mode — subtle grey border + slight shadow */
.md-typeset img {
  border: 1px solid #ccc;
  border-radius: var(--md-border-radius, 0.1rem);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Dark mode — lighter border that's visible on dark backgrounds */
[data-md-color-scheme="slate"] .md-typeset img {
  border-color: #495057;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Exclude emoji / icon images from the border treatment */
.md-typeset img.emojione,
.md-typeset img.twemoji,
.md-typeset img.emoji,
.md-typeset img.gemoji {
  border: none;
  box-shadow: none;
}


/*
 * Code formatting — brand-tinted backgrounds
 *
 * Makes inline `code` and fenced code blocks stand out against the
 * page background using tints derived from the GeoServer brand palette.
 */

/* --- Inline code --- */
.md-typeset code {
  background-color: rgba(0, 118, 161, 0.08);   /* gs-brand-primary @ 8 % */
  border: 1px solid rgba(0, 118, 161, 0.18);
  border-radius: 0.2rem;
  padding: 0.05em 0.35em;
  color: inherit;
}

/* Dark mode inline code */
[data-md-color-scheme="slate"] .md-typeset code {
  background-color: rgba(75, 160, 196, 0.14);   /* gs-brand-primary-light @ 14 % */
  border-color: rgba(75, 160, 196, 0.28);
}

/* --- Fenced / indented code blocks --- */
.md-typeset pre > code {
  background-color: rgba(0, 118, 161, 0.06);
  border: 1px solid rgba(0, 118, 161, 0.14);
  border-radius: 0.3rem;
  padding: 0.8em 1em;
}

[data-md-color-scheme="slate"] .md-typeset pre > code {
  background-color: rgba(75, 160, 196, 0.10);
  border-color: rgba(75, 160, 196, 0.22);
}

/* Ensure the highlight wrapper also picks up the border-radius */
.md-typeset .highlight > pre {
  border-radius: 0.3rem;
}

/* Remove double-border: inline code inside a link already has link colour */
.md-typeset a code {
  border-color: transparent;
}
