/*
  Funding page styles.
*/

#patronageForm, #progressIndicator, #thankYouMessage, #errorMessage {
  /* give form a max-width and center when it exceeds that width */
  margin: 1em auto;
  max-width: 21em;
}

#patronageForm fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

/* (for non-grid fallback) put gap between type of donation and tiers to make grouping clear */

#patronageForm .patronType {
  margin-bottom: 1em;
}

#patronageForm .option {
  margin-bottom: 0.5em;
}

@supports (display: grid) {
  #patronageForm .patronType,
  #patronageForm .paymentType,
  #patronageForm .patronTier {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-gap: 0.5em;
  }

  #patronageForm .option {
    grid-column: span 1; /* donation tier options span one column */
    grid-row: span 1; /* donation tier options span one row */
    margin-bottom: 0;
  }

  /* Type of payment */

  #patronageForm .paymentType {
    margin-top: 1em;
    margin-bottom: 0em;
    grid-template-rows: 1fr; /* type of donation is one row */
  }

  #patronageForm .paymentType label {
    padding: 0.15em 0;
    margin-bottom: 0.5em;
  }

  #patronageForm .paymentType .option {
    grid-column: span 2; /* make type of donation span two columns of grid */
  }

  #patronageForm .paymentType .option input {
    padding: 0;
    margin: 0;
    margin-bottom: 0.25em;
  }

  #patronageForm .paymentType .selectButton:checked + label:before {
    border: 0.16rem solid rgb(193, 208, 221);
  }

  #patronageForm .paymentType .selectButton:checked + label {
    background-color: #d8e5ef;
    color: rgb(48, 67, 73);
  }

  #patronageForm input[name="paymentType"] {
    display: none;
  }

  /* Nano payment */

  #nanoPaymentGrid {
    display: grid;
    grid-template-columns: 30% 1fr;
    grid-template-areas: "amount currency";
    grid-gap: 0.5em;
  }

  #localCurrency, #nanoPaymentAmount {
    /* ensure styles are consistent with that of other input types */
    background: #fff;
    border: 0.2em solid #d8e5ef;
    border-radius: 5px;
    box-sizing: border-box;
    color: rgb(48, 67, 73);
    width: 100%;
  }

  #localCurrency {
    grid-column: currency;
    margin: 0;
    padding: 0.5em;
  }

  #nanoPaymentAmount {
    grid-column: amount;
    padding: 0 !important;
    margin: 0 !important;
  }

  #apiCredits {
    text-align: center;
    font-size: small;
  }

  /* QR Code */

  #qrCode {
    margin-top: 0.5em;
    width: 100%;
  }

  #amountInNanoDisplay {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    padding: 0;
    width: 100%;
    text-align: center;
    font-size: 1.5em;
  }

  /* Type of donation */

  #patronageForm .patronType {
    margin-bottom: 0.5em;
    grid-template-rows: 1fr; /* type of donation is one row */
  }

  #patronageForm .patronType .option {
    grid-column: span 2; /* make type of donation span two columns of grid */
  }

  /* Donation tier */
  #patronageForm .patronTier {
    margin-bottom: 0;
    grid-template-rows: 1fr 1fr; /* donation tier is is two rows */
  }

  #patronageForm .patronTier .option label {
    /* give options min-height to ensure numbers and custom options are same height on grid */
    min-height: 2em;
  }

  #patronageForm .donationTierButtonLabel {
    font-size: 1.5em;
    line-height: 2;
    padding: 0.75em 0;
  }

  #patronageForm #customDonationLabel {
    font-size: 1em;
    line-height: 1;
    /* give options min-height to ensure numbers and custom options are same height on grid */
    min-height: 3.75em; /* matched to number options */
    padding: 0.75em 0.4em 0.75em;
  }
}

#patronageForm input, #patronageForm label, #patronageForm button {
  display: block;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1em;
  padding: 0.75em;
  position: relative;
  text-align: center;
  -webkit-appearance: none;
}

#patronageForm input[name="donationType"] {
  display: none;
}

#patronageForm label {
  background-color: #eee;
  border-radius: 0.5rem;
  border: 0;
  color: #304349;
}

/* Selected radio button/label */

#patronageForm .selectButton:checked + label:before {
  border: 0.16rem solid #76BCC7;
  border-radius: 0.4rem;
  box-sizing: border-box;
  content: " ";
  display: block;
  height: 100%;
  top: 0;
  left: 0;
  position: absolute;
  width: 100%;
}

#patronageForm .selectButton:checked + label {
  background-color: #AFE1E8;
  color: #154652;
}

#patronageForm .selectButton:disabled+ label {
  opacity: 0.5;
  cursor:default;
}

/* Type of donation radio button/label */

#patronageForm .donationTypeButtonLabel {
  background-color: #eee;
  border: 0;
  cursor: pointer;
}

#patronageForm input[name="donationType"] + label {
  border: 0.12em solid #eee;
}

/* Donation tier radio button/label */

#patronageForm .donationTierButtonLabel {
  cursor: pointer;
}

/* Custom donation option */

/* is disabled if not in use */

#patronageForm input[type='text']:disabled {
  cursor: not-allowed;
}

#patronageForm input[name="donationAmount"] + label {
  border: 0.12rem solid #eee;
}

#patronageForm #customDonationLabel > input {

  /* ensure styles are consistent with that of other input types */
  background: #fff;
  border: 0.06em solid #AFAFAF;
  border-radius: 5px;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #4d4d4d;
  margin-top: 0.5em;
  margin-bottom: 0;
  opacity: 0.5;
  padding: 0.25em;
  width: 100%;
}

#patronageForm button {
  background-color: #E3F9A8;
  border: 0;
  border-radius: 5px;
  color: #004E48;
  cursor: pointer;
  font-family: 'Rutan Medium', Helvetica, Arial, sans-serif;
  margin-top: 0.5em;
  width: 100%;
}

#patronageForm button:hover {
  background-color: #FDFEBE;
}

#patronageForm button:disabled {
  background-color: #eee;
  color: #ccc;
  cursor: not-allowed;
}

/* Note below button */

#patronageForm .donation-currency {
  color: #7d7d7d;
  font-size: 1em;
  display: block;
  font-style: italic;
  text-align: center;
}

/* Messages above form */

#testMessage {
  text-align: center;
  background-color: #82073B;
  color: white;
  text-align: center;
}

#errorMessage {
  transition: max-height 0.33s;
}

/* Generic functional classes */

.displayNone {
  display: none;
}

/* Accessibly hide elements, as per http://webaim.org/techniques/css/invisiblecontent/ */
#patronageForm .hidden {
  position:absolute;
  left:-10000px;
  top:auto;
  width:0.06em;
  height:0.06em;
  overflow:hidden;
}

/* Courtesy: https://stackoverflow.com/a/2310809 */
.unselectable {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}