/* Aglet estimator - design concept (Web Design Bot, design-aglet-estimator, 2026-10-22). Built on Web Bot's hooks
   (ESTIMATOR-HOOKS.md); no logic changes. Tokens come from styles.css (--navy, --gold, --rule, --label ...). */
.est-section [hidden] { display: none !important; }

/* ---------- hero: in-page language switch ---------- */
.est-section { scroll-margin-top: 16px; }

/* ---------- calculator ---------- */
.est-wrap { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .est-wrap { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }
.est-card { border-top: 4px solid var(--gold); }
.est-field input, .est-field select { max-width: 100%; min-height: 48px; }
/* Currency amounts: no browser stepper arrows, so the two boxes match. */
#est-revenue,
#est-amount {
  -moz-appearance: textfield;
  appearance: textfield;
}
#est-revenue::-webkit-outer-spin-button,
#est-revenue::-webkit-inner-spin-button,
#est-amount::-webkit-outer-spin-button,
#est-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* Wide layout: the two money labels share one row and the same block height (a wrapping label
   used to leave the other label one line shorter). Inputs stay on the next row. Term spans both
   columns. Phones stay a single stack (styles.css, max-width 640px). */
@media (min-width: 641px) {
  .est-form .form-grid > .est-field:has(#est-revenue),
  .est-form .form-grid > .est-field:has(#est-amount) {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
  }
  .est-form .form-grid > .est-field:has(#est-revenue) > label,
  .est-form .form-grid > .est-field:has(#est-amount) > label {
    display: grid;
    align-content: end;
    align-self: stretch;
    min-height: 2.6em; /* two lines of the label's 1.3 line-height */
  }
  .est-form .form-grid > .est-field:has(#est-term),
  .est-form .form-grid > .est-field:has(#est-credit) { grid-column: 1 / -1; }
  /* Sliders need the full row. The two-line label subgrid was for the old side-by-side inputs. */
  .est-form .form-grid > .est-field.est-slide,
  .est-form .form-grid > .est-field.est-slide:has(#est-revenue),
  .est-form .form-grid > .est-field.est-slide:has(#est-amount) {
    display: block;
    grid-template-rows: none;
    grid-row: auto;
    grid-column: 1 / -1;
  }
  .est-form .form-grid > .est-field.est-slide > label {
    display: block;
    min-height: 0;
    align-self: auto;
  }
}
/* Slider plus a number box. The range is 44px tall so the thumb has a touch area; the thumb itself is 28px. */
.est-slide-row { display: flex; align-items: center; gap: 12px; }
.est-slide-row input[type="number"] { width: 8.75rem; flex: 0 0 8.75rem; max-width: 46%; }
/* Fixed $ prefix inside the box, not part of the input value.
   flex-shrink must stay on so the row cannot force the card past the viewport. */
.est-wrap, .est-card, .est-form, .est-form .form-grid, .est-field, .est-slide-row {
  min-width: 0;
  max-width: 100%;
}
.est-slide-row { width: 100%; }
.est-slide-row .est-money-box {
  display: flex;
  align-items: center;
  flex: 0 1 12.5rem;
  width: 12.5rem;
  max-width: 52%;
  min-width: 0;
  min-height: 48px;
  box-sizing: border-box;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 0 12px 0 12px;
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.est-slide-row .est-money-prefix {
  flex: 0 0 auto;
  margin-right: 4px;
  color: var(--heading);
  font: 400 1rem/1.4 var(--sans);
  user-select: none;
  pointer-events: none;
}
.est-slide-row .est-money-box input.est-money {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  min-height: 46px;
  padding: 13px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.est-slide-row .est-money-box input.est-money:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}
.est-slide-row .est-money-box:focus-within {
  border-color: var(--heading);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field.invalid .est-money-box,
.est-money-box:has(input[aria-invalid="true"]) {
  border-color: var(--err);
  background: var(--err-bg);
}
@media (max-width: 414px) {
  .est-slide-row .est-money-box {
    flex: 0 1 10rem;
    width: auto;
    min-width: 0;
    max-width: 48%;
  }
}
.est-slide-row .est-range {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}
.est-slide-row .est-range:focus { outline: none; border: 0; box-shadow: none; }
.est-slide-row .est-range:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
.est-range::-webkit-slider-runnable-track { height: 6px; background: var(--rule); border-radius: 999px; }
.est-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid var(--gold);
}
.est-range::-moz-range-track { height: 6px; background: var(--rule); border-radius: 999px; }
.est-range::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid var(--gold);
}
.est-field input[type="number"], .est-field input.est-money { font-variant-numeric: tabular-nums; }
/* Hint text must meet WCAG AA 4.5:1 on the warm field background (#f6f4ef). --note is 4.19:1; --muted (#4d5a68) is 6.42:1. */
.est-hint, #est-cost-hint { color: var(--muted); }

.est-actions .est-calc-btn { min-height: 48px; min-width: 200px; }
@media (max-width: 640px) { .est-actions .est-calc-btn { width: 100%; } }

/* Optional payment: closed by default so the default result is the amount and term only. */
.est-pay-toggle { grid-column: 1 / -1; border: 1px dashed var(--input-border); border-radius: 8px; background: var(--warm); }
.est-pay-toggle > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px;
  color: var(--heading); font-weight: 700; font-size: 1rem; }
.est-pay-toggle > summary::-webkit-details-marker { display: none; }
.est-pay-toggle > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--gold-deep); border-bottom: 2px solid var(--gold-deep);
  transform: rotate(-45deg); transition: transform .15s; flex: 0 0 auto; }
.est-pay-toggle[open] > summary::before { transform: rotate(45deg); }
.est-pay-toggle > summary:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; border-radius: 8px; }
.est-pay-toggle .est-payment-field { padding: 0 16px 16px; }
@media (prefers-reduced-motion: reduce) { .est-pay-toggle > summary::before { transition: none; } }

/* ---------- result panel ---------- */
.est-out { background: var(--navy-deep); border: 1px solid var(--rule-navy); border-left: 4px solid var(--gold); border-radius: 12px;
  padding: 24px; min-width: 0; color: var(--on-navy-strong); }
.est-out dt, .est-out dd, .est-out p { color: var(--on-navy-strong); }
.est-out .est-empty { color: var(--on-navy); font-size: 1.05rem; }
.est-out .est-disclaimer, .est-out .est-cap-note, .est-out .est-payment-note, .est-out .est-apply-credit { color: var(--on-navy); }
.est-dl { margin: 0 0 16px; }
.est-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--rule-navy); flex-wrap: wrap; }
.est-row dt { margin: 0; color: var(--on-navy); } .est-row dd { margin: 0; font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.est-amount-row { display: block; border-bottom: 0; padding-top: 0; }
.est-amount-row dt { font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--gold-soft); }
.est-amount-row dd { font-family: var(--serif); font-size: clamp(2.2rem, 7vw, 3rem); line-height: 1.1; color: var(--hero-ink); margin-top: 8px; }
.est-cap-note { border-left: 3px solid var(--gold-soft); padding-left: 12px; }
.est-disclaimer, .est-cap-note, .est-payment-note, .est-apply-credit { font-size: .92rem; line-height: 1.5; }
.est-apply-credit { margin: 10px 0 0; max-width: 36rem; }
.est-next-more { margin: 10px 0 0 !important; }
.est-next-more .link-more { color: var(--gold-soft); min-height: 48px; display: inline-flex; align-items: center; }
@media (max-width: 860px) {
  /* Keep the apply soft-pull line clear of the sticky mobile action bar. */
  .est-out { padding-bottom: 72px; }
}
.est-out p { margin: 0 0 12px; }
.est-next { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 16px !important; }
.est-next .btn { min-height: 48px; }
.est-next .link-more { color: var(--gold-soft); min-height: 48px; display: inline-flex; align-items: center; }
/* Total repaid / cost of the money (only with the visitor's own factor) and a bar of the two (aria-hidden; the
   figures are in the dl above it). */
