/* DriveTrust tools: shared layout and form styling for every calculator under /learn/tools/.
   Loaded after styles.css. Reuses the site's .dt-form fields, .dt-btn buttons,
   .dt-crumb breadcrumb, .dt-learn-header title block and .dt-learn-cta block. */

.dt-tool-page .dt-container {
  max-width: 1200px;
  padding: 0 2rem;
}

.dt-tool-page [hidden],
.dt-tool-embed [hidden] {
  display: none !important;
}

.dt-tool-page .dt-learn-header {
  margin-bottom: 3rem;
}

/* ---------- Calculator + result, side by side on desktop ---------- */
.dt-tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

/* A tool embedded inside an article: one column, since the article column is narrow.
   The ".dt-tool-embed ..." selectors added to rules below re-apply the tool's own text styles,
   which the article's paragraph rule would otherwise override. Values live only in those rules. */
.dt-tool-embed {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0 1rem;
}

/* Undo the article's paragraph spacing and size inside the tool, so its text sits
   exactly as on the tool's own page (where paragraphs have no margin and inherit). */
.dt-tool-embed p {
  margin-bottom: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

.dt-tool-panel,
.dt-tool-result {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2rem;
}

.dt-tool-panel-title {
  font-family: var(--font-family-serif);
  font-size: 26px;
  color: var(--color-text-primary);
  margin-bottom: 1.5rem;
}

/* ---------- Fields ---------- */
.dt-tool-form .dt-form-label {
  font-size: 13px;
}

.dt-tool-form input,
.dt-tool-form select {
  border-radius: 4px;
  font-size: 16px; /* 16px stops iOS zooming into the field */
}

.dt-tool-form input[aria-invalid="true"],
.dt-tool-form select[aria-invalid="true"] {
  border-color: #e06c5a;
}

.dt-field-hint,
.dt-tool-embed .dt-field-hint {
  margin-top: 0.4rem;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.dt-field-error,
.dt-tool-embed .dt-field-error {
  margin-top: 0.4rem;
  font-size: 13px;
  line-height: 1.5;
  color: #f2b8ac;
}

.dt-tool-submit {
  width: 100%;
  margin-top: 0.25rem;
  font-size: 14px;
  padding: 1rem 2rem;
}

/* ---------- Result ---------- */
.dt-tool-result-empty,
.dt-tool-embed .dt-tool-result-empty {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.dt-tool-result-empty strong,
.dt-tool-embed .dt-tool-result-empty strong {
  display: block;
  font-family: var(--font-family-serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 0.5rem;
}

.dt-tool-result.is-filled {
  border-color: rgba(201, 168, 76, 0.35);
}

.dt-tool-result-eyebrow,
.dt-tool-embed .dt-tool-result-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9a84c;
  margin-bottom: 0.75rem;
}

.dt-tool-rule,
.dt-tool-embed .dt-tool-rule {
  font-family: var(--font-family-serif);
  font-size: 24px;
  line-height: 1.3;
  color: var(--color-text-primary);
  margin-bottom: 1.5rem;
}

/* Side by side when each box has room for its label on one line, stacked otherwise. */
.dt-tool-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.dt-tool-stat {
  padding: 1rem 1.25rem;
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.dt-tool-stat-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

/* Figures use the sans font: the serif's old-style numerals make "$150" read like "$1 50". */
.dt-tool-stat-value {
  margin: 0.35rem 0 0.15rem;
  font-family: var(--font-family-sans);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: #c9a84c;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dt-tool-stat-sub {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.dt-tool-verdict,
.dt-tool-embed .dt-tool-verdict {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.6;
}

.dt-tool-verdict--ok,
.dt-tool-embed .dt-tool-verdict--ok {
  border-color: rgba(201, 168, 76, 0.35);
  border-left-color: #c9a84c;
  background: var(--color-gold-light);
  color: var(--color-text-primary);
}

.dt-tool-verdict--warn,
.dt-tool-embed .dt-tool-verdict--warn {
  border-color: rgba(224, 108, 90, 0.45);
  border-left-color: #e06c5a;
  background: rgba(224, 108, 90, 0.1);
  color: #f5d3cb;
}

.dt-tool-notes {
  margin: 0 0 1.25rem;
  padding-left: 1.1rem;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.dt-tool-notes li + li {
  margin-top: 0.35rem;
}

.dt-tool-tip,
.dt-tool-embed .dt-tool-tip {
  font-size: 14px;
  line-height: 1.65;
  color: var(--color-text-secondary);
}

.dt-tool-tip strong,
.dt-tool-embed .dt-tool-tip strong {
  color: #c9a84c;
  font-weight: 600;
}

.dt-tool-source,
.dt-tool-embed .dt-tool-source {
  margin-top: 1rem;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

/* ---------- Grouped fields, hints with links, on/off switch ---------- */
.dt-tool-fieldset {
  border: 0;
  margin: 0;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--color-border);
  min-width: 0;
}

.dt-tool-fieldset legend {
  float: left; /* keeps the legend inside the fieldset's top border spacing */
  width: 100%;
  padding: 0;
  margin-bottom: 1rem;
  font-family: var(--font-family-serif);
  font-size: 22px;
  color: var(--color-text-primary);
}

.dt-tool-fieldset legend + * {
  clear: both;
}

.dt-tool-form .dt-form-row > div {
  min-width: 0;
}

.dt-field-hint a {
  color: #c9a84c;
}

.dt-field-hint a:hover {
  color: var(--color-gold-hover);
}

.dt-tool-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-family-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
}

.dt-tool-switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--color-border-hover);
  transition: background-color 0.25s ease;
}

.dt-tool-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-text-secondary);
  transition: transform 0.25s ease, background-color 0.25s ease;
}

.dt-tool-switch[aria-expanded="true"] .dt-tool-switch-track {
  background: #c9a84c;
}

.dt-tool-switch[aria-expanded="true"] .dt-tool-switch-track::after {
  transform: translateX(18px);
  background: var(--color-bg-dark);
}

.dt-tool-switch:focus-visible {
  outline: 2px solid #c9a84c;
  outline-offset: 4px;
}

/* Two-option segmented switch built from radio buttons (keyboard: arrow keys move between options) */
.dt-tool-segment-field {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.dt-tool-segment {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  background: rgba(7, 7, 7, 0.6);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.dt-tool-segment label {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.dt-tool-form .dt-tool-segment input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
}

.dt-tool-segment span {
  display: block;
  padding: 0.55rem 1.1rem;
  border-radius: 3px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  color: var(--color-text-secondary);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.dt-tool-segment input:checked + span {
  background: #c9a84c;
  color: var(--color-bg-dark);
}

.dt-tool-segment input:focus-visible + span {
  outline: 2px solid #c9a84c;
  outline-offset: 2px;
}

/* A stat box that flags a problem (for example a price above MSRP) */
.dt-tool-stat.is-warning {
  border-color: rgba(224, 108, 90, 0.45);
  background: rgba(224, 108, 90, 0.1);
}

.dt-tool-stat.is-warning .dt-tool-stat-value {
  color: #f2b8ac;
}

/* ---------- Headline figure, loan cards, breakdown ---------- */
.dt-tool-headline {
  margin-bottom: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.dt-tool-headline-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.dt-tool-headline-value {
  margin: 0.3rem 0 0.2rem;
  font-family: var(--font-family-sans);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #c9a84c;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dt-tool-headline-sub {
  font-size: 13.5px;
  color: var(--color-text-secondary);
}

/* Side by side when both cards have room, stacked otherwise. */
.dt-tool-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dt-tool-loan {
  padding: 1.1rem 1.25rem;
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.dt-tool-loan-title {
  font-family: var(--font-family-serif);
  font-size: 22px;
  color: var(--color-text-primary);
}

.dt-tool-loan-terms {
  margin: 0.15rem 0 0.75rem;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.dt-tool-loan-rows,
.dt-tool-breakdown-rows {
  margin: 0;
}

.dt-tool-loan-row,
.dt-tool-breakdown-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--color-border);
}

.dt-tool-loan-row dt,
.dt-tool-breakdown-row dt {
  font-size: 13.5px;
  color: var(--color-text-secondary);
}

.dt-tool-loan-row dd,
.dt-tool-breakdown-row dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dt-tool-loan-row:first-child dd {
  font-size: 20px;
  color: #c9a84c;
}

.dt-tool-breakdown {
  margin-top: 1.5rem;
}

/* Totals that follow a breakdown need the same gap above them */
.dt-tool-breakdown + .dt-tool-stats {
  margin-top: 1.5rem;
}

.dt-tool-breakdown-title {
  margin-bottom: 0.5rem;
  font-family: var(--font-family-serif);
  font-size: 20px;
  color: var(--color-text-primary);
}

.dt-tool-breakdown-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 12.5px;
  color: var(--color-text-secondary);
}

.dt-tool-breakdown-row.is-warning dt,
.dt-tool-breakdown-row.is-warning dd {
  color: #f2b8ac;
}

.dt-tool-breakdown-row.is-total {
  border-top-color: rgba(201, 168, 76, 0.45);
}

.dt-tool-breakdown-row.is-total dt,
.dt-tool-breakdown-row.is-total dd {
  color: var(--color-text-primary);
  font-weight: 600;
  font-size: 15px;
}

/* ---------- Related reading ---------- */
.dt-tool-related {
  margin-top: 4rem;
  padding: 2.5rem 0 0; /* overrides the site-wide section padding */
  border-top: 1px solid var(--color-border);
}

.dt-tool-related h2 {
  font-family: var(--font-family-serif);
  font-size: 26px;
  color: var(--color-text-primary);
  margin-bottom: 1.25rem;
}

.dt-tool-related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.dt-tool-related a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color 0.25s ease;
}

.dt-tool-related a::before {
  content: "\2192";
  color: #c9a84c;
}

.dt-tool-related a:hover,
.dt-tool-related a:focus-visible {
  color: #c9a84c;
}

/* ---------- Phone and small tablet ---------- */
@media (max-width: 900px) {
  .dt-tool-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
}

@media (max-width: 640px) {
  .dt-tool-page .dt-container {
    padding: 0 1.5rem;
  }

  .dt-tool-panel,
  .dt-tool-result {
    padding: 1.5rem;
  }

  .dt-tool-rule,
  .dt-tool-embed .dt-tool-rule {
    font-size: 22px;
  }

  /* Each figure becomes a compact row: label and note on the left, figure on the right. */
  .dt-tool-stats {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }

  .dt-tool-stat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1rem;
    align-items: center;
    padding: 0.9rem 1rem;
  }

  .dt-tool-stat-label,
  .dt-tool-stat-sub {
    grid-column: 1;
  }

  .dt-tool-stat-value {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 24px;
    text-align: right;
  }

  .dt-learn-cta {
    padding: 1.75rem 1.5rem;
  }
}

@media (max-width: 640px) {
  .dt-tool-headline-value {
    font-size: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dt-tool-related a,
  .dt-tool-switch-track,
  .dt-tool-switch-track::after,
  .dt-tool-segment span {
    transition: none;
  }
}
