/* BxB Energy Savings Calculators (SEER2 + AFUE) */

.bxb-calc--seer {
  --app-font: #f5f5f3;
  --input-font: #333;
  --main-bg-color: #1f5273;
  --secondary-bg-color: #4f798f;
  --layout-comparison-font-color: var(--app-font);
  --button-bg-color: #ceffff;
  --button-hover-bg-color: #1f5273;
  --button-font: #4f798f;
  --button-font-hover: #ceffff;
  --unit-label-color: rgba(244, 244, 242, 0.55);
  --unit-label-hover-color: rgba(244, 244, 242, 0.95);
}

/* Orange inverted */
.bxb-calc--afue {
  --app-font: #f6f5f0;
  --input-font: #45464b;
  --main-bg-color: #bc5628;
  --secondary-bg-color: #f6f5f0;
  --layout-comparison-font-color: #5d5e65;
  --button-bg-color: #e1e0df;
  --button-hover-bg-color: #ecd952;
  --button-font: #bc5628;
  --button-font-hover: #bc5628;
  --unit-label-color: #45464b;
  --unit-label-hover-color: #45464b;
}

/* ponytail: #bxb-calc matches nothing. Inside :is() it lifts these rules to ID-level
   specificity, like the old #bxb-energy-calculator-* selectors, so theme and
   page-builder styles don't bleed into the calculator. */
:is(.bxb-calc, #bxb-calc) {
  color: var(--app-font);
  display: block;
  font-variant-numeric: tabular-nums;
  margin: 0;
  max-width: 100%;
  text-align: center;
  width: 750px;

  & * {
    font-family: system-ui, sans-serif;
  }

  & [hidden] {
    display: none !important;
  }

  /* Themes built on Bootstrap 3 style output as a small grey block. */
  & output {
    color: inherit;
    display: inline;
    font-size: inherit;
    line-height: inherit;
    padding: 0;
  }

  & h2.bxb-calc__title {
    color: var(--app-font);
    font-size: 30px;
    margin: 0 auto;
    padding-top: 0;
  }

  & .bxb-calc__subheading {
    font-size: 25px;
    margin: 0;
  }

  & h2 {
    color: var(--app-font);
    font-size: 22px;
    margin: 0;
    padding-top: 1em;
  }

  & p {
    color: var(--app-font);
    font-size: 16px;
    font-weight: normal;
    margin-bottom: 0;
  }

  & select,
  & input {
    appearance: none;
    background-color: #fff;
    box-sizing: border-box;
    color: var(--input-font);
    display: block;
    font-size: 16px;
    line-height: 1;
    padding: 0.5em;
    width: 100%;
  }

  & .bxb-calc__button {
    background-color: var(--button-bg-color);
    border: none;
    border-radius: 5px;
    color: var(--button-font);
    font-size: 1em;
    font-weight: normal;
    margin: 0.25em 0;
    padding: 0.12em 0.25em 0.25em;
    transition: 0.25s;

    &:hover:not(:disabled) {
      background-color: var(--button-hover-bg-color);
      border: none;
      color: var(--button-font-hover);
    }

    /* A stepper at its limit */
    &:disabled {
      cursor: not-allowed;
      opacity: 0.4;
    }
  }

  &.bxb-calc--afue .bxb-calc__button--step {
    min-width: 1.4em;
  }

  & p.bxb-calc__percent {
    font-size: 60px;
    grid-column: 1/-1;
    grid-row: 1/-1;
    line-height: 0.6;
    margin: 0;
    position: relative;
    text-align: center;
  }

  & .bxb-calc__savings p {
    font-size: 20px;
    line-height: 1.2;
    margin: 0;
  }

  &.bxb-calc--afue .bxb-calc__customizer :is(h2, p) {
    color: var(--layout-comparison-font-color);
  }

  & .bxb-calc__button--customize {
    border-radius: 5px;
    display: block;
    font-size: 1em;
    font-weight: bold;
    margin: 1em auto;
    min-width: 250px;
    padding: 0.25em 1em;

    &:hover {
      background: var(--secondary-bg-color);
    }
  }

  &.bxb-calc--afue .bxb-calc__button--customize {
    background-color: var(--secondary-bg-color);
  }

  & .bxb-calc__year {
    border-bottom: 1px solid;
    font-size: 1.5em;
  }

  & .bxb-calc__change {
    font-size: 2em;
  }

  & .bxb-calc__rate {
    font-size: 1em;
    margin-bottom: 0;
  }

  & .bxb-calc__disclaimer p {
    font-size: 12px;
    font-weight: normal;
    margin-top: 1em;
  }

  @media (max-width: 680px) {
    width: 100%;

    & .bxb-calc__button--step {
      margin: 0.25em;
    }
  }
}