.est-bar { margin: 4px 0 16px; }
.est-bar-track { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--rule-navy); }
.est-bar-amt { background: var(--gold); }
.est-bar-cost { background: var(--on-navy); }
.est-bar-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; font-size: .85rem; color: var(--on-navy); }
.est-bar-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.est-bar-legend .k-amt::before { background: var(--gold); }
.est-bar-legend .k-cost::before { background: var(--on-navy); }
/* "Sent to Aglet Funding": only after a confirmed stored:true reply (data-est-stored="true"); never on any other reply. */
.est-out .est-saved { border-left: 3px solid var(--gold); padding-left: 12px; font-size: .92rem; color: var(--on-navy-strong); }
/* Room under Calculate, then the card's own bottom padding (~46px wide, 30px at 700px) keeps the note off the edge. */
.est-actions .est-sent { grid-column: 1 / -1; margin: 22px 0 0; }
@media (max-width: 640px) { .est-actions .est-sent { margin-top: 18px; } }
.est-out[data-est-capture="sending"] { opacity: .85; }
.est-home-link { margin-top: 12px; }

/* Estimator page only: a shorter hero and section top so the first input starts inside the first screen. */
body:has(.est-section) .page-hero { padding: 48px 0 40px; }
body:has(.est-section) .page-hero h1 { margin-bottom: 12px; }
.est-section { padding-top: 40px; }
@media (max-width: 860px) {
  body:has(.est-section) .page-hero { padding: 20px 0 22px; }
  body:has(.est-section) .page-hero .breadcrumbs { margin-bottom: 8px; }
  body:has(.est-section) .page-hero h1 { font-size: 1.85rem; margin-bottom: 8px; }
  body:has(.est-section) .page-hero .page-hero-sub { font-size: .98rem; line-height: 1.5; margin-bottom: 0; text-wrap: pretty; }
  .est-section { padding-top: 20px; }
}
/* No single-word last lines in the hero or the estimator's own text. */
body:has(.est-section) .page-hero-sub, .est-section p, .est-section dt { text-wrap: pretty; }
body:has(.est-section) .page-hero .eyebrow { text-wrap: balance; }

