/**
 * Standard Form
 *
 * When placing the "std-form" class on a form element, it will take on CR-specific form styling.
 * All fields should be wrapped in a single <div class="fields">.
 *
 * This component is designed to be used with the nested_input_label.html.twig Symfony form theme.
 *
 * See Also: validation_manager.css, login_form.css, signup_form.css
 */

/* Placeholders */
.std-form ::-webkit-input-placeholder {
  color: rgb(170, 170, 170);
}

.std-form :-moz-placeholder { /* Firefox 18- */
  color: rgb(170, 170, 170);
}

.std-form ::-moz-placeholder {  /* Firefox 19+ */
  color: rgb(170, 170, 170);
}

.std-form :-ms-input-placeholder {
  color: rgb(170, 170, 170);
}


/* Captcha iframe styling */
.std-form .g-recaptcha {
  margin-bottom: 1.5em;
}


/* Override default invalid styling */
.std-form :invalid {
  box-shadow: none;
}


/* Structural form elements */
.std-form p,
.std-form fieldset {
  margin-bottom: 1.5em;
  margin-top: 1.5em;

  color: rgb(123, 115, 126);
}

.std-form > .fields p {
  margin-top: 0;
}

.std-form fieldset > .fields {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 1.3em;
}

.std-form legend + .fields {
  margin-top: 0;
}


/* Labels */
.std-form label {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-align-items: center;
  align-items: center;

  cursor: default;
}

.std-form label + label {
  margin-left: 0.85em;
}

html[dir='rtl'] .std-form label + label {
  margin-left: 0;
  margin-right: 0.85em;
}


/* Form widgets */
.std-form input,
.std-form select {
  box-sizing: border-box;
  height: 3.4em;
  padding: 0.8em 1em;
  width: 100%;

  border: 0.0625em solid rgb(165, 162, 162);

  font-size: 1em;
  line-height: 1.8;

  background: rgb(100%, 100%, 100%);

  transition:
    padding 100ms ease-out,
    border-color 100ms ease-out;
}

.std-form select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  padding-right: 2.6em;

  /* Hack to remove Firefox select arrow */
  text-indent: 0.0008em;
  text-overflow: '';

  background: url('/i/subscription_form/select_triangle_inactive.svg') right 1.3em center / 1em auto no-repeat;

  border-radius: 0;
  cursor: pointer;
}

html[dir='rtl'] .std-form select {
  padding-left: 2.6em;
  padding-right: 0.8em;

  background-position: left 1.3em center;
}

/* IE11-specific. Removes custom background because IE11's arrows can't be removed. */
_:-ms-fullscreen,
.std-form select {
  padding-right: 0.8em;

  background-image: none;
}

_:-ms-fullscreen,
html[dir='rtl'] .std-form select {
  padding-right: 0.8em;
}


/* Fieldsets */
.std-form fieldset {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  padding: 0;

  border: 0;
}

.std-form fieldset input,
.std-form fieldset select {
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  margin: 0;
  width: auto;

  border-right-width: 0;
}

html[dir='rtl'] .std-form fieldset input,
html[dir='rtl'] .std-form fieldset select {
  border-left-width: 0;
  border-right-width: 0.0625em;
}


/* Checkbox and radio buttons */
.std-form [type='checkbox'],
.std-form [type='radio'] {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;

  box-sizing: border-box;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;

  background: rgb(100%, 100%, 100%);

  cursor: pointer;
}

/* This is to ensure other RTL styles don't mess with the padding */
html[dir='rtl'] .std-form [type='checkbox'],
html[dir='rtl'] .std-form [type='radio'] {
  padding: 0;
}


/* Actions */
.std-form .action {
  font-size: 1em;
}


.std-form [type='checkbox'] {
  height: 1.4em;
  width: 1.4em;

  border: 0.0625em solid rgb(165, 162, 162);
  outline: none;

  background: url('/i/subscription_form/check_mark_active.svg') center center / 0 0 no-repeat;

  transition:
      background 100ms ease-out,
      border 100ms ease-out;
}

/* RTL specificity correction */
html[dir='rtl'] .std-form [type='checkbox'] {
  background-position: center center;
}

