/*
 * DO NOT EDIT THIS FILE.
 * See the following change record for more information,
 * https://www.drupal.org/node/3084859
 * @preserve
 */

/**
 * @file
 * Dropbutton styles.
 *
 * Transparent border is needed for high contrast mode. The border-width has to
 * be set with !important to render borders with the defined width in high
 * contrast mode Firefox.
 *
 * @todo This file is overcomplicated and needs to be refactored.
 */

:root {
  /**
  * Dropbutton
  */
  --dropbutton-spacing-size: var(--admin-space-m);
  --dropbutton-font-size: var(--admin-font-size-m);
  --dropbutton-line-height: var(--admin-space-m);
  --dropbutton-toggle-size: 3rem;
  --dropbutton-border-size: 1px;
  --dropbutton-toggle-size-spacing: var(--dropbutton-border-size);
  --dropbutton-border-radius-size: 2px;
  --dropbutton-item-max-width: 12.5rem;
  /* Variant variables: small. */
  --dropbutton-small-spacing-size: 0.625rem;
  --dropbutton-small-font-size: var(--admin-font-size-xs);
  --dropbutton-small-line-height: 0.75rem;
  --dropbutton-small-toggle-size: calc((2 * var(--dropbutton-small-spacing-size)) + var(--dropbutton-small-line-height));
  /* Variant variables: extra small. */
  --dropbutton-extrasmall-spacing-size: 0.375rem;
  --dropbutton-extrasmall-font-size: var(--admin-font-size-xs);
  --dropbutton-extrasmall-line-height: 0.75rem;
  --dropbutton-extrasmall-toggle-size: calc((2 * var(--dropbutton-extrasmall-spacing-size)) + var(--dropbutton-extrasmall-line-height));
}

.dropbutton-wrapper {
  display: inline-flex;
  border-radius: var(--button-border-radius-size);
  box-shadow: none;
}

.form-actions .dropbutton-wrapper,
.field-actions .dropbutton-wrapper {
  margin-block: var(--admin-space-xs);
  margin-inline: 0 var(--admin-space-m);
}

.dropbutton-widget {
  position: relative;
  flex: 1 1 auto;
  border-radius: var(--button-border-radius-size);
  background-color: transparent;

  .js .dropbutton-wrapper.open & {
    z-index: var(--dropbutton-widget-z-index);
  }
}

/**
 * Dropbutton list.
 */

.dropbutton {
  display: block;
  overflow: visible;
  min-width: 6rem;
  /* Help mitigate long dropbutton text from obscuring other dropbuttons. */
  height: var(--dropbutton-toggle-size);
  margin: 0;
  list-style: none;
  border: 2px solid var(--admin-color-primary);
  border-radius: var(--admin-radius-m);
  box-shadow: 0 1px 2px var(--admin-color-primary-soft);

  .gin--dark-mode & {
    box-shadow: 0 4px 18px var(--admin-color-shadow-button);
  }

  &:hover {
    border-color: var(--admin-color-primary);
  }

  &:active {
    border-color: var(--admin-color-primary-active);
  }

  .dropbutton__items {
    position: absolute;
    min-width: 7.5rem;
    margin: 0;
    padding: 0.5em;
    list-style: none;
    border-radius: var(--admin-radius-l);
    background: var(--admin-color-bg-raised);
    box-shadow: var(--admin-shadow-2);
    inset-inline-end: 0;

    .node-form & {
      inset-inline-start: 0;
      inset-inline-end: auto;
    }

    @media (forced-colors: active) {
      border: 1px solid linktext;
    }
  }

  > .dropbutton__items > .dropbutton__item:first-of-type {
    > a,
    > input,
    > .button {
      border-radius: var(--admin-radius-s) var(--admin-radius-s) 0 0;
    }
  }

  /* Drupal 10.2.x fix */
  &.dropbutton--gin .dropbutton-action > .button {
    border: var(--dropbutton-border-size) solid transparent !important;
  }

  /* The ugly part: make it work for all different dropbutton versions out there */
  &:not(.dropbutton--gin) > .dropbutton__item ~ .dropbutton__item,
  .dropbutton__items > .dropbutton__item,
  .dropbutton__items > .dropbutton__item ~ .dropbutton__item {
    border: 0 none;
    background-color: var(--admin-color-bg);
    box-shadow: none;

    &:first-of-type {
      margin-inline-end: 0;
    }

    /* Multiple Dropbutton only has one item */
    &:first-of-type:last-of-type > * {
      .js .dropbutton--multiple & {
        border-radius: var(--admin-radius-s);
      }
    }

    > a,
    > input,
    > .button {
      display: block;
      overflow: hidden;
      box-sizing: border-box;
      width: 100%;
      max-width: 20rem;
      margin: 0;
      text-align: start;
      white-space: nowrap;
      text-overflow: ellipsis;
      color: var(--admin-color-primary);
      border: 0 none !important;
      border-radius: 0;
      background: var(--admin-color-bg-raised);
      box-shadow: none;
      font-weight: var(--admin-font-weight-heavy);

      &:focus {
        outline-offset: -2px;
      }

      &:hover,
      &:active {
        color: var(--admin-color-text-on-primary);
        border-radius: var(--admin-radius-s);
        background: var(--admin-color-primary);
      }
    }
  }

  & > .dropbutton__item:first-of-type {
    > a,
    > input,
    > .button {
      &:hover,
      &:active {
        color: var(--admin-color-text-on-primary);
        background: var(--admin-color-primary);
      }
    }
  }

  .dropbutton__items > .dropbutton__item {
    border-radius: var(--admin-radius-s);
  }

  /* Shadow for pseudo dropdown on views page */
  &:not(.dropbutton--gin) > .dropbutton__item.secondary-action {
    box-shadow: var(--admin-shadow-2);
  }

  &:not(.dropbutton--gin) > .dropbutton__item:not(:first-of-type),
  .dropbutton__items > .dropbutton__item,
  > .dropbutton__items > .dropbutton__item ~ .dropbutton__item {
    > a,
    > input,
    > .button {
      padding: 0.75em 1em !important;
      font-size: var(--admin-font-size-s) !important;
    }
  }
}

