/**
 * @file
 * Admin Navigation — sticky behavior overrides.
 *
 * Activated by `admin-navigation-sticky--disabled` on <html> (set by
 * hook_preprocess_html when the user picked "Disabled" in the General tab).
 * Targets BOTH sidebar mode (`[data-drupal-admin-styles].admin-toolbar`)
 * and top-bar mode (`aside.top-bar`) so the override works regardless of
 * the chosen position.
 */

.admin-navigation-sticky--disabled [data-drupal-admin-styles].admin-toolbar {
  position: absolute !important;
  top: 0 !important;
}
.admin-navigation-sticky--disabled aside.top-bar {
  position: absolute !important;
}

/* =============================================================================
   EMPTY TOP-BAR FALLBACK
   ==========================================================================
   The PHP preprocess hook (TopBarHooks::preprocessTopBar) strips
   hidden-only regions from <aside class="top-bar">, but it depends on
   running AFTER every other module that injects content there.  This
   :has() rule is the belt-and-suspenders fallback: hide the aside
   whenever none of its three regions contain a non-hidden child element.
   Activated by the `admin-navigation-hide-empty-top` class on <html>.
   Loaded for BOTH sidebar and top-bar modes (the top-bar exists
   regardless of where the main toolbar sits). */
.admin-navigation-hide-empty-top aside.top-bar:not(:has(
  .top-bar__tools > :not(.hidden),
  .top-bar__context > :not(.hidden),
  .top-bar__actions > :not(.hidden)
)) {
  display: none !important;
}

/* =============================================================================
   MOBILE — close button placement
   ==========================================================================
   In mobile (≤768px) when the sidebar is opened as an overlay, core puts
   the X close button at the top-right corner INSIDE the sidebar, where it
   visually competes with the navigation header.  Pull it OUT to the
   top-right of the viewport so it's always reachable regardless of how
   wide the sidebar happens to be.
*/
@media (max-width: 768px) {
  html[data-admin-toolbar="expanded"] [data-drupal-admin-styles].admin-toolbar .admin-toolbar__close-button {
    /* `position: fixed` so the X escapes `.admin-toolbar__scroll-wrapper`
       which has overflow:auto and would otherwise clip it.  Top/left are
       set inline by admin-navigation-general.js based on the live
       sidebar bounding rect, so the X always sits flush against the
       sidebar's right edge regardless of its width. */
    position: fixed !important;
    inset-inline-end: auto !important;
    z-index: 1001 !important;
    background-color: #fff !important;
    /* Tucked into the sidebar's top-right corner — only the right and
       bottom edges need a soft shadow to lift it off the page content. */
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.12) !important;
  }
}
