/* User Provided Stylesheet */

/* Preserve readable text sizing in iOS Safari and support native light/dark UI. */
html { /* Select the document root for browser text and color behavior. */
  -webkit-text-size-adjust: 100%; /* Prevent automatic text inflation in iOS Safari. */
  color-scheme: light dark; /* Enable native browser UI colors for light and dark modes. */
} /* End the root element rule. */

/* Hide the MyST front-matter downloads menu. */
.myst-fm-downloads-dropdown { /* Select MyST's front-matter downloads menu. */
  display: none !important; /* Hide the downloads menu. */
} /* End the downloads menu rule. */

/* Keep first-column labels together on wider screens. */
table td:first-child, /* Select the first data cell in each table row. */
table th:first-child { /* Select the first header cell in each table row. */
  white-space: nowrap; /* Keep first-column labels on one line by default. */
} /* End the first-column rule. */

/* Keep wide content usable on phones and other narrow screens. */
@media screen and (max-width: 768px) { /* Apply layout adjustments on narrow screens. */
  table, /* Select tables for narrow-screen overflow handling. */
  pre { /* Select preformatted text such as code blocks. */
    max-width: 100%; /* Keep content within the available width. */
    overflow-x: auto; /* Allow wide content to scroll horizontally. */
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling in WebKit browsers. */
  } /* End the table and code-block overflow rule. */

  table { /* Give tables their own horizontal scrolling area. */
    display: block; /* Allow tables to scroll independently of the page. */
  } /* End the responsive table rule. */

  table td:first-child, /* Select the first data cell in each table row. */
  table th:first-child { /* Select the first header cell in each table row. */
    white-space: normal; /* Allow first-column labels to wrap on narrow screens. */
  } /* End the responsive first-column rule. */

  img, /* Select images for responsive sizing. */
  video { /* Select videos for responsive sizing. */
    max-width: 100%; /* Keep media within its containing element. */
    height: auto; /* Preserve the media's intrinsic aspect ratio. */
  } /* End the responsive media rule. */

  iframe { /* Select embedded frames for responsive sizing. */
    max-width: 100%; /* Keep embedded frames within their containing element. */
  } /* End the responsive iframe rule. */
} /* End the narrow-screen media query. */

/* Improve MyST touch navigation on narrow screens. */
@media screen and (max-width: 768px) { /* Apply navigation enhancements on phones. */
  .myst-top-nav-menu-button, /* Select MyST's mobile menu button. */
  .myst-theme-button { /* Select MyST's theme toggle button. */
    min-width: 44px; /* Provide a comfortable touch target width. */
    min-height: 44px; /* Provide a comfortable touch target height. */
    touch-action: manipulation; /* Reduce tap delay without disabling gestures. */
  } /* End top navigation touch-target rules. */

  .myst-primary-sidebar-toc .myst-toc-item, /* Select MyST table-of-contents items. */
  .myst-primary-sidebar-toc .myst-toc-item button { /* Select expandable-folder buttons. */
    min-height: 44px; /* Ensure sidebar navigation targets are easy to tap. */
    touch-action: manipulation; /* Improve touch response for navigation controls. */
  } /* End sidebar touch-target rules. */

  .myst-primary-sidebar-nav { /* Select the MyST sidebar's scrolling container. */
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling in iOS browsers. */
    overscroll-behavior-y: contain; /* Prevent sidebar scrolling from chaining to the page. */
  } /* End sidebar scrolling rule. */
} /* End mobile navigation media query. */

/* Smooth anchor navigation only when reduced motion is not requested. */
@media (prefers-reduced-motion: no-preference) { /* Respect the user's motion preference. */
  html { /* Apply scrolling behavior to in-page links and headings. */
    scroll-behavior: smooth; /* Animate anchor navigation. */
    scroll-padding-top: 1rem; /* Keep target headings clear of the viewport edge. */
  } /* End smooth scrolling rule. */
} /* End reduced-motion preference query. */