/* Variants. */

.dropbutton--small {
  height: var(--dropbutton-small-toggle-size);
}

.dropbutton--extrasmall {
  height: var(--dropbutton-extrasmall-toggle-size);
}

/**
 * First dropbutton list item.
 */

.dropbutton--multiple .dropbutton__item:first-of-type {
  height: 100%;
  margin-right: calc(var(--dropbutton-toggle-size) + var(--dropbutton-toggle-size-spacing));
  white-space: nowrap;
  border-inline-end: 1px solid var(--admin-color-primary-soft-active);

  input {
    height: 100%;
    color: var(--admin-color-primary);
    border: 0 none !important;
    border-radius: 0 !important;
    background-color: transparent;
  }

  /* LTR */
  [dir="rtl"] & {
    margin-right: 0;
    margin-left: calc(var(--dropbutton-toggle-size) + var(--dropbutton-toggle-size-spacing));
  }
}

/* First dropbutton list item variants */

.no-touchevents .dropbutton--multiple.dropbutton--small .dropbutton__item:first-of-type {
  margin-right: calc(var(--dropbutton-small-toggle-size) + var(--dropbutton-toggle-size-spacing));
  /* LTR */
  white-space: nowrap;

  [dir="rtl"] & {
    margin-right: 0;
    margin-left: calc(var(--dropbutton-small-toggle-size) + var(--dropbutton-toggle-size-spacing));
  }
}

.no-touchevents .dropbutton--multiple.dropbutton--extrasmall .dropbutton__item:first-of-type {
  margin-right: calc(var(--dropbutton-extrasmall-toggle-size) + var(--dropbutton-toggle-size-spacing));
  /* LTR */
  white-space: nowrap;

  [dir="rtl"] & {
    margin-right: 0;
    margin-left: calc(var(--dropbutton-extrasmall-toggle-size) + var(--dropbutton-toggle-size-spacing));
  }
}

/**
 * Dropbutton toggler.
 */

