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

/**
 * @file
 * Replacement styles for table drag.
 *
 * Replaces core's tabledrag.module.css.
 *
 * @see tabledrag.js
 */

/*
 * When mouse is pressed, scrollbar disappears. This prevents the horizontal
 * layout shift from occurring
 */

html {
  scrollbar-gutter: stable;
}

body {
  &.drag {
    cursor: move;
  }

  &.drag-y {
    cursor: row-resize;
  }
}

.draggable-table {
  --table-row--dragging-bg-color: #fe7;
  --table-row--last-dragged-bg-color: #ffb;
  --tabledrag-handle-icon-size: 1.0625rem;

  /*
   * We remove all padding and hard-code the height of the <td> elements to
   * ensure that the "tree" icons span full height. You can replicate this in
   * the UI by clicking and holding down the drag icon. The tree icons will
   * become visible underneath.
   */
  :is(th, td) {
    height: 3.75rem;

    html[data-gin-layout-density="medium"] & {
      height: 3.125rem;
    }

    html[data-gin-layout-density="small"] & {
      height: 2.5rem;
    }

    .layer-wrapper {
      margin-block: var(--admin-space-density-s);
    }

    .draggable-table {
      margin-block: 0;
    }

    :is(th, td) {
      height: auto;
    }
  }

  /**
  * Reduce the spacing of draggable table cells.
  */
  & :is(th, td):first-child ~ :is(th, td) {
    padding-inline-start: 0;
  }
}

/* The block region's title row in table. */

.region-title {
  font-weight: bold;
}

/* Empty region message row in table. */

.region-message {
  color: var(--admin-color-text-soft);

  &.region-populated {
    /* If the region is populated, we shouldn't display the empty message. */
    display: none;
  }
}

/**
 * Remove border-bottom from abbr element. Class is duplicated in the selector
 * to increase weight to be able to win normalize.css selectors.
 */

.tabledrag-changed.tabledrag-changed {
  border-bottom: none;
}

.tabledrag-changed {
  /* Don't display the abbreviation of 'add-new' table rows. */
  .add-new & {
    display: none;
  }

  .draggable & {
    position: relative;
    inset-inline-start: calc(var(--admin-space-xs) * -1);
  }

  .tabledrag-cell--only-drag & {
    width: var(--admin-space-l);
    min-width: var(--admin-space-l);
  }
}

/**
 * Draggable row state colors.
 */

.draggable {
  &.region-title,
  &.region-title:focus {
    background-color: var(--table-row--dragging-bg-color);
  }

  &.region-title-previous {
    background-color: var(--table-row--last-dragged-bg-color);
  }

  &.drag-previous {
    background-color: var(--admin-color-bg-surface-nested);
    box-shadow: inset 6px 0 0 0 var(--admin-color-warning);

    &:dir(rtl) {
      box-shadow: inset -6px 0 0 0 var(--admin-color-warning);
    }

    &::after {
      position: absolute;
      width: 0.375rem;
      height: 100%;
      content: "";
    }

    @media (forced-colors: active) {
      position: relative;

      &::after {
        border-inline-start: 0.375rem solid linktext;
        inset-inline-start: 0;
      }
    }
  }

  &.drag,
  &.drag:focus {
    background-color: var(--admin-color-bg-surface-nested);

    .gin--dark-mode & {
      background-color: var(--admin-color-primary-soft-hover);
    }
  }

  /* Auto width for weight selects and number inputs. */
  td .form-element--type-select[name$="][_weight]"], /* Multiple field */
  td .term-weight, /* Taxonomy term list */
  td .field-weight /* Field UI table */ {
    width: auto;
  }

  a.tabledrag-handle {
    float: none;
    vertical-align: middle;
  }
}

/**
 * Handle styles.
 */

.tabledrag-handle {
  position: relative;
  z-index: 1;
  display: flex;
  overflow: visible;
  place-content: center;
  box-sizing: border-box;
  height: 2.75rem;
  cursor: move;
  text-align: center;
  vertical-align: text-top;
  margin-inline: calc(-1 * var(--admin-space-s)) var(--admin-space-s);
  padding-inline: var(--admin-space-s);

  &::after {
    display: inline-block;
    box-sizing: border-box;
    width: var(--tabledrag-handle-icon-size);
    height: var(--tabledrag-handle-icon-size);
    padding: var(--admin-space-xs);
    content: "";
    transition: transform 0.1s ease-in-out 0s;
    background-color: var(--admin-color-text-soft);
    mask-image: var(--admin-icon-drag);
    mask-repeat: no-repeat;
    mask-position: center center;
    mask-size: 1rem 1rem;

    @media (forced-colors: active) {
      background: linktext;
      mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 16 16'%3e%3cpath fill='%23000f33' d='M14.103 5.476a.5.5 0 00-.701-.053.526.526 0 00-.082.713l1.1 1.346H8.512V1.62l1.32 1.113a.501.501 0 00.732-.054.528.528 0 00-.085-.744L8.328.119a.5.5 0 00-.647 0L5.529 1.935a.527.527 0 00-.085.744.504.504 0 00.732.054l1.32-1.113v5.862H1.588L2.68 6.136a.526.526 0 00-.1-.68.5.5 0 00-.675.02L.117 7.67a.525.525 0 000 .66l1.788 2.194a.5.5 0 00.702.053.526.526 0 00.081-.713l-1.1-1.346h5.908v5.862l-1.32-1.113a.501.501 0 00-.698.082.526.526 0 00.051.716l2.152 1.817v-.001a.5.5 0 00.647 0l2.151-1.816a.526.526 0 00.052-.716.501.501 0 00-.699-.082l-1.32 1.113V8.518h5.908l-1.091 1.346a.527.527 0 00.022.776.504.504 0 00.752-.116l1.78-2.194a.527.527 0 000-.66z'/%3e%3c/svg%3e");
      mask-repeat: no-repeat;
      mask-position: center;

      @supports (mask-composite: source-over) {
        background-color: var(--admin-color-text-soft);
      }
    }
  }

  &:focus {
    outline-offset: calc(-1 * var(--outline-size, 0px));
  }

  &:hover {
    &::after {
      transform: scale(1);

      @media (forced-colors: none) {
        background-color: var(--admin-color-primary);
      }
    }
  }
}

