/* ==========================================================================
   What Should You Charge? — The Contractor Fight
   Stylesheet for the two-step pricing calculator.

   Contains no layout assumptions about the surrounding page other than that
   .tcf-charge is given the full width it needs. Everything is namespaced
   under .tcf-charge so it can drop into a themed site without bleeding.
   ========================================================================== */

.tcf-charge {
  /* ---- Design tokens ---------------------------------------------------- */
  --card:       #1D1B18;  /* card background          */
  --card-line:  #34302B;  /* borders and dividers     */
  --paper:      #FAF9F6;  /* result panel background  */
  --ink:        #F5F3EF;  /* primary text             */
  --ink-dim:    #9C948A;  /* secondary text           */
  --accent:     #D02027;  /* TCF kit red              */
  --accent-dim: #4A0A0D;  /* slider track start       */

  --field-bg:    #0F0E0C;
  --field-place: #5B564C;
  --thead-ink:   #6E6857;

  /* Verdict palette. These reds are intentionally distinct from --accent;
     they come straight from the source artifact. */
  --verdict-danger-bg:     #2A0D0F;
  --verdict-danger-ink:    #FF8A80;
  --verdict-danger-line:   #C8102E;
  --verdict-warn-bg:       #F4D6D3;
  --verdict-warn-ink:      #7A1420;
  --verdict-warn-line:     #C8102E55;
  --verdict-ok-bg:         #E4EBD8;
  --verdict-ok-ink:        #33421A;
  --verdict-ok-line:       #7FA24A55;
  --verdict-strong-bg:     #0A0908;
  --verdict-strong-ink:    #D02027;
  --verdict-strong-line:   #D02027;

  --sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: "Oswald", Impact, sans-serif;

  --pad-x: 28px;

  /* Page background comes from Elementor. Tokens still live here so the
     cards keep the designed palette when dropped into a themed page. */
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.tcf-charge *,
.tcf-charge *::before,
.tcf-charge *::after { box-sizing: border-box; }

.tcf-charge__inner {
  max-width: none;
  margin: 0;
  padding: 0;
}

.tcf-charge--panel .tcf-charge__card + .tcf-charge__card {
  margin-top: 24px;
}

/* ---- Utilities ---------------------------------------------------------- */

.tcf-charge .tcf-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tcf-charge :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Cards -------------------------------------------------------------- */

.tcf-charge__card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 4px;
  overflow: hidden;   /* keeps the cream result panel flush in the corner */
}

.tcf-charge__section {
  padding: 22px var(--pad-x);
}
.tcf-charge__section + .tcf-charge__section {
  border-top: 1px solid var(--card-line);
}
/* The table manages its own edge padding via first/last-child cells. */
.tcf-charge__section--flush { padding: 0; }

/* ---- Fields ------------------------------------------------------------- */

.tcf-charge__field-label {
  display: block;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 6px;
}

.tcf-charge__field-help {
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.tcf-charge__input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.tcf-charge__affix {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink-dim);
  pointer-events: none;
}
.tcf-charge__affix--prefix { left: 14px; }
.tcf-charge__affix--suffix { right: 14px; }

.tcf-charge input[type="number"] {
  width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--card-line);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  padding: 13px 14px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.12s ease;
}
.tcf-charge__input-wrap--prefixed input[type="number"] { padding-left: 32px; }
.tcf-charge__input-wrap--suffixed input[type="number"] { padding-right: 34px; }

.tcf-charge input[type="number"]:focus {
  border-color: var(--accent);
  outline: none;
}
.tcf-charge input[type="number"]:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.tcf-charge input[type="number"]::placeholder {
  color: var(--field-place);
  opacity: 1;
}

/* Spinners add nothing here and crowd the suffix. */
.tcf-charge input[type="number"]::-webkit-outer-spin-button,
.tcf-charge input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tcf-charge input[type="number"] { -moz-appearance: textfield; }

/* ---- Select (close rate picker) ----------------------------------------- */

.tcf-charge__select-wrap {
  position: relative;
  display: block;
}

/* Custom caret: the native one cannot be recoloured for a dark field. */
.tcf-charge__select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -6px;
  border-right: 2px solid var(--ink-dim);
  border-bottom: 2px solid var(--ink-dim);
  transform: rotate(45deg);
  pointer-events: none;
}