.dropbutton__toggle {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  inset-block-start: 2px;
  inset-inline-end: 2px;
  bottom: 0;
  width: calc(var(--admin-space-2xl) + 1px);
  height: 2.75rem;
  white-space: nowrap;
  border: var(--dropbutton-border-size) solid transparent !important;
  /* 1 */
  border-inline-start: var(--dropbutton-border-size, 1px) solid var(--admin-color-primary) !important;
  border-radius: 0 var(--button-border-radius-size) var(--button-border-radius-size) 0;
  /* LTR */
  background: none;
  box-shadow: none;
  font-size: var(--admin-font-size-s);
  font-weight: var(--admin-font-weight-semibold);
  appearance: none;

  [dir="rtl"] & {
    right: auto;
    left: 0;
    border-radius: var(--button-border-radius-size) 0 0 var(--button-border-radius-size);
  }

  &::before {
    position: absolute;
    top: 50%;
    right: 50%;
    width: 0.875rem;
    height: 0.5625rem;
    content: "";
    transform: translate(50%, -50%) rotate(0);
    background: url("data:image/svg+xml,%3csvg width='14' height='9' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M.238 1.938L1.647.517 7 5.819 12.354.517l1.408 1.421L7 8.636z' fill='%23000f33'/%3e%3c/svg%3e") no-repeat center;
    background-size: contain;
  }

  /* Toggler states. */
  &:hover {
    color: var(--admin-color-text-on-primary);
    background-color: var(--admin-color-primary);
    box-shadow: 0 2px 4px rgb(0, 0, 0, 0.25);
  }

  &:focus {
    z-index: 2;
  }

  &:active {
    color: var(--admin-color-text-on-primary);
    background-color: var(--button--active-bg-color);
  }

  @media (prefers-reduced-motion: no-preference) {
    transition: var(--admin-transition);
  }

  @media (--admin-wide) {
    font-size: var(--admin-font-size-m);
  }

  @media (forced-colors: active) {
    border-width: 0 !important;
  }

  @media not (forced-colors: active) {
    &::before {
      background-color: var(--admin-color-primary);
      background-image: none;
      mask-image: var(--admin-icon-drop);
      mask-repeat: no-repeat;
      mask-position: center center;
      mask-size: 0.75rem 0.75rem;
    }

    &:hover::before,
    &:active::before {
      background-color: var(--admin-color-text-on-primary);
    }
  }
}

.dropbutton-wrapper.open .dropbutton__toggle::before {
  transform: translate(50%, -50%) rotate(180deg);

  [dir="rtl"] & {
    transform: translate(50%, -50%) rotate(-180deg);
  }
}

/* Toggler variants */

.no-touchevents .dropbutton--small .dropbutton__toggle {
  width: var(--dropbutton-small-toggle-size);
  height: var(--dropbutton-small-toggle-size);
}

.no-touchevents .dropbutton--extrasmall .dropbutton__toggle {
  width: var(--dropbutton-extrasmall-toggle-size);
  height: var(--dropbutton-extrasmall-toggle-size);
}

.no-touchevents .dropbutton--small .dropbutton__toggle::before,
.no-touchevents .dropbutton--extrasmall .dropbutton__toggle::before {
  width: 0.75rem;
  /* 12px */
}

/* High contrast. */

@media (forced-colors: active) {
  /* Default. */
  .dropbutton__toggle::before {
    width: 0.5625rem;
    height: 0.5625rem;
    margin-top: calc(0.5625rem / (2 * -1.41429));
    transform: translate(50%, -50%) rotate(135deg);
    /* LTR */
    border-width: 0.125rem 0.125rem 0 0;
    border-style: solid;
    background: none;

    .dropbutton-wrapper.open & {
      margin-top: calc(0.5625rem / (2 * 1.41429));
      transform: translate(50%, -50%) rotate(315deg);
    }

    [dir="rtl"] .dropbutton-wrapper.open & {
      transform: translate(50%, -50%) rotate(-45deg);
    }
  }

  /* Variants */
  .no-touchevents .dropbutton--small .dropbutton__toggle::before,
  .no-touchevents .dropbutton--extrasmall .dropbutton__toggle::before {
    width: 0.4375rem;
    height: 0.4375rem;
    margin-top: calc(0.4375rem / (2 * -1.41429));
  }

  .dropbutton-wrapper.open .dropbutton__toggle::before {
    margin-top: calc(0.4375rem / (2 * 1.41429));
  }
}

/**
 * Item in the first dropbutton list item (that looks like a button).
 *
 * Duplicates base button styles.
 */

