/* ============================================
   SIGNAL HOMECARE — costs.css
   Cost comparison page: slider calculator,
   cost table, capability matrix
   ============================================ */

/* ----- Calculator card ----- */
.calc {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  max-width: 900px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .calc {
    padding: var(--space-2xl);
  }
}

.calc__legend {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-heading);
  line-height: 1.35;
  display: block;
  margin-bottom: var(--space-xs);
}

.calc__hint {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xl);
}

/* ----- Slider control ----- */
.calc__control {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.calc__slider {
  flex: 1 1 auto;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 2.75rem;
  background: transparent;
  cursor: pointer;
}

/* Restore a focus ring: styles.css sets input:focus-visible { outline: none } */
.calc__slider:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.calc__slider::-webkit-slider-runnable-track {
  height: 0.625rem;
  /* Pill, not 50% — --radius-full is 50%, which on a wide, short
     track renders an ellipse rather than a rounded bar. */
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
}

.calc__slider::-moz-range-track {
  height: 0.625rem;
  /* Pill, not 50% — --radius-full is 50%, which on a wide, short
     track renders an ellipse rather than a rounded bar. */
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
}

.calc__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 2rem;
  height: 2rem;
  margin-top: -0.75rem;
  border-radius: var(--radius-full);
  background: var(--surface-inverse);
  border: 3px solid var(--white);
  box-shadow: var(--shadow-md);
}

.calc__slider::-moz-range-thumb {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: var(--surface-inverse);
  border: 3px solid var(--white);
  box-shadow: var(--shadow-md);
}

/* Stepper buttons — a range input alone is hard to use on a phone
   or with a tremor, and this page's readers skew that way. */
.calc__stepper {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--text-brand);
  border: 2px solid var(--border-strong);
  font-size: 1.375rem;
  line-height: 1;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.calc__stepper:hover:not(:disabled) {
  background: var(--surface-sunken);
  border-color: var(--border-default);
}

.calc__stepper:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.calc__readout {
  text-align: center;
  margin-top: var(--space-md);
  font-size: 1.125rem;
  color: var(--text-body);
}

.calc__readout strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-heading);
  font-weight: 400;
}

/* Names the common patterns — "one every day", "weekdays only" —
   so the count reads the way families actually think about it. */
.calc__readout-note {
  display: block;
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ----- Results bars ----- */
.calc__results {
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-xl);
}

.calc__row + .calc__row {
  margin-top: var(--space-lg);
}

.calc__row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}

.calc__row-label {
  font-weight: 600;
  color: var(--text-body);
  font-size: 0.9375rem;
}

.calc__row-value {
  font-family: var(--font-display);
  font-size: 1.375rem;
  color: var(--text-heading);
  white-space: nowrap;
}

.calc__bar {
  height: 1.75rem;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calc__bar-fill {
  height: 100%;
  /* Keeps the shortest bar visible when it is ~2% of the longest.
     The figure is always printed as text as well, so the bar is
     illustrative rather than the only way to read the number. */
  min-width: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-inverse);
  transition: width var(--transition-slow);
}

.calc__bar-fill--signal {
  background: var(--action-primary);
}

.calc__bar-fill--signal-first {
  background: var(--action-primary);
  opacity: 0.55;
}

.calc__equiv {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--surface-sunken);
  border-left: 4px solid var(--action-primary);
  border-radius: var(--radius-sm);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-body);
}

.calc__assumption {
  margin-top: var(--space-lg);
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ----- Scrollable table wrapper ----- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.table-scroll__hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

@media (min-width: 900px) {
  .table-scroll__hint {
    display: none;
  }
}

/* ----- Cost table ----- */
.cost-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cost-table th,
.cost-table td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9375rem;
  vertical-align: top;
}

.cost-table thead th {
  background: var(--surface-inverse);
  color: var(--white);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  border-bottom: none;
}

.cost-table tbody th {
  font-weight: 600;
  color: var(--text-heading);
  font-family: var(--font-sans);
}

.cost-table tbody tr:last-child th,
.cost-table tbody tr:last-child td {
  border-bottom: none;
}

.cost-table .is-signal th,
.cost-table .is-signal td {
  background: var(--surface-brand-soft);
  border-top: 2px solid var(--action-primary);
  border-bottom: 2px solid var(--action-primary);
}

.cost-table .is-signal th {
  color: var(--action-primary);
}

.cost-table__cost {
  white-space: nowrap;
  font-weight: 600;
}

/* ----- Capability matrix ----- */
.matrix {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.matrix th,
.matrix td {
  padding: var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  text-align: center;
}

.matrix thead th {
  background: var(--surface-inverse);
  color: var(--white);
  font-family: var(--font-sans);
  font-weight: 600;
  vertical-align: bottom;
  border-bottom: none;
}

.matrix thead th.is-signal {
  background: var(--action-primary);
}

/* First column carries the row question — pin it so the row stays
   identifiable while the table scrolls sideways on narrow screens. */
.matrix tbody th,
.matrix thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  min-width: 15rem;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-heading);
}

.matrix tbody th {
  background: var(--white);
  box-shadow: 1px 0 0 var(--border-subtle);
}

.matrix thead th:first-child {
  background: var(--surface-inverse);
  z-index: 2;
}

.matrix tbody td.is-signal {
  background: var(--surface-brand-soft);
}

.matrix tbody tr:last-child th,
.matrix tbody tr:last-child td {
  border-bottom: none;
}

.matrix__mark {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
}

.matrix__mark--yes {
  color: var(--status-steady);
}

.matrix__mark--no {
  color: var(--action-primary);
}

.matrix__mark--partly {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ----- High contrast ----- */
html.a11y-high-contrast .calc,
html.a11y-high-contrast .cost-table,
html.a11y-high-contrast .matrix {
  border: 2px solid #000000;
}

html.a11y-high-contrast .calc__bar {
  border: 1px solid #000000;
}

/* Distinguishing the bars by fill alone is not enough once
   ink and maroon both darken — add a hatch to the
   first-year bar so the three rows stay tellable apart. */
html.a11y-high-contrast .calc__bar-fill--signal-first {
  opacity: 1;
  background: repeating-linear-gradient(
    45deg,
    #4a161d,
    #4a161d 6px,
    #FFFFFF 6px,
    #FFFFFF 10px
  );
}

html.a11y-high-contrast .matrix__mark--yes {
  color: #00470F;
}

/* ----- Narrow screens ----- */
@media (max-width: 600px) {
  .calc {
    padding: var(--space-lg);
  }

  .calc__row-value {
    font-size: 1.25rem;
  }

  .calc__equiv {
    font-size: 1rem;
  }
}