.tcf-charge select {
  width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--card-line);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  padding: 13px 40px 13px 14px;
  margin: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  /* iOS Safari refuses to shrink a select below its own idea of a minimum
     unless the height is stated outright. */
  height: 48px;
}
.tcf-charge select:focus { border-color: var(--accent); outline: none; }
.tcf-charge select:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
/* The dropdown list itself is drawn by the OS, so give it readable colours
   rather than dark-on-dark in browsers that honour these. */
.tcf-charge select option {
  background: #14120F;
  color: var(--ink);
}

.tcf-charge__custom-value { margin-top: 10px; }
.tcf-charge__custom-value[hidden] { display: none; }

/* ---- Step 1 table ------------------------------------------------------- */

.tcf-charge__table-wrap {
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tcf-charge table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}

.tcf-charge thead th {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--thead-ink);
  text-align: right;
  padding: 14px 10px;
  border-bottom: 1px solid var(--card-line);
  white-space: nowrap;
}
.tcf-charge thead th:first-child { text-align: left; padding-left: var(--pad-x); }
.tcf-charge thead th:last-child  { padding-right: var(--pad-x); }

.tcf-charge tbody th,
.tcf-charge tbody td {
  padding: 13px 10px;
  text-align: right;
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px solid var(--card-line);
  white-space: nowrap;
}
.tcf-charge tbody th {
  text-align: left;
  padding-left: var(--pad-x);
  font-weight: 700;
}
.tcf-charge tbody td:last-child { padding-right: var(--pad-x); }
.tcf-charge tbody tr:last-child th,
.tcf-charge tbody tr:last-child td { border-bottom: none; }

/* The floor row */
.tcf-charge tbody tr.is-floor th,
.tcf-charge tbody tr.is-floor td {
  background: var(--field-bg);
  color: var(--accent);
  font-weight: 700;
}

.tcf-charge__floor-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ---- Footnotes ---------------------------------------------------------- */

.tcf-charge__footnote {
  color: var(--ink-dim);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0;
}
.tcf-charge__footnote code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--card-line);
  border-radius: 2px;
  padding: 1px 5px;
  white-space: nowrap;
}

/* ---- Step 2: cost grid -------------------------------------------------- */

.tcf-charge__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

/* Qualified with h3 so this beats the Elementor kit's h3 clamp (26–40px Oswald). */
.tcf-charge h3.tcf-charge__section-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}

.tcf-charge__running-total {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.tcf-charge__running-total b {
  color: var(--accent);
  font-weight: 700;
}

.tcf-charge__cost-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.tcf-charge__cost-cell { min-width: 0; }

.tcf-charge__cost-grid .tcf-charge__field-label {
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

/* ---- Step 2: margin control --------------------------------------------- */

.tcf-charge__margin-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 18px;
}

.tcf-charge__margin-readout {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(40px, 8vw, 56px);
  line-height: 1;
  color: var(--accent);
}

.tcf-charge__margin-caption {
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.3;
}

.tcf-charge__slider-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  color: var(--thead-ink);
  margin-top: 8px;
}

.tcf-charge__presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

/* Qualified with button so this beats Hello Elementor's
   `[type=button], button { border/color: #c36 }` (0,1,1). */
.tcf-charge button.tcf-charge__preset {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  background: var(--field-bg);
  background-color: var(--field-bg);
  border: 1px solid var(--card-line);
  border-radius: 3px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  line-height: 1.2;
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.tcf-charge button.tcf-charge__preset:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.tcf-charge button.tcf-charge__preset.is-active {
  background: var(--accent);
  background-color: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

/* ---- Slider ------------------------------------------------------------- */

.tcf-charge input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: block;
}

.tcf-charge input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent-dim), var(--accent));
}
.tcf-charge input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;          /* (6px track - 22px thumb) / 2 */
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--field-bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.tcf-charge input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent-dim), var(--accent));
  border: none;
}
.tcf-charge input[type="range"]::-moz-range-thumb {
  width: 16px;               /* Firefox sizes the thumb inside the border box */
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--field-bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.tcf-charge input[type="range"]::-moz-focus-outer { border: 0; }

.tcf-charge input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 3px;
}

