/* ============================================================
   CHARTERED ADVISORY — CALCULATOR HUB v2
   Additive layer. Nothing here overrides a site-wide token; every
   colour and face is inherited from the :root set in app_shell.html
   so the hub stays visually identical to the rest of the site.
   Prefix: .calcx-
   ============================================================ */

/* ---------- 1. Tab strip ---------------------------------- */
/* Desktop keeps the existing wrapped pills. Mobile becomes a single
   scrollable rail so the inputs stay above the fold instead of sitting
   under seven stacked full-width buttons. */
#calc-tabs { scroll-behavior: smooth; }
#calc-tabs .calc-tab:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}
@media (max-width: 680px) {
  #calc-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px !important;
    margin: 0 -14px;
    padding: 2px 14px 10px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
  }
  #calc-tabs::-webkit-scrollbar { display: none; }
  #calc-tabs .calc-tab {
    width: auto !important;
    flex: 0 0 auto;
    white-space: nowrap;
    scroll-snap-align: center;
    min-height: 44px;
  }
}

/* ---------- 2. Money inputs ------------------------------- */
.calcx-money-wrap { position: relative; }
.calcx-echo {
  display: block;
  margin-top: 6px;
  font-family: var(--f-mono);
  font-size: .74rem;
  letter-spacing: .01em;
  color: var(--slate);
  min-height: 1.05em;
}
.calcx-echo.is-warn { color: #A8501C; font-weight: 600; }
.calcx-quick {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.calcx-quick button {
  border: 1px solid var(--line); background: #fff; color: var(--slate);
  border-radius: 999px; padding: .3em .68em; cursor: pointer;
  font: 600 .72rem/1 var(--f-mono); letter-spacing: .02em;
  transition: .15s;
}
.calcx-quick button:hover { border-color: var(--emerald); color: var(--emerald-deep); background: var(--emerald-soft); }
.calcx-quick button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

/* Segmented control replaces the monthly/annual <select>. */
.calcx-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: #fbfdfc; padding: 3px; gap: 2px; }
.calcx-seg button {
  border: 0; background: transparent; cursor: pointer; border-radius: 999px;
  padding: .5em 1.1em; font: 700 .82rem/1 var(--f-body); color: var(--slate); transition: .15s;
}
.calcx-seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.calcx-seg button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

/* ---------- 3. Advanced adjustments disclosure ------------ */
.calcx-adv { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fbfdfc; overflow: hidden; }
.calcx-adv > summary {
  cursor: pointer; list-style: none; padding: .85em 1em;
  font: 700 .88rem/1.3 var(--f-body); color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.calcx-adv > summary::-webkit-details-marker { display: none; }
.calcx-adv > summary::after { content: "+"; font-size: 1.25rem; line-height: 1; color: var(--emerald-deep); }
.calcx-adv[open] > summary::after { content: "\2212"; }
.calcx-adv[open] > summary { border-bottom: 1px solid var(--line); }
.calcx-adv-body { padding: 16px; display: grid; gap: 14px; }
.calcx-adv-body .field label { display: block; font: 600 .82rem/1.35 var(--f-body); color: var(--ink); margin-bottom: 5px; }
.calcx-adv-hint { font-size: .74rem; color: var(--slate); line-height: 1.5; margin-top: 4px; display: block; }

/* ---------- 4. Slab-by-slab working ladder ---------------- */
.calcx-ladder { margin-top: 20px; }
.calcx-ladder-h {
  font: 600 .68rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.55); margin-bottom: 10px;
}
.calcx-step {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px;
  padding: 9px 0; border-bottom: 1px solid var(--ink-line);
}
.calcx-step:last-child { border-bottom: 0; }
.calcx-step-band { font: 500 .78rem/1.4 var(--f-mono); color: rgba(255,255,255,.72); }
.calcx-step-amt  { font: 600 .82rem/1.4 var(--f-mono); color: #fff; text-align: right; white-space: nowrap; }
.calcx-step-note { grid-column: 1 / -1; font: 400 .7rem/1.45 var(--f-body); color: rgba(255,255,255,.45); }
.calcx-step.is-total { border-top: 1px solid rgba(255,255,255,.28); border-bottom: 0; margin-top: 4px; padding-top: 12px; }
.calcx-step.is-total .calcx-step-band { color: #fff; font-weight: 600; }
.calcx-step.is-total .calcx-step-amt  { color: #5ED6B4; font-size: .95rem; }
.calcx-step.is-credit .calcx-step-amt { color: #5ED6B4; }

/* ---------- 5. Slab chart --------------------------------- */
.calcx-chart { margin-top: 18px; }
.calcx-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.calcx-chart-legend {
  display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px;
  font: 500 .7rem/1 var(--f-mono); color: rgba(255,255,255,.6);
}
.calcx-chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ---------- 6. Result actions ----------------------------- */
.calcx-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 4px;
  position: relative; z-index: 1;
}
.calcx-actions button, .calcx-actions a {
  display: inline-flex; align-items: center; gap: .45em;
  border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.07);
  color: #fff; border-radius: 999px; padding: .6em 1.05em; cursor: pointer;
  font: 700 .8rem/1 var(--f-body); text-decoration: none; transition: .16s;
  min-height: 40px;
}
.calcx-actions button:hover, .calcx-actions a:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.4); }
.calcx-actions button:focus-visible, .calcx-actions a:focus-visible { outline: 2px solid #5ED6B4; outline-offset: 2px; }
.calcx-actions .is-done { background: #5ED6B4; border-color: #5ED6B4; color: #04231C; }

/* ---------- 7. Result-aware CTA --------------------------- */
.calcx-cta {
  position: relative; z-index: 1; margin-top: 18px; padding: 18px;
  border-radius: 16px; border: 1px solid rgba(94,214,180,.34);
  background: linear-gradient(180deg, rgba(94,214,180,.14), rgba(94,214,180,.05));
}
.calcx-cta b { display: block; font-family: var(--f-display); font-size: 1.06rem; color: #fff; margin-bottom: 5px; line-height: 1.3; }
.calcx-cta p { font-size: .86rem; line-height: 1.6; color: rgba(255,255,255,.78); margin: 0 0 12px; }
.calcx-cta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.calcx-cta-row a, .calcx-cta-row button {
  display: inline-flex; align-items: center; gap: .4em; min-height: 42px;
  padding: .62em 1.15em; border-radius: 999px; font: 700 .84rem/1 var(--f-body);
  text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: .16s;
}
.calcx-cta-row .is-primary { background: #5ED6B4; color: #04231C; }
.calcx-cta-row .is-primary:hover { background: #7FE3C6; }
.calcx-cta-row .is-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.calcx-cta-row .is-ghost:hover { background: rgba(255,255,255,.1); }

/* Inline email capture — reveals only when the user asks for it. */
.calcx-mail { display: none; margin-top: 12px; gap: 8px; flex-wrap: wrap; }
.calcx-mail.show { display: flex; }
.calcx-mail input {
  flex: 1 1 200px; min-height: 42px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08);
  color: #fff; font: 400 .88rem/1 var(--f-body);
}
.calcx-mail input::placeholder { color: rgba(255,255,255,.5); }
.calcx-mail input:focus { outline: none; border-color: #5ED6B4; box-shadow: 0 0 0 3px rgba(94,214,180,.2); }
.calcx-mail-msg { flex: 1 1 100%; font-size: .78rem; color: rgba(255,255,255,.7); margin: 0; }

/* ---------- 8. Rates-as-at stamp -------------------------- */
.calcx-stamp {
  display: inline-flex; align-items: center; gap: .5em; flex-wrap: wrap;
  margin-top: 14px; padding: .45em .85em; border-radius: 999px;
  border: 1px solid var(--line); background: var(--emerald-soft);
  font: 600 .72rem/1.5 var(--f-mono); color: var(--emerald-deep);
}
.calcx-stamp .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--emerald); flex: none; }

/* ---------- 9. TY comparison ------------------------------ */
.calcx-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; position: relative; z-index: 1; }
.calcx-compare-col { padding: 14px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid var(--ink-line); }
.calcx-compare-col.is-current { background: rgba(94,214,180,.12); border-color: rgba(94,214,180,.3); }
.calcx-compare-col .k { font: 600 .64rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.calcx-compare-col .v { font: 600 1.22rem/1.2 var(--f-mono); color: #fff; margin-top: 7px; }
.calcx-compare-col .s { font-size: .74rem; color: rgba(255,255,255,.6); margin-top: 4px; display: block; }
.calcx-delta { grid-column: 1 / -1; text-align: center; padding: 10px; border-radius: 12px; font: 700 .86rem/1.4 var(--f-body); }
.calcx-delta.is-saving  { background: rgba(94,214,180,.16); color: #5ED6B4; }
.calcx-delta.is-increase{ background: rgba(232,146,110,.16); color: #F2A98C; }
.calcx-delta.is-flat    { background: rgba(255,255,255,.07); color: rgba(255,255,255,.75); }
@media (max-width: 560px) { .calcx-compare { grid-template-columns: 1fr; } }

/* Saving / increase colouring on the legacy compare row. */
#o-saving.is-saving   { color: #5ED6B4; }
#o-saving.is-increase { color: #F2A98C; }

/* ---------- 10. Reverse (target take-home) mode ----------- */
.calcx-mode {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: 999px; background: #fbfdfc;
}
.calcx-mode button {
  border: 0; background: transparent; cursor: pointer; border-radius: 999px;
  padding: .5em 1em; font: 700 .8rem/1 var(--f-body); color: var(--slate); transition: .15s;
}
.calcx-mode button[aria-pressed="true"] { background: var(--emerald); color: #fff; }
.calcx-mode button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

/* ---------- 11. Value flash on update --------------------- */
@keyframes calcxFlash { 0% { opacity: .35; transform: translateY(2px); } 100% { opacity: 1; transform: none; } }
.calcx-flash { animation: calcxFlash .28s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .calcx-flash { animation: none; }
  #calc-tabs { scroll-behavior: auto; }
}

/* ---------- 12. Server-rendered SEO block ----------------- */
.calc-seo { padding: 52px 0 8px; border-top: 1px solid var(--line); }
.calc-seo h2 { font-family: var(--f-display); font-size: 1.55rem; margin: 0 0 12px; line-height: 1.24; }
.calc-seo h3 { font-size: 1.02rem; margin: 30px 0 12px; }
.calc-seo-lede { max-width: 74ch; color: var(--slate); font-size: .98rem; line-height: 1.75; margin: 0 0 18px; }
.calc-seo-scope {
  max-width: 74ch; font-size: .9rem; line-height: 1.65; color: var(--ink);
  background: var(--emerald-soft); border: 1px solid var(--line); border-left: 3px solid var(--emerald);
  border-radius: 0 12px 12px 0; padding: 14px 16px; margin: 0 0 20px;
}
.calc-seo-scope b { color: var(--emerald-deep); }
.calc-seo-table { width: 100%; border-collapse: collapse; margin: 6px 0 4px; font-size: .9rem; }
.calc-seo-table caption {
  text-align: left; font: 600 .68rem/1 var(--f-mono); letter-spacing: .1em;
  text-transform: uppercase; color: var(--emerald-deep); padding-bottom: 10px;
}
.calc-seo-table th, .calc-seo-table td { border: 1px solid var(--line); padding: 10px 13px; text-align: left; vertical-align: top; }
.calc-seo-table thead th { background: var(--emerald-soft); font-weight: 700; color: var(--ink); }
.calc-seo-table tbody th { font-weight: 500; color: var(--ink); background: #fff; }
.calc-seo-table td { font-family: var(--f-mono); font-size: .84rem; color: var(--slate); }
.calc-seo-stamp { margin: 14px 0 0; font: 500 .78rem/1.5 var(--f-mono); color: var(--slate); }

.calc-seo-faq { max-width: 74ch; }
.calc-seo-faq-item { border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px; overflow: hidden; }
.calc-seo-faq-item > summary {
  cursor: pointer; list-style: none; padding: 15px 46px 15px 18px; position: relative;
  font: 600 .96rem/1.45 var(--f-body); color: var(--ink);
}
.calc-seo-faq-item > summary::-webkit-details-marker { display: none; }
.calc-seo-faq-item > summary::after {
  content: "+"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  font-size: 1.3rem; font-weight: 400; color: var(--emerald-deep); line-height: 1;
}
.calc-seo-faq-item[open] > summary::after { content: "\2212"; }
.calc-seo-faq-item[open] > summary { border-bottom: 1px solid var(--line); }
.calc-seo-faq-item p { margin: 0; padding: 15px 18px; font-size: .93rem; line-height: 1.72; color: var(--slate); }

.calc-seo-links { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 8px; }
.calc-seo-links ul { list-style: none; margin: 0; padding: 0; }
.calc-seo-links li { margin-bottom: 9px; }
.calc-seo-links a {
  color: var(--emerald-deep); font-size: .92rem; font-weight: 600; text-decoration: none;
  border-bottom: 1px solid transparent; line-height: 1.5;
}
.calc-seo-links a:hover { border-bottom-color: currentColor; }
@media (max-width: 680px) { .calc-seo-links { grid-template-columns: 1fr; gap: 18px; } .calc-seo { padding-top: 36px; } }

.calc-seo-hub { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); gap: 14px; }
.calc-seo-hublink {
  display: flex; flex-direction: column; gap: 7px; height: 100%;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; text-decoration: none; color: inherit; transition: .18s;
}
.calc-seo-hublink:hover { border-color: var(--emerald); background: var(--emerald-soft); transform: translateY(-2px); }
.calc-seo-hublink b { font-size: 1rem; line-height: 1.3; color: var(--ink); }
.calc-seo-hublink span { font-size: .85rem; line-height: 1.6; color: var(--slate); }

/* ---------- 13. Print ------------------------------------- */
@media print {
  .header, .footer, .announce, .ctaband, .fbr-verify-wrap, .calcx-actions,
  .calcx-cta, .calc-tabs, .calc-chip-row, .phero, .calcx-quick, .calcx-mode,
  .nav, .burger, .ca-mobile-backdrop { display: none !important; }
  body { background: #fff !important; }
  .calc-wrap { grid-template-columns: 1fr !important; gap: 18px !important; }
  .calc-out, .calc-card {
    background: #fff !important; color: #000 !important;
    border: 1px solid #999 !important; box-shadow: none !important;
    page-break-inside: avoid; padding: 18px !important;
  }
  .calc-out *, .calcx-step-band, .calcx-step-amt, .calcx-step-note,
  .slabtable td, .o-cell .k, .o-cell .val, .calc-out .o-big, .calcx-ladder-h,
  .calcx-compare-col .k, .calcx-compare-col .v, .calcx-compare-col .s { color: #000 !important; }
  .o-cell, .calcx-compare-col { background: #f4f4f4 !important; border: 1px solid #ccc !important; }
  .calc-seo-faq-item { page-break-inside: avoid; }
  .calc-seo-faq-item > summary::after { display: none; }
  a[href]::after { content: "" !important; }
}