/* ---------- returning / calculated states. details.est-pay-toggle is opened by JS when the factor has a value. ---------- */

/* Returning (texted-link code or an earlier choice): less ceremony, the calculator comes up sooner on phones. */
@media (max-width: 860px) {
  body:has([data-est-state="returning"]) .page-hero { padding: 16px 0 18px; }
  body:has([data-est-state="returning"]) .page-hero h1 { font-size: 1.6rem; }
  [data-est-state="returning"].est-section { padding-top: 16px; }
}
[data-est-state="returning"] .est-out .est-empty { border-left: 3px solid var(--gold); padding-left: 12px; color: var(--on-navy-strong); }

/* Calculated (a valid estimate on screen): the result panel leads, the next step is the obvious action. */
[data-est-state="calculated"] .est-out { border: 1px solid var(--gold); border-left-width: 4px; box-shadow: 0 18px 40px rgba(0,0,0,.28); }
[data-est-state="calculated"] .est-next .btn { box-shadow: 0 6px 16px rgba(0,0,0,.25); }
@media (max-width: 640px) { [data-est-state="calculated"] .est-next .btn { width: 100%; justify-content: center; } }
@media (prefers-reduced-motion: no-preference) {
  [data-est-state="calculated"] .est-results { animation: est-in .25s ease-out; }
  @keyframes est-in { from { opacity: 0; transform: translateY(6px); } }
}
/* Factor toggle opened by the script (restored or typed value): mark it as in use. */
.est-pay-toggle[open] { border-style: solid; border-color: var(--gold); }
/* hooks7 (S6): visually hidden result announcement (Calculate only) */
.est-announce{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}

