/* ===========================================================================
   Cost calculator (/estimate). Loaded only on that page; tokens and the base
   components (card, btn, chip, info-card, faq …) come from styles.css.
   =========================================================================== */

/* A shared link carries a scope in its query string. The head script sets this
   class so the default scope never flashes before estimate.js applies it. */
.est-pending #estimator { visibility: hidden; }

.est-wrap { display: flex; flex-direction: column; gap: 28px; }
.est-hero { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.est-hero h1 { font-size: 38px; line-height: 1.15; letter-spacing: -0.015em; }
.est-hero .lead { font-size: 16px; line-height: 1.65; }
.est { display: flex; flex-direction: column; gap: 20px; scroll-margin-top: 76px; }
.est-noscript { padding: 14px 16px; border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--bg-paper); font-family: var(--font-body); font-size: 14px; }

/* ─── Option cards ───────────────────────────────────────────────────── */
/* Each is a real radio or checkbox: the input stays focusable but invisible,
   and the label's body draws the selected / focused states. */
.opt, .feat { position: relative; display: block; cursor: pointer; }
.opt input, .feat input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.opt-body { position: relative; height: 100%; padding: 14px 40px 14px 16px; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--divider); border-radius: var(--radius-lg); background: var(--bg-paper); transition: border-color .15s, background-color .15s, box-shadow .15s; }
.opt-body strong { font-size: 14px; font-weight: 600; line-height: 1.3; }
.opt-body small { font-size: 12px; line-height: 1.4; color: var(--text-secondary); }
.opt:hover .opt-body { border-color: var(--text-disabled); }
.opt input:checked + .opt-body { border-color: var(--primary-main); background: var(--bg-paper-highlight); box-shadow: inset 0 0 0 1px var(--primary-main); }
.opt input:focus-visible + .opt-body, .feat input:focus-visible + .feat-body { outline: 2px solid var(--primary-main); outline-offset: 2px; }
.opt input:disabled + .opt-body { opacity: .5; cursor: not-allowed; }
.opt-tick { position: absolute; top: 13px; right: 12px; width: 18px; height: 18px; border: 1.5px solid var(--text-disabled); border-radius: var(--radius-full); display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: background-color .15s, border-color .15s, color .15s; }
.opt-tick .icon { width: 11px; height: 11px; stroke-width: 3; }
.opt input[type="checkbox"] + .opt-body .opt-tick { border-radius: 5px; }
.opt input:checked + .opt-body .opt-tick { background: var(--primary-main); border-color: var(--primary-main); color: var(--primary-contrast); }

