/* ============================================
   TOOLS
   The calculators on /remortgage-calculator/ (total cost), the borrowing, loan to
   value, equity and costs calculators, the rate chart on /remortgage-rates/ and the
   payment tables. One sheet, so a form looks the same on every tool.
   ============================================ */

.tc-section { background: #f7f9f8; padding: 3.5rem 1.25rem; }
.tc-section--first { padding-top: 2.5rem; }
.tc-inner { max-width: 1100px; margin: 0 auto; }
.tc-inner h2 { color: var(--green-deep, #003D32); margin-bottom: .5rem; }
.tc-lead { max-width: 720px; margin-bottom: 1.75rem; color: #3d4f4a; }
.tc-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.5rem; align-items: start; }
.tc-grid--wide { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); }
.tc-form, .tc-result { background: #fff; border-radius: 16px; padding: 1.5rem; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.tc-field { display: block; margin-bottom: 1rem; }
.tc-field > span:first-child { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .35rem; color: #1f2d2a; }
.tc-field input, .tc-field select { width: 100%; font: inherit; padding: .65rem .75rem; border: 1.5px solid #cfd8d5; border-radius: 10px; background: #fff; color: #1f2d2a; }
.tc-field input:focus, .tc-field select:focus { outline: 2px solid #00796B; outline-offset: 1px; border-color: #00796B; }
.tc-money { display: flex; align-items: center; gap: .5rem; }
.tc-money > span { font-weight: 700; color: #3d4f4a; }
.tc-check { display: flex; gap: .5rem; align-items: center; margin: -.25rem 0 1rem; font-size: .92rem; }
.tc-source { font-size: .82rem; color: #5a6b67; margin: -.5rem 0 1rem; line-height: 1.5; }
.tc-source a, .tc-small a, .tl-note a { color: var(--green-deep, #003D32); font-weight: 600; }
.tc-headline { font-size: 1.25rem; font-weight: 800; color: var(--green-deep, #003D32); margin-bottom: 1rem; line-height: 1.3; }
.tc-sub { margin: -.5rem 0 1rem; color: #3d4f4a; line-height: 1.5; }
.tc-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tc-table th, .tc-table td { padding: .6rem .5rem; border-bottom: 1px solid #e8ede9; text-align: right; }
.tc-table th[scope="row"], .tc-table thead th:first-child { text-align: left; font-weight: 600; }
.tc-table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #5a6b67; }
.tc-table .tc-total th, .tc-table .tc-total td { font-weight: 800; background: #f1f6f4; }
.tc-even { margin: 1rem 0 .5rem; font-weight: 600; }
.tc-small { font-size: .82rem; line-height: 1.55; color: #5a6b67; margin: 1rem 0; }
.tc-help { max-width: 760px; margin-top: .5rem; padding-left: 1.2rem; }
.tc-help li { margin-bottom: .6rem; line-height: 1.55; }
.tc-inner h3 { margin-top: 2rem; color: var(--green-deep, #003D32); }
.tc-fieldset { border: 0; padding: 0; margin: 0 0 .5rem; }
.tc-fieldset legend { font-family: var(--font-display, inherit); font-weight: 700; color: var(--green-deep, #003D32); font-size: 1.05rem; padding: 0; margin: .25rem 0 .75rem; }
.tc-fieldset + .tc-fieldset { border-top: 1px solid #e8ede9; padding-top: 1rem; }

.tc-section--plain { background: #fff; }
.tc-section--plain .tc-lead { max-width: 46em; }
.pay-table { background: #fff; border: 1px solid #e2e8e6; border-radius: 12px; }
.pay-table th, .pay-table td { padding-left: .8rem; padding-right: .8rem; }
.pay-table tbody tr:nth-child(even) { background: #f7f9f8; }

/* The hidden attribute has to win over the display rules above. */
.tc-section [hidden] { display: none !important; }

/* On a wide screen the answer stays in view while a long form is filled in. */
@media (min-width: 821px) {
  .tc-grid > .tc-result { position: sticky; top: 96px; }
}

/* A lender by lender result. A table on a wide screen, one card per lender on a phone. */
.tl-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tl-table th, .tl-table td { padding: .65rem .5rem; border-bottom: 1px solid #e8ede9; text-align: left; vertical-align: top; line-height: 1.45; }
.tl-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #5a6b67; font-weight: 700; }
.tl-table tbody th { font-weight: 700; color: #1f2d2a; white-space: nowrap; }
.tl-table td.tl-num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-why { display: block; font-size: .82rem; color: #5a6b67; font-weight: 400; white-space: normal; }
.tl-ok { color: #00695C; font-weight: 700; }
.tl-over { color: #8a4b00; font-weight: 700; }
.tl-none { color: #5a6b67; }
.tl-note { font-size: .82rem; line-height: 1.55; color: #5a6b67; margin: .9rem 0 0; }
@media (max-width: 640px) {
  .tl-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tl-table, .tl-table tbody, .tl-table tr, .tl-table th, .tl-table td { display: block; }
  .tl-table tr { padding: .75rem 0; border-bottom: 1px solid #e8ede9; }
  .tl-table th, .tl-table td { border: 0; padding: .15rem 0; white-space: normal; }
  .tl-table tbody th { white-space: normal; font-size: 1rem; }
  .tl-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: #5a6b67; font-size: .82rem; }
  .tl-table td.tl-num { white-space: normal; }
}

/* Bands on the loan to value calculator */
.band-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.band-list li { text-align: center; padding: .5rem 0; border-radius: 8px; background: #eef3f1; font-weight: 700; font-size: .85rem; color: #3d4f4a; }
.band-list li.is-yours { background: var(--green-deep, #003D32); color: #fff; }
.band-list li.is-below { background: #d9ebe6; color: #00594d; }

/* Facts tables inside a tool page's article: the lender, then its own words. */
.tool-facts { width: 100%; border-collapse: collapse; margin: 1rem 0 .5rem; font-size: .95rem; }
.tool-facts th, .tool-facts td { padding: .7rem .6rem; border-bottom: 1px solid #e2e8e6; text-align: left; vertical-align: top; line-height: 1.55; }
.tool-facts thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #5a6b67; }
.tool-facts tbody th { width: 9.5rem; font-weight: 700; color: var(--green-deep, #003D32); }
.tool-facts .lf-cite, .tool-facts-note .lf-cite { font-size: .8rem; font-weight: 600; white-space: nowrap; }
.tool-facts-note { font-size: .85rem; color: #5a6b67; line-height: 1.55; margin: .5rem 0 1.5rem; }
.tool-facts--wide tbody th { width: auto; }
.tool-facts td.num, .tool-facts th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tool-facts thead th.num { white-space: normal; }
.tool-facts--wide tbody th { white-space: nowrap; }
@media (max-width: 640px) {
  .tool-facts:not(.tool-facts--keep), .tool-facts:not(.tool-facts--keep) tbody, .tool-facts:not(.tool-facts--keep) tr, .tool-facts:not(.tool-facts--keep) th, .tool-facts:not(.tool-facts--keep) td { display: block; width: auto; }
  .tool-facts:not(.tool-facts--keep) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tool-facts:not(.tool-facts--keep) tr { padding: .7rem 0; border-bottom: 1px solid #e2e8e6; }
  .tool-facts:not(.tool-facts--keep) th, .tool-facts:not(.tool-facts--keep) td { border: 0; padding: .15rem 0; }
  .tool-facts:not(.tool-facts--keep) td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: #5a6b67; font-size: .82rem; }
  .tool-facts--keep { font-size: .85rem; }
  .tool-facts--keep th, .tool-facts--keep td { padding: .55rem .3rem; }
}

/* Tables that have to stay as tables scroll inside their own box on a phone. */
.tool-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0 .5rem; }
.tool-scroll > table { margin: 0; min-width: 520px; }
/* Narrow tables of figures fit a phone without scrolling. Headings have a short form for a phone. */
.hd-short { display: none; }
.tool-scroll > table.tool-facts--fit { min-width: 0; }
.tool-facts--fit tbody th .lf-cite { display: block; font-weight: 600; }
@media (max-width: 640px) {
  .tool-scroll > table.tool-facts--fit { table-layout: fixed; width: 100%; font-size: .84rem; }
  .tool-facts--fit tbody th { white-space: normal; width: 30%; }
  .tool-facts--fit thead th:first-child { width: 30%; }
  .rh-inner .tool-facts--fit th, .rh-inner .tool-facts--fit td { padding-left: .4rem; padding-right: .4rem; }
  .rh-inner .tool-facts--fit th:first-child { padding-left: .7rem; }
  .rh-inner .tool-facts--fit td:last-child, .rh-inner .tool-facts--fit th:last-child { padding-right: .7rem; }
  .tool-facts--fit thead th { font-size: .66rem; letter-spacing: 0; }
  .hd-long { display: none; }
  .hd-short { display: inline; }
}

/* The rate history on /remortgage-rates/ */
.rh-section { background: #f7f9f8; padding: 4rem 1.25rem; }
.rh-inner { max-width: 900px; margin: 0 auto; }
.rh-inner > h2 { color: var(--green-deep, #003D32); margin-bottom: .75rem; }
.rh-inner > h3 { color: var(--green-deep, #003D32); margin: 2.25rem 0 .5rem; scroll-margin-top: 90px; }
.rh-inner > p { color: #2a3a36; line-height: 1.65; margin-bottom: .9rem; max-width: 46em; }
.rh-inner .tool-facts { background: #fff; border-radius: 12px; overflow: hidden; }
.rh-inner .tool-facts th, .rh-inner .tool-facts td { padding-left: .9rem; padding-right: .9rem; }

/* The rate chart. Colours are set once here, by the job each line does. The three
   pass the lightness, chroma, colour blind and contrast checks on a white surface. */
.rate-chart {
  --series-1: #00897B;  /* average two year fix */
  --series-2: #eb6834;  /* average five year fix */
  --series-3: #6250d6;  /* Bank Rate */
  --chart-grid: #e6ebe9;
  --chart-text: #1f2d2a;
  --chart-muted: #5a6b67;
  margin: 1.5rem 0 .5rem; background: #fff; border: 1px solid #e2e8e6; border-radius: 14px; padding: 1.1rem 1.1rem .9rem;
}
.rate-chart:focus-visible { outline: 2px solid #00796B; outline-offset: 2px; }
.rate-chart-plot { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rate-chart-canvas { position: relative; }
.rate-chart svg { display: block; width: 100%; height: auto; }
.rate-chart-frame { position: relative; }
.rate-chart-yaxis, .rate-chart-swipe { display: none; }
@media (max-width: 640px) {
  /* A chart squeezed to a phone's width cannot be read, so it keeps a readable width and
     scrolls sideways. The percent labels sit outside the scrolling part so they stay in view. */
  .rate-chart-canvas { min-width: 620px; }
  .rate-chart text { font-size: 14px; }
  .rate-chart-ylab { display: none; }
  .rate-chart-swipe { display: inline; }
  .rate-chart-yaxis { display: block; position: absolute; left: 0; top: 0; bottom: 0; width: 34px; z-index: 1; pointer-events: none; background: linear-gradient(to right, #fff 60%, rgba(255, 255, 255, 0)); }
  .rate-chart-yaxis span { position: absolute; left: 0; transform: translateY(-50%); font-size: 11.5px; color: var(--chart-muted); font-variant-numeric: tabular-nums; }
}
.rate-chart-legend { display: flex; flex-wrap: wrap; gap: .35rem 1.4rem; font-size: .9rem; color: var(--chart-text); margin: 0 0 .6rem; padding: 0; list-style: none; }
.rate-chart-legend li { display: flex; align-items: center; gap: .5rem; }
.rate-chart-key { display: inline-block; width: 20px; height: 0; border-top: 2px solid var(--series-1); border-radius: 1px; flex: none; }
.rate-chart-key--five { border-top-color: var(--series-2); }
.rate-chart-key--bank { border-top-color: var(--series-3); }
.rate-chart text { font-family: "Plus Jakarta Sans", system-ui, sans-serif; font-size: 12px; fill: var(--chart-muted); font-variant-numeric: tabular-nums; }
.rate-chart-grid, .rate-chart-tick { stroke: var(--chart-grid); stroke-width: 1; }
.rate-chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; stroke: var(--series-1); }
.rate-chart-line--five { stroke: var(--series-2); }
.rate-chart-line--bank { stroke: var(--series-3); }
.rate-chart-dot { fill: var(--series-1); stroke: #fff; stroke-width: 2; }
.rate-chart-dot--five { fill: var(--series-2); }
.rate-chart-dot--bank { fill: var(--series-3); }
.rate-chart-cross { stroke: #9aa9a5; stroke-width: 1; }
.rate-chart-tip { position: absolute; top: 6px; min-width: 190px; background: #fff; border: 1px solid #d5dedb; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); padding: .6rem .75rem; font-size: .85rem; color: var(--chart-text); pointer-events: none; z-index: 2; }
.rate-chart-tip-month { color: var(--chart-muted); font-size: .78rem; margin-bottom: .3rem; }
.rate-chart-tip-row { display: flex; align-items: center; gap: .5rem; line-height: 1.7; }
.rate-chart-tip-row strong { font-variant-numeric: tabular-nums; min-width: 3.4em; }
.rate-chart-tip-row span:last-child { color: var(--chart-muted); }
.rate-chart figcaption { font-size: .82rem; line-height: 1.55; color: var(--chart-muted); margin-top: .6rem; }

/* Tool pages: a long question as the heading needs tighter lines than a two word title. */
.tool-hero h1 { line-height: 1.12; max-width: 20em; }
.tool-hero .calc-standfirst { max-width: 40em; }

/* Tool pages: the article under the tool */
.tool-article { padding-top: 2.5rem; }
.tool-kicker { color: var(--green-glow, #4DB6AC); font-weight: 600; font-size: .95rem; margin-top: .75rem; }
.tool-kicker a { color: inherit; }

@media (max-width: 820px) {
  .tc-grid, .tc-grid--wide { grid-template-columns: 1fr; }
  .tc-section { padding: 2.5rem 1rem; }
  .band-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* The home page: the month's figures, the lender table and the calculators */
.home-facts { background: #fff; padding: 5rem 1.25rem; }
.home-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 2rem 0 1rem; }
.home-stat { background: #f7f9f8; border-radius: 14px; padding: 1.25rem 1.1rem; }
.home-stat strong { display: block; font-family: var(--font-display, inherit); font-size: 2rem; font-weight: 800; color: var(--green-deep, #003D32); line-height: 1.1; }
.home-stat span { display: block; margin-top: .35rem; font-size: .92rem; color: #3d4f4a; }
.home-facts-note { font-size: .85rem; line-height: 1.6; color: #5a6b67; max-width: 60em; margin: .75rem 0 0; }
.home-facts-note a { color: var(--green-deep, #003D32); font-weight: 600; }
.home-facts-h3 { font-family: var(--font-display, inherit); color: var(--green-deep, #003D32); font-size: 1.4rem; margin: 3rem 0 .5rem; }
.home-facts-lead { color: #3d4f4a; line-height: 1.6; max-width: 46em; margin-bottom: 1rem; }
.home-lenders { font-size: .93rem; }
.home-lenders tbody th { width: 8.5rem; }
.home-lenders tbody th a { color: var(--green-deep, #003D32); }
.home-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-top: 1rem; }
.home-tool { display: block; background: #f7f9f8; border: 1px solid #e2e8e6; border-radius: 14px; padding: 1.2rem 1.2rem 1.3rem; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.home-tool:hover, .home-tool:focus-visible { border-color: #00796B; box-shadow: 0 4px 14px rgba(0, 61, 50, .1); }
.home-tool strong { display: block; font-family: var(--font-display, inherit); color: var(--green-deep, #003D32); font-size: 1.08rem; margin-bottom: .35rem; }
.home-tool span { display: block; font-size: .92rem; line-height: 1.5; color: #3d4f4a; }
@media (max-width: 820px) {
  .home-facts { padding: 3.5rem 1rem; }
  .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-stat strong { font-size: 1.6rem; }
}