/* Change icon and cursor if only vertical drag is allowed. */

.tabledrag-handle.tabledrag-handle-y {
  cursor: row-resize;

  &::after {
    mask-image: var(--admin-icon-drag-y);
  }
}

.tabledrag-handle::after,
.tabledrag-disabled .tabledrag-handle.tabledrag-handle.tabledrag-handle::after {
  transform: scale(1);
}

.tabledrag-handle:is(:hover, :focus)::after,
.draggable.drag .tabledrag-handle::after {
  transform: scale(1.25);
}

/* Disabled tabledrag handle. */

.tabledrag-disabled {
  & .tabledrag-handle {
    cursor: default;
    opacity: 0.4;

    &.tabledrag-handle::before {
      content: none;
    }
  }
}

/**
 * Enhancements for touch-capable screens.
 */

/**
 * Increase handle size.
 */

.touchevents {
  & .tabledrag-handle::after {
    padding-block: var(--admin-space-s);
  }

  & .draggable .menu-item__link {
    padding-block: var(--admin-space-xs);
  }
}

/**
 * Wrapper of the toggle weight button (styled as a link).
 */

.tabledrag-toggle-weight-wrapper {
  text-align: end;
  line-height: calc(28rem / 16);

  & + table,
  & + .tableresponsive-toggle-columns + table {
    margin-block-start: 0;
  }

  /* Hide nested weight toggles as they are redundant. */
  .draggable-table & {
    display: none;
  }

  #field-display-overview,
  #field-display-overview-wrapper,
  .field--widget-entity-reference-paragraphs,
  .field--type-link,
  .field--type-smartdate {
    .gin-layer-wrapper > & {
      .action-link {
        pointer-events: all;
        background-color: var(--admin-color-bg-surface);
      }
      @media (min-width: 61em) {
        position: relative;
        z-index: 1;
        margin-block-end: calc(var(--admin-space-2xl) * -1);
        pointer-events: none;
      }
    }
  }

  .action-link {
    margin-block-end: var(--admin-space-xs);

    .action-link {
      margin-block-end: 0;
    }
  }
}

/**
 * If the first table cell is empty (like in a multiple field widget table),
 * we can save some space for the following cells.
 * If it isn't empty (Field UI table, taxonomy term overview page), this CSS
 * class won't be added.
 */

.tabledrag-cell--only-drag {
  width: 1px; /* This forces this cell to use the smallest possible width. */
  padding-inline-end: 0;
}

.tabledrag-cell-content {
  display: flex;
  align-items: center;
  height: 100%;

  & > * {
    display: table-cell;
    vertical-align: middle;
  }

  & .tree {
    flex-grow: 1;
  }

  & .tabledrag-handle::after {
    vertical-align: middle;
  }

  .table-file-multiple-widget & {
    display: flex;
  }
}

.tabledrag-cell-content__item {
  display: flex;
  align-items: center;
  padding-inline-end: var(--admin-space-xs);

  &:empty {
    display: none;
  }
}

/**
 * Indentation.
 */

.indentation {
  position: relative;
  display: inline-flex;
  overflow: clip;
  flex-direction: column;
  height: calc(100% + var(--cell-padding-y) * 2);
  inset-inline-start: calc(var(--admin-space-xs) * -0.5);
  margin-block: calc(-1 * var(--cell-padding-y));
}

/**
 * Tree is the visual representation for the simultaneously moved draggable
 * rows.
 *
 * These rules are styling the inline SVG that is placed inside the .indentation
 * element.
 */

.tree {
  width: 1.5625rem;
  height: 1.5625rem;
}

.tree__item {
  display: none;
}

/* LTR tree child. */

.tree-child path {
  &:not(.tree__item-child-ltr) {
    display: none;
  }

  &.tree__item-child-ltr {
    display: block;
  }
}

/* RTL tree child. */

[dir="rtl"] {
  & .tree-child path {
    &:not(.tree__item-child-rtl) {
      display: none;
    }
    &.tree__item-child-rtl {
      display: block;
    }
  }

  /* Last RTL tree child. */
  & .tree-child-last path {
    &:not(.tree__item-child-last-rtl) {
      display: none;
    }
    &.tree__item-child-last-rtl {
      display: block;
    }
  }
}

/* Last LTR tree child. */

.tree-child-last path {
  &:not(.tree__item-child-last-ltr) {
    display: none;
  }
  &.tree__item-child-last-ltr {
    display: block;
  }
}

/* Horizontal line. */

.tree-child-horizontal path {
  &:not(.tree__item-horizontal) {
    display: none;
  }

  &.tree__item-horizontal {
    display: block;
  }
}

/* @todo do these styles belong here? They were migrated from Gin. */

.field-plugin-settings-edit-wrapper,
.field-plugin-settings-edit-wrapper + a {
  margin-block: var(--admin-space-m);
}

.field-plugin-settings-edit-wrapper + a {
  margin-block-start: var(--admin-space-s);
}

/* Correctly align bulk action checkboxes when used in combination with tabledrag */

table:has(.tabledrag-cell-content__item .form-checkbox) th.select-all .form-checkbox {
  margin-inline-start: calc(var(--tabledrag-handle-icon-size, calc(17rem / 16)) + var(--admin-space-m));
}
