.search-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;

  .search-popup-toggle {
    position: relative;
    z-index: z(menu, icon);
    cursor: pointer;

    &:hover, &:focus {
      &::before {
        color: $color-gray-900;

        @include breakpoint(medium) {
          color: $color-primary-600;
        }
      }
    }

    @include breakpoint(small down) {
      position: absolute;
      top: calc(24px + var(--tabs-offset-y, 0px) - 2px);
      right: 54px;
      transform: translate3d(100%, 0, 0);
      opacity: 0;
      @include global-transition(transform);
    }

    @include replace-text-with-icon(search) {
      font-size: rem-calc(24);
      color: $color-white;

      @include breakpoint(medium) {
        color: $color-gray-900;
      }
    }
  }

  .search-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: z(popup);
    height: 100vh;
    width: 100vw;
    @include top-bottom(padding, calc(24px + var(--tabs-offset-y, 0px) - 2px));
    background: $color-white;
    overflow-y: auto;

    @include breakpoint(medium) {
      --search-popup-offset-y: calc(var(--header-offset) + var(--gin-toolbar-y-offset, 0px) + var(--tabs-offset-y, 0px));

      top: var(--search-popup-offset-y);
      border-top: 1px solid $color-gray-300;
      height: calc(100vh - var(--search-popup-offset-y));
    }

    @include breakpoint(small down) {
      width: rem-calc(326);
      max-width: 90vw;
    }

    .search-popup-wrapper {
      position: relative;
      @include content-width(default);
      max-width: 1000px;
    }

    .search-title {
      margin-bottom: 32px;

      @include breakpoint(medium) {
        margin-bottom: 50px;
        font-size: rem-calc(40);
      }
    }

    .view-search {
      color: $color-gray-900;

      .view-filters {
        margin-bottom: 32px;

        @include breakpoint(medium) {
          margin-bottom: 50px;
        }

        .form--inline {
          display: flex;
          align-items: flex-end;
        }

        .form-item-search-api-fulltext {
          display: flex;
          flex-direction: column;
          gap: 8px;
          margin: 0;
          flex-grow: 1;

          label {
            font-weight: $global-weight-bold;
            font-size: rem-calc(16);

            @include breakpoint(medium) {
              font-size: rem-calc(20);
            }
          }

          input {
            padding: 6px 14px;
            border: 1px solid $color-gray-900;
            border-right: 0;
            width: 100%;
            font-size: rem-calc(14);
            line-height: rem-calc(22);
            color: $color-gray-900;

            @include breakpoint(medium) {
              font-size: rem-calc(18);
              padding: 12px 20px;
            }

            &:hover, &:focus {
              outline: none;
              border-color: $color-primary-600;
            }

            &::placeholder {
              font-style: italic;
              color: $color-gray-500;
            }
          }
        }

        .form-actions {
          margin: 0;
          flex-shrink: 0;

          .form-submit {
            @include btn(primary);
            border: 0;
            padding: 6px 34px 6px 14px;
            text-transform: capitalize;
            letter-spacing: 0;
            background-image: url('../../../assets/images/svg/icons/search-light.svg');
            background-repeat: no-repeat;
            background-size: 14px 14px;
            background-position: calc(100% - 14px) center;

            @include breakpoint(medium) {
              padding: 12px 48px 12px 22px;
              font-size: rem-calc(18);
              background-size: 18px 18px;
              background-position: calc(100% - 22px) center;
            }
          }
        }
      }

      .view-content {
        display: flex;
        flex-direction: column;
        gap: 24px;

        .node {
          padding-inline: 12px;

          @include breakpoint(medium) {
            padding-inline: 24px;
          }

          a:has(.title, .field--name-title) {
            font-size: rem-calc(18);
            font-weight: $global-weight-bold;
            color: $color-gray-900;
            line-height: 1.2;

            &:hover, &:focus {
              color: $color-primary-600;
            }
          }

          .info {
            margin-top: 2px;
            margin-bottom: 8px;
            line-height: 1.2;

            @include breakpoint(medium) {
              margin-top: 0;
            }

            .bundle, .date, .field--name-field-date-range {
              display: inline;
              font-size: rem-calc(10);
              font-weight: $global-weight-medium;
              text-transform: uppercase;
            }

            .bundle {
              padding-right: 10px;
              color: $color-primary-600;
            }

            .date, .field--name-field-date-range {
              color: $color-gray-500;
            }
          }

          .field--name-field-intro, & > * {
            font-size: rem-calc(14);
            line-height: 1.2;

            @include breakpoint(medium) {
              font-size: rem-calc(16);
            }
          }
        }
      }

      .pager-show-more {
        margin-top: 32px;

        .pager__item {
          a {
            position: relative;
            line-height: 1.2;
            font-size: rem-calc(16);
            padding: 0 0 4px;
            font-weight: $global-weight-medium;
            color: $color-primary-700;

            &::after {
              content: '';
              position: absolute;
              bottom: 0;
              left: 0;
              width: 100%;
              height: 2px;
              background-color: $color-primary-600;
              transform: scaleX(0);
              transform-origin: right;
              @include global-transition(transform);
            }

            &:hover, &:focus {
              &::after {
                transform: scaleX(1);
              }
            }
          }
        }
      }
    }

    .close-popup {
      position: absolute;
      top: 0;
      right: 16px;
      font-size: 0;
      cursor: pointer;
      color: $color-gray-900;

      @include breakpoint(medium) {
        right: 32px;
        display: flex;
        align-items: center;
        gap: 2px;
        font-size: 16px;
        font-weight: $global-weight-medium;
        color: $color-primary-600;
      }

      &:hover, &:focus {
        color: $color-primary-700;
      }

      @include icon-before(close) {
        font-size: 24px;
      }
    }
  }

  &.is-search-open {
    .search-popup {
      display: block;
    }
  }

  // Render search btn with transition when mobile menu opens.
  .navigation-wrapper.is-active & {
    .search-popup-toggle {
      @include breakpoint(small down) {
        opacity: 1;
        transform: translate3d(0, 0, 0);
      }
    }
  }
}