/* Class-level rules: easy for themes to override, as before. */
:where(.bxb-calc) {
  /* MAIN SECTION */
  .bxb-calc__main {
    background-color: var(--main-bg-color);
    border-radius: 15px;
    padding: 1em;
    position: relative;
    z-index: 10;
  }

  .bxb-calc__comparison {
    display: grid;
    grid-gap: 1em;
    grid-template-areas:
      "donut seerrows"
      "donut savings15";
    grid-template-columns: 1fr 1fr;
    margin: 1em 0;
  }

  .bxb-calc__donut {
    align-items: center;
    display: grid;
    grid-area: donut;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    justify-items: center;
    position: relative;

    & svg {
      grid-column: 1/-1;
      grid-row: 1/-1;
    }
  }

  circle {
    fill: none;
    position: relative;
  }

  .bxb-calc__ring-border {
    stroke-width: 0;
  }

  .bxb-calc__ring-back {
    stroke: var(--secondary-bg-color);
    stroke-width: 30px;
  }

  /* stroke (the gradient) is set per instance in the markup */
  .bxb-calc__ring-front {
    stroke-width: 30px;
    stroke-dasharray: 629px;
    stroke-dashoffset: 314px;
    transition: stroke-dashoffset 0.5s ease;
  }

  .bxb-calc__percent span {
    font-size: 0.5em;
  }

  /* old unit vs new unit */
  .bxb-calc__rows {
    grid-area: seerrows;
  }

  .bxb-calc__unit {
    display: grid;
    font-weight: normal;
    grid-template-areas:
      "unitlabel seerbtns seer cost"
      "unitlabel seerbtns seer cost";
    grid-template-columns: 2em 3em 5em 1fr;
    justify-content: space-around;
    transition: 0.5s ease-in-out;

    &:hover .bxb-calc__unit-label {
      border-bottom: 1px solid var(--unit-label-hover-color);
      color: var(--unit-label-hover-color);
    }
  }

  &.bxb-calc--seer .bxb-calc__unit {
    opacity: 0.9;

    &:hover {
      opacity: 1;
    }
  }

  :is(.bxb-calc__unit--new, .bxb-calc__unit--old) {
    align-items: center;
    background: var(--secondary-bg-color);
    border-radius: 3px;
    color: var(--layout-comparison-font-color);
    justify-items: center;
    margin-bottom: 1em;
    padding: 0.5em;
  }

  .bxb-calc__unit--new {
    grid-area: newseer;
  }

  .bxb-calc__unit--old {
    grid-area: oldseer;
  }

  .bxb-calc__savings {
    align-self: center;
    font-size: 1.5em;
    grid-area: savings15;
    text-align: center;

    & span {
      font-size: 2em;
    }
  }

  .bxb-calc__unit-label {
    border-bottom: 1px solid var(--unit-label-color);
    color: var(--unit-label-color);
    font-size: 16px;
    grid-area: unitlabel;
    transform: rotate(-90deg);
    transition: 0.5s ease-in-out;
  }

  .bxb-calc__steppers {
    display: flex;
    flex-direction: column-reverse;
    grid-area: seerbtns;
    margin: 0 10px;
  }

  .bxb-calc__stepper {
    font-size: 20px;
  }

  :is(.bxb-calc__rating, .bxb-calc__cost) {
    font-size: 28px;
    line-height: 0.7;
    margin: 0 15px;
    text-align: center;

    & span {
      font-size: 0.5em;
    }
  }

  .bxb-calc__rating {
    grid-area: seer;
  }

  .bxb-calc__cost {
    grid-area: cost;
    white-space: nowrap;
  }

  .bxb-calc__button--step {
    font-size: 1em;
    height: 1.5em;
    line-height: 1;
    padding: 0.15em;
    width: 1.5em;
  }

  /* CUSTOMIZATION SECTION: slides down from behind the main panel. */
  .bxb-calc__customizer {
    background-color: var(--secondary-bg-color);
    border-radius: 0 0 15px 15px;
    margin-top: -15px;
    padding-bottom: 1em;
    padding-top: 15px;
    position: relative;
    transition: transform 0.5s, display 0.5s allow-discrete;

    &[hidden] {
      transform: translateY(-100%);
    }

    @starting-style {
      transform: translateY(-100%);
    }

    & p {
      margin: 0;
    }
  }

  .bxb-calc__fields {
    display: grid;
    grid-gap: 1em;
    grid-template-columns: 1fr 1fr;
    padding: 1em;
    text-align: left;

    & p {
      margin-bottom: 0;
    }

    & .bxb-calc__label {
      text-align: left;
    }
  }

  /* HISTORICAL SECTION */
  .bxb-calc__history {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    justify-items: center;
    padding: 1em;
  }

  .bxb-calc__history-item {
    color: var(--app-font);
    text-align: center;
  }

  .bxb-calc__rate sup {
    font-size: 0.5em;
  }

  @media (max-width: 680px) {
    .bxb-calc__comparison {
      grid-template-areas:
        "donut donut"
        "seerrows seerrows"
        "savings15 savings15";
    }

    .bxb-calc__rows {
      display: grid;
      grid-gap: 1em;
      grid-template-areas:
        "oldseer newseer"
        "savings15 savings15";
      grid-template-columns: 1fr 1fr;
      margin: 1em 0;
    }

    .bxb-calc__unit {
      grid-gap: 1em;
      grid-template-areas:
        "unitlabel"
        "seer"
        "seerbtns"
        "cost";
      grid-template-columns: 1fr;
      padding: 1em;
    }

    .bxb-calc__fields {
      grid-template-columns: 1fr;
    }

    .bxb-calc__history {
      grid-row-gap: 2em;
      grid-template-columns: 1fr 1fr;
    }

    .bxb-calc__unit-label {
      transform: rotate(0deg);
    }

    .bxb-calc__rating {
      font-size: 40px;
    }

    .bxb-calc__steppers {
      flex-direction: row;
      justify-items: center;
    }

    .bxb-calc__cost {
      font-size: 30px;
    }
  }
}