.std-form [type='radio'] {
  height: 1.41em;
  width: 1.41em;

  border: 0;
  box-shadow: 0 0 0 0.08em rgb(165, 162, 162);

  border-radius: 1.25em;

  transition:
      background 100ms ease-out,
      border 100ms ease-out,
      box-shadow 100ms ease-out;
}


/* Field-specific error messages */
.std-form .input-error-message {
  -webkit-flex: 1 0 100%;
  flex: 1 0 100%;
}


/* General styling for labels (and fieldset legends, which behave similarly) */
.std-form .label-text,
.std-form fieldset > legend {
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  margin-bottom: 0.5em;

  font-weight: normal;
  line-height: 1.2;
}


/* Checkbox and radio labels */
.std-form .radio-label,
.std-form .checkbox-label {
  cursor: pointer;
}

.std-form .checkbox-label {
  -webkit-align-items: flex-start;
  align-items: flex-start;
  -webkit-flex-wrap: nowrap;
  flex-wrap: nowrap;
  margin-top: 1.3em;
}

.std-form .radio-label {
  -webkit-flex: 0 1 auto;
  flex: 0 1 auto;
  margin-bottom: 0;
}


/* States for most form widgets */
.std-form input:focus,
.std-form select:focus,
.std-form input:hover,
.std-form select:hover {
  border-color: rgb(247, 140, 37);
}

.std-form select:focus,
.std-form select:hover {
  background-image: url('/i/subscription_form/select_triangle_active.svg');
}

/* IE11-specific. Removes custom background because IE11's arrows can't be removed. */
_:-ms-fullscreen,
.std-form select:focus,
.std-form select:hover {
  background-image: none;
}

.std-form input:focus,
.std-form input:hover,
.std-form input:last-of-type,
.std-form select:focus,
.std-form select:hover,
.std-form select:last-of-type {
  border-right-width: 0.0625em;
}

html[dir='rtl'] .std-form input:focus,
html[dir='rtl'] .std-form input:hover,
html[dir='rtl'] .std-form input:last-of-type,
html[dir='rtl'] .std-form select:focus,
html[dir='rtl'] .std-form select:hover,
html[dir='rtl'] .std-form select:last-of-type {
  border-left-width: 0.0625em;
}

.std-form input:focus + input,
.std-form input:hover + input,
.std-form input:focus + select,
.std-form input:hover + select,
.std-form select:focus + input,
.std-form select:hover + input,
.std-form select:focus + select,
.std-form select:hover + select {
  border-left-width: 0;
}

html[dir='rtl'] .std-form input:focus + input,
html[dir='rtl'] .std-form input:hover + input,
html[dir='rtl'] .std-form input:focus + select,
html[dir='rtl'] .std-form input:hover + select,
html[dir='rtl'] .std-form select:focus + input,
html[dir='rtl'] .std-form select:hover + input,
html[dir='rtl'] .std-form select:focus + select,
html[dir='rtl'] .std-form select:hover + select {
  border-right-width: 0;
}


/* Label text for checkbox and radio labels */
.std-form .checkbox-label .label-text {
  -webkit-flex: 0 1 auto;
  flex: 0 1 auto;
  margin-bottom: 0;
  margin-left: 0.8em;
  margin-right: 0.8em;
}

.std-form .radio-label .label-text {
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  margin: 0 0.8em;
}


/* States for checkboxes and radio buttons */
.std-form [type='checkbox']:checked {
  background-size: 0.9em auto;
}

.std-form [type='radio']:hover,
.std-form [type='radio']:focus {
  box-shadow: 0 0 0 0.08em rgb(247, 140, 37);
}

.std-form [type='radio']:checked {
  background: rgb(247, 140, 37);

  border: 0.3em solid rgb(100%, 100%, 100%);
}

/* RTL specificity correction */
html[dir='rtl'] .std-form [type='radio']:checked {
  border-width: 0.3em;
}


/* Backend error messages */
.std-form .messages > .error {
  margin: 1em 0;
  padding: 1.4em 1.5em 1.2em 1.5em;

  border: 0.0625em solid rgb(195, 47, 45);

  background-color: rgba(195, 47, 45, 0.2); /* Same color as border and text, less opaque */
  color: rgb(195, 47, 45);
}
