.region-sticky {
  position: sticky;
  top: var(--gin-toolbar-y-offset);
  z-index: 101;
  padding: 0;
  width: 100%;
  display: flex;
  align-items: center;
  min-height: var(--gin-height-sticky);
  background: var(--gin-bg-app);
  box-sizing: border-box;
  transition: var(--gin-transition);

  .gin--edit-form & {
    top: calc(var(--gin-toolbar-y-offset) - var(--gin-spacing-xxl) - var(--gin-spacing-xxs));
    padding-top: var(--gin-spacing-m);

    @include mq(large) {
      top: var(--gin-toolbar-y-offset);
      padding-top: var(--gin-spacing-s);
    }
  }

  &-watcher {
    position: sticky;
    top: -1px;
    height: 0;
  }

  &--is-sticky {
    opacity: .95;
    background: var(--gin-bg-app);

    @supports (backdrop-filter: blur()) {
      opacity: .999;
      background: rgba(var(--gin-bg-app-rgb), .8);
      backdrop-filter: blur(12px);
    }

    .gin--high-contrast-mode & {
      background: var(--gin-bg-app);
      backdrop-filter: none;
    }
  }

  @include mq(large) {
    top: -1px;
    padding: var(--gin-spacing-s) 0;
    height: var(--gin-height-sticky);
    margin-bottom: 0;

    .gin--navigation &,
    .gin--vertical-toolbar &,
    .gin--horizontal-toolbar &,
    .gin--classic-toolbar & {
      top: var(--gin-toolbar-y-offset);
    }
  }

  &__items {
    display: flex;
    align-items: center;
    min-width: 0;
    width: 100%;
    height: 100%;

    @include mq(small) {
      .settings-tray-editable {
        flex-shrink: 0;
      }
    }

    &__inner {
      display: flex;
      flex-wrap: wrap;
      width: 100%;

      @include mq(large) {
        flex-wrap: nowrap;
        align-items: center;
        margin-bottom: 0;

        .block-page-title-block {
          margin: 0;
        }
      }
    }

    .block-page-title-block {
      flex-grow: 1;
      align-self: center;
      display: flex;
      margin: 0;
      min-width: 0;

      .page-title {
        align-self: center;
        margin: 0;
      }
    }

    .gin-sticky-form-actions {
      display: flex;
      width: auto;
      margin-top: 0;

      @include mq(large) {
        padding-left: var(--gin-spacing-l);
      }
    }

    #block-gin-local-actions + .gin-sticky-form-actions {
      padding-left: var(--gin-spacing-xs);
    }
  }
}

.content-header {
  padding-top: 0;
  margin-bottom: 0;
  background-color: transparent;
  overflow: initial;

  // Normalize whitespace if empty.
  @include mq(small) {
    &:not(:has(.layout-container *)) {
      margin-top: calc(var(--gin-spacing-m) * -1);
    }
  }
}

.sticky-shadow {
  @include mq(large) {
    z-index: 98;
    position: relative;
    pointer-events: none;
    height: 40px;
    margin: calc(var(--gin-spacing-xxxl) * -1) auto var(--gin-spacing-l);
    box-shadow: 0 10px 20px -16px rgba(0, 0, 0, .4);

    .gin--dark-mode & {
      box-shadow: none;
    }
  }

  @include mq(large) {
    position: sticky;
    top: calc(var(--gin-toolbar-y-offset) + (var(--gin-height-sticky) - 40px));
    width: calc(100% - min(10vw, 96px) + var(--gin-spacing-l));

    .gin--edit-form & {
      max-width: 1300px;
    }
  }
}

.page-wrapper {
  @include mq(large) {
    margin-top: 1px; // fix for top: auto;
  }
}

.toolbar-tray-open:not(.toolbar-vertical) .layout-container,
body:not(.toolbar-tray-open) .layout-container {
  margin-left: var(--gin-spacing-m);
  margin-right: var(--gin-spacing-m);

  @include mq(small) {
    margin-left: var(--gin-spacing-xl);
    margin-right: var(--gin-spacing-xl);
  }

  @include mq(medium) {
    margin-left: m#{i}n(5vw, var(--gin-spacing-xxl));
    margin-right: m#{i}n(5vw, var(--gin-spacing-xxl));

    .layout-container {
      margin-left: 0;
      margin-right: 0;
    }
  }
}

.gin-sticky-form-actions {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  width: 100%;

  @include mq(large) {
    flex-wrap: nowrap;
    width: max-content;
  }

  .form-actions {
    margin: 0;
    flex-grow: 1;
    align-items: center;
    justify-content: flex-end;
  }

  .field--name-status {
    display: flex;
    align-items: center;
    margin-right: var(--gin-spacing-s);

    .form-item__label {
      font-size: 0.8125rem;

      @include mq($to: tiny) {
        display: none;
      }
    }

    .form-type--checkbox {
      margin-top: var(--gin-spacing-xs);
      margin-bottom: var(--gin-spacing-xs);
    }
  }
}
