@use "sass:list";
@use "../partials/palette";

.form-control {
  line-height: 2.25;
  border: 0.0625rem solid palette.$formBorder; /* 1px */
  padding: 0.5rem 0.875rem;
  &:focus {
    padding: 0.375rem 0.75rem;
    border: 0.1875rem solid list.nth(palette.$purple, 7);
    box-shadow: none;
  }
}

.form-check-label {
  .subtext {
    display: block;
    color: palette.$accentDeEmphasized;
  }
}

.control-label.required,
.asterisk-label {
  &::after {
    content: " *";
    color: list.nth(palette.$purple, 7);
  }
}

[id^="customDonation"] {
  appearance: textfield;
}

[id^="pricegrid"] {
  .customDonation-container {
    border-radius: 0.375rem;
    border: none;
    padding: 0;
    position: relative;
    z-index: 1;
    .input-group-text {
      background: transparent;
      position: absolute;
      color: palette.$black;
      top: .7em;
      border: none;
      z-index: 6;
      pointer-events: none;
      &:first-of-type {
        padding: 0.375rem 0.125rem 0.375rem 1.5rem;
        left: 0;
        top: 1.25em;
      }
      &:last-of-type {
        padding: 0.375rem 1.5rem 0.375rem 0.125rem;
        right: 0.6rem;
        color: palette.$accentDeEmphasized;
      }
      .form-control.is-invalid ~ & {
        display: none;
      }
    }
    .form-control {
      outline: none;
      padding-left: 2.125rem;
      border-radius: 0;
      border: 0;
      border-top: 0.1875rem solid white;
      border-bottom: 0.1875rem solid list.nth(palette.$purple, 3);
      z-index: 1;
      transition: none;
      &:focus {
        padding: 0.5rem 0.875rem;
        padding-left: 1.9375rem;
        transition: none;
        border: 0.1875rem solid list.nth(palette.$purple, 7);
        z-index: 5;
      }
      &.is-invalid {
        border: 0.1875rem solid red;
      }
    }
  }
}
.was-validated {
  [id^="pricegrid"] {
    .customDonation-container {
      .input-group-text {
        .form-control:invalid ~ & {
          display: none;
        }
      }
    }
  }
}

.shippingRestricted {
  padding-top: 1rem;
}

.donate-form--cc {
  label > small {
    display: block;
  }
}

.frequencyToggle {
  margin-bottom: 2rem;
}

.noPerk {
  padding: 1rem 1.5rem 1rem 1rem;
  margin-bottom: 0;
  background-color: palette.$borderNeutral;
  border: .1875rem solid #e4e9f0;
  border-radius: 0.5rem;
  display: flex;
  flex-flow: row nowrap;
  &.form-check {
    input {
      margin-left: 0;
      float: none;
    }
    label {
      margin-left: 1rem;
      flex-grow: 2;
    }
  }
  &:has(input[value="no_gift"]:checked) {
    border: .1875rem solid var(--bs-primary);
  }
}

label[for="noPerkCheckbox"] {
  cursor: pointer;
}

.Perk {
  display: grid;
  overflow: hidden;
  grid-template-columns: repeat(1, 1fr);
  grid-auto-rows: 1fr;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;

  .btn.unmet-single,
  .btn.unmet-monthly {
    display: none;
  }

  &.single {
    .btn.unmet-single {
      display: block;
    }
  }

  &.monthly {
    .btn.unmet-monthly {
      display: block;
    }
  }
}

.Perk-frame {
  display: flex;
  margin-top: 0;
}

.Perk-selection {
  margin: 2rem 0 0 0;
  display: flex;
  flex-flow: column;
  position: relative;

  .Perk-label {
    flex-basis: 100%;
    display: flex;
    flex-flow: column;
    align-content: space-between;
  }
  .btn-check + .Perk-label {
    .Perk-caption {
      padding: 0 0.1875rem 2rem;
      // flex-grow: 2;
    }
    .Perk-imgButton {
      border: 0.1875rem solid palette.$white;
      background: palette.$white;
      border-radius: 0.25rem;
      padding: 0.5rem;
      img {
        margin: 2.5rem 0;
        width: 100%;
        max-width: 100%;
        height: auto;
      }
      .btn {
        border-radius: 0.25rem;
      }
      .btn-tertiary {
        display: none;
      }
      .btn-chosen {
        i {
          &::before {
            color: palette.$black;
          }
        }
      }
    }
  }
  .btn-check:checked + .Perk-label {
    .Perk-imgButton {
      border: 0.1875rem solid list.nth(palette.$green, 7);
    }
  }
  &.Perk-active {
    cursor: pointer;
    .btn-check + .Perk-label {
      .btn-tertiary {
        &.btn-chosen {
          display: flex;
        }
        &.btn-unchosen {
          display: none;
        }
      }
      .btn-unmet {
        display: none;
      }
    }
    .btn-check:not(:checked) + .Perk-label {
      .btn-tertiary {
        &.btn-chosen {
          display: none;
        }
        &.btn-unchosen {
          display: block;
        }
      } 
    }
  }
}

.Card .Perk-caption {
  h5 {
    margin-top: initial;
  }
  p {
    margin-bottom: 0;
  }
}

[id^="id_single_or_monthly"] + label {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
}

.donate-form--emailUpdates {
  label {
    display: flex;
    flex-flow: row nowrap;
    align-items: baseline;
    gap: 0.3125rem;
    span {
      flex-grow: 2;
    }
  }
}

.donate-form--ccFields {
  display: flex;
  flex-flow: column;
  .ccFields-frame {
    display: flex;
    .form-group {
      display: flex;
      flex-flow: column;
      label {
        flex-grow: 2;
      }
    }
  }
}

.Card--shipping-info label {
    margin-bottom: 0.125rem;
}

#donatePaypal {
  .ph-info {
    font-size: 1.5rem;
  }
}

.Card--shipping-info {
  .form-group,
  label {
    line-height: 1;
  }
}
