/**
 * @file
 * Theme settings page styles.
 */

[data-drupal-selector="edit-preset-accent-color"] .form-radios {
  display: flex;
  flex-wrap: wrap;
  margin-block-start: var(--admin-space-xs);

  .form-item--preset-accent-color {
    position: relative;

    input {
      width: 32px;
      height: 32px;
      margin-inline-end: var(--admin-space-xs);
      cursor: pointer;
      border-color: transparent;
      inset-block-start: var(--admin-space-m);

      &:hover {
        box-shadow: none;
      }

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

      &:focus:checked,
      &:focus,
      &:checked {
        background-color: var(--admin-color-primary);
      }

      &[data-gin-accent="custom"] {
        border-color: var(--admin-color-border);
        background-color: #fff;
        background-image: url(../../images/settings/custom-color.jpg);
        background-repeat: no-repeat;
        background-size: 100%;

        &:checked {
          border-width: 1px;
          border-color: var(--admin-color-border);
          background-color: #fff;
        }
      }
    }

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

    .form-item__label {
      position: absolute;
      z-index: 1;
      overflow: hidden;
      clip: rect(1px, 1px, 1px, 1px);
      width: 1px;
      height: 1px;
      padding: var(--admin-space-xs);
      transform: translateX(-50%);
      background: var(--admin-color-bg-surface-nested);
      inset-block-start: 100%;
      inset-inline-start: -10px;

      &:dir(rtl) {
        transform: translateX(50%);
      }
    }

    &:hover .form-item__label,
    input:active ~ .form-item__label,
    input:focus ~ .form-item__label {
      overflow: revert;
      clip: revert;
      width: max-content;
      height: revert;
    }
  }
}

[data-drupal-selector="edit-accent-group"] .form-type--color,
[data-drupal-selector="edit-accent-group"] .form-type--textfield,
[data-drupal-selector="edit-focus-group"] .form-type--color,
[data-drupal-selector="edit-focus-group"] .form-type--textfield {
  float: inline-start;
  margin: 0;
  margin-block-end: var(--admin-space-xs);
}

[data-drupal-selector="edit-accent-group"] .form-type--color,
[data-drupal-selector="edit-focus-group"] .form-type--color {
  margin-inline-end: var(--admin-space-xs);
}

[data-drupal-selector="edit-accent-group"] .fieldset__description,
[data-drupal-selector="edit-focus-group"] .fieldset__description {
  clear: both;
}

[data-drupal-selector="edit-enable-dark-mode"] .form-radios {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 0 var(--admin-space-2xs);
  border: 1px solid var(--admin-color-border-input);
  border-radius: var(--admin-space-xl);

  .gin--dark-mode & {
    background: var(--admin-color-bg-surface-nested);
  }

  .form-type--radio {
    margin-block: 0;
    margin-inline-start: 0;
  }

  .form-item__label {
    display: inline-block;
    box-sizing: border-box;
    margin: var(--admin-space-2xs) 0;
    padding: 0.375rem var(--admin-space-m);
    border: 2px solid transparent;
    border-radius: var(--admin-radius-xl);

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

  input {
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    border: 0;

    &:checked + .form-item__label {
      color: var(--admin-color-text-on-primary);
      background: var(--admin-color-primary);
    }

    &:focus + .form-item__label {
      outline: var(--focus-outline);
    }
  }
}

[data-drupal-selector="edit-layout-density"] .form-radios {
  display: flex;
  flex-wrap: wrap;
  margin-block-start: var(--admin-space-xs);

  .form-item {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    width: 140px;
    margin: 0;
    margin-inline-end: var(--admin-space-s);

    input {
      position: static;
      width: 140px;
      height: 100px;
      margin-inline-start: 0;
      cursor: pointer;
      transform: none;
      border-radius: var(--admin-radius-l);
      background-repeat: no-repeat;
      background-size: 100% 100%;

      &:checked {
        border-color: var(--admin-color-primary);
        box-shadow: inset 0 0 0 1px var(--admin-color-primary);
      }

      &[data-drupal-selector="edit-layout-density-default"] {
        background-image: url(../../images/settings/layout_density_default.png);

        .gin--dark-mode & {
          background-image: url(../../images/settings/layout_density_default_dark_mode.png);
        }
      }

      &[data-drupal-selector="edit-layout-density-medium"] {
        background-image: url(../../images/settings/layout_density_medium.png);

        .gin--dark-mode & {
          background-image: url(../../images/settings/layout_density_medium_dark_mode.png);
        }
      }

      &[data-drupal-selector="edit-layout-density-small"] {
        background-image: url(../../images/settings/layout_density_small.png);

        .gin--dark-mode & {
          background-image: url(../../images/settings/layout_density_small_dark_mode.png);
        }
      }
    }

    /* Original has a broken selector here — keeping behavior as-is */

    .form-item__label {
      display: block;
      margin-block-start: var(--admin-space-xs);
      margin-block-end: var(--admin-space-m);
      font-size: var(--admin-font-size-2xs);
    }
  }
}