/* ─── Top row: mode switch + reset ───────────────────────────────────── */
.est-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.seg { flex: 1 1 420px; max-width: 600px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg-sm { flex: 0 1 340px; }
.seg-sm .opt-body { padding: 10px 36px 10px 14px; }
.seg-sm .opt-tick { top: 50%; margin-top: -9px; }

.mini-btn { min-height: 34px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--divider); border-radius: var(--radius-md); background: var(--bg-paper); color: var(--text-secondary); font-family: var(--font-sans); font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.mini-btn:hover { background: var(--action-hover); border-color: var(--text-secondary); color: var(--text-primary); }
.mini-btn .icon { width: 14px; height: 14px; }
.mini-btn.done { border-color: var(--success-dark); color: var(--success-dark); }
.link-btn { min-height: 24px; padding: 4px 0; border: 0; background: none; color: var(--primary-main); font-family: var(--font-sans); font-size: 12px; font-weight: 500; cursor: pointer; }
.link-btn:hover { color: var(--primary-dark); text-decoration: underline; }
.link-btn:disabled { color: var(--text-disabled); text-decoration: none; cursor: default; }

/* ─── Layout: steps beside a sticky result ───────────────────────────── */
.est-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.est-main { min-width: 0; }
.est-steps { display: flex; flex-direction: column; gap: 16px; }
.est-aside { position: sticky; top: 76px; }
.est-card { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; overflow: visible; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 17px; line-height: 1.3; }
.step-n { flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--radius-full); background: var(--primary-light); color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.step-tools { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-secondary); }
.est-sub { margin-top: -6px; font-family: var(--font-body); font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.est-hint { padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-default); font-family: var(--font-body); font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.opt-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* four options read better 2×2 than 3+1 */
.approach { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.approach-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

/* templates + presets */
.tpl-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl { height: 34px; padding: 0 14px; display: inline-flex; align-items: center; border: 1px solid var(--divider); border-radius: var(--radius-full); background: var(--bg-paper); color: var(--text-secondary); font-family: var(--font-sans); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.tpl:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.tpl[aria-pressed="true"] { background: var(--primary-main); border-color: var(--primary-main); color: var(--primary-contrast); }
.tpl-note { font-family: var(--font-body); font-size: 13px; line-height: 1.55; color: var(--text-secondary); }

/* features */
.feat-group { display: flex; flex-direction: column; gap: 8px; }
.feat-group h3 { margin-top: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.feat-body { min-height: 44px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--divider); border-radius: 10px; background: var(--bg-paper); font-size: 13px; line-height: 1.3; transition: border-color .15s, background-color .15s; }
.feat:hover .feat-body { border-color: var(--text-disabled); }
.feat-box { flex-shrink: 0; width: 16px; height: 16px; border: 1.5px solid var(--text-disabled); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: background-color .15s, border-color .15s, color .15s; }
.feat-box .icon { width: 10px; height: 10px; stroke-width: 3.5; }
.feat-name { flex: 1; min-width: 0; }
.feat-price { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.feat input:checked + .feat-body { border-color: var(--primary-main); background: var(--bg-paper-highlight); }
.feat input:checked + .feat-body .feat-box { background: var(--primary-main); border-color: var(--primary-main); color: var(--primary-contrast); }
.feat input:checked + .feat-body .feat-price { color: var(--primary-dark); }

/* hire mode */
.range { display: flex; flex-direction: column; gap: 6px; }
.range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.range-head output { font-size: 15px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.range input[type="range"] { width: 100%; height: 28px; margin: 0; accent-color: var(--primary-main); cursor: pointer; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-family: var(--font-body); font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.check-list li { display: flex; align-items: flex-start; gap: 10px; }
.check-list .icon { margin-top: 4px; width: 14px; height: 14px; stroke-width: 3; color: var(--primary-main); }

/* ─── Result card ────────────────────────────────────────────────────── */
.est-result { padding: 24px; display: flex; flex-direction: column; gap: 14px; border-color: var(--primary-main); box-shadow: var(--shadow-4); scroll-margin-top: 76px; }
.result-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.result-price { margin-top: -8px; font-family: var(--font-sans); font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.result-facts { margin: 0; padding: 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); }
.result-facts dt { font-size: 11px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-secondary); }
.result-facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.result-tip { padding: 10px 12px; border-radius: var(--radius-md); background: var(--yellow-100); color: var(--yellow-900); font-family: var(--font-body); font-size: 13px; line-height: 1.5; }
[data-color-scheme="dark"] .result-tip { background: #3A2F0B; color: #FDE68A; }
.est-result .btn { width: 100%; justify-content: center; }
.result-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.result-actions .mini-btn { padding: 0 6px; }
.result-note { font-family: var(--font-body); font-size: 12px; line-height: 1.55; color: var(--text-secondary); }

/* ─── Insight cards under the calculator ─────────────────────────────── */
.est-insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar-head span:last-child { color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar { height: 8px; margin-top: 6px; border-radius: var(--radius-full); background: var(--action-hover); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--primary-main); transition: width .3s ease; }
.line-list { list-style: none; margin: 0; padding: 0; }
.line { min-height: 40px; padding: 4px 0; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--divider); font-size: 13px; line-height: 1.35; }
.line:last-child { border-bottom: 0; }
.line-label { flex: 1; min-width: 0; }
.line-cost { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.line-x { flex-shrink: 0; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-md); background: none; color: var(--text-secondary); cursor: pointer; }
.line-x:hover { background: var(--action-hover); color: var(--red-600); }
[data-color-scheme="dark"] .line-x:hover { color: #FF8A80; }
.line-x .icon { width: 14px; height: 14px; }
.line-x-none { flex-shrink: 0; width: 26px; }
.ctx { display: flex; flex-direction: column; gap: 4px; }
.ctx + .ctx { padding-top: 14px; border-top: 1px solid var(--divider); }
.ctx h3 { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.ctx-n { font-family: var(--font-sans); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ctx p:not(.ctx-n) { font-family: var(--font-body); font-size: 13px; line-height: 1.55; color: var(--text-secondary); }

/* saved estimates */
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.saved-item { padding: 14px; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--divider); border-radius: var(--radius-lg); }
.saved-name { font-size: 13px; font-weight: 600; }
.saved-price { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.saved-meta { font-size: 12px; color: var(--text-secondary); }
.saved-actions { margin-top: 8px; display: flex; gap: 8px; }

/* ─── Typical costs table ────────────────────────────────────────────── */
.tc { width: 100%; border-collapse: collapse; font-size: 14px; }
.tc th, .tc td { padding: 14px 18px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--divider); }
.tc thead th { background: var(--bg-default); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); white-space: nowrap; }
.tc tbody tr:last-child th, .tc tbody tr:last-child td { border-bottom: 0; }
.tc tbody th { font-weight: 400; }
.tc td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tc-name { display: block; font-family: var(--font-sans); font-size: 14px; font-weight: 600; }
.tc-blurb, .tc-similar { display: block; margin-top: 2px; font-family: var(--font-body); font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.tc-similar a { font-weight: 500; }
.tc-act { text-align: right; }

/* ─── Sticky price bar (small screens, while the result is off-screen) ── */
.est-bar { display: none; }

@media (max-width: 980px) {
  .est-grid { grid-template-columns: 1fr; }
  .est-aside { position: static; }
  .est-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg-paper); border-top: 1px solid var(--divider); box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.10); transform: translateY(110%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s; }
  .est-bar.show { transform: none; visibility: visible; transition: transform .2s ease; }
  .est-bar-text { min-width: 0; display: flex; flex-direction: column; }
  .est-bar-text small { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
  .est-bar-text strong { font-size: 17px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
}

@media (max-width: 760px) {
  .est-hero h1 { font-size: 30px; }
  .est-hero .lead { font-size: 15px; }
  .est-card { padding: 18px 16px; }
  .est-result { padding: 20px 16px; }
  .seg { flex-basis: 100%; max-width: none; }
  .opt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feat-grid { grid-template-columns: 1fr; }

  /* the table becomes a stack of cards; roles in the markup keep it a table
     for assistive tech even though display is no longer table-* */
  .tc thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .tc, .tc tbody, .tc tr, .tc th, .tc td { display: block; }
  .tc tr { padding: 16px 18px; border-bottom: 1px solid var(--divider); }
  .tc tbody tr:last-child { border-bottom: 0; }
  .tc th, .tc td { padding: 0; border: 0; }
  .tc td { padding-top: 8px; display: flex; justify-content: space-between; gap: 16px; white-space: normal; }
  .tc td[data-label]::before { content: attr(data-label); font-size: 12px; color: var(--text-secondary); }
  .tc td.tc-act { justify-content: flex-start; }
}

@media (max-width: 480px) {
  /* side by side, the two mode cards wrap into four cramped lines each */
  .est-top .seg { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .result-price { font-size: 25px; }
  .result-actions { grid-template-columns: 1fr; }
}
