/* Calculator pages (/calculators/). OWNER: calculators builder.
   The main site's look: square corners, hairline boxes, www's form fields (site.css), the
   result in a navy panel, rule tables as www's white tables, and the list of calculators as
   www's tool cards. Every rule is scoped to .calc-page so it cannot change the shared
   layout. Mobile first; no sideways scrolling at 375px (wide tables scroll inside
   .table-wrap). Colours come from the --c-* brand properties the layout sets from
   src/brand.js. Warnings are www's notice: cream, a gold rule and brown text. */

.calc-page {
  --calc-warn-bg: var(--c-surface);
  --calc-warn-ink: var(--c-notice);
  --calc-warn-line: var(--c-accent);
  min-width: 0;
}

.calc-page [hidden] {
  display: none !important;
}

/* The notes under the hero: www's gold-ruled note */

.calc-page .calc-privacy,
.calc-page .calc-noscript {
  max-width: 760px;
  margin: 0 0 40px;
  padding: 18px 20px;
  border-left: 3px solid var(--c-accent);
  background: var(--c-surface);
  color: var(--c-ink);
  font-size: 15px;
}

.calc-page .calc-noscript {
  border-left-color: var(--calc-warn-line);
  background: var(--calc-warn-bg);
  color: var(--calc-warn-ink);
}

/* Form and results: one column on phones, two side by side on wide screens. */

.calc-layout {
  display: grid;
  gap: 32px;
  align-items: start;
}

.calc-layout > * {
  min-width: 0;
}

.calc-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.calc-section {
  min-width: 0;
  margin: 0 0 16px;
  padding: 20px 18px 22px;
  border: 1px solid var(--c-line);
  background: var(--c-raised);
}

.calc-section legend {
  float: left;
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  color: var(--c-primary);
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 470;
  line-height: 1.25;
}

.calc-section legend + * {
  clear: both;
}

.calc-grid {
  display: grid;
  gap: 0 20px;
  clear: both;
}

.calc-field {
  min-width: 0;
  margin-top: 18px;
}

.calc-page .calc-hint {
  margin: -3px 0 9px;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1.45;
}

.calc-section > .calc-hint {
  clear: both;
  margin: 4px 0 0;
}

.calc-input {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.calc-input input {
  min-width: 0;
  flex: 1 1 auto;
}

.calc-affix {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--c-field-line);
  background: var(--c-surface);
  color: var(--c-muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.calc-input.has-prefix .calc-affix {
  border-right: 0;
}

.calc-input.has-suffix .calc-affix {
  border-left: 0;
}

.calc-fields:disabled input,
.calc-fields:disabled select {
  background-color: var(--c-surface);
  color: inherit;
  opacity: 1;
}

.calc-actions {
  margin: 0;
}

/* www's quiet outline button */
.calc-button-secondary {
  display: inline-flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  padding: 0 23px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--c-line);
  color: var(--c-primary);
  cursor: pointer;
  font-size: var(--t-ui-size);
  font-weight: var(--t-ui-weight);
  transition: background 180ms ease;
}

.calc-button-secondary:hover {
  background: var(--c-surface);
}

/* Results */

.calc-results {
  min-width: 0;
  padding: 22px 18px;
  border: 1px solid var(--c-line);
  background: var(--c-raised);
}

.calc-results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 18px;
}