/* ---- Step 2: result panel ----------------------------------------------- */

.tcf-charge__result {
  background: var(--paper);
  color: #14120F;
  padding: 26px var(--pad-x) 24px;
}

.tcf-charge__result-label {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6B6459;
  margin: 0 0 4px;
}

.tcf-charge__price {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(48px, 9vw, 68px);
  line-height: 1;
  color: #14120F;
  margin: 0 0 20px;
  word-break: break-word;
}

.tcf-charge__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  padding: 0 0 20px;
  border-bottom: 1px solid #DED9CF;
  margin: 0 0 18px;
}

.tcf-charge__stat { min-width: 0; }

.tcf-charge__stat-label {
  display: block;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6B6459;
  margin: 0 0 3px;
}

.tcf-charge__stat-value {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 19px;
  color: #14120F;
}

/* ---- Verdict ------------------------------------------------------------ */

.tcf-charge__verdict {
  border-radius: 3px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}
.tcf-charge__verdict[data-style="danger"] {
  background: var(--verdict-danger-bg);
  color: var(--verdict-danger-ink);
  border: 1px solid var(--verdict-danger-line);
}
.tcf-charge__verdict[data-style="warn"] {
  background: var(--verdict-warn-bg);
  color: var(--verdict-warn-ink);
  border: 1px solid var(--verdict-warn-line);
}
.tcf-charge__verdict[data-style="ok"] {
  background: var(--verdict-ok-bg);
  color: var(--verdict-ok-ink);
  border: 1px solid var(--verdict-ok-line);
}
.tcf-charge__verdict[data-style="strong"] {
  background: var(--verdict-strong-bg);
  color: var(--verdict-strong-ink);
  border: 1px solid var(--verdict-strong-line);
}

.tcf-charge__result .tcf-charge__footnote {
  color: #6B6459;
  margin-top: 18px;
}
.tcf-charge__result .tcf-charge__footnote code {
  color: #14120F;
  background: #EFEBE2;
  border-color: #DED9CF;
}

/* ---- Small screens ------------------------------------------------------ */

@media (max-width: 480px) {
  .tcf-charge { --pad-x: 18px; }
  .tcf-charge__cost-grid { grid-template-columns: minmax(0, 1fr); }
  /* Re-assert the flush modifier: the rule above has equal specificity and
     comes later in source order, so without this the break-even table stops
     running edge-to-edge inside the card. */
  .tcf-charge__section { padding: 18px var(--pad-x); }
  .tcf-charge__section--flush { padding: 0; }
  .tcf-charge__result { padding: 22px var(--pad-x) 20px; }
  .tcf-charge table { font-size: 12px; }

  /* The brief does not cover the table on a phone, and at 390px the five
     nowrap headers need ~495px, so REVENUE / MONTH — the payoff column —
     sat off-screen behind a scroll nobody would discover. Letting the
     header labels wrap onto two lines brings all five columns into view.
     The cell values stay nowrap so no figure ever breaks mid-number, and
     .tcf-charge__table-wrap still scrolls as a fallback below ~330px. */
  .tcf-charge thead th {
    font-size: 9px;
    padding: 10px 5px;
    white-space: normal;
    letter-spacing: 0.04em;
    vertical-align: bottom;
  }
  /* Longhand, not the `padding: 11px 5px` shorthand: the shorthand reset the
     padding-left that tbody th inherits from the base rule, leaving the row
     labels indented 13px less than the column header above them. */
  .tcf-charge tbody th,
  .tcf-charge tbody td {
    padding-top: 11px;
    padding-bottom: 11px;
    padding-left: 5px;
    padding-right: 5px;
  }
  .tcf-charge tbody th { padding-left: var(--pad-x); }
  .tcf-charge__floor-badge { margin-left: 5px; padding: 2px 4px; }
  .tcf-charge__stats { gap: 14px 20px; }

  /* The card clips with overflow:hidden and nothing scrolls horizontally, so a
     nowrap chip wider than the card is simply lost. Let the formulas wrap at
     their spaces instead; they read fine over two lines. */
  .tcf-charge__footnote code {
    white-space: normal;
    overflow-wrap: break-word;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tcf-charge *,
  .tcf-charge *::before,
  .tcf-charge *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
