/* ============================================================
   19-cost-estimator.css — interactive cost estimator
   Module: <section id="estimator">
   Logic: js/cost-estimator.js
   ============================================================ */

#estimator {
  background: linear-gradient(180deg, var(--c-bg) 0%, var(--c-white) 100%);
}
#estimator .container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--s-6);
  align-items: start;
}

.est-intro h2 { margin-bottom: var(--s-3); }
.est-intro p { color: var(--c-muted); font-size: 1.05rem; }

/* ---- Collapsible disclaimer ---- */
/* Default: collapsed. JS in cost-estimator.js toggles .is-open. */
.est-disclaimer-toggle {
  margin-top: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--c-blue);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.est-disclaimer-toggle:hover { color: var(--c-blue-dark); }
.est-disclaimer-toggle svg {
  width: 14px; height: 14px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.est-disclaimer-toggle.is-open svg { transform: rotate(180deg); }

.est-disclaimer {
  margin-top: var(--s-2);
  padding: var(--s-3);
  background: var(--c-card);
  border-left: 3px solid var(--c-blue);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--c-muted);
  /* collapsed by default — max-height: 0 pattern (same as FAQ accordion) */
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.25s ease;
  padding-top: 0;
  padding-bottom: 0;
}
.est-disclaimer.is-open {
  max-height: 200px;
  padding: var(--s-3);
}

@media (prefers-reduced-motion: reduce) {
  .est-disclaimer { transition: none; }
  .est-disclaimer-toggle svg { transition: none; }
}

.est-tool {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 90px;
}

.est-field { margin-bottom: var(--s-4); }
.est-field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.est-field label {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--c-ink);
}
.est-field-value {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--c-blue);
  font-variant-numeric: tabular-nums;
}

/* ---- Slider value label (shown below track) ---- */
.est-slider-wrap {
  position: relative;
}
.est-slider-label {
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-blue);
  text-align: center;
  letter-spacing: 0.02em;
  min-height: 1.2em;
}

/* ---- Range slider — gradient fill via CSS custom property ---- */
/* The JS sets --slider-pct on each input so we can draw the "filled"
   portion in green and the "empty" portion in grey, like a progress bar. */
.est-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  /* Gradient: green for filled portion, grey for the rest.
     --slider-pct is set by JS on every input event. Default 50%. */
  background: linear-gradient(
    to right,
    var(--c-green) 0%,
    var(--c-green) var(--slider-pct, 50%),
    var(--c-line)  var(--slider-pct, 50%),
    var(--c-line)  100%
  );
  outline: none;
  cursor: pointer;
  transition: background 0.12s ease;
}
/* Thumb — large enough for finger taps (meets 44px touch target guideline) */
.est-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--c-green);
  border: 3px solid var(--c-white);
  box-shadow: 0 2px 8px rgba(45,106,79,0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  /* Expand the invisible tap area to 44px minimum */
  margin-top: -10px; /* centres the thumb on the 6px track */
}
.est-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 4px 14px rgba(45,106,79,0.55);
}
.est-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(45,106,79,0.25), 0 2px 8px rgba(45,106,79,0.4);
}
.est-slider::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--c-green);
  border: 3px solid var(--c-white);
  box-shadow: 0 2px 8px rgba(45,106,79,0.4);
  cursor: pointer;
}
.est-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--c-line);
}

/* Pill toggle group — pills size to content + wrap to next row when full
   (was flex:1 which clipped longer labels like "Sloped / tight" on mobile) */
.est-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.est-pill {
  flex: 0 1 auto;
  padding: 10px 16px;
  border: 1.5px solid var(--c-line);
  background: var(--c-white);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-ink);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  white-space: nowrap;
  min-height: 44px;     /* WCAG touch target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 480px) {
  .est-pill {
    flex: 1 1 auto;     /* Phones: stretch evenly across the row, but still wrap if too narrow */
    padding: 10px 12px;
    font-size: 0.84rem;
  }
}
.est-pill:hover { border-color: var(--c-blue); color: var(--c-blue); }
.est-pill.is-active {
  background: var(--c-blue);
  border-color: var(--c-blue);
  color: var(--c-white);
}

/* ---- Result panel — bigger, friendlier ---- */
.est-result {
  margin-top: var(--s-4);
  padding: var(--s-5);
  background: var(--c-blue);
  color: var(--c-white);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: 0 6px 24px rgba(30,58,95,0.25);
}
.est-result-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-yellow);
  margin-bottom: 6px;
}
/* Price figure — big and friendly */
.est-result-range {
  font-family: var(--f-display);
  font-size: clamp(2.2rem, 5vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  /* Subtle glow so the number 'pops' against dark bg */
  text-shadow: 0 2px 12px rgba(255,255,255,0.1);
}
.est-result-note {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.82;
}
.est-result-cta {
  margin-top: var(--s-3);
  display: block;
  width: 100%;
}

@media (max-width: 880px) {
  #estimator .container { grid-template-columns: 1fr; }
  .est-tool { position: static; }
}

/* Mobile: ensure 44px touch target for slider thumb on iOS */
@media (max-width: 600px) {
  .est-slider {
    height: 8px;
  }
  .est-slider::-webkit-slider-thumb {
    width: 30px; height: 30px;
    margin-top: -11px;
  }
  .est-slider::-moz-range-thumb {
    width: 30px; height: 30px;
  }
}