.dropbutton__item:first-of-type {
  & > * {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    margin: 0;
    padding: calc(0.875rem - 1px) calc(var(--admin-space-l) - 1px);
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    -webkit-text-decoration: none;
    text-decoration: none;
    color: var(--admin-color-primary);
    border: var(--dropbutton-border-size) solid transparent !important;
    /* 1 */
    border-radius: var(--button-border-radius-size);
    background: none;
    box-shadow: none;
    font-size: var(--admin-font-size-s);
    font-weight: var(--admin-font-weight-semibold);
    line-height: var(--dropbutton-line-height);
    appearance: none;
    -webkit-font-smoothing: antialiased;

    /* This is a fix for when an <input> is the first item within a dropdown.
    This can be replicated using the theming_tools development contrib module. */
    &:not(:is(:hover)) {
      color: var(--admin-color-primary) !important;
    }

    &:hover {
      background-color: var(--admin-color-primary-hover);
    }

    &:active {
      background-color: var(--admin-color-primary-active);
    }

    &:hover,
    &:active {
      color: var(--admin-color-text-on-primary);
    }

    @media (prefers-reduced-motion: no-preference) {
      transition: var(--admin-transition);
    }

    @media (--admin-wide) {
      font-size: var(--admin-font-size-m);
    }

    @media (forced-colors: active) {
      border-width: 0 !important;
    }
  }

  .dropbutton--multiple & > * {
    padding-inline: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size));
  }

  /* Variants */
  .no-touchevents .dropbutton--small & > * {
    padding-block: calc(var(--dropbutton-small-spacing-size) - var(--dropbutton-border-size));
    font-size: var(--dropbutton-small-font-size);
    line-height: var(--dropbutton-small-line-height);
  }

  .no-touchevents .dropbutton--extrasmall & > * {
    padding-top: calc(var(--dropbutton-extrasmall-spacing-size) - var(--dropbutton-border-size));
    padding-bottom: calc(var(--dropbutton-extrasmall-spacing-size) - var(--dropbutton-border-size));
    font-size: var(--dropbutton-extrasmall-font-size);
    line-height: var(--dropbutton-extrasmall-line-height);
  }

  & > *:hover,
  & > .button:hover {
    -webkit-text-decoration: none;
    text-decoration: none;
    color: var(--button-fg-color);
    background-color: var(--button--hover-bg-color);
    box-shadow: 0 2px 4px rgb(0, 0, 0, 0.25);
  }

  & > *:active {
    color: var(--button-fg-color);
    background-color: var(--button--active-bg-color);
  }

  .dropbutton--multiple & > * {
    position: relative;
    z-index: 3;
  }

  .dropbutton--multiple & > *:focus {
    z-index: 2;
  }

  .dropbutton--multiple & > * {
    border-radius: var(--button-border-radius-size) 0 0 var(--button-border-radius-size);
    /* LTR */
  }

  & ~ .dropbutton__item__item ~ .dropbutton__item:last-child {
    border-color: var(--admin-color-primary);
  }

  [dir="rtl"] .dropbutton--multiple & > * {
    border-radius: 0 var(--button-border-radius-size) var(--button-border-radius-size) 0;
  }
}

.dropbutton > .dropbutton__item > a,
.dropbutton > .dropbutton__item > .button {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  text-align: left;
  /* LTR */
}

[dir="rtl"] .dropbutton > .dropbutton__item > a,
[dir="rtl"] .dropbutton > .dropbutton__item > .button {
  text-align: right;
}

.dropbutton-wrapper:not(.open) .dropbutton__item:first-of-type ~ .dropbutton__item {
  visibility: hidden;
  /**
  * By setting a height of 1px, the dropbutton items are hidden
  * from view while still occupying minimal space, ensuring the layout remains intact.
  */
  height: 1px;
}

/**
 * Non-first dropbutton list elements.
 */

.dropbutton__item:first-of-type ~ .dropbutton__item {
  max-width: unset;
  border: var(--dropbutton-border-size) solid var(--admin-color-primary);
  border-bottom: 0;
  box-shadow: 0 2px 10px rgb(0, 0, 0, 0.15);

  & ~ .dropbutton__item {
    border-top: 0;
  }

  & > *:hover {
    background-color: var(--admin-color-bg-raised);
  }
}

.dropbutton__item ~ .dropbutton__item:last-child {
  border-bottom: var(--dropbutton-border-size) solid var(--admin-color-border);
  border-radius: 0 0 var(--dropbutton-border-radius-size) var(--dropbutton-border-radius-size);
}

/**
 * Dropbutton items of non-first dropbutton list elements.
 */

.dropbutton__item:first-of-type ~ .dropbutton__item {
  max-width: var(--dropbutton-item-max-width);
}

