@use '@cfpb/cfpb-design-system/src/abstracts' as *;
@use './vars.scss' as *;

main.college-costs {
  .undergrad-content,
  .associates-content,
  .graduate-content,
  .community-college,
  .program-select {
    display: none;
  }

  [data-state-based-visibility] {
    display: none;
  }

  // 2 vs 4 year
  &[data-state_communitycollege='true'] {
    span.community-college {
      display: inline;
    }
    tr.community-college {
      display: table-row;
    }
    span.four-year-college {
      display: none;
    }
  }

  // Grad & undergrad content control
  &[data-state_programlevel='undergrad'] {
    &[data-state_programdependency='dependent'] {
      .dependent-content {
        display: block;
      }
      span.dependent-content {
        display: inline;
      }
      .independent-content {
        display: none;
      }
    }

    &[data-state_programdependency='independent'] {
      .independent-content {
        display: block;
      }
      span.independent-content {
        display: inline;
      }
      .dependent-content {
        display: none;
      }
    }

    .undergrad-content {
      display: block;
    }
    span.undergrad-content {
      display: inline;
    }
    li.undergrad-content {
      display: list-item;
    }
    tr.undergrad-content {
      display: table-row;
    }
  }

  &[data-state_pid] {
    .no-program-selected {
      display: none;
    }
    [data-state-based-visibility='program-is-selected'] {
      display: block;
    }
    span[data-state-based-visibility='program-is-selected'] {
      display: inline;
    }
  }

  &[data-state_programlevel='graduate'] {
    .graduate-content {
      display: block;
    }
    span.graduate-content {
      display: inline;
    }
    li.graduate-content {
      display: list-item;
    }
    tr.graduate-content {
      display: table-row;
    }
  }

  &[data-state_programtype='associates'] {
    .associates-content {
      display: block;
    }
    span.associates-content {
      display: inline;
    }
    li.associates-content {
      display: list-item;
    }
    tr.associates-content {
      display: table-row;
    }
  }

  // App

  &[data-state_gotstarted='false'] .app-container {
    display: none;
  }

  &[data-state_gotstarted='false'] .costs-not-covered-sticky {
    display: none;
  }

  &[data-state_gotstarted='false'] .o-college-costs-nav {
    display: none;
  }

  &[data-state_gotstarted='true'] {
    .college-costs__intro-segment {
      display: none;
    }

    .college-costs__tool-section.active {
      display: block;
    }
  }

  // Section visibility by application state

  &[data-state_activesection='customize-estimate'] {
    // Desktop and above.
    @include respond-to-min($bp-med-min) {
      @supports (position: sticky) {
        .costs-not-covered-sticky {
          display: block;
        }
        .costs-not-covered-notification {
          display: none;
        }
      }
    }
  }

  // Save and finish later section visibility
  &[data-state_save-for-later='active'] {
    [data-state-based-visibility='save-for-later'] {
      display: block;
    }
  }

  // Program selection visibility
  &[data-state_schoolhasprograms='yes'] {
    [data-state-based-visibility='school-has-programs'] {
      display: block;
    }
    span[data-state-based-visibility='school-has-programs'] {
      display: inline;
    }
  }
  &[data-state_schoolhasprograms='no'] {
    [data-state-based-visibility='school-no-programs'] {
      display: block;
    }
    span[data-state-based-visibility='school-no-programs'] {
      display: inline;
    }
  }
  &[data-state_schoolselected='required'] {
    [data-state-based-visibility='school-no-programs'] {
      display: none;
    }
    span[data-state-based-visibility='school-no-programs'] {
      display: none;
    }
  }

  &:not([data-state_pid]) {
    [data-state-based-visibility='no-program-selected'] {
      display: block;
    }
    span[data-state-based-visibility='no-program-selected'] {
      display: inline;
    }
  }

  &[data-state_programtype='graduate']:not([data-state_pid]) {
    [data-state-based-visibility='no-program-selected'] {
      display: block;
    }
    span[data-state-based-visibility='no-program-selected'] {
      display: inline;
    }

    .college-costs__tool-section.college-costs__tool-section--affording
      .affording-loans-choices {
      display: none;
    }

    [data-state-based-visibility='expenses-hourly-wages'] {
      display: block;
    }
    .debt-guideline__salary-info {
      display: none;
    }
  }

  &[data-state_costsquestion] {
    #costs__inputs-section {
      display: block;
    }
    [data-state-based-visibility='costs-question-hide'] {
      display: none;
    }
  }

  &[data-state_costsquestion='y'],
  &[data-state_costsquestion='o'] {
    [data-state-based-visibility='costs-question-yes'] {
      display: block;
    }
  }

  &[data-state_costsquestion='n'] {
    [data-state-based-visibility='costs-question-no'] {
      display: block;
    }
  }

  // Action plan choices
  &[data-state_actionplan='action'] {
    [data-state-based-visibility='put-into-action'] {
      display: block;
    }
  }

  &[data-state_actionplan='consider'] {
    [data-state-based-visibility='consider-other-options'] {
      display: block;
    }
  }

  // Notification visibility controls
  &[data-state_uncoveredcosts='true'] {
    [data-state-based-visibility='uncovered-costs'] {
      display: block;
    }
  }

  &[data-state_excessfunding='true'] {
    [data-state-based-visibility='excesss-funding'] {
      display: block;
    }
  }

  &[data-state_debtruleviolation='true'] {
    [data-state-based-visibility='debt-rule-violation'] {
      display: block;
    }
    span[data-state-based-visibility='debt-rule-violation'] {
      display: inline;
    }
  }

  &[data-state_debtruleviolation='false'] {
    span[data-state-based-visibility='debt-rule-passed'] {
      display: inline;
    }
    [data-state-based-visibility='debt-rule-okay'] {
      display: block;
    }
  }

  &[data-state_expensesremainder='surplus'] {
    [data-state-based-visibility='expenses-surplus'] {
      display: block;
    }
  }

  &[data-state_expensesremainder='shortage'] {
    [data-state-based-visibility='expenses-shortage'] {
      display: block;
    }
  }

  &[data-state_expenseschoice='hourly'] {
    [data-state-based-visibility='expenses-hourly-wages'] {
      display: block;
    }
  }

  &[data-state_expenseschoice='monthly'] {
    [data-state-based-visibility='expenses-monthly-budget'] {
      display: block;
    }
  }

  &:not([data-state_schoolcontrol='Private']) {
    [data-state-based-visibility='control-nonprivate'] {
      display: block;
    }
  }

  &[data-state_programprogress='0'],
  &[data-state_programprogress='n'] {
    [data-state-based-visibility='is_first_year-true'] {
      display: block;
    }
  }

  &:not([data-state_programprogress='0'], [data-state_programprogress='n']) {
    [data-state-based-visibility='is_first_year-false'] {
      display: block;
    }
  }

  // Don't show the next button on the save & finish page
  &[data-state_activesection='save-and-finish'] {
    .college-costs__tool-section-buttons {
      display: none;
    }
  }

  .comparison-section--default-rate .big-percentile {
    border-color: var(--gray-20);
  }

  &[data-state_rategraduationrange='high'] {
    .comparison-section--grad-rate .big-percentile {
      border-color: $college-costs-chart-max;
    }
  }

  &[data-state_rategraduationrange='medium'] {
    .comparison-section--grad-rate .big-percentile {
      border-color: $college-costs-chart-median;
    }
  }

  &[data-state_rategraduationrange='low'] {
    .comparison-section--grad-rate .big-percentile {
      border-color: $college-costs-chart-min;
    }
  }

  &[data-state_raterepay3yrrange='high'] {
    .comparison-section--repayment-rate .big-percentile {
      border-color: $college-costs-chart-max;
    }
  }

  &[data-state_raterepay3yrrange='medium'] {
    .comparison-section--repayment-rate .big-percentile {
      border-color: $college-costs-chart-median;
    }
  }

  &[data-state_raterepay3yrrange='low'] {
    .comparison-section--repayment-rate .big-percentile {
      border-color: $college-costs-chart-min;
    }
  }

  &[data-state_defaultraterange='high'] {
    .comparison-section--default-rate .big-percentile {
      border-color: $college-costs-chart-min;
    }
  }

  &[data-state_defaultraterange='medium'] {
    .comparison-section--default-rate .big-percentile {
      border-color: $college-costs-chart-median;
    }
  }

  &[data-state_defaultraterange='low'] {
    .comparison-section--default-rate .big-percentile {
      border-color: $college-costs-chart-max;
    }
  }

  &[data-state_repay3yrmissing='true'] {
    .comparison-section--repayment-rate {
      display: none;
    }
  }

  &[data-state_gradratemissing='true'] {
    .comparison-section--grad-rate {
      display: none;
    }
  }

  &[data-state_defaultratemissing='true'] {
    .comparison-section--default-rate {
      display: none;
    }
  }

  // Error visibility
  &[data-state_showschoolerrors='yes'] {
    [data-state-based-visibility='school-fields-errors'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_schoolselected='required'] {
    [data-state-based-visibility='school-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_programtypeselected='required'] {
    [data-state-based-visibility='type-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_programlengthselected='required'] {
    [data-state-based-visibility='length-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_programprogressselected='required'] {
    [data-state-based-visibility='progress-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_rateselected='required'] {
    [data-state-based-visibility='rate-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_housingselected='required'] {
    [data-state-based-visibility='housing-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_dependencyselected='required'] {
    [data-state-based-visibility='dependency-required'] {
      display: block;
    }
  }

  &[data-state_showschoolerrors='yes'][data-state_incomeselected='required'] {
    [data-state-based-visibility='income-required'] {
      display: block;
    }
  }

  &[data-state_programrate='outOfState'] {
    span[data-state-based-visibility='out-of-state'] {
      display: inline;
    }
  }

  &[data-state_usingnetprice='no'] {
    [data-state-based-visibility='using-net-price'] {
      display: block;
    }

    span[data-state-based-visibility='using-net-price'] {
      display: inline;
    }
  }

  &[data-state_investigation='yes'] {
    [data-state-based-visibility='investigation'] {
      display: block;
    }
    li[data-state-based-visibility='investigation'] {
      display: list-item;
    }
  }
}
