/* Let the calculator column shrink to the viewport, not the table's min-content width. */
.pph21-page .layout > div,
.pph21-page #results {
  min-width: 0;
}

.pph21-page #results .amount,
.pph21-page #results .note,
.pph21-page #results .breakdown-legend {
  overflow-wrap: anywhere;
}

/* The desktop workspace has a half-width result column. Fit the four-column
   breakdown with normal word wrapping, not mid-word breaks from #results. */
@media screen and (min-width: 1024px) {
  .pph21-page #results th,
  .pph21-page #results td {
    padding-inline: 8px;
    overflow-wrap: normal;
    word-break: normal;
  }
}

@media screen and (max-width: 640px) {
  .pph21-page #results .result-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pph21-page #results .calc-action-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .pph21-page #results .btn {
    min-width: 0;
    white-space: normal;
  }

  /* Preserve the table semantics; repeat each column heading beside its value. */
  .pph21-page #results thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    border: 0;
  }

  .pph21-page #results table,
  .pph21-page #results tbody {
    display: block;
  }

  .pph21-page #results tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .pph21-page #results td {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 12px;
    padding: 6px 0;
    border: 0;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .pph21-page #results td::before {
    content: attr(data-label);
    color: var(--ink-soft);
    font-family: var(--font-sans, sans-serif);
    font-size: .78rem;
    font-weight: 500;
  }
}