.dropbutton__item:first-of-type ~ .dropbutton__item > a,
.dropbutton__item:first-of-type ~ .dropbutton__item > .button {
  position: relative;
  padding: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size));
  white-space: normal;
  -webkit-text-decoration: none;
  text-decoration: none;
  color: var(--admin-color-text-soft);
  border: var(--dropbutton-border-size) solid transparent !important;
  /* 1 */
  border-radius: var(--dropbutton-border-radius-size);
  background: var(--admin-color-bg-raised);
  box-shadow: none;
  font-size: var(--dropbutton-font-size);
  font-weight: normal;
  line-height: var(--dropbutton-line-height);
  -webkit-font-smoothing: antialiased;
}

.dropbutton__item:first-of-type ~ .dropbutton__item > a:not(:focus),
.dropbutton__item:first-of-type ~ .dropbutton__item > .button:not(:focus) {
  z-index: 1;
}

/* Variants. */

.no-touchevents .dropbutton--small .dropbutton__item:first-of-type ~ .dropbutton__item > a,
.no-touchevents .dropbutton--small .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
  padding-top: var(--dropbutton-small-spacing-size);
  padding-bottom: var(--dropbutton-small-spacing-size);
  font-size: var(--dropbutton-small-font-size);
  line-height: var(--dropbutton-small-line-height);
}

.no-touchevents .dropbutton--extrasmall .dropbutton__item:first-of-type ~ .dropbutton__item > a,
.no-touchevents .dropbutton--extrasmall .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
  padding-top: var(--dropbutton-extrasmall-spacing-size);
  padding-bottom: var(--dropbutton-extrasmall-spacing-size);
  font-size: var(--dropbutton-extrasmall-font-size);
  line-height: var(--dropbutton-extrasmall-line-height);
}

/* States. */

.dropbutton__item {
  & > *:focus {
    position: relative;
    z-index: 3;
  }

  &:first-of-type ~ & > *:hover {
    color: var(--admin-color-text);
    background: var(--admin-color-bg-surface-nested);
  }

  & > .button:not(:focus) {
    box-shadow: none;
  }

  &:first-of-type ~ & > *:focus {
    border-color: var(--admin-color-focus) !important;
    /* 1 */
    box-shadow:
      inset 0 0 0 1px var(--admin-color-focus),
      0 0 0 1px var(--admin-color-focus);
  }
}

/* Overlay the dropdown button on top of the sticky header and main toolbar */

html.js {
  .dropbutton-wrapper.open {
    .dropbutton-widget {
      z-index: 502;
      /* Above toolbar and sticky header */
    }

    .dropbutton {
      background: var(--admin-color-bg-raised);
    }
  }

  .dropbutton {
    box-sizing: border-box;
    height: 3rem;
    min-height: 3rem;
  }

  .dropbutton-wrapper:not(.open) .dropbutton__items {
    visibility: hidden;
    opacity: 0;
  }

  .dropbutton-wrapper .dropbutton__items {
    visibility: visible;
    overflow: auto;
    max-height: 30vh;
    opacity: 1;
  }

  .dropbutton-wrapper:not(.open) .dropbutton__item:first-of-type ~ .dropbutton__items {
    display: none;
  }

  .dropbutton-wrapper:not(.open) .dropbutton__items .dropbutton__item:first-of-type ~ .dropbutton__item {
    display: block;
    height: auto;
  }
}

html.js.no-touchevents {
  .dropbutton--multiple.dropbutton--small .dropbutton__item:first-of-type {
    margin-inline-end: 0;
  }

  .dropbutton--multiple.dropbutton--small > .dropbutton__item:first-of-type {
    margin-inline-end: var(--admin-space-xl);
  }

  .dropbutton--multiple.dropbutton--extrasmall > .dropbutton__item:first-of-type {
    margin-inline-end: var(--admin-space-l);
  }

  .dropbutton--small {
    min-width: 0;
    height: 2.25rem;
    min-height: 2.25rem;
    border-radius: var(--admin-radius-s);

    .dropbutton__toggle {
      width: calc(var(--dropbutton-small-toggle-size, 2rem) + 1px);
    }
  }

  .dropbutton--extrasmall {
    min-width: 0;
    height: 1.75rem;
    min-height: 1.75rem;
    border-radius: var(--admin-radius-s);

    .dropbutton__toggle {
      width: calc(var(--dropbutton-extrasmall-toggle-size, 1.5rem) + 1px);
    }

    .dropbutton__item:first-of-type > * {
      padding-inline: var(--admin-space-s);
    }
  }

  .dropbutton--multiple.dropbutton--extrasmall .dropbutton__items .dropbutton__item {
    margin-inline-end: 0;
  }
}
