/**
 * Drupal 11 Preview & Gin Toolbar Layout Fixes
 *
 * With the standard Gin toolbar (not Navigation module), Gin handles
 * body padding via --gin-toolbar-y-offset and --gin-toolbar-x-offset.
 * This file handles preview mode and any marine-specific adjustments.
 */

/**
 * PREVIEW MODE: Hide toolbar during preview.
 * Gives an accurate preview of what visitors will see.
 */
body:has(.node-preview-form-select) #toolbar-administration,
body:has(.node-preview-form-select) .gin-secondary-toolbar {
  display: none !important;
}

body:has(.node-preview-form-select) {
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-inline-start: 0 !important;
}

/**
 * Preview form positioning.
 */
.node-preview-form-select {
  position: relative;
  z-index: 10;
  background: #fff;
  padding: 1rem;
  border-bottom: 1px solid #ccc;
  width: 100%;
  box-sizing: border-box;
}

/**
 * Main content area.
 */
main#main-content {
  position: relative;
  z-index: 1;
}

/**
 * ADMIN TOOLBAR PROTECTION
 *
 * Undo specific marine theme styles that bleed into admin toolbar elements.
 * Only reset properties that the marine theme's broad selectors set.
 */
#toolbar-bar h2,
.admin-toolbar h2,
.admin-toolbar h3,
.gin-secondary-toolbar h2,
.gin-secondary-toolbar h3 {
  font-family: inherit;
  text-transform: none;
}

/**
 * Ensure toolbar button labels match link font sizes.
 * Buttons (Structure, Configuration, Reports) use span.toolbar-link__label
 * which may not inherit the same font-size as a.toolbar-link items.
 */
.admin-toolbar .toolbar-link__label {
  font-size: inherit;
}

/**
 * GIN TOP BAR WIDTH FIX
 *
 * The Gin secondary toolbar (top bar) is position:fixed but its width
 * can overflow when the sidebar is open. Ensure it respects viewport bounds
 * by constraining to the available width after the sidebar offset.
 */
/**
 * GIN TOP BAR WIDTH FIX
 *
 * Gin's navigation.css adds margin-inline-start: var(--gin-toolbar-x-offset)
 * on .gin--navigation .gin-secondary-toolbar--frontend, which double-offsets
 * the top bar since the body already has padding-inline-start for the sidebar.
 * Additionally, constrain the toolbar width to prevent overflow.
 */
.gin--navigation .gin-secondary-toolbar--frontend {
  margin-inline-start: 0;
  max-width: calc(100vw - var(--drupal-displace-offset-left, 0px));
}
