/* Tiny Home Raleigh calculators (/lot-rules, /cost, /money).
   Theme tokens from sites/tiny-home-raleigh/site.json with page-token fallbacks:
   brand #1F3A5F, bg #F7F4EC, accent #BF8233, hairline borders, radius 6, flat shadow. */

.thr-calc {
  --thr-brand: var(--brand, #1F3A5F);
  --thr-page: var(--page, #F7F4EC);
  --thr-accent: var(--accent, #BF8233);
  --thr-line: var(--line, #D9D2C2);
  --thr-surface: var(--surface, #FBF9F4);
  --thr-muted: var(--muted, #555A60);
  max-width: 44rem;
  margin-inline: auto;
  padding: 1.4rem 1.2rem 1.2rem;
  background: var(--thr-surface);
  color: var(--text, #1B1F24);
  border: 1px solid var(--thr-line);
  border-radius: 6px;
  box-shadow: 2px 2px 0 rgb(31 58 95 / 0.08);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.thr-calc h2 {
  margin: 0 0 0.4rem;
  color: var(--thr-brand);
  font-size: 1.35rem;
  line-height: 1.25;
}

.thr-calc h3 {
  margin: 0 0 0.3rem;
  color: var(--thr-brand);
  font-size: 1rem;
}

.thr-lead {
  margin: 0 0 1rem;
  color: var(--thr-muted);
}

.thr-form {
  margin: 0 0 1rem;
}

.thr-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .thr-grid { grid-template-columns: 1fr 1fr; }
  .thr-field--wide { grid-column: 1 / -1; }
}

.thr-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.thr-field label,
.thr-field legend,
.thr-legend {
  display: block;
  margin: 0 0 0.25rem;
  padding: 0;
  font-weight: 600;
  color: var(--thr-brand);
}

.thr-field input[type="number"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--thr-line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.thr-choices {
  display: block;
}

.thr-choice {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin: 0.25rem 0;
  min-width: 0;
}

.thr-choice input {
  flex: none;
  accent-color: var(--thr-brand);
}

.thr-hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--thr-muted);
}

.thr-result {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--thr-line);
  border-left: 4px solid var(--thr-accent);
  border-radius: 6px;
  background: var(--thr-page);
}

.thr-result:empty {
  display: none;
}

.thr-headline {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.thr-warnings {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
}

.thr-lines {
  margin: 0;
}

/* Result lines stack by default so a long break-even value ("323 months
   (26 years, 11 months)") can never force horizontal scroll at 320px;
   the two-column row returns only where there is room for it. */
.thr-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--thr-line);
}

.thr-line:last-of-type {
  border-bottom: 0;
}

.thr-line dt {
  min-width: 0;
  color: var(--thr-muted);
}

.thr-line dd {
  margin: 0;
  font-weight: 700;
  color: var(--thr-brand);
  white-space: normal;
  overflow-wrap: break-word;
  min-width: 0;
  max-width: 100%;
}

/* Same specificity as the base rules, so this must come AFTER them in source
   order to win; the two-column row returns only where there is room for it. */
@media (min-width: 640px) {
  .thr-line {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
  }
}

.thr-table {
  width: 100%;
  max-width: 100%;
  margin: 0 0 1rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.thr-table caption {
  text-align: left;
  font-weight: 600;
  color: var(--thr-brand);
  padding-bottom: 0.35rem;
}

.thr-table th,
.thr-table td {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--thr-line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.thr-table thead th {
  background: var(--thr-page);
  color: var(--thr-brand);
}

.thr-benchmarks {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
  margin: 0 0 1rem;
}

@media (min-width: 640px) {
  .thr-benchmarks { grid-template-columns: 1fr 1fr; }
}

.thr-benchmark {
  min-width: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--thr-line);
  border-radius: 6px;
  background: var(--thr-page);
}

.thr-amount {
  margin: 0 0 0.2rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--thr-brand);
}

.thr-label {
  margin: 0 0 0.3rem;
  font-weight: 600;
}

.thr-source {
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
  color: var(--thr-muted);
}

.thr-note {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--thr-muted);
}

.thr-sources ul {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.thr-sources a {
  color: var(--link, #1F3A5F);
}

.thr-disclaimer {
  margin: 0.8rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--thr-line);
  font-size: 0.88rem;
  color: var(--thr-muted);
}