.page-body .calc-results-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--t-subhead-size);
  font-weight: 520;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.calc-status {
  color: var(--c-link);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.calc-hero {
  position: relative;
  overflow: hidden;
  margin: 0 0 16px;
  padding: 24px 22px;
  background: var(--c-primary);
  color: var(--c-on-primary);
}

.calc-hero p {
  max-width: none;
  margin: 0;
}

.calc-hero-label {
  color: var(--c-eyebrow-on-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.calc-hero-value {
  margin-top: 10px !important;
  font-size: clamp(38px, 4.2vw, 54px);
  font-weight: var(--t-section-weight);
  letter-spacing: -0.045em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.calc-hero.is-empty .calc-hero-value {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.calc-hero-sub {
  margin-top: 10px !important;
  color: var(--c-intro-on-primary);
  font-size: 15px;
}

.calc-cards {
  display: grid;
  gap: 1px;
  margin: 0 0 16px;
  padding: 1px;
  background: var(--c-line);
}

.calc-card {
  padding: 16px 18px;
  background: var(--c-raised);
}

.calc-card p {
  max-width: none;
  margin: 0;
}

.calc-card-label {
  color: var(--c-link);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}

.calc-card-value {
  margin-top: 6px !important;
  color: var(--c-primary);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.calc-card-sub {
  margin-top: 4px !important;
  color: var(--c-muted);
  font-size: 13px;
}

.calc-page .calc-table {
  background: var(--c-raised);
}

.calc-table caption {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--c-line);
  background: var(--c-surface);
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.45;
  text-align: left;
  text-transform: uppercase;
}

/* Label and value rows (a result): the label is plain, the value bold. In a grid (the
   rule tables) row labels are bold, as in www's tables. */
.calc-table:not(.is-grid) th[scope="row"] {
  color: var(--c-ink);
  font-weight: 500;
}

.calc-table .num {
  text-align: right;
  white-space: nowrap;
}

.calc-table.is-list th[scope="row"] {
  width: 50%;
}

.calc-table.is-list td {
  font-weight: 500;
}

.calc-table tr.is-total th,
.calc-table tr.is-total td {
  border-top: 2px solid var(--c-primary);
  color: var(--c-primary);
  font-weight: 800;
}

.calc-table tr.is-sub th {
  padding-left: 28px;
  color: var(--c-muted);
}

.calc-notes {
  max-width: none;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.calc-page .calc-note {
  max-width: none;
  margin: 0 0 8px;
  padding: 14px 16px;
  border-left: 3px solid var(--c-tint);
  background: var(--c-surface);
  color: var(--c-ink);
  font-size: 14px;
  line-height: 1.55;
}

.calc-page .calc-note.is-warn {
  border-left-color: var(--c-accent);
  background: var(--calc-warn-bg);
  color: var(--calc-warn-ink);
}

.calc-schedule {
  margin: 0 0 16px;
}

.calc-schedule summary,
.calc-send summary {
  display: inline-flex;
  width: fit-content;
  padding: 4px 0;
  border-bottom: 1px solid var(--c-primary);
  color: var(--c-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.calc-schedule[open] summary,
.calc-send details[open] summary {
  margin-bottom: 14px;
}

.calc-page .calc-disclaimer {
  margin: 0;
  color: var(--c-muted);
  font-size: 13px;
}

/* "Want a consultant to go through these numbers?" */

.calc-send {
  max-width: 760px;
  margin-top: 40px;
  padding: 24px 20px;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
}

.page-body .calc-send h2 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: var(--t-subhead-size);
  font-weight: 520;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.calc-send p {
  color: var(--c-muted);
  font-size: 15px;
}

.calc-preview {
  max-width: 100%;
  overflow-x: auto;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--c-line);
  background: var(--c-raised);
  font-size: 13px;
  white-space: pre-wrap;
}

/* Rule tables: a full-width cream band, like www's sections (site.css .pd-section), that
   runs on to the consult band with the link to every calculator. */

.calc-rules,
.calc-page .calc-more {
  background: var(--c-surface);
  box-shadow: 0 0 0 100vmax var(--c-surface);
  clip-path: inset(0 -100vmax);
}

.calc-rules {
  margin-top: 52px;
  padding-top: 52px;
}

.calc-rules > p {
  color: var(--c-muted);
  font-size: var(--t-copy-size);
}

.calc-rule {
  margin-top: 40px;
}

.calc-rule .table-wrap {
  margin-bottom: 12px;
}

.calc-page .calc-rule-note {
  color: var(--c-ink);
  font-size: 15px;
}

.calc-sources {
  max-width: 760px;
  margin: 0;
  padding-left: 1.2rem;
  color: var(--c-muted);
  font-size: 14px;
}

.calc-page .calc-more {
  margin: 0 0 -52px;
  padding: 44px 0 52px;
}

.calc-page .calc-more a {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--c-primary);
  color: var(--c-primary);
  font-size: var(--t-ui-size);
  font-weight: var(--t-ui-weight);
  text-decoration: none;
}

.calc-page .calc-more a::after {
  content: "\2197";
  content: "\2197" / "";
}

/* The list of calculators: www's tool cards in a hairline grid */

.calc-hub-group + .calc-hub-group {
  margin-top: 52px;
}

/* Group headings: www's serif table heading (the fee guide), not a section heading. */
.page-body .calc-hub-group h2 {
  margin: 0 0 22px;
  font-family: var(--font-serif);
  font-size: var(--t-subhead-size);
  font-weight: 520;
  letter-spacing: 0;
  line-height: 1.1;
}

.calc-hub-list {
  display: grid;
  max-width: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--c-line);
  border-left: 1px solid var(--c-line);
  list-style: none;
}

.calc-hub-list li {
  max-width: none;
  min-width: 0;
}

.page-body .calc-hub-list a {
  display: flex;
  height: 100%;
  min-height: 220px;
  flex-direction: column;
  padding: 24px 22px;
  border-right: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease;
}

.page-body .calc-hub-list a:hover {
  position: relative;
  z-index: 2;
  transform: translateY(-7px);
  background: var(--c-raised);
}

.calc-hub-list i {
  order: -1;
  margin-bottom: 28px;
  color: var(--c-link);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.calc-hub-list strong {
  display: block;
  color: var(--c-primary);
  font-family: var(--font-serif);
  font-size: var(--t-card-size);
  font-weight: var(--t-card-weight);
  letter-spacing: var(--t-card-tracking);
  line-height: 1.1;
}

.calc-hub-list span {
  display: block;
  margin-top: 12px;
  color: var(--c-muted);
  font-size: 14px;
  font-weight: 500;
}

/* www's card link line, at the foot of the card */
.calc-hub-list .calc-hub-go {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 800;
}

.calc-hub-list .calc-hub-go::after {
  content: "\2197";
  content: "\2197" / "";
}

@media (min-width: 640px) {
  .calc-grid,
  .calc-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calc-hub-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calc-button-secondary {
    width: auto;
  }
}

@media (min-width: 761px) {
  .calc-page .calc-privacy,
  .calc-page .calc-noscript {
    margin-bottom: 56px;
    padding: 22px 24px;
  }

  .calc-section {
    padding: 24px 28px 28px;
  }

  .calc-results {
    padding: 28px;
  }

  .calc-hero {
    padding: 30px 28px;
  }

  .calc-send {
    margin-top: 56px;
    padding: 32px;
  }

  .calc-rules {
    margin-top: 80px;
    padding-top: 80px;
  }

  .calc-page .calc-more {
    margin-bottom: -80px;
    padding: 56px 0 80px;
  }

  .calc-hub-group + .calc-hub-group {
    margin-top: 72px;
  }

  .page-body .calc-hub-list a {
    min-height: 250px;
    padding: 27px;
  }
}

@media (min-width: 981px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
  }

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

  .calc-hub-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-body .calc-hub-list a:hover {
    transform: none;
  }
}

/* Result grids at phone width (the year-by-year tables, the payment stages, the side-by-side
   comparison): tighter cells, so two or three columns of figures fit beside their labels
   without scrolling the box. */
@media (max-width: 480px) {
  .calc-results .calc-table.is-grid th,
  .calc-results .calc-table.is-grid td {
    padding: 10px 8px;
    font-size: 13px;
  }
}
