/* ==========================================================================
   Revenue calculator section (experimental, self-contained).
   To remove the feature: delete the "Revenue calculator" block in index.html,
   plus the <link> to this file and the <script> for js/calculator.js.
   Only .calc-* classes are defined here; shared styles are reused, not changed.
   ========================================================================== */

.calc-head { max-width: 46rem; }
.calc-head h2 { max-width: 16ch; }
.calc-intro {
  margin-top: var(--space-6);
  max-width: 580px;
  font-size: 16px; line-height: 1.6; color: #BDBDBD;
}

/* White working area on the black band */
.calc {
  margin-top: var(--space-8);
  background: #FFFFFF; color: #111111;
  display: grid;
}
.calc-inputs, .calc-results { padding: var(--space-8) var(--space-6); }
.calc-results { border-top: 1px solid #E8E8E8; display: flex; flex-direction: column; }

.calc-step {
  display: block; margin-bottom: var(--space-2);
  font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: #666666;
}
/* Steps sit in one flex column: spacing comes from the gap, not per-item margins */
.calc-inputs { display: flex; flex-direction: column; gap: var(--space-6); }
.calc-inputs .field { gap: 6px; }

/* Step 3: two equal columns. Each month spans two shared rows (label row, input row) via subgrid,
   so labels, values and underlines line up whatever the month names, even when a label wraps. */
.calc-month-row {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto;
  column-gap: var(--space-6); row-gap: 6px; margin-top: 6px;
}
.calc-month { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: inherit; }
.calc-month label { align-self: end; }
@supports not (grid-template-rows: subgrid) {
  .calc-month { grid-template-rows: 1fr auto; }
}
.calc-inputs .field label { color: #111111; font-size: 15px; font-weight: 500; }
.calc-hint { font-size: 13px; color: #666666; }

/* £ prefix inside the job value box */
.calc-money { position: relative; }
.calc-money span {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  font-size: 18px; color: #111111; pointer-events: none;
}
.calc-money input { padding-left: 18px; }
.calc-inputs input { font-size: 18px; }

/* Capacity: three square choices, styled radios */
.calc-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 2px; }
.calc-choice { position: relative; }
.calc-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.calc-choice span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 52px; padding: 8px 10px;
  border: 1px solid #D4D4D4; background: #FFFFFF; color: #111111;
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
  transition: background-color .3s ease, color .3s ease, border-color .3s ease;
}
.calc-choice span:hover { border-color: #111111; }
.calc-choice input:checked + span { background: #111111; color: #FFFFFF; border-color: #111111; }
.calc-choice input:focus-visible + span { outline: 2px solid #111111; outline-offset: 2px; }

/* Results */
.calc-big-label { font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: #666666; }
.calc-big {
  margin-top: var(--space-2);
  font-family: var(--font-display); font-weight: 600; color: #111111;
  font-size: clamp(48px, 6.4vw, 84px); line-height: 0.95; letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.calc-big small { font-size: 0.32em; letter-spacing: -0.01em; font-weight: 500; color: #666666; margin-left: 6px; }
.calc-sub { margin-top: var(--space-4); font-size: 16px; line-height: 1.55; color: #3A3A3A; max-width: 30rem; }

.calc-compare { margin-top: var(--space-6); display: grid; gap: var(--space-4); }
.calc-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.calc-row-name { font-size: 14px; color: #666666; }
.calc-row-val { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.calc-bar { margin-top: 10px; height: 6px; background: #F0F0F0; overflow: hidden; }
.calc-bar i { display: block; height: 100%; width: 0; background: #111111; transition: width .9s var(--ease-out, ease); }
.calc-bar--now i { background: #A8A8A8; }
.calc-eq { margin-top: 8px; font-size: 13px; color: #666666; font-variant-numeric: tabular-nums; }

.calc-note { margin-top: var(--space-4); font-size: 13px; line-height: 1.55; color: #666666; max-width: 32rem; }
/* The results column is a flex column stretched to the form's height: the auto margin pushes the CTA to the bottom,
   so it lines up with the bottom of Step 4. padding-top keeps a minimum gap when space is tight. */
.calc-cta { margin-top: auto; padding-top: var(--space-4); }
.calc-section .calc-cta-title {
  font-family: var(--font-display); font-weight: 600; color: #111111;
  font-size: 20px; line-height: 1.2; letter-spacing: -0.02em;
}
.calc-cta-text { margin-top: 6px; font-size: 15px; line-height: 1.5; color: #3A3A3A; max-width: 30rem; }
.calc-cta .btn { margin-top: var(--space-4); }

/* ---------- Stages (class on .calc-results, set by js/calculator.js) ---------- */
.calc-noroom, .calc-lead, .calc-cta { display: none; }

/* is-empty: faded placeholder breakdown, as before */
.calc-results.is-empty .calc-big { color: #CFCFCF; }
.calc-results.is-empty .calc-compare { opacity: .35; }

/* is-preview: the estimate, then the unlock form. The breakdown and disclaimer wait for stage 3 (the summary line carries the disclaimer). */
.calc-results.is-preview .calc-compare,
.calc-results.is-preview .calc-note { display: none; }
.calc-results.is-preview .calc-lead { display: block; }

/* is-unlocked: full breakdown, disclaimer, then the CTA pushed to the bottom of the column */
.calc-results.is-unlocked .calc-cta { display: block; }
/* The breakdown repeats the summary line and the disclaimer sits under it, so the summary is dropped here to stay compact */
.calc-results.is-unlocked .calc-sub { display: none; }

/* is-noroom */
.calc-results.is-noroom .calc-compare, .calc-results.is-noroom .calc-big-wrap { display: none; }
.calc-results.is-noroom .calc-noroom { display: block; }
.calc-noroom strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 3vw, 34px); line-height: 1.1; letter-spacing: -0.03em; }
.calc-noroom span { display: block; margin-top: var(--space-4); color: #3A3A3A; }

/* Breakdown: third row is the difference, no bar, separated by a hairline */
.calc-compare:focus { outline: none; }
.calc-row-extra { padding-top: var(--space-4); border-top: 1px solid #E8E8E8; }
.calc-row-extra .calc-row-name { color: #111111; font-weight: 500; }
.calc-row-extra .calc-eq { margin-top: 4px; }

/* Lead form: sits under the estimate, set off by a hairline. Same underline inputs as the rest of the site. */
.calc-lead { margin-top: auto; padding-top: var(--space-6); }
.calc-lead::before { content: ""; display: block; border-top: 1px solid #E8E8E8; margin-bottom: var(--space-4); }
.calc-section .calc-lead-title {
  font-family: var(--font-display); font-weight: 600; color: #111111;
  font-size: 20px; line-height: 1.2; letter-spacing: -0.02em;
}
.calc-lead-text { margin-top: 6px; font-size: 15px; line-height: 1.5; color: #3A3A3A; max-width: 30rem; }
.calc-lead-fields { margin-top: var(--space-4); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-6); }
.calc-lead .field { gap: 4px; align-content: start; }
.calc-lead .field label { font-size: 13px; color: #666666; }
.calc-lead .field input { font-size: 16px; padding: 8px 0; }
.calc-lead .field input:focus-visible, .calc-lead .field.has-error input { padding-bottom: 7px; }
.calc-lead .btn { margin-top: 12px; white-space: nowrap; }
@media (max-width: 360px) { .calc-lead .btn { padding: 18px 18px; letter-spacing: 0.08em; } }
.calc-lead-status { font-size: 14px; line-height: 1.5; color: #3A3A3A; }
.calc-lead-status:not(:empty) { margin-top: var(--space-4); }
.calc-lead-status.is-error { color: #111111; font-weight: 500; }
/* Privacy note sits directly above the button so the two read as one group; the button is the last item in the column */
.calc-privacy { margin-top: var(--space-4); font-size: 12px; line-height: 1.5; color: #666666; max-width: 32rem; }
.calc-privacy a { color: #111111; text-underline-offset: 3px; }

/* Subtle fade-up when a stage's block appears (matches the site's reveal motion) */
@keyframes calc-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.calc-results.is-preview .calc-lead,
.calc-results.is-unlocked .calc-compare,
.calc-results.is-unlocked .calc-note { animation: calc-in .7s cubic-bezier(.2,.7,.2,1) both; }
.calc-results.is-unlocked .calc-cta { animation: calc-in .7s cubic-bezier(.2,.7,.2,1) .25s both; }
@media (prefers-reduced-motion: reduce) {
  .calc-results .calc-lead, .calc-results .calc-compare, .calc-results .calc-note, .calc-results .calc-cta { animation: none !important; }
}

@media (max-width: 380px) {
  .calc-lead-fields { grid-template-columns: 1fr; }
}

@media (min-width: 900px) {
  .calc { grid-template-columns: 1fr 1fr; }
  .calc-inputs, .calc-results { padding: var(--space-8) var(--space-12); }
  .calc-results { border-top: 0; border-left: 1px solid #E8E8E8; }
  .calc-intro { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .calc-bar i, .calc-choice span { transition: none; }
}

.calc-capacity { border: 0; margin: 0; padding: 0; min-width: 0; }
/* Desktop: both columns stretch to the same height. Step 4 takes up the left column's spare height and its auto margin
   drops the Yes / Not sure / No group to the bottom, level with the last button in the right column.
   The question stays put under its step label. When stacked, the column has no spare height, so nothing moves. */
@media (min-width: 900px) {
  .calc-capacity { flex: 1 1 auto; display: flex; flex-direction: column; }
  .calc-capacity .calc-choices { margin-top: auto; }
  .calc-capacity .calc-question { margin-bottom: 6px; }
}
.calc-question { color: #111111; font-size: 15px; font-weight: 500; }

/* ---------- Revenue figure that always fits ----------
   js/calculator.js sets --chars to the length of the final figure (e.g. "£1,008,000" = 10).
   The size is the smaller of the usual size and what fits the results column, so 7- to 9-figure amounts never overflow.
   Browsers without container units keep the size above. */
.calc-results { container-type: inline-size; }
.calc-big { font-size: clamp(28px, min(max(48px, 6.4vw), calc(100cqi / (var(--chars, 8) * 0.55))), 84px); overflow-wrap: normal; }
#calc-big-num { white-space: nowrap; }
.calc-big small { white-space: nowrap; }

/* ---------- Phones ---------- */
@media (max-width: 899px) {
  /* Stacked: only show what matters for the current stage. Before all four steps are answered,
     the results panel is just the £0 figure and what's still needed, not the faded breakdown. */
  .calc-results.is-empty .calc-compare,
  .calc-results.is-empty .calc-note { display: none; }
  .calc-cta .btn, .calc-lead .btn { width: 100%; justify-content: center; min-height: 54px; }
}
@media (max-width: 480px) {
  .calc { margin-top: var(--space-6); }
  .calc-inputs, .calc-results { padding: var(--space-6) 20px; }
  .calc-intro { margin-top: var(--space-4); }
  /* Yes / Not sure / No: three equal, thumb-sized buttons with every label on one line */
  .calc-choice span { min-height: 52px; padding: 8px 4px; font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; }
  /* Lead form: name and business side by side; email and phone full width (long values, longer labels) */
  .calc-lead-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-4); }
  .calc-lead-fields .field:nth-child(n+3) { grid-column: 1 / -1; }
  .calc-month-row { column-gap: var(--space-4); }
}
@media (max-width: 380px) {
  .calc-lead-fields { grid-template-columns: 1fr; }
}

/* Mobile compaction, round 2 */
@media (max-width: 767px) {
  .calc { margin-top: 20px; }
  .calc-intro { margin-top: 10px; }
  .calc-inputs { gap: 20px; }
  .calc-inputs, .calc-results { padding-top: 20px; padding-bottom: 20px; }
  .calc-lead { padding-top: 18px; }
  .calc-compare { margin-top: 18px; }
}
