/*
 * Maryland Pre-K Cost Calculator
 * MDWDS iframe application styles
 *
 * MDWDS owns:
 * - typography
 * - standard links
 * - standard buttons
 * - form controls
 * - base focus treatment
 *
 * This file owns only application-specific structure, spacing, chart sizing,
 * result presentation, iframe behavior, and print behavior.
 */


/*
 * Local screen-reader-only utility. This replaces reliance on Bootstrap's
 * similarly named helper and remains available even if MDWDS changes.
 */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --------------------------------------------------------------------------
   Application shell
   -------------------------------------------------------------------------- */

.calculator-app {
  box-sizing: border-box;
  width: min(100%, 88rem);
  margin-inline: auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.calculator-app *,
.calculator-app *::before,
.calculator-app *::after {
  box-sizing: inherit;
}

.calculator-introduction,
.calculator-form,
.calculator-results {
  width: 100%;
}

.calculator-intro {
  font-size: 1.25rem;
  line-height: 1.55;
}

.calculator-centered {
  margin-block: 2rem;
  text-align: center;
}

/*
 * This is a navigational link, not a button. It remains a link so its semantics
 * accurately communicate that it opens another page.
 */
.calculator-navigation-link {
  display: inline-block;
  padding-block: 0.5rem;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Informational notice
   -------------------------------------------------------------------------- */

.calculator-notice {
  margin-block: 2rem;
  padding: 1.5rem;
  border: 2px solid currentColor;
}

.calculator-notice h2 {
  margin-top: 0;
  text-align: center;
}

.calculator-notice p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Form structure
   -------------------------------------------------------------------------- */

.calculator-form {
  margin-top: 2rem;
  padding: clamp(1rem, 3vw, 2rem);
  border: 3px solid currentColor;
  border-radius: 0.25rem;
}

.calculator-form__header {
  max-width: 48rem;
  margin-inline: auto;
  text-align: center;
}

.calculator-fieldset,
.calculator-filter {
  max-width: 48rem;
  margin-inline: auto;
  border: 0;
}

.calculator-fieldset {
  padding: 1.5rem 0 0;
}

.calculator-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}

.calculator-field {
  min-width: 0;
}

.calculator-field input,
.calculator-field select {
  width: min(100%, 32rem);
}

.calculator-hint {
  max-width: 46rem;
  margin-block: 0.25rem 0.75rem;
}

.calculator-help {
  max-width: 46rem;
  margin-block: 0.5rem 1rem;
}

.calculator-help summary,
.calculator-table-help summary {
  cursor: pointer;
  font-weight: 700;
}

.calculator-help p:last-child,
.calculator-table-help p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Currency input
   -------------------------------------------------------------------------- */

.calculator-currency-input {
  position: relative;
  width: min(100%, 32rem);
}

.calculator-currency-input__prefix {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.calculator-currency-input input {
  width: 100%;
  padding-left: 2rem;
}

/* --------------------------------------------------------------------------
   Filter checkbox
   -------------------------------------------------------------------------- */

.calculator-filter {
  margin-top: 2rem;
  padding: 1.5rem 0 0;
}

.calculator-filter legend {
  margin-bottom: 1rem;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Validation summary
   -------------------------------------------------------------------------- */

.calculator-error-summary {
  max-width: 48rem;
  margin: 1.5rem auto;
  padding: 1.25rem;
  border: 3px solid currentColor;
}

.calculator-error-summary h3 {
  margin-top: 0;
}

.calculator-error-summary ul {
  margin-bottom: 0;
}

.calculator-error-summary a {
  font-weight: 700;
}

/*
 * aria-invalid is managed in app.js. This extra outline does not replace
 * MDWDS focus styling; it provides a persistent visual indication of error.
 */
.calculator-app [aria-invalid="true"] {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Actions
   -------------------------------------------------------------------------- */

.calculator-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

/*
 * MDWDS supplies the actual button design. These rules only enforce a usable
 * target size and prevent cramped labels.
 */
.calculator-actions button {
  min-width: 10rem;
  min-height: 2.75rem;
}

.calculator-required-note {
  max-width: 48rem;
  margin: 1rem auto 0;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Results
   -------------------------------------------------------------------------- */

.calculator-results {
  margin-top: 3rem;
}

.calculator-results__heading,
.calculator-results h3 {
  text-align: center;
}

.calculator-results__heading {
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.calculator-result-message {
  margin-block: 1.5rem;
  padding: 1.25rem;
  border: 2px solid currentColor;
  text-align: center;
}

.calculator-result-message p:last-child {
  margin-bottom: 0;
}

.calculator-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  align-items: start;
}

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */

.calculator-chart {
  position: relative;
  width: 100%;
  min-height: 20rem;
  padding: 1rem;
  border: 1px solid currentColor;
}

.calculator-chart--donut {
  height: 23rem;
}

.calculator-chart--fpl {
  height: 21rem;
}

.calculator-chart-summary {
  margin-top: 1rem;
  text-align: center;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Results table
   -------------------------------------------------------------------------- */

.calculator-table-region {
  min-height: 20rem;
  overflow-x: auto;
  border: 1px solid currentColor;
}

.calculator-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calculator-table th,
.calculator-table td {
  padding: 1rem;
  border-bottom: 1px solid currentColor;
  vertical-align: top;
}

.calculator-table tr:last-child th,
.calculator-table tr:last-child td {
  border-bottom: 0;
}

.calculator-table th {
  width: 65%;
  text-align: left;
}

.calculator-table td {
  width: 35%;
  font-size: 1.125rem;
  font-weight: 700;
  text-align: right;
}

.calculator-table-help {
  margin-top: 0.5rem;
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   Federal Poverty Level and contact sections
   -------------------------------------------------------------------------- */

.calculator-fpl,
.calculator-contact {
  margin-top: 3rem;
  padding: 1.5rem;
  border: 1px solid currentColor;
}

.calculator-fpl > p,
.calculator-contact {
  text-align: center;
}

.calculator-heading-year {
  white-space: nowrap;
  font-size: 0.8em;
}

.calculator-fpl__summary {
  margin-block: 1.5rem;
  font-size: 1.125rem;
}

.calculator-fpl-note {
  max-width: 48rem;
  margin: 1rem auto 1.5rem;
  padding: 1rem 1.25rem;
  border-left: 0.25rem solid currentColor;
  text-align: left;
}

.calculator-fpl-note p {
  margin: 0;
}

/* --------------------------------------------------------------------------
   Responsive behavior
   -------------------------------------------------------------------------- */

@media (max-width: 56rem) {
  .calculator-results-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 36rem) {
  .calculator-app {
    padding: 0.75rem;
  }

  .calculator-form {
    padding: 1rem;
  }

  .calculator-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .calculator-actions button {
    width: 100%;
  }

  .calculator-table {
    table-layout: auto;
  }

  .calculator-table th {
    width: 60%;
  }

  .calculator-results__heading {
    letter-spacing: 0.04em;
  }
}


/* --------------------------------------------------------------------------
   Compact field-help disclosures
   --------------------------------------------------------------------------

   Each input keeps a normal, static HTML label. Directly below that label is
   a compact native <details>/<summary> disclosure. The arrow and prompt are
   the only elements that expand or collapse the explanation.
   -------------------------------------------------------------------------- */

.calculator-field-label {
  display: block;
  margin: 0 0 0.25rem;
  padding: 0;
  font-weight: 700;
}

.calculator-filter__label {
  margin-bottom: 0.25rem;
}



.calculator-field-help {
  width: min(100%, 46rem);
  margin: 0 0 0.75rem;
}

.calculator-field-help > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.25rem 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.calculator-field-help > summary::-webkit-details-marker {
  display: none;
}

.calculator-field-help__prompt {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.calculator-field-help__arrow {
  display: inline-block;
  flex: 0 0 auto;
  font-size: 0.85em;
  line-height: 1;
  transform-origin: center;
  transition: transform 0.15s ease-in-out;
}

.calculator-field-help[open] .calculator-field-help__arrow {
  transform: rotate(90deg);
}

.calculator-field-help__content {
  max-width: 46rem;
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  border-left: 0.25rem solid currentColor;
}

.calculator-field-help__content p {
  margin: 0;
}

.calculator-field-help + input,
.calculator-field-help + select,
.calculator-field-help + .calculator-currency-input,
.calculator-filter .calculator-checkbox {
  margin-top: 0.25rem;
}

.calculator-checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 46rem;
}

.calculator-checkbox input {
  margin: 0;
}

.calculator-checkbox__text {
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 36rem) {
  .calculator-field-help > summary {
    align-items: flex-start;
  }
}


/* ==========================================================================
   Legacy Bootstrap utility compatibility
   --------------------------------------------------------------------------
   These classes support markup carried over from the SharePoint calculator.
   They provide layout and spacing only. They do not recreate Bootstrap
   components, colors, typography, tooltips, or JavaScript behavior.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Visibility
   -------------------------------------------------------------------------- */

.d-none {
  display: none !important;
}

.d-block {
  display: block !important;
}

.d-inline-block {
  display: inline-block !important;
}

/* Prefer the native hidden attribute for new markup. */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Width and container utilities
   -------------------------------------------------------------------------- */

.container-fluid {
  width: 100%;
  margin-inline: auto;
}

.w-100 {
  width: 100% !important;
}

/* --------------------------------------------------------------------------
   Basic grid
   -------------------------------------------------------------------------- */

.row {
  display: flex;
  flex-wrap: wrap;
  margin-inline: -0.75rem;
}

.row > * {
  min-width: 0;
  padding-inline: 0.75rem;
}

.col-12 {
  flex: 0 0 auto;
  width: 100%;
}

.col-md-4,
.col-md-6 {
  flex: 0 0 auto;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Grid gaps
   -------------------------------------------------------------------------- */

.g-3 {
  row-gap: 1rem;
}

.g-4 {
  row-gap: 1.5rem;
}

.g-5 {
  row-gap: 3rem;
}

/* --------------------------------------------------------------------------
   Flex utilities
   -------------------------------------------------------------------------- */

.d-flex {
  display: flex !important;
}

.flex-column {
  flex-direction: column !important;
}

.flex-row {
  flex-direction: row !important;
}

.flex-wrap {
  flex-wrap: wrap !important;
}

.justify-content-center {
  justify-content: center !important;
}

.justify-content-around {
  justify-content: space-around !important;
}

.align-items-start {
  align-items: flex-start !important;
}

.align-items-center {
  align-items: center !important;
}

/* --------------------------------------------------------------------------
   Text alignment
   -------------------------------------------------------------------------- */

.text-center {
  text-align: center !important;
}

.text-start {
  text-align: left !important;
}

.text-end {
  text-align: right !important;
}

/* --------------------------------------------------------------------------
   Margin utilities
   -------------------------------------------------------------------------- */

.m-0 {
  margin: 0 !important;
}

.mt-1 {
  margin-top: 0.25rem !important;
}

.mt-3 {
  margin-top: 1rem !important;
}

.mt-4 {
  margin-top: 1.5rem !important;
}

.mt-5 {
  margin-top: 3rem !important;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mb-2 {
  margin-bottom: 0.5rem !important;
}

.mb-3 {
  margin-bottom: 1rem !important;
}

.mb-4 {
  margin-bottom: 1.5rem !important;
}

.mb-5 {
  margin-bottom: 3rem !important;
}

.ms-2 {
  margin-left: 0.5rem !important;
}

.me-2 {
  margin-right: 0.5rem !important;
}

.mx-5 {
  margin-inline: 3rem !important;
}

.my-5 {
  margin-block: 3rem !important;
}

/* --------------------------------------------------------------------------
   Padding utilities
   -------------------------------------------------------------------------- */

.p-0 {
  padding: 0 !important;
}

.p-3 {
  padding: 1rem !important;
}

.p-4 {
  padding: 1.5rem !important;
}

/* --------------------------------------------------------------------------
   Borders
   -------------------------------------------------------------------------- */

.border {
  border: 1px solid currentColor !important;
}

.rounded {
  border-radius: 0.25rem !important;
}

/* --------------------------------------------------------------------------
   Links
   -------------------------------------------------------------------------- */

.text-decoration-underline {
  text-decoration: underline !important;
}

/* --------------------------------------------------------------------------
   Responsive utilities
   -------------------------------------------------------------------------- */

@media (min-width: 48rem) {
  .col-md-4 {
    width: 33.333333%;
  }

  .col-md-6 {
    width: 50%;
  }

  .flex-md-row {
    flex-direction: row !important;
  }

  .text-md-start {
    text-align: left !important;
  }

  .text-md-end {
    text-align: right !important;
  }

  .mb-md-0 {
    margin-bottom: 0 !important;
  }

  .mt-md-0 {
    margin-top: 0 !important;
  }
}

/* --------------------------------------------------------------------------
   Print behavior
   -------------------------------------------------------------------------- */

@media print {
  @page {
    size: landscape;
    margin: 0.5in;
  }

  .screen-only,
  .no-print,
  .calculator-field-help,
  .calculator-table-help {
    display: none !important;
  }

  body,
  .calculator-app {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .calculator-form {
    margin-top: 0;
    padding: 1rem;
    border-width: 2px;
    break-inside: avoid;
  }

  .calculator-results {
    display: block !important;
    margin-top: 1rem;
  }

  .calculator-results__heading {
    break-before: page;
  }

  .calculator-results-grid,
  .calculator-fpl,
  .calculator-contact {
    break-inside: avoid;
  }

  .calculator-chart {
    min-height: 18rem;
    border: 1px solid currentColor;
  }

  .calculator-chart--donut,
  .calculator-chart--fpl {
    height: 18rem;
  }

  canvas {
    max-width: 100% !important;
  }

  a {
    color: currentColor;
    text-decoration: none;
  }
}

/* --------------------------------------------------------------------------
   Optimized print layout
   -------------------------------------------------------------------------- */

/* Chart snapshots are created by app.js immediately before printing. Using an
   image in the print layout prevents Chart.js from resizing a canvas while the
   browser is paginating the document. */
.calculator-print-chart {
  display: none;
}

@media print {
  @page {
    size: letter landscape;
    margin: 0.35in;
  }

  html,
  body {
    font-size: 10pt;
  }

  body {
    color: #000;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .calculator-app {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  /* Keep the entered values, but change the form from a tall single-column
     screen layout into a compact three-column print summary. */
  .calculator-form {
    margin: 0;
    padding: 0.16in 0.22in;
    border-width: 1.5px;
    border-radius: 0;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .calculator-form__header {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: baseline;
    gap: 0.18in;
    max-width: none;
    margin: 0;
    text-align: left;
  }

  .calculator-form__header h2 {
    margin: 0;
    font-size: 15pt;
    line-height: 1.15;
  }

  .calculator-form__header p {
    margin: 0;
    font-size: 9pt;
    line-height: 1.25;
  }

  .calculator-fieldset {
    max-width: none;
    margin: 0;
    padding: 0.12in 0 0;
  }

  .calculator-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.16in;
  }

  .calculator-field-label {
    margin-bottom: 0.03in;
    font-size: 9pt;
    line-height: 1.15;
  }

  .calculator-field input,
  .calculator-field select,
  .calculator-currency-input {
    width: 100%;
    max-width: none;
  }

  .calculator-field input,
  .calculator-field select {
    min-height: 0;
    height: 0.32in;
    padding: 0.04in 0.08in;
    border: 1px solid #555;
    border-radius: 0;
    color: #000;
    background: #fff;
    font-size: 10pt;
    line-height: 1.1;
  }

  .calculator-currency-input__prefix {
    left: 0.09in;
  }

  .calculator-currency-input input {
    padding-left: 0.22in;
  }

  .calculator-filter {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: 0.16in;
    max-width: none;
    margin: 0.12in 0 0;
    padding: 0.09in 0 0;
    border-top: 1px solid #aaa;
  }

  .calculator-filter__label,
  .calculator-filter .calculator-checkbox {
    margin: 0;
  }

  .calculator-checkbox__text {
    font-size: 9pt;
  }

  .calculator-required-note {
    display: none;
  }

  /* Core results remain together beneath the compact input summary. */
  .calculator-results {
    margin-top: 0.16in;
  }

  .calculator-results__heading {
    margin: 0 0 0.09in;
    font-size: 15pt;
    line-height: 1.15;
    letter-spacing: 0.04em;
    break-before: auto;
    break-after: avoid-page;
    page-break-before: auto;
    page-break-after: avoid;
  }

  .calculator-result-message {
    margin: 0 0 0.1in;
    padding: 0.1in 0.14in;
    font-size: 9pt;
  }

  .calculator-results-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 0.18in;
    align-items: start;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .calculator-results-grid > section {
    min-width: 0;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .calculator-results h3 {
    margin: 0 0 0.04in;
    font-size: 12pt;
    line-height: 1.15;
  }

  .calculator-hint {
    margin: 0 0 0.05in;
    font-size: 8pt;
    line-height: 1.2;
  }

  .calculator-chart {
    min-height: 0;
    padding: 0.06in;
    overflow: hidden;
  }

  .calculator-chart--donut {
    height: 2.15in;
  }

  .calculator-chart--fpl {
    height: 3.15in;
  }

  .calculator-chart canvas {
    display: none !important;
  }

  .calculator-print-chart {
    display: block !important;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  .calculator-chart-summary {
    margin: 0.04in 0 0;
    font-size: 8pt;
    line-height: 1.2;
  }

  .calculator-table-region {
    min-height: 0;
    overflow: visible;
  }

  .calculator-table {
    table-layout: fixed;
  }

  .calculator-table tr,
  .calculator-table th,
  .calculator-table td {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .calculator-table th,
  .calculator-table td {
    padding: 0.065in 0.08in;
    font-size: 8.5pt;
    line-height: 1.15;
  }

  .calculator-table th {
    width: 68%;
  }

  .calculator-table td {
    width: 32%;
    font-size: 9.5pt;
  }

  #displayMonthsLabel {
    display: block;
    margin-top: 0.02in;
    font-size: 7.5pt;
    font-weight: 400;
  }

  /* The FPL section starts page 2 and is deliberately sized to leave room for
     its summary and the contact block. */
  .calculator-fpl {
    margin: 0;
    padding: 0.18in 0.22in;
    break-before: page;
    page-break-before: always;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .calculator-fpl h3 {
    margin: 0;
    font-size: 15pt;
    line-height: 1.15;
  }

  .calculator-fpl > p,
  .calculator-fpl__summary {
    margin: 0.07in 0;
    font-size: 9pt;
    line-height: 1.25;
  }

  .calculator-fpl-note {
    margin: 0.07in auto;
    padding: 0.07in 0.1in;
    font-size: 8.5pt;
  }

  .calculator-contact {
    margin: 0.16in 0 0;
    padding: 0.13in 0.18in;
    break-inside: avoid-page;
    page-break-inside: avoid;
    font-size: 9pt;
    line-height: 1.25;
  }

  .calculator-contact p {
    margin: 0;
  }
}
