/* Applies the design tokens to what the parent theme and the quiz plugin style themselves. Loaded after the parent theme's generated stylesheet so equal selectors resolve here. */

body {
  font-family: var(--font-body);
  font-weight: var(--weight-body);
  color: var(--text);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  color: var(--heading);
}

h1 {
  font-weight: var(--weight-title);
}

/* Gradient text is a background showing through transparent letters, and printing and forced colours drop backgrounds, so it applies on screen only. Page builder gradient headings print their own colours with the page, so the second selector matches that rule's weight to bring them onto the token. inline-block sizes the gradient to the words. */
@media screen and (forced-colors: none) {
  h1,
  body .nectar-gradient-text[data-color][data-direction] > * {
    display: inline-block;
    color: var(--blue);
    background-image: var(--gradient-title);
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  /* Text nested in the heading shows the heading's gradient through, so one sweep runs across the whole title. */
  body .nectar-gradient-text[data-color][data-direction] > * * {
    display: inline;
    background: none;
  }
}

body a {
  color: var(--blue);
}

/* Each form plugin draws its own fields; this gives them one fill, shape and inner spacing. */
body :is(.nf-form-content, .wppb-user-forms) :is(input:not([type="submit"], [type="button"], [type="checkbox"], [type="radio"], [type="file"]), textarea, select) {
  border: 1px solid var(--field-border);
  background-color: var(--field-fill);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 24px;

  &:focus {
    border-color: var(--blue);
    background-color: var(--white);
  }

  /* A select sizes itself from the platform's line box, which comes up short of the text inputs. */
  &:is(select) {
    box-sizing: border-box;
    min-height: 46px;
  }
}

/* The site's button, built from the button tokens with no inner markup, so it styles a link, a button or an input alike. A plugin's own control joins by its selector here, since its markup belongs to the plugin. */
body .ipi-button,
body .container-wrap :is(.nf-form-content, .wppb-user-forms) input[type="submit"],
body .container-wrap .qmn_quiz_container input.qsm-submit-btn {
  display: inline-block;
  padding: var(--button-padding) !important;
  font: var(--weight-bold) 14px/20px var(--font-body);
  color: var(--button-text);
  text-decoration: none;
  border: 0;
  border-radius: var(--button-radius);
  box-shadow: none;
  background-color: var(--button-fill-hover) !important;
  background-image: var(--button-fill) !important;
  cursor: pointer;
  transition: transform var(--button-ease), box-shadow var(--button-ease);

  &:is(:hover, :focus-visible) {
    color: var(--button-text);
    opacity: 1;
    background-image: none !important;
    transform: var(--button-lift);
    box-shadow: var(--button-shadow) !important;
  }
}

/* The secondary button. Its edge is an outline, which adds nothing to the box, so it measures the same as the filled one. */
body .ipi-button.ipi-button-outline {
  color: var(--blue);
  background-color: var(--white) !important;
  background-image: none !important;
  outline: 1px solid var(--blue);
  outline-offset: -1px;

  &:is(:hover, :focus-visible) {
    background-color: var(--button-fill-hover) !important;
  }
}

/* The quiz stylesheet is printed with the quiz, after this file, so these rules carry one more selector than the ones they replace. */
body .qmn_quiz_container {
  :is(select, textarea, input[type="text"], input[type="number"], input[type="email"], input[type="url"]) {
    border-color: var(--blue);

    &:is(:hover, :focus) {
      border-color: var(--blue);
      box-shadow: 0 0 10px color-mix(in srgb, var(--blue) 35%, transparent);
    }
  }

  :is(.qmn_btn, .btn) {
    background: var(--blue) !important;

    &:hover {
      background: var(--blue-deep) !important;
    }
  }

  /* The plugin's "border" class on this row is also a Bootstrap utility, which draws an !important hairline. */
  .qsm-pagination {
    border: 0 !important;

    /* The row is a flex line spread edge to edge; the auto margin keeps the button beside the questions. */
    input.qsm-submit-btn {
      margin-inline: 0 auto;
    }
  }

  .quiz_section :is(.qsm-question-title-label, .mlw_qmn_question, .mlw_qmn_question_number, .mlw_qmn_new_question) {
    font-weight: var(--weight-bold);
  }

  .qsm-progress-bar .progressbar-text {
    color: var(--blue);
  }
}