/* ---- lead-magnet capture (hidden unless CAPTURE_ENABLED) ---- */
.est-range-note { border-left: 3px solid var(--gold-soft); padding-left: 12px; font-size: .92rem; line-height: 1.5; color: var(--on-navy); margin: 0 0 12px; }
.est-capture { background: #fff; color: var(--heading); border-radius: 10px; padding: 16px 18px 18px; margin: 16px 0 8px; }
.est-capture-title { margin: 0 0 8px; font-size: 1.15rem; color: var(--heading); }
.est-out .est-capture,
.est-exit-dialog .est-capture { color: var(--heading); }
.est-out .est-capture p,
.est-out .est-capture label,
.est-out .est-capture .consent-label span,
.est-out .est-capture .form-note,
.est-out .est-capture .est-capture-title,
.est-exit-dialog .est-capture p,
.est-exit-dialog .est-capture label,
.est-exit-dialog .est-capture .consent-label span,
.est-exit-dialog .est-capture .form-note,
.est-exit-dialog .est-capture .est-capture-title { color: var(--heading); }
.est-out .est-capture .field-err,
.est-exit-dialog .est-capture .field-err { color: var(--err-deep); }
.est-capture-lead { margin: 0 0 14px; font-size: .95rem; line-height: 1.5; }
.est-capture .field { margin-bottom: 12px; }
.est-capture input[type="text"],
.est-capture input[type="tel"],
.est-capture input[type="email"] { width: 100%; min-height: 48px; }
.est-capture .consent-block { margin: 4px 0 14px; }
.est-capture .est-contact-err { margin: 0 0 12px; }
.est-capture .form-actions { margin: 0; }
.est-capture-btn { min-height: 48px; width: 100%; justify-content: center; }
.est-exit-dialog { border: 0; border-radius: 12px; padding: 0; max-width: 36rem; width: calc(100% - 32px); background: #fff; color: var(--heading); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.est-exit-dialog::backdrop { background: rgba(8, 16, 28, .55); }
.est-exit-inner { position: relative; padding: 28px 24px 24px; }
.est-exit-close { position: absolute; top: 8px; right: 8px; width: 48px; height: 48px; border: 0; background: transparent; color: var(--heading); font-size: 1.8rem; line-height: 1; cursor: pointer; border-radius: 8px; }
.est-exit-close:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
.est-exit-inner h2 { margin: 0 20px 8px 0; font-size: 1.35rem; color: var(--heading); }
.est-exit-lead { margin: 0 0 16px; color: #44505e; line-height: 1.5; }
.est-exit-slot .est-capture { margin: 0; padding: 0; }
@media (prefers-reduced-motion: reduce) {
  .est-exit-dialog, .est-exit-dialog::backdrop { transition: none; }
}

.est-capture[hidden], .est-exit-dialog[hidden] { display: none !important; }

/* Estimator H1: wrap inside the container at every width; never clip or overflow. */
body:has(.est-section) .page-hero,
body:has(.est-section) .page-hero .container {
  overflow: visible;
}
body:has(.est-section) .page-hero h1 {
  max-width: min(24ch, 100%);
  width: auto;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  overflow: visible;
  line-height: 1.2;
}
@media (max-width: 414px) {
  body:has(.est-section) .page-hero h1 {
    font-size: clamp(1.5rem, 7vw, 1.85rem);
  }
}

/* Optional extras (affordability, consolidation, offer compare). Collapsed by default. */
.est-extra-body { padding: 0 16px 16px; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.est-extra-body .est-field { margin: 0; min-width: 0; }
.est-extra-body select { width: 100%; min-height: 48px; }
.est-extra-body .est-money-box,
.est-extra-body input#est-pos-count {
  width: 100%; max-width: 16rem; min-height: 48px; box-sizing: border-box;
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--radius);
}
.est-extra-body input#est-pos-count { padding: 0 12px; }
.est-extra-body .est-money-box { display: flex; align-items: center; padding: 0 12px; cursor: text; }
.est-extra-body .est-money-prefix { flex: 0 0 auto; margin-right: 4px; color: var(--heading); font: 400 1rem/1.4 var(--sans); user-select: none; pointer-events: none; }
.est-extra-body .est-money-box input.est-money {
  flex: 1 1 auto; width: auto; min-width: 0; max-width: none; min-height: 46px;
  padding: 13px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.est-extra-body .est-money-box input.est-money:focus { outline: none; border: 0; box-shadow: none; }
.est-extra-body .est-money-box:focus-within { border-color: var(--heading); box-shadow: 0 0 0 3px var(--focus-ring); }
.est-extra-out {
  margin: 4px 0 0;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.est-extra-out p { margin: 0 0 8px; }
.est-extra-out p:last-child { margin-bottom: 0; }
.est-method { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }
.est-compare { width: 100%; border-collapse: collapse; margin: 4px 0 12px; font-size: 0.92rem; }
.est-compare th, .est-compare td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule, #e4ddd0);
  vertical-align: top; overflow-wrap: anywhere;
}
.est-compare th { font-weight: 600; color: var(--heading); }
.est-compare th:nth-child(2),
.est-compare th:nth-child(3),
.est-compare td:nth-child(2),
.est-compare td:nth-child(3) { text-align: right; }
@media (max-width: 480px) {
  .est-compare { font-size: 0.8rem; }
  .est-compare th, .est-compare td { padding: 8px 4px; }
}

/* "Send my estimate": the honeypot a person never sees or fills; the send error sits above the button. */
.est-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.est-out .est-capture .est-send-err { margin: 0 0 10px; }
